Skip to content

Commit 12c7af7

Browse files
committed
rebase fixes
1 parent f51fae7 commit 12c7af7

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

coderd/idpsync/group_test.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestGroupSyncTable(t *testing.T) {
8585
testCases := []orgSetupDefinition{
8686
{
8787
Name: "SwitchGroups",
88-
Settings: &codersdk.GroupSyncSettings{
88+
GroupSettings: &codersdk.GroupSyncSettings{
8989
Field: "groups",
9090
Mapping: map[string][]uuid.UUID{
9191
"foo": {ids.ID("sg-foo"), ids.ID("sg-foo-2")},
@@ -113,7 +113,7 @@ func TestGroupSyncTable(t *testing.T) {
113113
},
114114
{
115115
Name: "StayInGroup",
116-
Settings: &codersdk.GroupSyncSettings{
116+
GroupSettings: &codersdk.GroupSyncSettings{
117117
Field: "groups",
118118
// Only match foo, so bar does not map
119119
RegexFilter: regexp.MustCompile("^foo$"),
@@ -135,7 +135,7 @@ func TestGroupSyncTable(t *testing.T) {
135135
},
136136
{
137137
Name: "UserJoinsGroups",
138-
Settings: &codersdk.GroupSyncSettings{
138+
GroupSettings: &codersdk.GroupSyncSettings{
139139
Field: "groups",
140140
Mapping: map[string][]uuid.UUID{
141141
"foo": {ids.ID("ng-foo"), uuid.New()},
@@ -160,7 +160,7 @@ func TestGroupSyncTable(t *testing.T) {
160160
},
161161
{
162162
Name: "CreateGroups",
163-
Settings: &codersdk.GroupSyncSettings{
163+
GroupSettings: &codersdk.GroupSyncSettings{
164164
Field: "groups",
165165
RegexFilter: regexp.MustCompile("^create"),
166166
AutoCreateMissing: true,
@@ -175,7 +175,7 @@ func TestGroupSyncTable(t *testing.T) {
175175
},
176176
{
177177
Name: "GroupNamesNoMapping",
178-
Settings: &codersdk.GroupSyncSettings{
178+
GroupSettings: &codersdk.GroupSyncSettings{
179179
Field: "groups",
180180
RegexFilter: regexp.MustCompile(".*"),
181181
AutoCreateMissing: false,
@@ -194,7 +194,7 @@ func TestGroupSyncTable(t *testing.T) {
194194
},
195195
{
196196
Name: "NoUser",
197-
Settings: &codersdk.GroupSyncSettings{
197+
GroupSettings: &codersdk.GroupSyncSettings{
198198
Field: "groups",
199199
Mapping: map[string][]uuid.UUID{
200200
// Extra ID that does not map to a group
@@ -219,7 +219,7 @@ func TestGroupSyncTable(t *testing.T) {
219219
},
220220
{
221221
Name: "LegacyMapping",
222-
Settings: &codersdk.GroupSyncSettings{
222+
GroupSettings: &codersdk.GroupSyncSettings{
223223
Field: "groups",
224224
RegexFilter: regexp.MustCompile("^legacy"),
225225
LegacyNameMapping: map[string]string{
@@ -401,7 +401,7 @@ func TestSyncDisabled(t *testing.T) {
401401
ids.ID("baz"): false,
402402
ids.ID("bop"): false,
403403
},
404-
Settings: &codersdk.GroupSyncSettings{
404+
GroupSettings: &codersdk.GroupSyncSettings{
405405
Field: "groups",
406406
Mapping: map[string][]uuid.UUID{
407407
"foo": {ids.ID("foo")},
@@ -747,11 +747,15 @@ func SetupOrganization(t *testing.T, s *idpsync.AGPLIDPSync, db database.Store,
747747

748748
manager := runtimeconfig.NewManager()
749749
orgResolver := manager.OrganizationResolver(db, org.ID)
750-
err = s.Group.SetRuntimeValue(context.Background(), orgResolver, def.GroupSettings)
751-
require.NoError(t, err)
750+
if def.GroupSettings != nil {
751+
err = s.Group.SetRuntimeValue(context.Background(), orgResolver, (*idpsync.GroupSyncSettings)(def.GroupSettings))
752+
require.NoError(t, err)
753+
}
752754

753-
err = s.Role.SetRuntimeValue(context.Background(), orgResolver, def.RoleSettings)
754-
require.NoError(t, err)
755+
if def.RoleSettings != nil {
756+
err = s.Role.SetRuntimeValue(context.Background(), orgResolver, def.RoleSettings)
757+
require.NoError(t, err)
758+
}
755759

756760
if !def.NotMember {
757761
dbgen.OrganizationMember(t, db, database.OrganizationMember{
@@ -822,7 +826,7 @@ type orgSetupDefinition struct {
822826
// NotMember if true will ensure the user is not a member of the organization.
823827
NotMember bool
824828

825-
GroupSettings *idpsync.GroupSyncSettings
829+
GroupSettings *codersdk.GroupSyncSettings
826830
RoleSettings *idpsync.RoleSyncSettings
827831

828832
assertGroups *orgGroupAssert

0 commit comments

Comments
 (0)