Skip to content

Commit

Permalink
enable autoaccepting in e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor committed Oct 6, 2023
1 parent ec641b4 commit eed1938
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 109 deletions.
1 change: 1 addition & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@ def ocisService(type, tika_enabled = False):
"WEB_ASSET_PATH": "%s/dist" % dir["web"],
"FRONTEND_SEARCH_MIN_LENGTH": "2",
"FRONTEND_OCS_ENABLE_DENIALS": True,
"FRONTEND_AUTO_ACCEPT_SHARES": True,
}
if type == "app-provider":
environment["GATEWAY_GRPC_ADDR"] = "0.0.0.0:9142"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
FRONTEND_OCS_ENABLE_DENIALS: "true"
FRONTEND_FULL_TEXT_SEARCH_ENABLED: "true"
FRONTEND_PASSWORD_POLICY_BANNED_PASSWORDS_LIST: '/etc/ocis/password-policy-banned-passwords.txt'
FRONTEND_AUTO_ACCEPT_SHARES: "true"

# IDM
IDM_CREATE_DEMO_USERS: "${DEMO_USERS:-true}"
Expand Down
6 changes: 0 additions & 6 deletions tests/e2e/cucumber/features/journeys/kindergarten.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ Feature: Kindergarten can use web to organize a day
When "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
And "Brian" accepts the following share
| name |
| meal plan |
And "Brian" downloads the following resources using the sidebar panel
| resource | from | type |
| data.zip | meal plan | file |
Expand All @@ -52,9 +49,6 @@ Feature: Kindergarten can use web to organize a day
When "Carol" logs in
And "Carol" opens the "files" app
And "Carol" navigates to the shared with me page
And "Carol" accepts the following shares
| name |
| meal plan |
And "Carol" downloads the following resources using the sidebar panel
| resource | from | type |
| data.zip | meal plan | file |
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/cucumber/features/smoke/denyShareAccess.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ Feature: deny share access
And "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
And "Brian" accepts the following share
| name |
| folder_to_shared |
And "Brian" opens folder "folder_to_shared"
Then following resources should not be displayed in the files list for user "Brian"
| resource |
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/cucumber/features/smoke/fullTextSearch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ Feature: Search
| fileToShare.txt | Brian | user | Can edit |
And "Alice" logs out
And "Brian" logs in
And "Brian" accepts the following share using API
| name |
| fileToShare.txt |
And "Brian" creates the following folder in personal space using API
| name |
| testFolder |
Expand Down
6 changes: 4 additions & 2 deletions tests/e2e/cucumber/features/smoke/groupActions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Feature: Group actions
| Brian | sales |
| Brian | finance |
| Brian | security |
And "Brian" logs in
# disabling auto accepting to check accepting share
And "Brian" disables auto-accepting using API

And "Alice" logs in
And "Alice" creates the following folders in personal space using API
| name |
Expand Down Expand Up @@ -53,11 +57,9 @@ Feature: Group actions
| sharedFolder | finance | group | Can edit |
| sharedFolder | security | group | Can edit |

When "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page

# multiple share accept
And "Brian" accepts all pending shares using the batch actions
And "Alice" logs out
And "Brian" logs out
9 changes: 5 additions & 4 deletions tests/e2e/cucumber/features/smoke/internalLink.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ Feature: internal link share
When "Alice" edits the public link named "Link" of resource "myfolder" changing role to "Invited people"
And "Brian" opens the public link "Link"
And "Brian" logs in from the internal link
And "Brian" opens shared-with-me page from the internal link
And "Brian" accepts the following share
| name |
| myfolder |

