Skip to content

Commit

Permalink
Then step implementation checking public link share details (#11918)
Browse files Browse the repository at this point in the history
then step implementation checking public link share details (#11918)
  • Loading branch information
ishabaral authored Oct 7, 2024
1 parent ee43758 commit 8e8c0d1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 23 deletions.
29 changes: 23 additions & 6 deletions test/gui/shared/scripts/helpers/api/sharing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,24 @@ def download_last_public_link_resource(user, resource, public_link_password=None

def share_resource(user, resource, receiver, permissions, receiver_type):
permissions = get_permission_value(permissions)
url = get_share_url()
body = {
'path': resource,
'shareType': share_types[receiver_type],
'shareWith': receiver,
'permissions': permissions,
}
response = request.post(url, body, user=user)
response = request.post(get_share_url(), body, user=user)
request.assert_http_status(
response,
200,
f"Failed to share resource '{resource}' to {receiver_type} '{receiver}'",
f'Failed to share resource "{resource}" to {receiver_type} "{receiver}"',
)
check_success_ocs_status(response)


def create_link_share(
user, resource, permissions, name=None, password=None, expire_date=None
):
url = get_share_url()
permissions = get_permission_value(permissions)
body = {
'path': resource,
Expand All @@ -130,8 +128,27 @@ def create_link_share(
body['password'] = password
if expire_date is not None:
body['expireDate'] = expire_date
response = request.post(url, body, user=user)
response = request.post(get_share_url(), body, user=user)
request.assert_http_status(
response, 200, f"Failed to create public link for resource '{resource}'"
response, 200, f'Failed to create public link for resource "{resource}"'
)
check_success_ocs_status(response)


def get_shares(user):
response = request.get(get_share_url(), user=user)
request.assert_http_status(response, 200, 'Failed to get public link share details')
check_success_ocs_status(response)
return json.loads(response.text)['ocs']['data']


def get_share(user, path, share_type, share_with=None):
shares = get_shares(user)
for share in shares:
if share['path'] == path and share['share_type'] == share_types[share_type]:
if share['share_type'] == share_types['public_link']:
return share
if share_with and share_with == share['share_with']:
return share
raise ValueError(f'No share_with found for a {share_type} share')
raise ValueError(f'No valid share found for resource "{path}"')
23 changes: 23 additions & 0 deletions test/gui/shared/steps/server_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,26 @@ def step(context, user):
data['password'],
data['expireDate'],
)


@Then('user "|any|" should have a share with these details in the server:')
def step(context, user):
path = None
share_type = None
share_with = None
for key, value in context.table[1:]:
if key == 'path':
path = value
elif key == 'share_type':
share_type = value
elif key == 'share_with':
share_with = value

share = sharing_helper.get_share(user, path, share_type, share_with)

for key, value in context.table[1:]:
if key == 'permissions':
value = sharing_helper.get_permission_value(value)
if key == 'share_type':
value = sharing_helper.share_types[value]
assert share.get(key) == value, 'Key value did not match'
33 changes: 16 additions & 17 deletions test/gui/tst_sharing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Feature: Sharing

Background:
Given user "Alice" has been created in the server with default attributes
And the setting "shareapi_auto_accept_share" on the server of app "core" has been set to "yes"

@smokeTest
Scenario: simple sharing with user
Expand Down Expand Up @@ -581,13 +580,13 @@ Feature: Sharing
When the user creates a new public link for folder "simple-folder" using the client-UI with these details:
| role | <role> |
And the user closes the sharing dialog
Then user "Alice" on the server should have a share with these details:
Then user "Alice" should have a share with these details in the server:
| field | value |
| share_type | public_link |
| uid_owner | Alice |
| permissions | <permissions> |
| path | /simple-folder |
| name | Public link |
| item_type | folder |
Examples:
| role | permissions |
| Viewer | read |
Expand All @@ -597,24 +596,24 @@ Feature: Sharing

Scenario: sharing a folder by public link with "Uploader" role and check if file can be downloaded
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created file "simple-folder/lorem.txt" on the server
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "simple-folder/lorem.txt" in the server
And user "Alice" has set up a client with default settings
When the user creates a new public link for folder "simple-folder" using the client-UI with these details:
| role | Contributor |
And the user closes the sharing dialog
Then user "Alice" on the server should have a share with these details:
Then user "Alice" should have a share with these details in the server:
| field | value |
| share_type | public_link |
| uid_owner | Alice |
| permissions | create |
| path | /simple-folder |
| name | Public link |
| item_type | folder |
And the public should not be able to download the file "lorem.txt" from the last created public link by "Alice" in the server


Scenario Outline: change collaborator permissions of a file & folder
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created file "lorem.txt" on the server
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "lorem.txt" in the server
And user "Brian" has been created in the server with default attributes
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
Expand All @@ -625,22 +624,22 @@ Feature: Sharing
And the user removes permissions "<permissions>" for user "Brian Murphy" of resource "lorem.txt" using the client-UI
Then "<permissions>" permissions should not be displayed for user "Brian Murphy" for resource "lorem.txt" on the client-UI
And the user closes the sharing dialog
And user "Alice" on the server should have a share with these details:
And user "Alice" should have a share with these details in the server:
| field | value |
| uid_owner | Alice |
| share_with | Brian |
| share_type | user |
| file_target | /simple-folder |
| item_type | folder |
| uid_owner | Alice |
| permissions | <expected-folder-permission> |
And user "Alice" on the server should have a share with these details:
| path | /simple-folder |
| item_type | folder |
| share_with | Brian |
And user "Alice" should have a share with these details in the server:
| field | value |
| uid_owner | Alice |
| share_with | Brian |
| share_type | user |
| file_target | /lorem.txt |
| item_type | file |
| uid_owner | Alice |
| permissions | <expected-file-permission> |
| path | /lorem.txt |
| item_type | file |
| share_with | Brian |
Examples:
| permissions | expected-folder-permission | expected-file-permission |
| edit | read, share | read, share |
Expand Down

0 comments on commit 8e8c0d1

Please sign in to comment.