generated from vshn/go-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from vshn/user-merge-client-side
Merge keycloak user on the client side
- Loading branch information
Showing
6 changed files
with
81 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/vshn/appuio-keycloak-adapter | ||
|
||
go 1.17 | ||
go 1.18 | ||
|
||
require ( | ||
github.com/Nerzal/gocloak/v11 v11.0.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,32 +18,31 @@ func TestPutUser_simple(t *testing.T) { | |
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
subject := gocloak.User{ | ||
ID: gocloak.StringP("fuuser-id"), | ||
Username: gocloak.StringP("fuuser"), | ||
FirstName: gocloak.StringP("Fuu"), | ||
LastName: gocloak.StringP("Ser"), | ||
Email: gocloak.StringP("[email protected]"), | ||
Attributes: &map[string][]string{ | ||
KeycloakDefaultOrganizationRef: {"foo"}, | ||
}, | ||
} | ||
|
||
mKeycloak := NewMockGoCloak(ctrl) | ||
c := Client{ | ||
Client: mKeycloak, | ||
} | ||
mockLogin(mKeycloak, c) | ||
mockGetUsers(mKeycloak, c, "fuuser", | ||
[]*gocloak.User{ | ||
{ | ||
ID: gocloak.StringP("fuuser-id"), | ||
Username: gocloak.StringP("fuuser"), | ||
FirstName: gocloak.StringP("Fuu"), | ||
LastName: gocloak.StringP("Ser"), | ||
Email: gocloak.StringP("[email protected]"), | ||
Attributes: &map[string][]string{ | ||
KeycloakDefaultOrganizationRef: {"foo"}, | ||
}, | ||
}, | ||
}) | ||
mockGetUsers(mKeycloak, c, "fuuser", []*gocloak.User{&subject}) | ||
mockUpdateUser(mKeycloak, c, | ||
gocloak.User{ | ||
ID: gocloak.StringP("fuuser-id"), | ||
Username: gocloak.StringP("fuuser"), | ||
Attributes: &map[string][]string{ | ||
func() gocloak.User { | ||
updated := subject | ||
updated.Attributes = &map[string][]string{ | ||
KeycloakDefaultOrganizationRef: {"new-foo"}, | ||
}, | ||
}) | ||
} | ||
return updated | ||
}()) | ||
|
||
u, err := c.PutUser(context.TODO(), User{Username: "fuuser", DefaultOrganizationRef: "new-foo"}) | ||
require.NoError(t, err) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters