blob: e223d54b0bfb81c85c4aa058b598b084bc1070a8 [file] [log] [blame]
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package familylink
import (
func init() {
Func: PolicyLogin,
Desc: "Checks if Unicorn login with policy setup is working",
Contacts: []string{"", ""},
Attr: []string{"group:mainline", "informational"},
SoftwareDeps: []string{"chrome"},
Timeout: 5 * time.Minute,
Fixture: "familyLinkUnicornPolicyLogin",
func PolicyLogin(ctx context.Context, s *testing.State) {
fdms := s.FixtValue().(*familylink.FixtData).FakeDMS
cr := s.FixtValue().(*familylink.FixtData).Chrome
tconn := s.FixtValue().(*familylink.FixtData).TestConn
// The ForceGoogleSafeSearch policy is arbitrarily chosen just to illustrate
// that setting policies works for Family Link users.
policies := []policy.Policy{
&policy.ForceGoogleSafeSearch{Val: true},
pb := fakedms.NewPolicyBlob()
pb.PolicyUser = s.FixtValue().(*familylink.FixtData).PolicyUser
if err := policyutil.ServeBlobAndRefresh(ctx, fdms, cr, pb); err != nil {
s.Fatal("Failed to serve policies: ", err)
s.Log("Verifying policies delivered to device")
if err := policyutil.Verify(ctx, tconn, policies); err != nil {
s.Fatal("Failed to verify policies: ", err)