MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestNewAdminUserCreatePlan

Function TestNewAdminUserCreatePlan

internal/cmd/admin_user_create_plan_test.go:8–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestNewAdminUserCreatePlan(t *testing.T) {
9 t.Parallel()
10
11 plan, err := newAdminUserCreatePlan(adminUserCreateInput{
12 Email: " ada@example.com ",
13 GivenName: " Ada ",
14 FamilyName: " Lovelace ",
15 Password: " hashed-password ",
16 ChangePwd: true,
17 OrgUnit: " /Engineering ",
18 Suspended: true,
19 Archived: true,
20 RecoveryEmail: " recovery@example.net ",
21 RecoveryPhone: " +15551234567 ",
22 HashFunction: " sha1 ",
23 })
24 if err != nil {
25 t.Fatalf("newAdminUserCreatePlan: %v", err)
26 }
27 if plan.Email != "ada@example.com" || plan.Password != "hashed-password" || plan.GeneratePassword {
28 t.Fatalf("unexpected password plan: %#v", plan)
29 }
30 if plan.User.PrimaryEmail != "ada@example.com" ||
31 plan.User.Name == nil ||
32 plan.User.Name.GivenName != "Ada" ||
33 plan.User.Name.FamilyName != "Lovelace" {
34 t.Fatalf("unexpected identity: %#v", plan.User)
35 }
36 if plan.User.OrgUnitPath != "/Engineering" ||
37 plan.User.RecoveryEmail != "recovery@example.net" ||
38 plan.User.RecoveryPhone != "+15551234567" ||
39 plan.User.HashFunction != "SHA-1" {
40 t.Fatalf("unexpected profile: %#v", plan.User)
41 }
42 if !plan.User.ChangePasswordAtNextLogin || !plan.User.Suspended || !plan.User.Archived {
43 t.Fatalf("unexpected state: %#v", plan.User)
44 }
45 if plan.StatePatch == nil || !plan.StatePatch.Suspended || !plan.StatePatch.Archived {
46 t.Fatalf("unexpected state patch: %#v", plan.StatePatch)
47 }
48 request := plan.insertRequest(plan.Password)
49 if request.Password != "hashed-password" || plan.User.Password != "" {
50 t.Fatalf("unexpected insert request: %#v template=%#v", request, plan.User)
51 }
52}
53
54func TestNewAdminUserCreatePlanGeneratesPassword(t *testing.T) {
55 t.Parallel()

Callers

nothing calls this directly

Calls 2

newAdminUserCreatePlanFunction · 0.85
insertRequestMethod · 0.80

Tested by

no test coverage detected