mgs

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: 17 Imported by: 0

Documentation

Overview

Package mgs provides ways to set policies for local device accounts in MGS mode.

Index

Constants

View Source
const (

	// LoginScreenExtensionID is the ID for "Login screen APIs test extension".
	LoginScreenExtensionID = "oclffehlkdgibkainkilopaalpdobkan"
	// InSessionExtensionID is the ID for "Login screen APIs in-session test extension".
	InSessionExtensionID = "ofcpkomnogjenhfajfjadjmjppbegnad"
)

Variables

View Source
var (
	// MgsAccountID is the default MGS ID.
	MgsAccountID = "defaultMgsSetByTast"
	// AccountType is the default public session account type.
	AccountType = policy.AccountTypePublicSession
)

Functions

This section is empty.

Types

type Config

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

Config contains configurations for MGS mode. It holds the necessary policies that will be set to enable MGS mode. Once retrieved by NewConfig() it should be used to read from not to modify.

func NewConfig

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

NewConfig creates new configuration.

type FixtData

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

FixtData holds chrome instance and session login time.

func (FixtData) Chrome

func (f FixtData) Chrome() *chrome.Chrome

Chrome returns the chrome instance.

func (FixtData) LoginTime

func (f FixtData) LoginTime() time.Duration

LoginTime returns the duration of the login session.

type MGS

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

MGS holds chrome and fakedms instances.

func New

func New(ctx context.Context, fdms *fakedms.FakeDMS, opts ...Option) (*MGS, *chrome.Chrome, error)

New starts Chrome, sets passed MGS related options to policies and restarts Chrome. Use mgs.AutoLaunch()to auto start MGS for a given account ID. Alternatively use mgs.ExtraChromeOptions() passing chrome.LoadSigninProfileExtension(). In that case Chrome is started and stays on Signin screen with mgs accounts loaded. Use defer mgs.Close() to perform clean up including closing Chrome instance.

func (*MGS) Chrome

func (m *MGS) Chrome() *chrome.Chrome

Chrome returns chrome instance.

func (*MGS) Close

func (m *MGS) Close(ctx context.Context) (retErr error)

Close closes chrome, cleans and refreshes empty policies.

type MutableConfig

type MutableConfig struct {
	// MGSAccounts applies DeviceLocalAccountInfo custom DeviceLocalAccountInfo configuration.
	MGSAccounts *policy.DeviceLocalAccounts
	// ExtraPolicies holds extra policies that will be applied.
	ExtraPolicies []policy.Policy
	// PublicAccountPolicies holds public accounts' IDs with associated polices
	// that will be applied to the them.
	PublicAccountPolicies map[string][]policy.Policy
	// AutoLaunch determines whether to set MGS mode to autolaunch. When true
	// AutoLaunchMGSAppID id is set to autolaunch.
	AutoLaunch bool
	// AutoLaunchMGSAppID is an id of the autolaunched MGS account.
	AutoLaunchMGSAppID *string
	// ExtraChromeOptions holds all extra options that will be passed to Chrome
	// instance that will run in MGS mode.
	ExtraChromeOptions []chrome.Option
}

MutableConfig holds pieces of configuration that are set with Options.

type Option

type Option func(cfg *MutableConfig) error

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

func Accounts

func Accounts(accountIDs ...string) Option

Accounts creates DeviceLocalAccountInfo (of a type policy.AccountTypePublicSession) for each passed accountID and adds them all to policy.DeviceLocalAccounts.

func AddPublicAccountPolicies

func AddPublicAccountPolicies(accountID string, policies []policy.Policy) Option

AddPublicAccountPolicies adds policies that will be applied to the account.

func AutoLaunch

func AutoLaunch(accountID string) Option

AutoLaunch sets MGS ID to be started after Chrome restart.

func DefaultAccount

func DefaultAccount() Option

DefaultAccount applies default local account configuration using one arbitrary MGS definition in the mgs package. MGS account id is exposed from the package.

func ExtraChromeOptions

func ExtraChromeOptions(opts ...chrome.Option) Option

ExtraChromeOptions passes Chrome options that will be applied to the Chrome instance running in MGS mode.

func ExtraPolicies

func ExtraPolicies(p []policy.Policy) Option

ExtraPolicies adds policies to be applied with MGS.

Jump to

Keyboard shortcuts

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