|
| 1 | +import { test } from '@playwright/test' |
| 2 | +import { config } from '../../../e2e/config.js' |
| 3 | +import { ActorsEnvironment, UsersEnvironment } from '../../../e2e/support/environment/index.js' |
| 4 | +import { setAccessAndRefreshToken } from '../../helpers/setAccessAndRefreshToken.js' |
| 5 | +import * as api from '../../steps/api/api.js' |
| 6 | +import * as ui from '../../steps/ui/index' |
| 7 | +import { editor } from '../../../e2e/support/objects/app-files/utils/index.js' |
| 8 | + |
| 9 | +test.describe('groups management', () => { |
| 10 | + let actorsEnvironment |
| 11 | + const usersEnvironment = new UsersEnvironment() |
| 12 | + |
| 13 | + test.beforeEach(async ({ browser }) => { |
| 14 | + actorsEnvironment = new ActorsEnvironment({ |
| 15 | + context: { |
| 16 | + acceptDownloads: config.acceptDownloads, |
| 17 | + reportDir: config.reportDir, |
| 18 | + tracingReportDir: config.tracingReportDir, |
| 19 | + reportHar: config.reportHar, |
| 20 | + reportTracing: config.reportTracing, |
| 21 | + reportVideo: config.reportVideo, |
| 22 | + failOnUncaughtConsoleError: config.failOnUncaughtConsoleError |
| 23 | + }, |
| 24 | + browser: browser |
| 25 | + }) |
| 26 | + |
| 27 | + await setAccessAndRefreshToken(usersEnvironment) |
| 28 | + }) |
| 29 | + |
| 30 | + test.afterEach(async () => {}) |
| 31 | + |
| 32 | + test('keycloak group sync with oCIS', async () => { |
| 33 | + // Given "Admin" creates following user using API |
| 34 | + // | id | |
| 35 | + // | Alice | |
| 36 | + // | Brian | |
| 37 | + await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Alice' }) |
| 38 | + await api.userHasBeenCreated({ usersEnvironment, stepUser: 'Admin', userToBeCreated: 'Brian' }) |
| 39 | + |
| 40 | + // And "Alice" creates the following files into personal space using API |
| 41 | + // | pathToFile | content | |
| 42 | + // | shareToSales.txt | Keycloak group share | |
| 43 | + // | shareToSecurity.txt | Keycloak group share | |
| 44 | + await api.userHasCreatedFile({ |
| 45 | + usersEnvironment, |
| 46 | + stepUser: 'Alice', |
| 47 | + filename: 'shareToSales.txt', |
| 48 | + content: 'Keycloak group share' |
| 49 | + }) |
| 50 | + await api.userHasCreatedFile({ |
| 51 | + usersEnvironment, |
| 52 | + stepUser: 'Alice', |
| 53 | + filename: 'shareToSecurity.txt', |
| 54 | + content: 'Keycloak group share' |
| 55 | + }) |
| 56 | + // When "Admin" logs in |
| 57 | + await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Admin' }) |
| 58 | + |
| 59 | + // And "Admin" opens the "admin-settings" app |
| 60 | + await ui.openApplication({ actorsEnvironment, stepUser: 'Admin', name: 'admin-settings' }) |
| 61 | + |
| 62 | + // And "Admin" navigates to the groups management page |
| 63 | + await ui.navigateToGroupsManagementPage({ actorsEnvironment, stepUser: 'Admin' }) |
| 64 | + |
| 65 | + // When "Admin" creates the following groups |
| 66 | + // | id | |
| 67 | + // | security | |
| 68 | + // | sales | |
| 69 | + await ui.userCreatesGroup({ actorsEnvironment, stepUser: 'Admin', group: 'security' }) |
| 70 | + await ui.userCreatesGroup({ actorsEnvironment, stepUser: 'Admin', group: 'sales' }) |
| 71 | + |
| 72 | + // Then "Admin" should see the following group |
| 73 | + // | group | |
| 74 | + // | security | |
| 75 | + // | keycloak sales | |
| 76 | + // | keycloak finance | |
| 77 | + await ui.userShouldSeeGroups({ |
| 78 | + actorsEnvironment, |
| 79 | + stepUser: 'Admin', |
| 80 | + groups: ['security', 'keycloak sales', 'keycloak finance'] |
| 81 | + }) |
| 82 | + |
| 83 | + // When "Admin" navigates to the users management page |
| 84 | + await ui.userNavigatesToUserManagementPage({ actorsEnvironment, stepUser: 'Admin' }) |
| 85 | + // And "Admin" adds the user "Brian" to the groups "security,keycloak sales" using the sidebar panel |
| 86 | + await ui.userAddsUserToGroup({ |
| 87 | + actorsEnvironment, |
| 88 | + stepUser: 'Admin', |
| 89 | + action: 'adds', |
| 90 | + groups: ['security', 'keycloak sales'], |
| 91 | + user: 'Brian' |
| 92 | + }) |
| 93 | + |
| 94 | + // And "Admin" logs out |
| 95 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Admin' }) |
| 96 | + // And "Alice" logs in |
| 97 | + await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Alice' }) |
| 98 | + |
| 99 | + // And "Alice" shares the following resource using the sidebar panel |
| 100 | + // | resource | recipient | type | role | resourceType | |
| 101 | + // | shareToSales.txt | keycloak sales | group | Can edit without versions | file | |
| 102 | + // | shareToSecurity.txt | security | group | Can edit without versions | file | |
| 103 | + await ui.shareResource({ |
| 104 | + actorsEnvironment, |
| 105 | + usersEnvironment, |
| 106 | + stepUser: 'Alice', |
| 107 | + actionType: 'SIDEBAR_PANEL', |
| 108 | + resource: 'shareToSales.txt', |
| 109 | + recipient: 'keycloak sales', |
| 110 | + type: 'group', |
| 111 | + role: 'Can edit without versions', |
| 112 | + resourceType: 'file' |
| 113 | + }) |
| 114 | + |
| 115 | + await ui.shareResource({ |
| 116 | + actorsEnvironment, |
| 117 | + usersEnvironment, |
| 118 | + stepUser: 'Alice', |
| 119 | + actionType: 'SIDEBAR_PANEL', |
| 120 | + resource: 'shareToSales.txt', |
| 121 | + recipient: 'security', |
| 122 | + type: 'group', |
| 123 | + role: 'Can edit without versions', |
| 124 | + resourceType: 'file' |
| 125 | + }) |
| 126 | + |
| 127 | + // And "Alice" logs out |
| 128 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Alice' }) |
| 129 | + |
| 130 | + // And "Brian" logs in |
| 131 | + await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Brian' }) |
| 132 | + // And "Brian" navigates to the shared with me page |
| 133 | + await ui.navigateToSharedWithMePage({ actorsEnvironment, stepUser: 'Brian' }) |
| 134 | + |
| 135 | + // # user should have access to unsynced shares |
| 136 | + // When "Brian" opens the following file in texteditor |
| 137 | + // | resource | |
| 138 | + // | shareToSales.txt | |
| 139 | + await ui.userOpensTheFollowingFileIn({ |
| 140 | + actorsEnvironment, |
| 141 | + stepUser: 'Brian', |
| 142 | + resource: 'shareToSales.txt', |
| 143 | + actionType: 'texteditor' |
| 144 | + }) |
| 145 | + // And "Brian" closes the file viewer |
| 146 | + const { page } = actorsEnvironment.getActor({ key: 'Brian' }) |
| 147 | + await editor.close(page) |
| 148 | + // And "Brian" edits the following resources |
| 149 | + // | resource | content | |
| 150 | + // | shareToSecurity.txt | new content | |
| 151 | + await ui.userEditsResource({ |
| 152 | + actorsEnvironment, |
| 153 | + stepUser: 'Brian', |
| 154 | + resource: 'shareToSecurity.txt', |
| 155 | + content: 'new content' |
| 156 | + }) |
| 157 | + // And "Brian" logs out |
| 158 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Brian' }) |
| 159 | + |
| 160 | + // When "Admin" logs in |
| 161 | + await ui.logInUser({ usersEnvironment, actorsEnvironment, stepUser: 'Admin' }) |
| 162 | + |
| 163 | + // And "Admin" opens the "admin-settings" app |
| 164 | + await ui.openApplication({ actorsEnvironment, stepUser: 'Admin', name: 'admin-settings' }) |
| 165 | + |
| 166 | + // And "Admin" navigates to the groups management page |
| 167 | + await ui.navigateToGroupsManagementPage({ actorsEnvironment, stepUser: 'Admin' }) |
| 168 | + |
| 169 | + // # Renaming a Keycloak group results in the creation of a new group on the oCIS server (see https://github.com/owncloud/ocis/issues/10445). |
| 170 | + // # After renaming a group, it may take up to 5 minutes for the changes to sync, so avoid using the renamed group in the subsequent steps. |
| 171 | + // And "Admin" changes displayName to "a renamed group" for group "keycloak finance" using the sidebar panel |
| 172 | + await ui.userRenamesGroup({ |
| 173 | + actorsEnvironment, |
| 174 | + stepUser: 'Admin', |
| 175 | + attribute: 'displayName', |
| 176 | + value: 'a renamed group', |
| 177 | + user: 'keycloak finance' |
| 178 | + }) |
| 179 | + |
| 180 | + // When "Admin" deletes the following group using the context menu |
| 181 | + // | group | |
| 182 | + // | sales | |
| 183 | + await ui.userDeletesGroup({ |
| 184 | + actorsEnvironment, |
| 185 | + stepUser: 'Admin', |
| 186 | + actionType: 'contex menu', |
| 187 | + group: 'sales' |
| 188 | + }) |
| 189 | + // Then "Admin" should not see the following group |
| 190 | + // | group | |
| 191 | + // | sales | |
| 192 | + await ui.userShouldSeeGroups({ actorsEnvironment, stepUser: 'Admin', groups: ['sales'] }) |
| 193 | + // And "Admin" logs out |
| 194 | + await ui.logOutUser({ actorsEnvironment, stepUser: 'Admin' }) |
| 195 | + }) |
| 196 | +}) |
0 commit comments