Skip to content

Commit

Permalink
given step implementation of sharing file or folder in the server
Browse files Browse the repository at this point in the history
  • Loading branch information
ishabaral committed Sep 16, 2024
1 parent dff84d6 commit 7dd5e3b
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 37 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[tool.black]
line-length = 88
target-version = ['py36', 'py37', 'py38']
target-version = ['py36', 'py37', 'py38', 'py310']
include = '\.pyi?$'
skip-string-normalization = true
extend-exclude = '''
Expand Down
2 changes: 1 addition & 1 deletion test/gui/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ load-plugins=
pylint.extensions.overlapping_exceptions,
pylint.extensions.typing,
pylint.extensions.redefined_variable_type,
py-version=3.8
py-version=3.10
unsafe-load-any-extension=no

[BASIC]
Expand Down
39 changes: 39 additions & 0 deletions test/gui/shared/scripts/helpers/api/sharing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@
)


def getPermissionsRoleIdByName(permissionsRole):
match permissionsRole:
case "read" | "Download / View":
return 1

case "create" | "Download / View / Upload":
return 4

case "edit":
return 2

case "delete":
return 8

case "read, share":
return 17

case "read, share, update" | "edit,share":
return 19

case "all":
return 31


def get_share_url():
return oc.format_json(
url_join(
Expand Down Expand Up @@ -77,3 +101,18 @@ def download_last_public_link_resource(user, resource, public_link_password=None
return False
else:
raise Exception(f"Server returned status code: {response.status_code}")


def share_folder(user, folder_name, receiver, permissions):
permissions = getPermissionsRoleIdByName(permissions)
url = get_share_url()
body = {
"path": f"/{folder_name}",
"shareType": 0,
"shareWith": receiver,
"permissions": permissions,
}
response = request.post(url, body, user=user)
request.assertHttpStatus(
response, 200, f"Failed to share folder '{folder_name}' to user '{user}'"
)
9 changes: 9 additions & 0 deletions test/gui/shared/steps/server_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,12 @@ def step(context, user, group_name):
@Given('user "|any|" has been created in the server with default attributes')
def step(context, user):
Provisioning.create_user(user)


@Given(
r'user "([^"].*)" has shared (?:file|folder) "([^"].*)" in the server'
r'with user "([^"].*)" with "([^"].*)" permission(?:s)?',
regexp=True,
)
def step(context, user, folder_name, receiver, permissions):
sharing_helper.share_folder(user, folder_name, receiver, permissions)
70 changes: 35 additions & 35 deletions test/gui/tst_sharing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Feature: Sharing
And user "Alice" has created folder "simple-folder" in the server
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" in the server
And user "Alice" has uploaded file with content "shared file" to "sharedfile.txt" in the server
And user "Alice" has shared folder "shared" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "sharedfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "shared" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "sharedfile.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has set up a client with default settings
When the user adds "Brian Murphy" as collaborator of resource "textfile.txt" with permissions "edit,share" using the client-UI
And the user adds "Brian Murphy" as collaborator of resource "simple-folder" with permissions "edit,share" using the client-UI
Expand Down Expand Up @@ -72,8 +72,8 @@ Feature: Sharing
Given user "Brian" has been created in the server with default attributes
And user "Alice" has created folder "SharedFolder" in the server
And user "Alice" has uploaded file with content "ownCloud test text file" to "/textfile.txt" in the server
And user "Alice" has shared folder "SharedFolder" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "SharedFolder" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has set up a client with default settings
When the user opens the sharing dialog of "textfile.txt" using the client-UI
And the user searches for collaborator "Brian Murphy" using the client-UI
Expand Down Expand Up @@ -132,11 +132,11 @@ Feature: Sharing
And user "TestUser2" has been created in the server with default attributes
And user "TestUser3" has been created in the server with default attributes
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" in the server
And user "Alice" has shared file "textfile.txt" on the server with user "Carol" with "all" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "TestUser1" with "all" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "TestUser3" with "all" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "TestUser2" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Carol" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "TestUser1" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "TestUser3" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "TestUser2" with "all" permissions
And user "Alice" has set up a client with default settings
When the user opens the sharing dialog of "textfile.txt" using the client-UI
Then the collaborators should be listed in the following order:
Expand All @@ -163,8 +163,8 @@ Feature: Sharing
Given user "Brian" has been created in the server with default attributes
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" in the server
And user "Alice" has created folder "Folder" in the server
And user "Alice" has shared file "/textfile0.txt" on the server with user "Brian" with "read, share" permission
And user "Alice" has shared folder "Folder" on the server with user "Brian" with "read, share" permission
And user "Alice" has shared file "/textfile0.txt" in the server with user "Brian" with "read, share" permission
And user "Alice" has shared folder "Folder" in the server with user "Brian" with "read, share" permission
And user "Brian" has set up a client with default settings
When the user opens the sharing dialog of "textfile0.txt" using the client-UI
Then the error text "The item is not shared with any users or groups" should be displayed in the sharing dialog
Expand Down Expand Up @@ -195,8 +195,8 @@ Feature: Sharing
And user "Brian" on the server has been added to group "grp1"
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" in the server
And user "Alice" has created folder "Folder" in the server
And user "Alice" has shared file "/textfile0.txt" on the server with user "Brian" with "read, share, update" permission
And user "Alice" has shared folder "Folder" on the server with user "Brian" with "read, share, update" permission
And user "Alice" has shared file "/textfile0.txt" in the server with user "Brian" with "read, share, update" permission
And user "Alice" has shared folder "Folder" in the server with user "Brian" with "read, share, update" permission
And user "Alice" has shared file "/textfile0.txt" on the server with group "grp1" with "read, share, update" permission
And user "Alice" has shared folder "Folder" on the server with group "grp1" with "read, share, update" permission
And user "Brian" has set up a client with default settings
Expand All @@ -213,8 +213,8 @@ Feature: Sharing
And user "Alice" has uploaded file with content "file inside a folder" to "simple-folder/textfile.txt" in the server
And user "Alice" has uploaded file with content "file in the root" to "textfile.txt" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared folder "simple-folder" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "simple-folder" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
When the user overwrites the file "textfile.txt" with content "overwrite file in the root"
And the user waits for file "textfile.txt" to be synced
Expand All @@ -231,8 +231,8 @@ Feature: Sharing
And user "Alice" has uploaded file with content "file inside a folder" to "Parent/textfile.txt" in the server
And user "Alice" has uploaded file with content "file in the root" to "textfile.txt" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared folder "Parent" on the server with user "Brian" with "read" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "read" permissions
And user "Alice" has shared folder "Parent" in the server with user "Brian" with "read" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "read" permissions
And user "Brian" has set up a client with default settings
When the user tries to overwrite the file "Parent/textfile.txt" with content "overwrite file inside a folder"
And the user tries to overwrite the file "textfile.txt" with content "overwrite file in the root"
Expand All @@ -248,8 +248,8 @@ Feature: Sharing
And user "Alice" has created folder "FOLDER" in the server
And user "Alice" has uploaded file with content "some content" to "FOLDER/simple.txt" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "FOLDER" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "FOLDER" in the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
When the user opens the add-account dialog
And the user adds the following account:
Expand All @@ -272,7 +272,7 @@ Feature: Sharing
Scenario: sharee creates a file and a folder inside a shared folder
Given user "Alice" has created folder "Parent" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared folder "Parent" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "Parent" in the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
When user "Brian" creates a file "Parent/localFile.txt" with the following content inside the sync folder
"""
Expand All @@ -290,7 +290,7 @@ Feature: Sharing
Scenario: sharee tries to create a file and a folder inside a shared folder without write permission
Given user "Alice" has created folder "Parent" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared folder "Parent" on the server with user "Brian" with "read" permissions
And user "Alice" has shared folder "Parent" in the server with user "Brian" with "read" permissions
And user "Brian" has set up a client with default settings
When user "Brian" creates a file "Parent/localFile.txt" with the following content inside the sync folder
"""
Expand All @@ -309,8 +309,8 @@ Feature: Sharing
Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "textfile.txt" in the server
And user "Alice" has created folder "FOLDER" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "FOLDER" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "FOLDER" in the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
When the user renames a file "textfile.txt" to "lorem.txt"
And the user renames a folder "FOLDER" to "PARENT"
Expand All @@ -331,8 +331,8 @@ Feature: Sharing
Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "textfile.txt" in the server
And user "Alice" has created folder "Folder" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "Folder" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "Folder" in the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
When the user deletes the file "textfile.txt"
And the user deletes the folder "Folder"
Expand All @@ -347,8 +347,8 @@ Feature: Sharing
Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "textfile.txt" in the server
And user "Alice" has created folder "Folder" in the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "read" permissions
And user "Alice" has shared file "Folder" on the server with user "Brian" with "read" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "read" permissions
And user "Alice" has shared file "Folder" in the server with user "Brian" with "read" permissions
And user "Brian" has set up a client with default settings
When the user deletes the file "textfile.txt"
And the user deletes the folder "Folder"
Expand All @@ -365,8 +365,8 @@ Feature: Sharing
And user "Carol" has been created in the server with default attributes
And user "Alice" has created folder "FOLDER" in the server
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" in the server
And user "Alice" has shared file "FOLDER" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "FOLDER" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "all" permissions
And user "Brian" has set up a client with default settings
When the user adds "Carol King" as collaborator of resource "FOLDER" with permissions "edit,share" using the client-UI
And the user adds "Carol King" as collaborator of resource "textfile.txt" with permissions "edit,share" using the client-UI
Expand All @@ -381,8 +381,8 @@ Feature: Sharing
And user "Carol" has been created in the server with default attributes
And user "Alice" has created folder "FOLDER" in the server
And user "Alice" has uploaded file with content "ownCloud test text file" to "textfile.txt" in the server
And user "Alice" has shared file "FOLDER" on the server with user "Brian" with "read" permissions
And user "Alice" has shared file "textfile.txt" on the server with user "Brian" with "read" permissions
And user "Alice" has shared file "FOLDER" in the server with user "Brian" with "read" permissions
And user "Alice" has shared file "textfile.txt" in the server with user "Brian" with "read" permissions
And user "Brian" has set up a client with default settings
When the user opens the sharing dialog of "FOLDER" using the client-UI
Then the error text "The file can not be shared because it was shared without sharing permission." should be displayed in the sharing dialog
Expand All @@ -396,8 +396,8 @@ Feature: Sharing
Given user "Brian" has been created in the server with default attributes
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "textfile0.txt" in the server
And user "Alice" has created folder "simple-folder" in the server
And user "Alice" has shared file "textfile0.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "simple-folder" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "textfile0.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "simple-folder" in the server with user "Brian" with "all" permissions
And user "Alice" has set up a client with default settings
When the user unshares the resource "textfile0.txt" for collaborator "Brian Murphy" using the client-UI
Then the text "The item is not shared with any users or groups" should be displayed in the sharing dialog
Expand Down Expand Up @@ -615,8 +615,8 @@ Feature: Sharing
And user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created file "lorem.txt" on the server
And user "Brian" has been created in the server with default attributes
And user "Alice" has shared folder "simple-folder" on the server with user "Brian" with "all" permissions
And user "Alice" has shared file "lorem.txt" on the server with user "Brian" with "all" permissions
And user "Alice" has shared folder "simple-folder" in the server with user "Brian" with "all" permissions
And user "Alice" has shared file "lorem.txt" in the server with user "Brian" with "all" permissions
And user "Alice" has set up a client with default settings
When the user removes permissions "<permissions>" for user "Brian Murphy" of resource "simple-folder" using the client-UI
Then "<permissions>" permissions should not be displayed for user "Brian Murphy" for resource "simple-folder" on the client-UI
Expand Down

0 comments on commit 7dd5e3b

Please sign in to comment.