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