Skip to content

Commit

Permalink
Then step implementation checking public link share details
Browse files Browse the repository at this point in the history
Please enter the commit message for your changes. Lines starting
  • Loading branch information
ishabaral committed Oct 4, 2024
1 parent 201b52e commit 78330bf
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 22 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, f'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_with is not None:
assert share['share_with'] == share_with, f'Shared with wrong user'
return share
raise ValueError(f'No valid share found for resource "{path}"')
24 changes: 24 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,27 @@ def step(context, user):
data['password'],
data['expireDate'],
)


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

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

for row in context.table[1:]:
key, value = row
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, f'Key value did not match'
32 changes: 16 additions & 16 deletions test/gui/tst_sharing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,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" in the server should have a share with these details:
| 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 +597,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" in the server should have a share with these details:
| 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 +625,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" in the server should have a share with these details:
| 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" in the server should have a share with these details:
| 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 78330bf

Please sign in to comment.