Skip to content

Commit

Permalink
[test-only][full-ci] Given step implementation of uploading various t…
Browse files Browse the repository at this point in the history
…ypes of files in the server (#11922)

given step implementation of uploading files with various types in the server #11922
  • Loading branch information
ishabaral authored Oct 8, 2024
1 parent 10b0c0b commit 145097c
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 97 deletions.
Binary file added test/gui/shared/files-for-upload/simple.pdf
Binary file not shown.
Binary file added test/gui/shared/files-for-upload/test_video.mp4
Binary file not shown.
Binary file added test/gui/shared/files-for-upload/testavatar.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/gui/shared/files-for-upload/testavatar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/gui/shared/files-for-upload/testavatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
4 changes: 4 additions & 0 deletions test/gui/shared/scripts/helpers/ConfigHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import builtins
from tempfile import gettempdir
from configparser import ConfigParser
from pathlib import Path

CURRENT_DIR = Path(__file__).resolve().parent


def read_env_file():
Expand Down Expand Up @@ -100,6 +103,7 @@ def get_default_home_dir():
'record_video_on_failure': False,
'retrying': False,
'video_recording_started': False,
'files_for_upload': os.path.join(CURRENT_DIR.parent.parent, 'files-for-upload'),
}
CONFIG.update(DEFAULT_PATH_CONFIG)

Expand Down
7 changes: 6 additions & 1 deletion test/gui/shared/scripts/helpers/FilesHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ctypes
import shutil

from helpers.ConfigHelper import is_windows
from helpers.ConfigHelper import is_windows, get_config


def build_conflicted_regex(filename):
Expand Down Expand Up @@ -122,3 +122,8 @@ def cleanup_created_paths():
else:
os.unlink(prefix_path_namespace(path))
CREATED_PATHS = []


def get_file_for_upload(file_name):
base_upload_dir = get_config("files_for_upload")
return os.path.join(base_upload_dir, file_name)
15 changes: 12 additions & 3 deletions test/gui/shared/scripts/helpers/api/webdav_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import helpers.api.http_helper as request
from helpers.api.utils import url_join
from helpers.ConfigHelper import get_config
from helpers.FilesHelper import get_file_for_upload


def get_webdav_url():
Expand Down Expand Up @@ -59,9 +60,17 @@ def create_folder(user, folder_name):
def create_file(user, file_name, contents):
url = get_resource_path(user, file_name)
response = request.put(url, body=contents, user=user)
assert (
response.status_code == 201
), f"Could not create file '{file_name}' for user {user}"
assert response.status_code in [
201,
204,
], f"Could not create file '{file_name}' for user {user}"


def upload_file(user, file_name, destination):
file_path = get_file_for_upload(file_name)
with open(file_path, 'rb') as file:
contents = file.read()
create_file(user, destination, contents)


def delete_resource(user, resource):
Expand Down
5 changes: 5 additions & 0 deletions test/gui/shared/steps/server_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,8 @@ def step(context, user):
if key == 'share_type':
value = sharing_helper.share_types[value]
assert share.get(key) == value, 'Key value did not match'


@Given('user "|any|" has uploaded file "|any|" to "|any|" in the server')
def step(context, user, file_name, destination):
webdav.upload_file(user, file_name, destination)
89 changes: 11 additions & 78 deletions test/gui/tst_sharing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Feature: Sharing
Scenario: User (non-author) can not share to a group to which the file/folder is already shared
Given user "Brian" has been created in the server with default attributes
And group "grp1" has been created in the server
And user "Brian" on the server has been added to group "grp1"
And user "Brian" has been added to group "grp1" in the server
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" in the server with user "Brian" with "read, share, update" permission
Expand Down Expand Up @@ -336,10 +336,10 @@ Feature: Sharing
When the user deletes the file "textfile.txt"
And the user deletes the folder "Folder"
And the user waits for the files to sync
Then as "Brian" file "textfile.txt" on the server should not exist
And as "Brian" folder "Folder" on the server should not exist
And as "Alice" file "textfile.txt" on the server should exist
And as "Alice" folder "Folder" on the server should exist
Then as "Brian" file "textfile.txt" should not exist in the server
And as "Brian" folder "Folder" should not exist in the server
And as "Alice" file "textfile.txt" should exist in the server
And as "Alice" folder "Folder" should exist in the server

@issue-11102
Scenario: sharee tries to delete shared file and folder without permissions
Expand All @@ -353,10 +353,10 @@ Feature: Sharing
And the user deletes the folder "Folder"
And the user waits for the files to sync
# Sharee can delete (means unshare) the file shared with read permission
Then as "Brian" file "textfile.txt" on the server should not exist
And as "Brian" folder "Folder" on the server should not exist
And as "Alice" file "textfile.txt" on the server should exist
And as "Alice" folder "Folder" on the server should exist
Then as "Brian" file "textfile.txt" should not exist in the server
And as "Brian" folder "Folder" should not exist in the server
And as "Alice" file "textfile.txt" should exist in the server
And as "Alice" folder "Folder" should exist in the server


