Skip to content

Commit c81812c

Browse files
Fixed regression in databricks_group data not to require workspace admin privileges (#2210)
1 parent e30b8e0 commit c81812c

File tree

4 files changed

+13
-57
lines changed

4 files changed

+13
-57
lines changed

exporter/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (ic *importContext) cacheGroups() error {
200200
if len(ic.allGroups) == 0 {
201201
log.Printf("[INFO] Caching groups in memory ...")
202202
groupsAPI := scim.NewGroupsAPI(ic.Context, ic.Client)
203-
g, err := groupsAPI.Filter("", true)
203+
g, err := groupsAPI.Filter("")
204204
if err != nil {
205205
return err
206206
}

scim/data_group_test.go

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestDataSourceGroup(t *testing.T) {
1818
Fixtures: []qa.HTTPFixture{
1919
{
2020
Method: "GET",
21-
Resource: "/api/2.0/preview/scim/v2/Groups?excludedAttributes=roles&filter=displayName%20eq%20%27ds%27",
21+
Resource: "/api/2.0/preview/scim/v2/Groups?filter=displayName%20eq%20%27ds%27",
2222
Response: GroupList{
2323
Resources: []Group{
2424
{
@@ -48,43 +48,11 @@ func TestDataSourceGroup(t *testing.T) {
4848
Value: "abc",
4949
},
5050
},
51-
},
52-
},
53-
},
54-
},
55-
{
56-
Method: "GET",
57-
Resource: "/api/2.0/preview/scim/v2/Groups/eerste?attributes=members,roles,entitlements,externalId",
58-
Response: Group{
59-
DisplayName: "ds",
60-
ID: "eerste",
61-
Entitlements: []ComplexValue{
62-
{
63-
Value: "allow-cluster-create",
64-
},
65-
},
66-
Roles: []ComplexValue{
67-
{
68-
Value: "a",
69-
},
70-
},
71-
Members: []ComplexValue{
72-
{
73-
Ref: "Users/1112",
74-
Value: "1112",
75-
},
76-
{
77-
Ref: "ServicePrincipals/1113",
78-
Value: "1113",
79-
},
80-
{
81-
Ref: "Groups/1114",
82-
Value: "1114",
83-
},
84-
},
85-
Groups: []ComplexValue{
86-
{
87-
Value: "abc",
51+
Roles: []ComplexValue{
52+
{
53+
Value: "a",
54+
},
55+
},
8856
},
8957
},
9058
},

scim/groups.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,27 @@ func (a GroupsAPI) Read(groupID, attributes string) (group Group, err error) {
4040
}
4141

4242
// Filter returns groups matching the filter
43-
func (a GroupsAPI) Filter(filter string, includeRoles bool) (GroupList, error) {
43+
func (a GroupsAPI) Filter(filter string) (GroupList, error) {
4444
var groups GroupList
4545
req := map[string]string{}
4646
if filter != "" {
4747
req["filter"] = filter
4848
}
49-
if !includeRoles {
50-
// We exclude roles to reduce load on the scim service
51-
req["excludedAttributes"] = "roles"
52-
}
5349
err := a.client.Scim(a.context, http.MethodGet, "/preview/scim/v2/Groups", req, &groups)
5450
return groups, err
5551
}
5652

5753
func (a GroupsAPI) ReadByDisplayName(displayName, attributes string) (group Group, err error) {
58-
groupList, err := a.Filter(fmt.Sprintf("displayName eq '%s'", displayName), false)
54+
groupList, err := a.Filter(fmt.Sprintf("displayName eq '%s'", displayName))
5955
if err != nil {
6056
return
6157
}
6258
if len(groupList.Resources) == 0 {
6359
err = fmt.Errorf("cannot find group: %s", displayName)
6460
return
6561
}
66-
// We GET the group again to fetch any fields that were excluded the first
67-
// time around
68-
return a.Read(groupList.Resources[0].ID, attributes)
62+
group = groupList.Resources[0]
63+
return
6964
}
7065

7166
func (a GroupsAPI) Patch(groupID string, r patchRequest) error {

scim/resource_group_test.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func TestCreateForceOverwriteCannotListGroups(t *testing.T) {
354354
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
355355
{
356356
Method: "GET",
357-
Resource: "/api/2.0/preview/scim/v2/Groups?excludedAttributes=roles&filter=displayName%20eq%20%27abc%27",
357+
Resource: "/api/2.0/preview/scim/v2/Groups?filter=displayName%20eq%20%27abc%27",
358358
Status: 417,
359359
Response: apierr.APIError{
360360
Message: "cannot find group",
@@ -376,7 +376,7 @@ func TestCreateForceOverwriteFindsAndSetsGroupID(t *testing.T) {
376376
qa.HTTPFixturesApply(t, []qa.HTTPFixture{
377377
{
378378
Method: "GET",
379-
Resource: "/api/2.0/preview/scim/v2/Groups?excludedAttributes=roles&filter=displayName%20eq%20%27abc%27",
379+
Resource: "/api/2.0/preview/scim/v2/Groups?filter=displayName%20eq%20%27abc%27",
380380
Response: GroupList{
381381
Resources: []Group{
382382
{
@@ -392,13 +392,6 @@ func TestCreateForceOverwriteFindsAndSetsGroupID(t *testing.T) {
392392
ID: "123",
393393
},
394394
},
395-
{
396-
Method: "GET",
397-
Resource: "/api/2.0/preview/scim/v2/Groups/123?attributes=",
398-
Response: Group{
399-
ID: "123",
400-
},
401-
},
402395
{
403396
Method: "PUT",
404397
Resource: "/api/2.0/preview/scim/v2/Groups/123",

0 commit comments

Comments
 (0)