@@ -359,6 +359,23 @@ var emptyGlobalSQLConfig = qa.HTTPFixture{
359359}
360360
361361func TestImportingUsersGroupsSecretScopes (t * testing.T ) {
362+ listSpFixtures := qa .ListServicePrincipalsFixtures ([]iam.ServicePrincipal {
363+ {
364+ Id : "345" ,
365+ ApplicationId : "spn" ,
366+ },
367+ })
368+ listUserFixtures := qa .ListUsersFixtures ([]iam.User {
369+ {
370+ Id : "123" ,
371+ 372+ },
373+ })
374+ listGroupFixtures := qa .ListGroupsFixtures ([]iam.Group {
375+ {Id : "a" },
376+ {Id : "b" },
377+ {Id : "c" },
378+ })
362379 qa .HTTPFixturesApply (t ,
363380 []qa.HTTPFixture {
364381 meAdminFixture ,
@@ -379,18 +396,8 @@ func TestImportingUsersGroupsSecretScopes(t *testing.T) {
379396 allKnownWorkspaceConfs ,
380397 dummyWorkspaceConf ,
381398 emptyGlobalSQLConfig ,
382- {
383- Method : "GET" ,
384- Resource : "/api/2.0/preview/scim/v2/ServicePrincipals?attributes=id%2CuserName" ,
385- Response : iam.ListServicePrincipalResponse {
386- Resources : []iam.ServicePrincipal {
387- {
388- Id : "345" ,
389- ApplicationId : "spn" ,
390- },
391- },
392- },
393- },
399+ listSpFixtures [0 ],
400+ listSpFixtures [1 ],
394401 {
395402 Method : "GET" ,
396403 Resource : "/api/2.0/preview/scim/v2/ServicePrincipals/345?attributes=userName,displayName,active,externalId,entitlements" ,
@@ -409,29 +416,10 @@ func TestImportingUsersGroupsSecretScopes(t *testing.T) {
409416 },
410417 ReuseRequest : true ,
411418 },
412- {
413- Method : "GET" ,
414- Resource : "/api/2.0/preview/scim/v2/Users?attributes=userName%2Cid" ,
415-
416- Response : iam.ListUsersResponse {
417- Resources : []iam.User {
418- {
419- Id : "123" ,
420- 421- },
422- },
423- },
424- },
425- {
426- Method : "GET" ,
427- Resource : "/api/2.0/preview/scim/v2/Groups?attributes=id" ,
428- Response : scim.GroupList {
429- Resources : []scim.Group {
430- {ID : "a" },
431- {ID : "b" },
432- {ID : "c" },
433- }},
434- },
419+ listUserFixtures [0 ],
420+ listUserFixtures [1 ],
421+ listGroupFixtures [0 ],
422+ listGroupFixtures [1 ],
435423 {
436424 Method : "GET" ,
437425 Resource : "/api/2.0/preview/scim/v2/Groups/a" ,
@@ -488,6 +476,34 @@ func TestImportingUsersGroupsSecretScopes(t *testing.T) {
488476 },
489477 ReuseRequest : true ,
490478 },
479+ // Get requests appear to be made with two different sets of parameters. The first set is defined in `util.go`, the second
480+ // in the groups resource definition itself.
481+ {
482+ Method : "GET" ,
483+ Resource : "/api/2.0/preview/scim/v2/Groups/a?attributes=id,displayName,active,externalId,entitlements,groups,roles,members" ,
484+ Response : scim.Group {ID : "a" , DisplayName : "admins" ,
485+ Members : []scim.ComplexValue {
486+ {
Display :
"[email protected] " ,
Value :
"123" ,
Ref :
"Users/123" },
487+ {Display : "Test group" , Value : "f" , Ref : "Groups/f" },
488+ {Display : "spn" , Value : "spn" , Ref : "ServicePrincipals/spn" },
489+ },
490+ },
491+ ReuseRequest : true ,
492+ },
493+ {
494+ Method : "GET" ,
495+ Resource : "/api/2.0/preview/scim/v2/Groups/b?attributes=id,displayName,active,externalId,entitlements,groups,roles,members" ,
496+ Response : scim.Group {ID : "b" , DisplayName : "users" },
497+ },
498+ {
499+ Method : "GET" ,
500+ Resource : "/api/2.0/preview/scim/v2/Groups/c?attributes=id,displayName,active,externalId,entitlements,groups,roles,members" ,
501+ Response : scim.Group {ID : "c" , DisplayName : "test" ,
502+ Groups : []scim.ComplexValue {
503+ {Display : "admins" , Value : "a" , Ref : "Groups/a" , Type : "direct" },
504+ },
505+ },
506+ },
491507 {
492508 Method : "GET" ,
493509 Resource : "/api/2.0/preview/scim/v2/Groups/a?attributes=displayName,externalId,entitlements" ,
@@ -624,11 +640,7 @@ func TestImportingNoResourcesError(t *testing.T) {
624640 emptyInstancePools ,
625641 emptyClusterPolicies ,
626642 dummyWorkspaceConf ,
627- {
628- Method : "GET" ,
629- Resource : "/api/2.0/preview/scim/v2/Groups?attributes=id" ,
630- Response : scim.GroupList {Resources : []scim.Group {}},
631- },
643+ qa .ListGroupsFixtures ([]iam.Group {})[0 ],
632644 emptyGitCredentials ,
633645 emptyIpAccessLIst ,
634646 emptyWorkspace ,
@@ -1466,25 +1478,16 @@ func TestImportingGlobalInitScripts(t *testing.T) {
14661478}
14671479
14681480func TestImportingUser (t * testing.T ) {
1481+ userFixture := qa .ListUsersFixtures ([]iam.User {
1482+ {
1483+ Id : "123" ,
1484+ UserName : "me" ,
1485+ },
1486+ })
14691487 qa .HTTPFixturesApply (t ,
14701488 []qa.HTTPFixture {
1471- {
1472- Method : "GET" ,
1473- Resource : "/api/2.0/preview/scim/v2/Users?attributes=userName%2Cid" ,
1474- Response : iam.ListUsersResponse {
1475- Resources : []iam.User {
1476- {
1477- Id : "123" ,
1478- UserName : "me" ,
1479- },
1480- },
1481- },
1482- },
1483- {
1484- Method : "GET" ,
1485- Resource : "/api/2.0/preview/scim/v2/Users?attributes=userName%2Cid&startIndex=1" ,
1486- Response : iam.ListUsersResponse {},
1487- },
1489+ userFixture [0 ],
1490+ userFixture [1 ],
14881491 {
14891492 Method : "GET" ,
14901493 ReuseRequest : true ,
@@ -1779,6 +1782,9 @@ func TestImportingSqlObjects(t *testing.T) {
17791782}
17801783
17811784func TestImportingDLTPipelines (t * testing.T ) {
1785+ userFixture := qa .ListUsersFixtures ([]iam.User {
1786+ {
Id :
"123" ,
UserName :
"[email protected] " },
1787+ })
17821788 qa .HTTPFixturesApply (t ,
17831789 []qa.HTTPFixture {
17841790 meAdminFixture ,
@@ -1830,20 +1836,8 @@ func TestImportingDLTPipelines(t *testing.T) {
18301836 },
18311837 ReuseRequest : true ,
18321838 },
1833- {
1834- Method : "GET" ,
1835- Resource : "/api/2.0/preview/scim/v2/Users?attributes=userName%2Cid" ,
1836- Response : iam.ListUsersResponse {
1837- Resources : []iam.User {
1838- {
Id :
"123" ,
UserName :
"[email protected] " },
1839- },
1840- },
1841- },
1842- {
1843- Method : "GET" ,
1844- Resource : "/api/2.0/preview/scim/v2/Users?attributes=userName%2Cid&startIndex=1" ,
1845- Response : iam.ListUsersResponse {},
1846- },
1839+ userFixture [0 ],
1840+ userFixture [1 ],
18471841 {
18481842 Method : "GET" ,
18491843 Resource : "/api/2.0/preview/scim/v2/Users/123?attributes=userName,displayName,active,externalId,entitlements" ,
0 commit comments