Skip to content

Commit

Permalink
Added SCIM Patch Acceptance Tests (#540)
Browse files Browse the repository at this point in the history
## Changes
Adds an acceptance test covering SCIM user patch that users can leverage
when interacting with the SCIM API.

## Tests
<!-- 
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->

- [ ] `make test` passing
- [ ] `make fmt` applied
- [ ] relevant integration tests applied
  • Loading branch information
mgyucht authored Jul 18, 2023
1 parent 546814a commit 180c7ee
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
35 changes: 34 additions & 1 deletion internal/scim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAccCurrentUser(t *testing.T) {
assert.NotEmpty(t, me.UserName)
}

func TestAccUsers(t *testing.T) {
func TestAccWorkspaceUsers(t *testing.T) {
ctx, w := workspaceTest(t)

// create new user
Expand Down Expand Up @@ -71,6 +71,39 @@ func TestAccUsers(t *testing.T) {
assert.True(t, apierr.IsMissing(err))
}

func TestAccAccountUsers(t *testing.T) {
ctx, a := accountTest(t)

user, err := a.Users.Create(ctx, iam.User{
DisplayName: RandomName("Me "),
UserName: RandomEmail(),
})
require.NoError(t, err)
t.Cleanup(func() {
err := a.Users.DeleteById(ctx, user.Id)
require.True(t, err == nil || apierr.IsMissing(err))
})

assert.Equal(t, 0, len(user.Roles))
err = a.Users.Patch(ctx, iam.PartialUpdate{
Id: user.Id,
Schema: []iam.PatchSchema{iam.PatchSchemaUrnIetfParamsScimApiMessages20PatchOp},
Operations: []iam.Patch{
{Op: iam.PatchOpAdd, Value: iam.User{
Roles: []iam.ComplexValue{
{Value: "account_admin"},
},
}},
},
})
require.NoError(t, err)

byId, err := a.Users.GetById(ctx, user.Id)
require.NoError(t, err)
assert.Equal(t, user.Id, byId.Id)
assert.Equal(t, 1, len(byId.Roles))
}

func TestAccGroups(t *testing.T) {
ctx, w := workspaceTest(t)

Expand Down
2 changes: 1 addition & 1 deletion openapi/roll/optimize.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *suiteOptimizer) enumConstant(l *lookup) expression {
Name: prefix,
},
Named: code.Named{
Name: value,
Name: e.Content,
},
Content: e.Content,
}
Expand Down
2 changes: 1 addition & 1 deletion service/iam/model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 180c7ee

Please sign in to comment.