kioskmode

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

Documentation

Overview

Package kioskmode provides ways to set policies for local device accounts in a Kiosk mode.

Index

Constants

This section is empty.

Variables

View Source
var (
	// WebKioskAccountID identifier of the web Kiosk application.
	WebKioskAccountID = "arbitrary_id_web_kiosk_1"

	// KioskAppAccountID identifier of the Kiosk application.
	KioskAppAccountID = "arbitrary_id_store_app_2"

	// KioskAppID pointing to the Printtest app - not listed in the WebStore.
	KioskAppID = "aajgmlihcokkalfjbangebcffdoanjfo"
	// KioskAppBtnNode node representing this application on the Apps menu on
	// the Sign-in screen.
	KioskAppBtnNode = nodewith.Name("Simple Printest").ClassName("MenuItemView")

	// DefaultLocalAccountsConfiguration holds default Kiosks accounts
	// configuration. Each, when setting public account policies can be
	// referred by id: KioskAppAccountID and WebKioskAccountID
	DefaultLocalAccountsConfiguration = policy.DeviceLocalAccounts{
		Val: []policy.DeviceLocalAccountInfo{
			kioskAppPolicy,
			webKioskPolicy,
		},
	}
)

Functions

func ConfirmKioskStarted

func ConfirmKioskStarted(ctx context.Context, reader *syslog.Reader) error

ConfirmKioskStarted uses reader for looking for logs that confirm Kiosk mode starting and also successful launch of Kiosk. reader Reader instance should be processing logs filtered for Chrome only.

func IsKioskAppStarted

func IsKioskAppStarted(ctx context.Context) error

IsKioskAppStarted searches for existing logs to confirm Kiosk is running.

func WaitForCrxInCache

func WaitForCrxInCache(ctx context.Context, id string) error

WaitForCrxInCache waits for Kiosk crx to be available in cache.

Types

type Config

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

Config contains configurations for Kiosk mode. It holds the necessary policies that will be set to enable Kiosk 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 Kiosk

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

Kiosk structure holds necessary references and provides a way to safely close Kiosk mode.

func New

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

New starts Chrome, sets passed Kiosk related options to policies and restarts Chrome. When kioskmode.AutoLaunch() is used, then it auto starts given Kiosk application. Alternatively use kioskmode.ExtraChromeOptions() passing chrome.LoadSigninProfileExtension(). In that case Chrome is started and stays on Signin screen with Kiosk accounts loaded. Use defer kiosk.Close(ctx) to clean.

func (*Kiosk) Close

func (k *Kiosk) Close(ctx context.Context) (retErr error)

Close clears policies, but keeps serving device local accounts then closes Chrome. Ideally we would serve an empty policies slice however, that makes Chrome crashes when AutoLaunch() option was used.

func (*Kiosk) RestartChromeWithOptions

func (k *Kiosk) RestartChromeWithOptions(ctx context.Context, opts ...chrome.Option) (*chrome.Chrome, error)

RestartChromeWithOptions replaces the current Chrome in kiosk instance with a new one using custom options. It will be closed by Kiosk.Close().

type MutableConfig

type MutableConfig struct {
	// DeviceLocalAccounts is the configuration with local device accounts.
	DeviceLocalAccounts *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 Kiosk mode to autolaunch. When true
	// AutoLaunchKioskAppID id is set to autolaunch.
	AutoLaunch bool
	// AutoLaunchKioskAppID is an id of the autolaunched Kiosk account.
	AutoLaunchKioskAppID *string
	// ExtraChromeOptions holds all extra options that will be passed to Chrome
	// instance that will run in Kiosk 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 Kiosk mode. See https://commandcenter.blogspot.com.au/2014/01/self-referential-functions-and-design.html for details about this pattern.

func AutoLaunch

func AutoLaunch(accountID string) Option

AutoLaunch sets Kiosk app ID to be started after Chrome restart. When used then defer cleaning and refreshing policies policyutil.ServeAndRefresh(ctx, fdms, cr, []policy.Policy{}). Otherwise with next Chrome restart Kiosk will auto start.

func CustomLocalAccounts

func CustomLocalAccounts(accounts *policy.DeviceLocalAccounts) Option

CustomLocalAccounts sets custom local accounts on DUT. Use when the default configuration provided by DefaultLocalAccounts() option is not enough. E.g. when test has to use a specific website or a specific Chrome App.

func DefaultLocalAccounts

func DefaultLocalAccounts() Option

DefaultLocalAccounts uses default Kiosk applications configuration stored in kioskmode.defaultLocalAccountsConfiguration.

func ExtraChromeOptions

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

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

func ExtraPolicies

func ExtraPolicies(p []policy.Policy) Option

ExtraPolicies adds extra policies to be applied with Kiosk app.

func PublicAccountPolicies

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

PublicAccountPolicies adds policies that will be applied to the account.

Directories

Path Synopsis
Package fixtures contains fixtures useful for Kiosk mode tests.
Package fixtures contains fixtures useful for Kiosk mode tests.

Jump to

Keyboard shortcuts

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