-
Notifications
You must be signed in to change notification settings - Fork 25
update keycloak tests #906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| Feature: keycloak integration | ||
| As a user | ||
| I want to use Keycloak users and groups in OpenCloud | ||
| So that I can verify that Keycloak-created entities are accessible and functional in OpenCloud | ||
|
|
||
|
|
||
| Scenario: keycloak integration | ||
| Given admin creates following users using keycloak API | ||
| | id | | ||
| | Alice | | ||
| | Brian | | ||
| | Carol | | ||
| And admin assigns following roles to the users using keycloak API | ||
| | id | role | | ||
| | Alice | Space Admin | | ||
| # Group role assignment - all members of the group inherit the assigned role | ||
| And admin creates following groups using keycloak API | ||
| | id | role | | ||
| | sales | | | ||
| | finance | Space Admin | | ||
| | security | User | | ||
| And admin adds users to the group using keycloak API | ||
| | user | group | | ||
| | Alice | sales | | ||
| | Brian | finance | | ||
| | Carol | security | | ||
| | Carol | finance | | ||
|
|
||
| When "Alice" logs in | ||
| Then "Alice" should have self info: | ||
| | key | value | | ||
| | username | alice | | ||
| | displayname | Alice Hansen | | ||
| | email | alice@example.org | | ||
| | groups | sales | | ||
| And "Alice" opens the "files" app | ||
| And "Alice" navigates to the projects space page | ||
| And "Alice" creates the following project spaces | ||
| | name | id | | ||
| | teamSpace | teamSpace.1 | | ||
| And "Alice" navigates to the project space "teamSpace.1" | ||
| And "Alice" creates the following resources | ||
| | resource | type | | ||
| | security-folder | folder | | ||
| | finance-folder | folder | | ||
|
|
||
| And "Alice" shares the following resource using the sidebar panel | ||
| | resource | recipient | type | role | resourceType | | ||
| | finance-folder | finance | group | Can edit | folder | | ||
| | finance-folder | Brian | user | Can edit | file | | ||
| | security-folder | security | group | Can view | folder | | ||
| | security-folder | Carol | user | Can view | file | | ||
| And "Alice" logs out | ||
|
|
||
| And "Brian" logs in | ||
| And "Brian" navigates to the projects space page | ||
| And "Brian" creates the following project spaces | ||
| | name | id | | ||
| | brianSpace | brianSpace.1 | | ||
| And "Brian" navigates to the project space "brianSpace.1" | ||
| And "Brian" adds following users to the project space | ||
| | user | role | kind | | ||
| | Carol | Can edit | user | | ||
| | security | Can view | group | | ||
| And "Brian" logs out | ||
|
|
||
| When "Carol" logs in | ||
| Then "Carol" should have self info: | ||
| | key | value | | ||
| | username | carol | | ||
| | displayname | Carol King | | ||
| | email | carol@example.org | | ||
| | groups | finance, security | | ||
| And "Carol" opens the "files" app | ||
| And "Carol" navigates to the project space "brianSpace.1" | ||
| And "Carol" logs out |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import join from 'join-path' | ||
| import { request, realmBasePath } from './utils' | ||
| import { checkResponseStatus } from '../http' | ||
| import { Group, User } from '../../types' | ||
| import { UsersEnvironment } from '../../environment' | ||
| import { getAdminUser, getRealmRole, openCloudKeycloakUserRoles } from './user' | ||
|
|
||
| export const createGroup = async ({ | ||
| group, | ||
| role | ||
| }: { | ||
| group: Group | ||
| role?: string | ||
| }): Promise<Group> => { | ||
| const creationRes = await request({ | ||
| method: 'POST', | ||
| path: join(realmBasePath, 'groups'), | ||
| body: { name: group.displayName }, | ||
| user: getAdminUser(), | ||
| header: { 'Content-Type': 'application/json' } | ||
| }) | ||
| checkResponseStatus(creationRes, 'Failed while creating group') | ||
| const groupId = creationRes.headers()['location'].split('/').pop() | ||
| const usersEnvironment = new UsersEnvironment() | ||
| usersEnvironment.storeCreatedGroup({ group: { ...group, keycloakUuid: groupId } }) | ||
|
|
||
| if (role) { | ||
| const roleData = await getRealmRole(openCloudKeycloakUserRoles[role]) | ||
| const roleAssignmentRes = await request({ | ||
| method: 'POST', | ||
| path: join(realmBasePath, 'groups', groupId, 'role-mappings/realm'), | ||
| body: [ | ||
| { | ||
| id: roleData.id, | ||
| name: roleData.name, | ||
| description: '', | ||
| composite: false, | ||
| clientRole: false, | ||
| containerId: 'openCloud' | ||
| } | ||
| ], | ||
| user: getAdminUser(), | ||
| header: { 'Content-Type': 'application/json' } | ||
| }) | ||
| checkResponseStatus(roleAssignmentRes, `Failed while assigning role ${role} to group`) | ||
| } | ||
| return group | ||
| } | ||
|
|
||
| export const addUserToGroup = async ({ | ||
| user, | ||
| group | ||
| }: { | ||
| user: User | ||
| group: Group | ||
| }): Promise<void> => { | ||
| const response = await request({ | ||
| method: 'PUT', | ||
| path: join(realmBasePath, 'users', user.keycloakUuid, 'groups', group.keycloakUuid), | ||
| body: {}, | ||
| user: getAdminUser(), | ||
| header: { 'Content-Type': 'application/json' } | ||
| }) | ||
| checkResponseStatus(response, 'Failed while adding a user to the group') | ||
| } | ||
|
|
||
| export const deleteGroup = async ({ group }: { group: Group }): Promise<Group> => { | ||
| const response = await request({ | ||
| method: 'DELETE', | ||
| path: join(realmBasePath, 'groups', group.keycloakUuid), | ||
| body: {}, | ||
| user: getAdminUser(), | ||
| header: { 'Content-Type': 'application/json' } | ||
| }) | ||
| checkResponseStatus(response, 'Failed while adding a user to the group') | ||
| return group | ||
| } | ||
This file contains hidden or 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,3 +1,4 @@ | ||
| export * from './user' | ||
| export * from './utils' | ||
| export * from './openCloudUserToken' | ||
| export * from './group' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.