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 (
"context"
"time"
"chromiumos/tast/common/policy"
"chromiumos/tast/common/policy/fakedms"
"chromiumos/tast/local/chrome/familylink"
"chromiumos/tast/local/policyutil"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: PolicyLogin,
Desc: "Checks if Unicorn login with policy setup is working",
Contacts: []string{"xiqiruan@chromium.org", "cros-families-eng+test@google.com"},
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
pb.AddPolicies(policies)
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)
}
}