Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit188f3d5

Browse files
committed
test: add deleted organization noise to existing enterprise idp sync test
1 parenta849974 commit188f3d5

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

‎enterprise/coderd/enidpsync/organizations_test.go

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/coder/coder/v2/coderd/database"
1515
"github.com/coder/coder/v2/coderd/database/db2sdk"
1616
"github.com/coder/coder/v2/coderd/database/dbauthz"
17+
"github.com/coder/coder/v2/coderd/database/dbfake"
1718
"github.com/coder/coder/v2/coderd/database/dbgen"
1819
"github.com/coder/coder/v2/coderd/database/dbtestutil"
1920
"github.com/coder/coder/v2/coderd/entitlements"
@@ -89,7 +90,8 @@ func TestOrganizationSync(t *testing.T) {
8990
Name:"SingleOrgDeployment",
9091
Case:func(t*testing.T,db database.Store)OrganizationSyncTestCase {
9192
def,_:=db.GetDefaultOrganization(context.Background())
92-
other:=dbgen.Organization(t,db, database.Organization{})
93+
other:=dbfake.Organization(t,db).Do()
94+
deleted:=dbfake.Organization(t,db).Deleted(true).Do()
9395
returnOrganizationSyncTestCase{
9496
Entitlements:entitled,
9597
Settings: idpsync.DeploymentSyncSettings{
@@ -123,11 +125,19 @@ func TestOrganizationSync(t *testing.T) {
123125
})
124126
dbgen.OrganizationMember(t,db, database.OrganizationMember{
125127
UserID:user.ID,
126-
OrganizationID:other.ID,
128+
OrganizationID:other.Org.ID,
129+
})
130+
dbgen.OrganizationMember(t,db, database.OrganizationMember{
131+
UserID:user.ID,
132+
OrganizationID:deleted.Org.ID,
127133
})
128134
},
129135
Sync:ExpectedUser{
130-
Organizations: []uuid.UUID{def.ID,other.ID},
136+
Organizations: []uuid.UUID{
137+
def.ID,other.Org.ID,
138+
// The user remains in the deleted org because no idp sync happens.
139+
deleted.Org.ID,
140+
},
131141
},
132142
},
133143
},
@@ -138,17 +148,19 @@ func TestOrganizationSync(t *testing.T) {
138148
Name:"MultiOrgWithDefault",
139149
Case:func(t*testing.T,db database.Store)OrganizationSyncTestCase {
140150
def,_:=db.GetDefaultOrganization(context.Background())
141-
one:=dbgen.Organization(t,db, database.Organization{})
142-
two:=dbgen.Organization(t,db, database.Organization{})
143-
three:=dbgen.Organization(t,db, database.Organization{})
151+
one:=dbfake.Organization(t,db).Do()
152+
two:=dbfake.Organization(t,db).Do()
153+
three:=dbfake.Organization(t,db).Do()
154+
deleted:=dbfake.Organization(t,db).Deleted(true).Do()
144155
returnOrganizationSyncTestCase{
145156
Entitlements:entitled,
146157
Settings: idpsync.DeploymentSyncSettings{
147158
OrganizationField:"organizations",
148159
OrganizationMapping:map[string][]uuid.UUID{
149-
"first": {one.ID},
150-
"second": {two.ID},
151-
"third": {three.ID},
160+
"first": {one.Org.ID},
161+
"second": {two.Org.ID},
162+
"third": {three.Org.ID},
163+
"deleted": {deleted.Org.ID},
152164
},
153165
OrganizationAssignDefault:true,
154166
},
@@ -167,7 +179,7 @@ func TestOrganizationSync(t *testing.T) {
167179
{
168180
Name:"AlreadyInOrgs",
169181
Claims: jwt.MapClaims{
170-
"organizations": []string{"second","extra"},
182+
"organizations": []string{"second","extra","deleted"},
171183
},
172184
ExpectedParams: idpsync.OrganizationParams{
173185
SyncEntitled:true,
@@ -180,18 +192,18 @@ func TestOrganizationSync(t *testing.T) {
180192
})
181193
dbgen.OrganizationMember(t,db, database.OrganizationMember{
182194
UserID:user.ID,
183-
OrganizationID:one.ID,
195+
OrganizationID:one.Org.ID,
184196
})
185197
},
186198
Sync:ExpectedUser{
187-
Organizations: []uuid.UUID{def.ID,two.ID},
199+
Organizations: []uuid.UUID{def.ID,two.Org.ID},
188200
},
189201
},
190202
{
191203
Name:"ManyClaims",
192204
Claims: jwt.MapClaims{
193205
// Add some repeats
194-
"organizations": []string{"second","extra","first","third","second","second"},
206+
"organizations": []string{"second","extra","first","third","second","second","deleted"},
195207
},
196208
ExpectedParams: idpsync.OrganizationParams{
197209
SyncEntitled:true,
@@ -204,11 +216,11 @@ func TestOrganizationSync(t *testing.T) {
204216
})
205217
dbgen.OrganizationMember(t,db, database.OrganizationMember{
206218
UserID:user.ID,
207-
OrganizationID:one.ID,
219+
OrganizationID:one.Org.ID,
208220
})
209221
},
210222
Sync:ExpectedUser{
211-
Organizations: []uuid.UUID{def.ID,one.ID,two.ID,three.ID},
223+
Organizations: []uuid.UUID{def.ID,one.Org.ID,two.Org.ID,three.Org.ID},
212224
},
213225
},
214226
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp