MCPcopy Index your code
hub / github.com/coder/coder / TestGetGroupSyncSettings

Function TestGetGroupSyncSettings

enterprise/coderd/idpsync_test.go:23–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func TestGetGroupSyncSettings(t *testing.T) {
24 t.Parallel()
25
26 t.Run("OK", func(t *testing.T) {
27 t.Parallel()
28
29 owner, db, user := coderdenttest.NewWithDatabase(t, &coderdenttest.Options{
30 LicenseOptions: &coderdenttest.LicenseOptions{
31 Features: license.Features{
32 codersdk.FeatureCustomRoles: 1,
33 codersdk.FeatureMultipleOrganizations: 1,
34 },
35 },
36 })
37 orgAdmin, _ := coderdtest.CreateAnotherUser(t, owner, user.OrganizationID, rbac.ScopedRoleOrgAdmin(user.OrganizationID))
38
39 ctx := testutil.Context(t, testutil.WaitShort)
40 dbresv := runtimeconfig.OrganizationResolver(user.OrganizationID, runtimeconfig.NewStoreResolver(db))
41 entry := runtimeconfig.MustNew[*idpsync.GroupSyncSettings]("group-sync-settings")
42 err := entry.SetRuntimeValue(dbauthz.AsSystemRestricted(ctx), dbresv, &idpsync.GroupSyncSettings{Field: "august"})
43 require.NoError(t, err)
44
45 settings, err := orgAdmin.GroupIDPSyncSettings(ctx, user.OrganizationID.String())
46 require.NoError(t, err)
47 require.Equal(t, "august", settings.Field)
48 })
49
50 t.Run("Legacy", func(t *testing.T) {
51 t.Parallel()
52
53 dv := coderdtest.DeploymentValues(t)
54 dv.OIDC.GroupField = "legacy-group"
55 dv.OIDC.GroupRegexFilter = serpent.Regexp(*regexp.MustCompile("legacy-filter"))
56 dv.OIDC.GroupMapping = serpent.Struct[map[string]string]{
57 Value: map[string]string{
58 "foo": "bar",
59 },
60 }
61
62 owner, user := coderdenttest.New(t, &coderdenttest.Options{
63 Options: &coderdtest.Options{
64 DeploymentValues: dv,
65 },
66 LicenseOptions: &coderdenttest.LicenseOptions{
67 Features: license.Features{
68 codersdk.FeatureCustomRoles: 1,
69 codersdk.FeatureMultipleOrganizations: 1,
70 },
71 },
72 })
73 orgAdmin, _ := coderdtest.CreateAnotherUser(t, owner, user.OrganizationID, rbac.ScopedRoleOrgAdmin(user.OrganizationID))
74
75 ctx := testutil.Context(t, testutil.WaitShort)
76
77 settings, err := orgAdmin.GroupIDPSyncSettings(ctx, user.OrganizationID.String())
78 require.NoError(t, err)
79 require.Equal(t, dv.OIDC.GroupField.Value(), settings.Field)
80 require.Equal(t, dv.OIDC.GroupRegexFilter.String(), settings.RegexFilter.String())

Callers

nothing calls this directly

Calls 15

NewWithDatabaseFunction · 0.92
CreateAnotherUserFunction · 0.92
ScopedRoleOrgAdminFunction · 0.92
ContextFunction · 0.92
OrganizationResolverFunction · 0.92
NewStoreResolverFunction · 0.92
AsSystemRestrictedFunction · 0.92
DeploymentValuesFunction · 0.92
NewFunction · 0.92
SetRuntimeValueMethod · 0.80
GroupIDPSyncSettingsMethod · 0.80
MustCompileMethod · 0.80

Tested by

no test coverage detected