Documentation ¶
Overview ¶
Package policyutil contains utilities for using policies.
Index ¶
- func CheckCertificateVisibleInSystemSettings(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome, ...) error
- func CurrentPage(cr *chrome.Chrome) *openedPage
- func EnsureCookiesAccepted(ctx context.Context, br *browser.Browser, url, acceptBtnLocator string) error
- func EnsureGoogleCookiesAccepted(ctx context.Context, br *browser.Browser) error
- func MaximizeActiveWindow(ctx context.Context, tconn *chrome.TestConn) error
- func OSSettingsPage(ctx context.Context, cr *chrome.Chrome, shortLink string) *openedPage
- func OSSettingsPageWithPassword(ctx context.Context, cr *chrome.Chrome, shortLink, password string) *openedPage
- func Refresh(ctx context.Context, tconn *chrome.TestConn) error
- func RefreshChromePolicies(ctx context.Context, cr *chrome.Chrome) error
- func ResetChrome(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome) error
- func ResetChromeWithBlob(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, pb *policy.Blob) error
- func ServeAndRefresh(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, ...) error
- func ServeAndVerify(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, ...) error
- func ServeAndVerifyOnLoginScreen(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, ...) error
- func ServeBlobAndRefresh(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, pb *policy.Blob) error
- func SettingsPage(ctx context.Context, cr *chrome.Chrome, br ash.ConnSource, shortLink string) *openedPage
- func Verify(ctx context.Context, tconn *chrome.TestConn, ps []policy.Policy) error
- func VerifyNodeState(ctx context.Context, tconn *chrome.TestConn, finder *nodewith.Finder, ...) error
- func VerifyNotExists(ctx context.Context, tconn *chrome.TestConn, finder *nodewith.Finder, ...) error
- func WaitUntilExistsStatus(ctx context.Context, tconn *chrome.TestConn, finder *nodewith.Finder, ...) error
- type DUTPolicies
- type DUTPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCertificateVisibleInSystemSettings ¶
func CheckCertificateVisibleInSystemSettings(ctx context.Context, tconn *chrome.TestConn, cr *chrome.Chrome, certName string) error
CheckCertificateVisibleInSystemSettings checks that a certificate with the given name is usable for configuring a Wi-Fi connection. Fully creating such a connection would require a special network environment, so it just tests that the certificate is visible and selectable.
func CurrentPage ¶
CurrentPage return with an openedPage, which can be used to select a node from the node tree (not just from the page).
func EnsureCookiesAccepted ¶
func EnsureCookiesAccepted(ctx context.Context, br *browser.Browser, url, acceptBtnLocator string) error
EnsureCookiesAccepted ensures that cookies page for the given url is accepted and gone. It will open the url and click on the button with the given ID acceptBtnLocator.
func EnsureGoogleCookiesAccepted ¶
EnsureGoogleCookiesAccepted ensures that google related cookies are accepted (i.e. search, translate and extensions). It will open google page then click on Accept button.
func MaximizeActiveWindow ¶
MaximizeActiveWindow maximizes the browser active window.
func OSSettingsPage ¶
OSSettingsPage opens the OS settings page with given link (e.g. "osAccessibility" -> "chrome://os-settings/osAccessibility"). The returned openedPage value can be used to select a node from the node tree (not just from the page).
func OSSettingsPageWithPassword ¶
func OSSettingsPageWithPassword(ctx context.Context, cr *chrome.Chrome, shortLink, password string) *openedPage
OSSettingsPageWithPassword open the OS settings page with given link (e.g. "osAccessibility" -> "chrome://os-settings/osAccessibility"). If the opened settings page is password protected, try to authenticate with the given password. The returned openedPage value can be used to select a node from the node tree (not just from the page).
func Refresh ¶
Refresh takes a running Chrome API connection and refreshes policies. If the policices served have changed between now and the last time policies were fetched, this function will ensure that Chrome uses the changes. Note that this will not work for policies which require a reboot before a change is applied.
func RefreshChromePolicies ¶
RefreshChromePolicies forces an immediate refresh of policies in Chrome.
func ResetChrome ¶
ResetChrome resets chrome and removes all policies previously served by the FakeDMS.
func ResetChromeWithBlob ¶
func ResetChromeWithBlob(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, pb *policy.Blob) error
ResetChromeWithBlob resets chrome and replaces all policies previously served by the FakeDMS with PolicyBlob.
func ServeAndRefresh ¶
func ServeAndRefresh(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, ps []policy.Policy) error
ServeAndRefresh updates the policies served by FakeDMS and refreshes them in Chrome. Not all polcies can be set in this way and may require restarting Chrome or a reboot.
func ServeAndVerify ¶
func ServeAndVerify(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, ps []policy.Policy) error
ServeAndVerify serves the policies using ServeAndRefresh and verifies that they are set in Chrome.
func ServeAndVerifyOnLoginScreen ¶
func ServeAndVerifyOnLoginScreen(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, ps []policy.Policy) error
ServeAndVerifyOnLoginScreen same as ServeAndVerify but in the login context. It uses the Signin Profile Test API connection.
func ServeBlobAndRefresh ¶
func ServeBlobAndRefresh(ctx context.Context, fdms *fakedms.FakeDMS, cr *chrome.Chrome, pb *policy.Blob) error
ServeBlobAndRefresh updates the policy blob of FakeDMS and refreshes the policies in Chrome.
func SettingsPage ¶
func SettingsPage(ctx context.Context, cr *chrome.Chrome, br ash.ConnSource, shortLink string) *openedPage
SettingsPage opens a settings page with given link (e.g. "content/location" -> "chrome://settings/content/location"). The returned openedPage value can be used to select a node from the node tree (not just from the page).
func Verify ¶
Verify takes a TestAPIConn struct and slice of Policies and ensures that Chrome has the given policies are set correctly. Only the first error is returned.
Policies with StatusUnset or StatusDefault will be verified as not set or set with default source, respectively. This function does NOT ensure that other policies are not set on the DUT. Only policies passed in are considered, preventing test failures due to unrelated default policies.
func VerifyNodeState ¶
func VerifyNodeState(ctx context.Context, tconn *chrome.TestConn, finder *nodewith.Finder, exists bool, timeout time.Duration) error
VerifyNodeState repeatedly checks the existence of a node to make sure it reaches the desired status and stays in that state. Fully waits until the timeout expires to ensure non-existence. If the JavaScript fails to execute, an error is returned.
func VerifyNotExists ¶
func VerifyNotExists(ctx context.Context, tconn *chrome.TestConn, finder *nodewith.Finder, timeout time.Duration) error
VerifyNotExists checks if the element does not appear during timeout. The function first waits until the element disappears. Note: this waits for the full timeout to check that the element does not appear.
func WaitUntilExistsStatus ¶
func WaitUntilExistsStatus(ctx context.Context, tconn *chrome.TestConn, finder *nodewith.Finder, exists bool, timeout time.Duration) error
WaitUntilExistsStatus repeatedly checks the existence of a node until the desired status is found or the timeout is reached. If the JavaScript fails to execute, an error is returned.
Types ¶
type DUTPolicies ¶
type DUTPolicies struct { Chrome map[string]*DUTPolicy `json:"chromePolicies"` DeviceLocal map[string]*DUTPolicy `json:"deviceLocalAccountPolicies"` Extension map[string]*DUTPolicy `json:"extensionPolicies"` }
DUTPolicies represents the format returned from the getAllEnterprisePolicies API. Each member map matches a string policy name (as shown in chrome://policy, not a device policy field name) to a DUTPolicy struct of information on that policy.
func PoliciesFromDUT ¶
PoliciesFromDUT uses the passed in TestAPIConn to call autotestPrivate's getAllEnterprisePolicies function. For example data, see the Export to JSON button on chrome://policy. Note that a DUTPolicy contains a json.RawMessage value, not an unmarshalled value.
type DUTPolicy ¶
type DUTPolicy struct { Level string Scope string Source string Status string ValueJSON json.RawMessage `json:"value"` Error string }
A DUTPolicy represents the information about a single policy as returned by the getAllEnterprisePolicies API. Example JSON: {"scope": "user", "level": "mandatory", "source": "cloud",
"value": false, "error": "This policy has been deprecated."}
Directories ¶
Path | Synopsis |
---|---|
Package externaldata contains helpers to provide a http server for policies that download their contents from an external source.
|
Package externaldata contains helpers to provide a http server for policies that download their contents from an external source. |
Package fixtures contains fixtures useful for policy tests.
|
Package fixtures contains fixtures useful for policy tests. |
Package safesearch contains helpers for Google and YouTube safe search related policies.
|
Package safesearch contains helpers for Google and YouTube safe search related policies. |