# comment out after fixing #9776
# And "Brian" opens shared-with-me page from the internal link
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
And "Brian" uploads the following resource
| resource | to |
| simple.pdf | myfolder |
Expand Down
22 changes: 8 additions & 14 deletions tests/e2e/cucumber/features/smoke/link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,16 @@ Feature: link
And "Alice" renames the most recently created public link of resource "testavatar.jpg" to "imageLink"
And "Alice" logs out
And "Brian" logs in
And "Brian" navigates to the shared with me page
And "Brian" accepts the following share
| name |
| folderPublic |
| simple.pdf |
| testavatar.jpg |
When "Brian" opens the public link "folderLink"
And "Brian" uploads the following resources
| resource |
| lorem.txt |
When "Brian" opens the public link "textLink"
Then for "Brian" file "shareToBrian.txt" should be selected
When "Brian" opens the public link "markdownLink"
Then for "Brian" file "shareToBrian.md" should be selected
When "Brian" opens the public link "pdfLink"
Then for "Brian" file "simple.pdf" should be selected
When "Brian" opens the public link "imageLink"
Then for "Brian" file "testavatar.jpg" should be selected
# When "Brian" opens the public link "textLink"
# Then for "Brian" file "shareToBrian.txt" should be selected
# When "Brian" opens the public link "markdownLink"
# Then for "Brian" file "shareToBrian.md" should be selected
# When "Brian" opens the public link "pdfLink"
# Then for "Brian" file "simple.pdf" should be selected
# When "Brian" opens the public link "imageLink"
# Then for "Brian" file "testavatar.jpg" should be selected
And "Brian" logs out
8 changes: 1 addition & 7 deletions tests/e2e/cucumber/features/smoke/reshare.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ Feature: reshare
And "Alice" shares the following resource using API
| resource | recipient | type | role |
| folder_to_shared | Brian | user | Can edit |

And "Brian" logs in
And "Brian" accepts the following share using API
| name |
| folder_to_shared |

And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
And "Brian" reshares the following resource
Expand All @@ -34,9 +31,6 @@ Feature: reshare
And "Carol" logs in
And "Carol" opens the "files" app
And "Carol" navigates to the shared with me page
And "Carol" accepts the following share
| name |
| folder_to_shared |
And "Carol" reshares the following resource
| resource | recipient | type | role | resourceType |
| folder_to_shared | Alice | user | Can view | folder |
Expand Down
10 changes: 0 additions & 10 deletions tests/e2e/cucumber/features/smoke/search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ Feature: Search
And "Brian" logs out

When "Alice" logs in
And "Alice" navigates to the shared with me page
And "Alice" accepts the following share
| name |
| new_share_from_brian |
| new-lorem-big.txt |
And "Alice" opens the "files" app
And "Alice" creates the following resources
| resource | type |
Expand Down Expand Up @@ -130,11 +125,6 @@ Feature: Search

# search re-shared resources
When "Carol" logs in
And "Carol" navigates to the shared with me page
And "Carol" accepts the following share
| name |
| new_share_from_brian |
| new-lorem-big.txt |
And "Carol" opens the "files" app
And "Carol" creates the following resources
| resource | type |
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/cucumber/features/smoke/share.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Feature: share
| id |
| Alice |
| Brian |
And "Brian" logs in
# disabling auto accepting to check accepting share
And "Brian" disables auto-accepting using API

Scenario: folder
Given "Alice" logs in
Expand All @@ -23,7 +26,7 @@ Feature: share
| folder_to_shared | Brian | user | Can edit | folder |
| shared_folder | Brian | user | Can edit | folder |
| folder_to_customShared | Brian | user | custom_permissions:read,create,delete | folder |
And "Brian" logs in

And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
And "Brian" accepts the following share
Expand Down Expand Up @@ -93,7 +96,7 @@ Feature: share
| testavatar.jpeg | Brian | user | Can view | file |
| simple.pdf | Brian | user | custom_permissions:read,update,share | file |
| sharedFile.txt | Brian | user | Can edit | file |
And "Brian" logs in

And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
Then "Brian" should not be able to open the file "shareToBrian.txt"
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/cucumber/features/smoke/spaces/project.feature
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ Feature: spaces.personal
And "Brian" logs in
And "Brian" opens the "files" app
And "Brian" navigates to the shared with me page
And "Brian" accepts the following share
| name |
| folder_to_shared |
And "Brian" renames the following resource
| resource | as |
| folder_to_shared/lorem.txt | lorem_new.txt |
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/cucumber/features/smoke/tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ Feature: Users can use web to organize tags