Scenario: reshare a file/folder
Expand Down Expand Up @@ -400,12 +400,12 @@ Feature: Sharing
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
And as "Brian" file "textfile0.txt" on the server should not exist
And as "Brian" file "textfile0.txt" should not exist in the server
When the user closes the sharing dialog
And the user unshares the resource "simple-folder" 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
And the user closes the sharing dialog
And as "Brian" folder "simple-folder" on the server should not exist
And as "Brian" folder "simple-folder" should not exist in the server


Scenario: share a file with many users
Expand Down Expand Up @@ -506,73 +506,6 @@ Feature: Sharing
Then the expiration date of the last public link of file "textfile.txt" should be "%default%"
And as user "Alice" the file "textfile.txt" should have a public link in the server

@issue-9321 @skipOnWindows @skip
Scenario: simple sharing of file and folder by public link with expiration date
Given 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 set up a client with default settings
When the user creates a new public link with following settings using the client-UI:
| path | textfile.txt |
| expireDate | 2031-10-14 |
Then as user "Alice" the file "textfile.txt" should have a public link in the server
And the last public link share response of user "Alice" should include the following fields on the server
| expireDate | 2031-10-14 |
When the user closes the sharing dialog
And the user creates a new public link with following settings using the client-UI:
| path | FOLDER |
| expireDate | 2031-12-30 |
And the user closes the sharing dialog
Then as user "Alice" the folder "FOLDER" should have a public link in the server
And the last public link share response of user "Alice" should include the following fields on the server
| expireDate | 2031-12-30 |

@issue-9321 @skipOnWindows @skip
Scenario: simple sharing of a file by public link with password and expiration date
Given user "Alice" has uploaded file with content "ownCloud test text file" to "/textfile.txt" in the server
And user "Alice" has set up a client with default settings
When the user creates a new public link with following settings using the client-UI:
| path | textfile.txt |
| password | pass123 |
| expireDate | 2031-10-14 |
And the user closes the sharing dialog
Then as user "Alice" the file "textfile.txt" should have a public link in the server
And the last public link share response of user "Alice" should include the following fields on the server
| expireDate | 2031-10-14 |
And the public should be able to download the file "textfile.txt" with password "pass123" from the last created public link by "Alice" in the server

@skip @issue-9321 @skipOnWindows
Scenario: user changes the expiration date of an already existing public link for file using client-UI
Given user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" in the server
And user "Alice" has created the following public link share in the server
| resource | textfile0.txt |
| permissions | read |
| name | Public link |
| expireDate | 2031-10-14 |
And user "Alice" has set up a client with default settings
When the user opens the public links dialog of "textfile0.txt" using the client-UI
And the user edits the public link named "Public link" of file "textfile0.txt" changing following
| expireDate | 2038-07-21 |
And the user closes the sharing dialog
Then the last public link share response of user "Alice" should include the following fields on the server
| expireDate | 2038-07-21 |

@skip @issue-9321 @skipOnWindows
Scenario: user changes the expiration date of an already existing public link for folder using client-UI
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created the following public link share in the server
| resource | simple-folder |
| permissions | read, update, create, delete |
| name | Public link |
| expireDate | 2031-10-14 |

And user "Alice" has set up a client with default settings
When the user opens the public links dialog of "simple-folder" using the client-UI
And the user edits the public link named "Public link" of file "simple-folder" changing following
| expireDate | 2038-07-21 |
And the user closes the sharing dialog
Then the last public link share response of user "Alice" should include the following fields on the server
| expireDate | 2038-07-21 |


Scenario Outline: simple sharing of folder by public link with different roles
Given user "Alice" has created folder "simple-folder" in the server
Expand Down
30 changes: 15 additions & 15 deletions test/gui/tst_syncing/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Feature: Syncing files
Scenario: Syncing all files and folders from the server
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has created folder "large-folder" in the server
And user "Alice" has uploaded file on the server with content "test content" to "uploaded-lorem.txt"
And user "Alice" has uploaded file with content "test content" to "uploaded-lorem.txt" in the server
And user "Alice" has set up a client with default settings
Then the file "uploaded-lorem.txt" should exist on the file system
And the file "uploaded-lorem.txt" should exist on the file system with the following content
Expand All @@ -35,14 +35,14 @@ Feature: Syncing files

