-
Notifications
You must be signed in to change notification settings - Fork 33
Test to check the shared file MUST point ALWAYS to the latest version #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
labkode
wants to merge
4
commits into
cernbox:master
Choose a base branch
from
labkode:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
|
|
||
| __doc__ = """ | ||
|
|
||
| Test public file sharing after updating file. | ||
| With this test we want to check that after updating a file we still get the lastest version via the shared link and not a previous one. | ||
|
|
||
| Steps: | ||
| - 1) Create workdir | ||
| - 2) Upload file | ||
| - 3) Share file by link | ||
| - 4) Download file shared via the link and check ifit has the same contents as the original | ||
| - 5) Upload new version of a file (the fileid changes) | ||
| - 6) Re-download file shared and check that the contents are the same as the updated file and not to the original (now a version) | ||
|
|
||
| """ | ||
|
|
||
| from smashbox.utilities import * | ||
| import smashbox.curl | ||
| import time | ||
| import os | ||
| import owncloud | ||
|
|
||
| # The name of the file to upload | ||
| filename = "shared_file.txt" | ||
|
|
||
| # The contents of the file | ||
| file_data = "some data" | ||
|
|
||
| # The contents to update the file, please be sure this is different from file_data | ||
| file_data_updated = "other data" | ||
|
|
||
| # The name of the local file created after download the file via the shared link | ||
| filename_step4 = filename + "_step4" | ||
|
|
||
| # The name of the local file created after re-download the file via shared link | ||
| filename_step6 = filename + "_step6" | ||
|
|
||
| # The block size to generate random file | ||
| filesizeKB = int(config.get('share_filesizeKB',10)) | ||
|
|
||
|
|
||
|
|
||
| @add_worker | ||
| def checker(step): | ||
|
|
||
| # Create workdir | ||
| step(1) | ||
| d = make_workdir() | ||
| fullpath = os.path.join(d,filename) | ||
| createfile(fullpath, file_data, count=1000, bs=filesizeKB) | ||
| original_sum = md5sum(fullpath) | ||
|
|
||
| # Upload file | ||
| step(2) | ||
| client = smashbox.curl.Client() | ||
| r = client.PUT(fullpath, os.path.join(oc_webdav_url(), filename)) | ||
| fatal_check(r.rc == 201, "we should get 201 uploading the file") | ||
|
|
||
|
|
||
| # Share file by link | ||
| step(3) | ||
| share_info = share_file_with_link(filename, verify_certs = False) | ||
| shared_link = share_info.link + '&download' # the download query params is to go directly to the file and not to the webpage showing the file | ||
| logger.info("You can access the shared file via this link: " + shared_link) | ||
|
|
||
| # Download file shared via the link and check ifit has the same contents as the original | ||
| step(4) | ||
| client = smashbox.curl.Client() | ||
| r = client.GET(shared_link, os.path.join(d,filename_step4)) | ||
| sum = md5sum(os.path.join(d,filename_step4)) | ||
| fatal_check(sum == original_sum, "the file downloaded by link is corrupted") | ||
|
|
||
| # Upload new version of a file (the fileid changes) | ||
| step(5) | ||
| createfile(fullpath, file_data_updated, count=1000, bs=filesizeKB) | ||
| updated_sum = md5sum(fullpath) | ||
| client = smashbox.curl.Client() | ||
| r = client.PUT(fullpath, os.path.join(oc_webdav_url(), filename)) | ||
| fatal_check(r.rc == 201, "we shoudl get 201 uploading the file") | ||
|
|
||
| # Re-download file shared and check that the contents are the same as the updated file and not to the original (now a version) | ||
| step(6) | ||
| client = smashbox.curl.Client() | ||
| r = client.GET(shared_link, os.path.join(d,filename_step6)) | ||
| sum = md5sum(os.path.join(d,filename_step6)) | ||
| fatal_check(sum == updated_sum, "the shared link is pointing to a previous version") | ||
| logger.info('SUCCESS') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need verfy_certs=False here?