And "Brian" logs in
And "Brian" navigates to the shared with me page
And "Brian" accepts the following share
| name |
| folder_to_shared |
Then the following resources should contain the following tags in the files list for user "Brian"
| resource | tags |
| folder_to_shared/lorem.txt | tag 1, tag 2 |
Expand Down
11 changes: 3 additions & 8 deletions tests/e2e/cucumber/steps/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,10 @@ Given(
)

Given(
'{string} accepts the following share(s) using API',
async function (this: World, stepUser: string, stepTable: DataTable): Promise<void> {
'{string} disables auto-accepting using API',
async function (this: World, stepUser: string): Promise<void> {
const user = this.usersEnvironment.getUser({ key: stepUser })
for (const info of stepTable.hashes()) {
await api.share.acceptShare({
user,
path: info.name
})
}
await api.settings.disableAutoAccepting({ user })
}
)

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/support/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * as dav from './davSpaces'
export * as share from './share'
export * as keycloak from './keycloak'
export * as provision from './provision'
export * as settings from './userSettings'
2 changes: 1 addition & 1 deletion tests/e2e/support/api/share/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { createShare, acceptShare } from './share'
export { createShare } from './share'
43 changes: 0 additions & 43 deletions tests/e2e/support/api/share/share.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import join from 'join-path'
import convert from 'xml-js'
import _ from 'lodash/object'

import { checkResponseStatus, request } from '../http'
import { User } from '../../types'
Expand Down Expand Up @@ -54,44 +52,3 @@ export const createShare = async ({
})
checkResponseStatus(response, 'Failed while creating share')
}

export const acceptShare = async ({ user, path }: { user: User; path: string }): Promise<void> => {
const params = new URLSearchParams({
include_tags: 'false',
state: 'all',
shared_with_me: 'true'
})
const shareId = await getShareId({ user, path, params: params.toString() })
const response = await request({
method: 'POST',
path: join('ocs', 'v2.php', 'apps', 'files_sharing', 'api', 'v1', 'shares', 'pending', shareId),
user: user
})
checkResponseStatus(response, 'Failed while accepting share')
}

const getShareId = async ({
user,
path,
params = 'include_tags=false&state=all&shared_with_me=true'
}: {
user: User
path: string
params?: string
}): Promise<string> => {
const response = await request({
method: 'GET',
path: join('ocs', 'v2.php', 'apps', 'files_sharing', 'api', 'v1', 'shares', `?${params}`),
user: user
})
checkResponseStatus(response, 'Failed while geting share id')
const fileData = JSON.parse(convert.xml2json(await response.text(), { compact: true }))
let elements = _.get(fileData, 'ocs.data.element')
elements = elements instanceof Array ? elements : [elements]
for (const element of elements) {
const elementPath = element.path._text.split('/').pop()
if (elementPath === path) {
return element.id._text
}
}
}
1 change: 1 addition & 0 deletions tests/e2e/support/api/userSettings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { disableAutoAccepting } from './settings'
25 changes: 25 additions & 0 deletions tests/e2e/support/api/userSettings/settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import join from 'join-path'

import { checkResponseStatus, request } from '../http'
import { User } from '../../types'

export const disableAutoAccepting = async ({ user }: { user: User }): Promise<void> => {
const body = JSON.stringify({
value: {
accountUuid: 'me',
bundleId: '2a506de7-99bd-4f0d-994e-c38e72c28fd9',
settingId: 'ec3ed4a3-3946-4efc-8f9f-76d38b12d3a9',
resource: {
type: 'TYPE_USER'
},
boolValue: false
}
})
const response = await request({
method: 'POST',
path: join('api', 'v0', 'settings', 'values-save'),
body: body,
user: user
})
checkResponseStatus(response, 'Failed while disabling auto accept')
}

0 comments on commit eed1938

Please sign in to comment.