@issue-9733
Scenario: Syncing a file from the server and creating a conflict
Given user "Alice" has uploaded file on the server with content "server content" to "/conflict.txt"
Given user "Alice" has uploaded file with content "server content" to "/conflict.txt" in the server
And user "Alice" has set up a client with default settings
And the user has paused the file sync
And the user has changed the content of local file "conflict.txt" to:
"""
client content
"""
And user "Alice" has uploaded file on the server with content "changed server content" to "/conflict.txt"
And user "Alice" has uploaded file with content "changed server content" to "/conflict.txt" in the server
When the user resumes the file sync on the client
And the user clicks on the activity tab
And the user selects "Not Synced" tab in the activity
Expand Down Expand Up @@ -123,9 +123,9 @@ Feature: Syncing files
@issue-9733
Scenario: sort folders list by name and size
Given user "Alice" has created folder "123Folder" in the server
And user "Alice" has uploaded file on the server with content "small" to "123Folder/lorem.txt"
And user "Alice" has uploaded file with content "small" to "123Folder/lorem.txt" in the server
And user "Alice" has created folder "aFolder" in the server
And user "Alice" has uploaded file on the server with content "more contents" to "aFolder/lorem.txt"
And user "Alice" has uploaded file with content "more contents" to "aFolder/lorem.txt" in the server
And user "Alice" has created folder "bFolder" in the server
And the user has started the client
And the user has entered the following account information:
Expand Down Expand Up @@ -189,7 +189,7 @@ Feature: Syncing files

@skipOnLinux
Scenario: Try to sync files having space at the end (Windows only)
Given user "Alice" has uploaded file on the server with content "lorem epsum" to "trailing-space.txt "
Given user "Alice" has uploaded file with content "lorem epsum" to "trailing-space.txt " in the server
And user "Alice" has set up a client with default settings
When user "Alice" creates a folder "folder with space at end " inside the sync folder
And the user force syncs the files
Expand Down Expand Up @@ -306,8 +306,8 @@ Feature: Syncing files
Scenario: Invalid system names are synced (Linux only)
Given user "Alice" has created folder "CON" in the server
And user "Alice" has created folder "test%" in the server
And user "Alice" has uploaded file on the server with content "server content" to "/PRN"
And user "Alice" has uploaded file on the server with content "server content" to "/foo%"
And user "Alice" has uploaded file with content "server content" to "/PRN" in the server
And user "Alice" has uploaded file with content "server content" to "/foo%" in the server
And user "Alice" has set up a client with default settings
Then the folder "CON" should exist on the file system
And the folder "test%" should exist on the file system
Expand All @@ -322,8 +322,8 @@ Feature: Syncing files
Scenario: Sync invalid system names (Windows only)
Given user "Alice" has created folder "CON" in the server
And user "Alice" has created folder "test%" in the server
And user "Alice" has uploaded file on the server with content "server content" to "/PRN"
And user "Alice" has uploaded file on the server with content "server content" to "/foo%"
And user "Alice" has uploaded file with content "server content" to "/PRN" in the server
And user "Alice" has uploaded file with content "server content" to "/foo%" in the server
And user "Alice" has set up a client with default settings
Then the folder "test%" should exist on the file system
And the file "foo%" should exist on the file system
Expand All @@ -333,12 +333,12 @@ Feature: Syncing files

Scenario: various types of files can be synced from server to client
Given user "Alice" has created folder "simple-folder" in the server
And user "Alice" has uploaded file "testavatar.png" to "simple-folder/testavatar.png" on the server
And user "Alice" has uploaded file "testavatar.jpg" to "simple-folder/testavatar.jpg" on the server
And user "Alice" has uploaded file "testavatar.png" to "simple-folder/testavatar.png" in the server
And user "Alice" has uploaded file "testavatar.jpg" to "simple-folder/testavatar.jpg" in the server
And user "Alice" has uploaded file "testavatar.jpeg" to "simple-folder/testavatar.jpeg" on the server
And user "Alice" has uploaded file "testimage.mp3" to "simple-folder/testimage.mp3" on the server
And user "Alice" has uploaded file "test_video.mp4" to "simple-folder/test_video.mp4" on the server
And user "Alice" has uploaded file "simple.pdf" to "simple-folder/simple.pdf" on the server
And user "Alice" has uploaded file "testimage.mp3" to "simple-folder/testimage.mp3" in the server
And user "Alice" has uploaded file "test_video.mp4" to "simple-folder/test_video.mp4" in the server
And user "Alice" has uploaded file "simple.pdf" to "simple-folder/simple.pdf" in the server
And user "Alice" has set up a client with default settings
Then the folder "simple-folder" should exist on the file system
And the file "simple-folder/testavatar.png" should exist on the file system
Expand Down

0 comments on commit 145097c

Please sign in to comment.