nolint:paralleltest, tparallel
(t *testing.T)
| 95 | |
| 96 | //nolint:paralleltest, tparallel |
| 97 | func 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{ |
nothing calls this directly
no test coverage detected