config

package
v0.0.0-...-683b059 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package config defines a struct to hold configurations of chrome.Chrome.

Index

Constants

View Source
const (
	// DefaultUser contains the email address used to log into Chrome when authentication credentials are not supplied.
	DefaultUser = "testuser@gmail.com"

	// DefaultPass contains the password we use to log into the DefaultUser account.
	DefaultPass = "testpass"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ARCMode

type ARCMode int

ARCMode describes the mode that ARC should be put into.

const (
	ARCDisabled ARCMode = iota
	ARCEnabled
	ARCSupported // ARC is supported and can be launched by user policy
)

Valid values for ARCMode.

type AuthType

type AuthType string

AuthType describes the type of authentication to be used in GAIA.

const (
	UnknownAuth  AuthType = ""         // cannot determine the authentication type
	PasswordAuth AuthType = "password" // password based authentication
	ContactAuth  AuthType = "contact"  // contact email approval based authentication
)

Valid values for AuthType.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config contains configurations for chrome.Chrome instance as requested by options to chrome.New.

This is an immutable struct. Modification outside NewConfig is prohibited.

func NewConfig

func NewConfig(opts []Option) (*Config, error)

NewConfig constructs Config from a list of options given to chrome.New.

func Unmarshal

func Unmarshal(data []byte) (*Config, error)

Unmarshal unmarshals the data to a Config struct.

func (*Config) ARCMode

func (c *Config) ARCMode() ARCMode

ARCMode returns the mode of ARC.

func (*Config) ARCUseHugePages

func (c *Config) ARCUseHugePages() bool

ARCUseHugePages returns the memory mode of the guest memory.

func (*Config) BreakpadTestMode

func (c *Config) BreakpadTestMode() bool

BreakpadTestMode returns whether to tell Chrome's breakpad to always write dumps directly to a hard-coded directory.

func (*Config) Creds

func (c *Config) Creds() Creds

Creds returns login credentials.

func (*Config) CustomLoginTimeout

func (c *Config) CustomLoginTimeout() time.Duration

CustomLoginTimeout returns a custom timeout for login. If 0, use chrome.LoginTimeout.

func (*Config) DMSAddr

func (c *Config) DMSAddr() string

DMSAddr returns the address of a device management server.

func (*Config) DeferLogin

func (c *Config) DeferLogin() bool

DeferLogin returns whether to defer login in chrome.New. If it is true, users should call Chrome.ContinueLogin to continue login.

func (*Config) DisableFeatures

func (c *Config) DisableFeatures() []string

DisableFeatures returns extra Chrome features to disable.

func (*Config) DisablePolicyKeyVerification

func (c *Config) DisablePolicyKeyVerification() bool

DisablePolicyKeyVerification returns whether to disable policy key verification in Chrome.

func (*Config) EnableFeatures

func (c *Config) EnableFeatures() []string

EnableFeatures returns extra Chrome features to enable.

func (*Config) EnableFilesAppSWA

func (c *Config) EnableFilesAppSWA() bool

EnableFilesAppSWA returns true if the Files app is running the SWA variant. TODO(b/207576612): Remove this config item once Files app SWA is fully launched.

func (*Config) EnableLoginVerboseLogs

func (c *Config) EnableLoginVerboseLogs() bool

EnableLoginVerboseLogs returns whether to enable verbose logs on login.

func (*Config) EnableRestoreTabs

func (c *Config) EnableRestoreTabs() bool

EnableRestoreTabs returns true if creating browser windows on login should be skipped.

func (*Config) EncryptedReportingAddr

func (c *Config) EncryptedReportingAddr() string

EncryptedReportingAddr returns the address of a encrypted reporting endpoint.

func (*Config) EnrollMode

func (c *Config) EnrollMode() EnrollMode

EnrollMode returns an enterprise enrollment mode.

func (*Config) EnrollmentCreds

func (c *Config) EnrollmentCreds() Creds

EnrollmentCreds returns the credential used to enroll the device.

func (*Config) EphemeralUser

func (c *Config) EphemeralUser() bool

EphemeralUser returns true if user mount should be validated to be ephemeral, e.g. for guest user.

func (*Config) ExtraArgs

func (c *Config) ExtraArgs() []string

ExtraArgs returns extra arguments to pass to Chrome.

func (*Config) ExtraExtDirs

func (c *Config) ExtraExtDirs() []string

ExtraExtDirs returns directories containing extra unpacked extensions to load.

func (*Config) ForceLaunchBrowser

func (c *Config) ForceLaunchBrowser() bool

ForceLaunchBrowser returns true if to force FullRestoreService to launch browser for telemetry tests.

func (*Config) HideCrashRestoreBubble

func (c *Config) HideCrashRestoreBubble() bool

HideCrashRestoreBubble returns true if to skip "Chrome did not shut down correctly" bubble.

func (*Config) InstallWebApp

func (c *Config) InstallWebApp() bool

InstallWebApp returns whether to automatically install essential web apps.

func (*Config) KeepOwnership

func (c *Config) KeepOwnership() bool

KeepOwnership returns whether to keep existing ownership of the device. This is critical for enrolled devices.

func (*Config) KeepState

func (c *Config) KeepState() bool

KeepState returns whether to keep existing user profiles.

func (*Config) LacrosDisableFeatures

func (c *Config) LacrosDisableFeatures() []string

LacrosDisableFeatures returns extra Lacros Chrome features to disable.

func (*Config) LacrosEnableFeatures

func (c *Config) LacrosEnableFeatures() []string

LacrosEnableFeatures returns extra Lacros Chrome features to enable.

func (*Config) LacrosExtraArgs

func (c *Config) LacrosExtraArgs() []string

LacrosExtraArgs returns extra arguments to pass to Lacros Chrome.

func (*Config) LoginMode

func (c *Config) LoginMode() LoginMode

LoginMode returns a login mode.

func (*Config) Marshal

func (c *Config) Marshal() ([]byte, error)

Marshal marshals the Config struct to bytes.

func (*Config) NormalizedUser

func (c *Config) NormalizedUser() string

NormalizedUser returns a normalized user email.

func (*Config) PolicyEnabled

func (c *Config) PolicyEnabled() bool

PolicyEnabled returns whether to enable policy.

func (*Config) RealtimeReportingAddr

func (c *Config) RealtimeReportingAddr() string

RealtimeReportingAddr returns the address of a realtime reporting endpoint.

func (*Config) Region

func (c *Config) Region() string

Region returns a region of a user session.

func (*Config) RemoveNotification

func (c *Config) RemoveNotification() bool

RemoveNotification returns true if to remove all notiviations after restarting.

func (*Config) RestrictARCCPU

func (c *Config) RestrictARCCPU() bool

RestrictARCCPU returns whether to restrict CPU usage of ARC in background.

func (*Config) SigninExtKey

func (c *Config) SigninExtKey() string

SigninExtKey returns a private key for the sign-in profile test extension.

func (*Config) SkipForceOnlineSignInForTesting

func (c *Config) SkipForceOnlineSignInForTesting() bool

SkipForceOnlineSignInForTesting returns true if online sign-in enforcement should be disabled.

func (*Config) SkipOOBEAfterLogin

func (c *Config) SkipOOBEAfterLogin() bool

SkipOOBEAfterLogin returns whether to skip OOBE after login.

func (*Config) TryReuseSession

func (c *Config) TryReuseSession() bool

TryReuseSession returns whether to try reusing a current user session.

func (*Config) UseSandboxGaia

func (c *Config) UseSandboxGaia() bool

UseSandboxGaia returns true if the sandbox instance of Gaia should be used.

func (*Config) VKEnabled

func (c *Config) VKEnabled() bool

VKEnabled returns whether to force enable the virtual keyboard.

func (*Config) VerifySessionReuse

func (c *Config) VerifySessionReuse(newCfg *Config) error

VerifySessionReuse compares two configurations to see if they are compatible for the existing Chrome session to be re-used. This function is called when TryReuseSession option is set for the new Chrome session request. Default comparison logic is implemented here. Customized comparison logic goes to customizedReuseCheck() function .

func (*Config) WaitForCryptohome

func (c *Config) WaitForCryptohome() bool

WaitForCryptohome returns whether to wait for the cryptohome mount after login.

type Creds

type Creds struct {
	// User is the user name of a user account. It is typically an email
	// address (e.g. example@gmail.com).
	User string
	// Pass is the password of a user account.
	Pass string

	// GAIAID is a GAIA ID used on fake logins. If it is empty, an ID is
	// generated from the user name. The field is ignored on other type of
	// logins.
	GAIAID string

	// Contact is an email address of a user who owns a test account.
	// When logging in with a test account, its contact user may be
	// notified of a login attempt and asked for approval.
	Contact string

	// ParentUser is the user name of a parent account. It is used to
	// approve a login attempt when a child account is supervised by a
	// parent account.
	ParentUser string
	// ParentPass is the pass of a parent account. It is used to approve
	// a login attempt when a child account is supervised by a parent
	// account.
	ParentPass string
}

Creds contains credentials to log into a Chrome user session.

func ParseCreds

func ParseCreds(creds string) ([]Creds, error)

ParseCreds parses a string containing a list of credentials.

creds is a string containing multiple credentials separated by newlines:

user1:pass1
user2:pass2
user3:pass3
...

type EnrollMode

type EnrollMode int

EnrollMode describes how the test should enroll.

const (
	NoEnroll   EnrollMode = iota // do not enroll device
	FakeEnroll                   // enroll with a fake, local device management server
	GAIAEnroll                   // real network based enrollment using a real, live device management server
)

Valid values for EnrollMode.

type LoginMode

type LoginMode int

LoginMode describes the user mode for the login.

const (
	NoLogin    LoginMode = iota // restart Chrome but don't log in
	FakeLogin                   // fake login with no authentication
	GAIALogin                   // real network-based login using GAIA backend
	GuestLogin                  // sign in as ephemeral guest user
)

Valid values for LoginMode.

type MutableConfig

type MutableConfig struct {
	Creds                           Creds      `reuse_match:"true"`
	NormalizedUser                  string     `reuse_match:"true"`
	KeepState                       bool       `reuse_match:"false"`
	KeepOwnership                   bool       `reuse_match:"true"`
	DeferLogin                      bool       `reuse_match:"customized"`
	EnableRestoreTabs               bool       `reuse_match:"false"`
	LoginMode                       LoginMode  `reuse_match:"customized"`
	TryReuseSession                 bool       `reuse_match:"false"`
	EnableLoginVerboseLogs          bool       `reuse_match:"true"`
	VKEnabled                       bool       `reuse_match:"true"`
	SkipOOBEAfterLogin              bool       `reuse_match:"false"`
	WaitForCryptohome               bool       `reuse_match:"false"`
	CustomLoginTimeout              int64      `reuse_match:"false"` // time.Duration can not be serialized to JSON. Store duration in nanoseconds.
	InstallWebApp                   bool       `reuse_match:"true"`
	Region                          string     `reuse_match:"true"`
	PolicyEnabled                   bool       `reuse_match:"true"`
	DMSAddr                         string     `reuse_match:"true"`
	RealtimeReportingAddr           string     `reuse_match:"true"`
	EncryptedReportingAddr          string     `reuse_match:"true"`
	EnrollMode                      EnrollMode `reuse_match:"true"`
	EnrollmentCreds                 Creds      `reuse_match:"true"`
	DisablePolicyKeyVerification    bool       `reuse_match:"true"`
	ARCMode                         ARCMode    `reuse_match:"true"`
	ARCUseHugePages                 bool       `reuse_match:"true"`
	RestrictARCCPU                  bool       `reuse_match:"true"`
	BreakpadTestMode                bool       `reuse_match:"true"`
	ExtraArgs                       []string   `reuse_match:"true"`
	LacrosExtraArgs                 []string   `reuse_match:"true"`
	EnableFeatures                  []string   `reuse_match:"true"`
	LacrosEnableFeatures            []string   `reuse_match:"true"`
	DisableFeatures                 []string   `reuse_match:"true"`
	LacrosDisableFeatures           []string   `reuse_match:"true"`
	ExtraExtDirs                    []string   `reuse_match:"customized"`
	SigninExtKey                    string     `reuse_match:"customized"`
	SkipForceOnlineSignInForTesting bool       `reuse_match:"true"`
	RemoveNotification              bool       `reuse_match:"true"`
	HideCrashRestoreBubble          bool       `reuse_match:"true"`
	ForceLaunchBrowser              bool       `reuse_match:"true"`
	EphemeralUser                   bool       `reuse_match:"true"`
	EnableFilesAppSWA               bool       `reuse_match:"true"`
	UseSandboxGaia                  bool       `reuse_match:"true"`
}

MutableConfig is a mutable version of Config. MutableConfig is wrapped with Config to prevent mutation after it is returned by NewConfig.

When TryReuseSession flag is set for a new chrome session, the configuration of the new session will be checked with the existing chrome session, to see if session reuse is possible. The "reuse_match" tag defines how a field should be handled when trying to reuse the existing chrome session. It has the following values: - "false": this field doesn't have to match for reused session - "true": this field have to match for reused session - "customized": Reuse checking logic is expected to be customized in customizedReuseCheck() function. This tag must be set for every field with one of the above values. Otherwise, unit test will fail.

type Option

type Option func(cfg *MutableConfig) error

Option is a self-referential function can be used to configure Chrome. See https://commandcenter.blogspot.com.au/2014/01/self-referential-functions-and-design.html for details about this pattern.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL