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

Function TestGroupSyncTable

coderd/idpsync/group_test.go:97–396  ·  view source on GitHub ↗

nolint:paralleltest, tparallel

(t *testing.T)

Source from the content-addressed store, hash-verified

95
96//nolint:paralleltest, tparallel
97func TestGroupSyncTable(t *testing.T) {
98 t.Parallel()
99
100 userClaims := jwt.MapClaims{
101 "groups": []string{
102 "foo", "bar", "baz",
103 "create-bar", "create-baz",
104 "legacy-bar",
105 },
106 }
107
108 ids := coderdtest.NewDeterministicUUIDGenerator()
109 testCases := []orgSetupDefinition{
110 {
111 Name: "SwitchGroups",
112 GroupSettings: &codersdk.GroupSyncSettings{
113 Field: "groups",
114 Mapping: map[string][]uuid.UUID{
115 "foo": {ids.ID("sg-foo"), ids.ID("sg-foo-2")},
116 "bar": {ids.ID("sg-bar")},
117 "baz": {ids.ID("sg-baz")},
118 },
119 },
120 Groups: map[uuid.UUID]bool{
121 uuid.New(): true,
122 uuid.New(): true,
123 // Extra groups
124 ids.ID("sg-foo"): false,
125 ids.ID("sg-foo-2"): false,
126 ids.ID("sg-bar"): false,
127 ids.ID("sg-baz"): false,
128 },
129 assertGroups: &orgGroupAssert{
130 ExpectedGroups: []uuid.UUID{
131 ids.ID("sg-foo"),
132 ids.ID("sg-foo-2"),
133 ids.ID("sg-bar"),
134 ids.ID("sg-baz"),
135 },
136 },
137 },
138 {
139 Name: "StayInGroup",
140 GroupSettings: &codersdk.GroupSyncSettings{
141 Field: "groups",
142 // Only match foo, so bar does not map
143 RegexFilter: regexp.MustCompile("^foo$"),
144 Mapping: map[string][]uuid.UUID{
145 "foo": {ids.ID("gg-foo"), uuid.New()},
146 "bar": {ids.ID("gg-bar")},
147 "baz": {ids.ID("gg-baz")},
148 },
149 },
150 Groups: map[uuid.UUID]bool{
151 ids.ID("gg-foo"): true,
152 ids.ID("gg-bar"): false,
153 },
154 assertGroups: &orgGroupAssert{

Callers

nothing calls this directly

Calls 15

IDMethod · 0.95
AssertMethod · 0.95
NewDBFunction · 0.92
NewManagerFunction · 0.92
NewAGPLSyncFunction · 0.92
ContextFunction · 0.92
UserFunction · 0.92
SetupOrganizationFunction · 0.85
MustCompileMethod · 0.80
NewMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected