Skip to content

Commit

Permalink
[Tests-Only] update test scenarios to work with ocis
Browse files Browse the repository at this point in the history
  • Loading branch information
dpakach committed Jun 10, 2021
1 parent bdf8b58 commit f6f6cfe
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 29 deletions.
8 changes: 4 additions & 4 deletions tests/TestHelpers/Asserts/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public static function assertContentOfRemoteAndLocalFileIsSame(
$result = DownloadHelper::download(
$baseUrl, $username, $password, $remoteFile
);

$localContent = \file_get_contents($localFile);
$downloadedContent = $result->getBody()->getContents();

if ($shouldBeSame) {
self::assertSame(
$localContent, $downloadedContent
Expand Down Expand Up @@ -154,11 +154,11 @@ public static function assertContentOfDAVFileAndSkeletonFileOnSUT(
$remoteFile
);
$downloadedContent = $result->getBody()->getContents();

$localContent = SetupHelper::readSkeletonFile(
$fileInSkeletonFolder, $baseUrl, $adminUsername, $adminPassword
);

if ($shouldBeSame) {
self::assertSame(
$localContent, $downloadedContent
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ default:
contexts:
- FeatureContext: *common_feature_context_params
- LoggingContext:
- OccContext:
- WebDavPropertiesContext:
- AppConfigurationContext:

Expand Down
14 changes: 10 additions & 4 deletions tests/acceptance/features/apiMain/checksums.feature
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,27 @@ Feature: checksums
@files_sharing-app-required
@issue-ocis-reva-196
Scenario: Sharing a file with checksum should return the checksum in the propfind using new DAV path
Given using new DAV path
Given the administrator has set the default folder for received shares to "Shares"
And auto-accept shares has been disabled
And using new DAV path
And user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/myChecksumFile.txt" with checksum "MD5:d70b40f177b14b470d1756a3c12b963a"
When user "Alice" shares file "/myChecksumFile.txt" with user "Brian" using the sharing API
And user "Brian" requests the checksum of "/myChecksumFile.txt" via propfind
And user "Brian" accepts share "/myChecksumFile.txt" offered by user "Alice" using the sharing API
And user "Brian" requests the checksum of "/Shares/myChecksumFile.txt" via propfind
Then the webdav checksum should match "SHA1:3ee962b839762adb0ad8ba6023a4690be478de6f MD5:d70b40f177b14b470d1756a3c12b963a ADLER32:8ae90960"

@files_sharing-app-required
@issue-ocis-reva-196
Scenario: Sharing and modifying a file should return correct checksum in the propfind using new DAV path
Given using new DAV path
Given the administrator has set the default folder for received shares to "Shares"
And auto-accept shares has been disabled
And using new DAV path
And user "Brian" has been created with default attributes and without skeleton files
And user "Alice" has uploaded file "filesForUpload/textfile.txt" to "/myChecksumFile.txt" with checksum "MD5:d70b40f177b14b470d1756a3c12b963a"
When user "Alice" shares file "/myChecksumFile.txt" with user "Brian" using the sharing API
And user "Brian" uploads file with checksum "SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399" and content "Some Text" to "/myChecksumFile.txt" using the WebDAV API
And user "Brian" accepts share "/myChecksumFile.txt" offered by user "Alice" using the sharing API
And user "Brian" uploads file with checksum "SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399" and content "Some Text" to "/Shares/myChecksumFile.txt" using the WebDAV API
Then as user "Alice" the webdav checksum of "/myChecksumFile.txt" via propfind should match "SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399 MD5:56e57920c3c8c727bfe7a5288cdf61c4 ADLER32:1048035a"

@issue-ocis-reva-56
Expand Down
42 changes: 24 additions & 18 deletions tests/acceptance/features/apiWebdavProperties1/copyFile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Feature: copy file

Background:
Given using OCS API version "1"
And the administrator has set the default folder for received shares to "Shares"
And auto-accept shares has been disabled
And user "Alice" has been created with default attributes and without skeleton files
And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt"
And user "Alice" has uploaded file with content "ownCloud test text file 1" to "/textfile1.txt"
Expand Down Expand Up @@ -341,7 +343,7 @@ Feature: copy file
And user "Brian" has created folder "BRIAN-Folder/sample-folder"
And user "Brian" has shared folder "BRIAN-Folder" with group "grp1"
When user "Alice" copies file "/textfile1.txt" to "/BRIAN-Folder" using the WebDAV API
Then the HTTP status code should be "204"
Then the HTTP status code should be "204" or "201"
And the content of file "/BRIAN-Folder" for user "Alice" should be "ownCloud test text file 1"
And as "Alice" folder "/BRIAN-Folder/sample-folder" should not exist
And as "Alice" file "/textfile1.txt" should exist
Expand All @@ -362,7 +364,7 @@ Feature: copy file
And user "Brian" has shared file "/sharedfile1.txt" with group "grp1"
And user "Alice" has created folder "FOLDER/sample-folder"
When user "Alice" copies folder "/FOLDER" to "/sharedfile1.txt" using the WebDAV API
Then the HTTP status code should be "204"
Then the HTTP status code should be "204" or "201"
And as "Alice" folder "/FOLDER/sample-folder" should exist
And as "Alice" folder "/sharedfile1.txt/sample-folder" should exist
And user "Alice" should not have any received shares
Expand All @@ -382,11 +384,12 @@ Feature: copy file
And user "Brian" has created folder "BRIAN-FOLDER/second-level-folder"
And user "Brian" has created folder "BRIAN-FOLDER/second-level-folder/third-level-folder"
And user "Brian" has shared folder "BRIAN-FOLDER" with group "grp1"
And user "Alice" has accepted share "/BRIAN-FOLDER" offered by user "Brian"
And user "Alice" has created folder "Sample-Folder-A"
And user "Alice" has created folder "Sample-Folder-A/sample-folder-b"
And user "Alice" has created folder "Sample-Folder-A/sample-folder-b/sample-folder-c"
When user "Alice" copies folder "Sample-Folder-A/sample-folder-b" to "BRIAN-FOLDER/second-level-folder/third-level-folder" using the WebDAV API
Then the HTTP status code should be "204"
When user "Alice" copies folder "Sample-Folder-A/sample-folder-b" to "Shares/BRIAN-FOLDER/second-level-folder/third-level-folder" using the WebDAV API
Then the HTTP status code should be "204" or "201"
And as "Alice" folder "/Sample-Folder-A/sample-folder-b/sample-folder-c" should exist
And as "Alice" folder "/BRIAN-FOLDER/second-level-folder/third-level-folder/sample-folder-c" should exist
And the response when user "Alice" gets the info of the last share should include
Expand All @@ -407,15 +410,16 @@ Feature: copy file
And user "Brian" has created folder "BRIAN-FOLDER/second-level-folder"
And user "Brian" has created folder "BRIAN-FOLDER/second-level-folder/third-level-folder"
And user "Brian" has shared folder "BRIAN-FOLDER" with group "grp1"
And user "Alice" has accepted share "/BRIAN-FOLDER" offered by user "Brian"
And user "Alice" has created folder "Sample-Folder-A"
And user "Alice" has created folder "Sample-Folder-A/sample-folder-b"
And user "Alice" has uploaded file with content "sample file-c" to "Sample-Folder-A/sample-folder-b/textfile-c.txt"
When user "Alice" copies file "Sample-Folder-A/sample-folder-b/textfile-c.txt" to "BRIAN-FOLDER/second-level-folder" using the WebDAV API
Then the HTTP status code should be "204"
And as "Alice" folder "BRIAN-FOLDER/second-level-folder/third-level-folder" should not exist
When user "Alice" copies file "Sample-Folder-A/sample-folder-b/textfile-c.txt" to "Shares/BRIAN-FOLDER/second-level-folder" using the WebDAV API
Then the HTTP status code should be "204" or "201"
And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/third-level-folder" should not exist
And as "Alice" file "Sample-Folder-A/sample-folder-b/textfile-c.txt" should exist
And as "Alice" file "BRIAN-FOLDER/second-level-folder" should exist
And the content of file "BRIAN-FOLDER/second-level-folder" for user "Alice" should be "sample file-c"
And as "Alice" file "Shares/BRIAN-FOLDER/second-level-folder" should exist
And the content of file "Shares/BRIAN-FOLDER/second-level-folder" for user "Alice" should be "sample file-c"
And the response when user "Alice" gets the info of the last share should include
| file_target | /BRIAN-FOLDER |
Examples:
Expand All @@ -433,15 +437,16 @@ Feature: copy file
And user "Brian" has created folder "BRIAN-FOLDER"
And user "Brian" has uploaded file with content "file at second level" to "BRIAN-FOLDER/second-level-file.txt"
And user "Brian" has shared folder "BRIAN-FOLDER" with group "grp1"
And user "Alice" has accepted share "/BRIAN-FOLDER" offered by user "Brian"
And user "Alice" has created folder "Sample-Folder-A"
And user "Alice" has created folder "Sample-Folder-A/sample-folder-b"
And user "Alice" has uploaded file with content "sample file-c" to "Sample-Folder-A/sample-folder-b/textfile-c.txt"
When user "Alice" copies file "Sample-Folder-A/sample-folder-b/textfile-c.txt" to "BRIAN-FOLDER/second-level-file.txt" using the WebDAV API
When user "Alice" copies file "Sample-Folder-A/sample-folder-b/textfile-c.txt" to "Shares/BRIAN-FOLDER/second-level-file.txt" using the WebDAV API
Then the HTTP status code should be "204"
And as "Alice" file "Sample-Folder-A/sample-folder-b/textfile-c.txt" should exist
And as "Alice" file "BRIAN-FOLDER/second-level-file.txt" should exist
And as "Alice" file "BRIAN-FOLDER/textfile-c.txt" should not exist
And the content of file "BRIAN-FOLDER/second-level-file.txt" for user "Alice" should be "sample file-c"
And as "Alice" file "Shares/BRIAN-FOLDER/second-level-file.txt" should exist
And as "Alice" file "Shares/BRIAN-FOLDER/textfile-c.txt" should not exist
And the content of file "Shares/BRIAN-FOLDER/second-level-file.txt" for user "Alice" should be "sample file-c"
And the response when user "Alice" gets the info of the last share should include
| file_target | /BRIAN-FOLDER |
Examples:
Expand All @@ -451,7 +456,7 @@ Feature: copy file

@issue-ocis-reva-34 @issue-ocis-reva-387
Scenario Outline: copy a folder into a file at different level received as a group share
Given using <dav_version> DAV path
Given using old DAV path
And user "Brian" has been created with default attributes and without skeleton files
And group "grp1" has been created
And user "Alice" has been added to group "grp1"
Expand All @@ -460,14 +465,15 @@ Feature: copy file
And user "Brian" has created folder "BRIAN-FOLDER/second-level-folder"
And user "Brian" has uploaded file with content "file at third level" to "BRIAN-FOLDER/second-level-folder/third-level-file.txt"
And user "Brian" has shared folder "BRIAN-FOLDER" with group "grp1"
And user "Alice" has accepted share "/BRIAN-FOLDER" offered by user "Brian"
And user "Alice" has created folder "FOLDER/second-level-folder"
And user "Alice" has created folder "FOLDER/second-level-folder/third-level-folder"
When user "Alice" copies folder "FOLDER/second-level-folder" to "BRIAN-FOLDER/second-level-folder/third-level-file.txt" using the WebDAV API
When user "Alice" copies folder "FOLDER/second-level-folder" to "Shares/BRIAN-FOLDER/second-level-folder/third-level-file.txt" using the WebDAV API
Then the HTTP status code should be "204"
And as "Alice" folder "BRIAN-FOLDER/second-level-folder/third-level-file.txt" should exist
And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/third-level-file.txt" should exist
And as "Alice" folder "FOLDER/second-level-folder/third-level-folder" should exist
And as "Alice" folder "BRIAN-FOLDER/second-level-folder/third-level-file.txt/third-level-folder" should exist
And as "Alice" folder "BRIAN-FOLDER/second-level-folder/second-level-folder" should not exist
And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/third-level-file.txt/third-level-folder" should exist
And as "Alice" folder "Shares/BRIAN-FOLDER/second-level-folder/second-level-folder" should not exist
And the response when user "Alice" gets the info of the last share should include
| file_target | /BRIAN-FOLDER |
Examples:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Feature: upload file to shared folder
And user "Brian" has been added to group "grp1"
And user "Alice" has created folder "/FOLDER"
And user "Alice" has shared folder "FOLDER" with group "grp1" with permissions "change"
And user "Brian" has accepted share "/FOLDER" offered by user "Alice"
When user "Brian" uploads file with content "uploaded content" to "/Shares/FOLDER/textfile.txt" using the TUS protocol on the WebDAV API
Then the HTTP status code should be "200"
And as "Alice" file "/FOLDER/textfile.txt" should exist
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/ChecksumContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public function userHasUploadedChunkFileOfWithToWithChecksum(
$destination,
$checksum
);
$this->featureContext->theHTTPStatusCodeShouldBe(201);
$this->featureContext->theHTTPStatusCodeShouldBeOr(201, 206);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -1719,14 +1719,14 @@ public function getListOfShares($user) {
/**
* Extracts `id` from responseXml
*
* @return int|null
* @return string|null
*/
public function extractLastSharedIdFromLastResponse() {
// extract max id
$xpath = '/ocs/data/element/id[not (. < ../../element/id)][1]';
$id = $this->getResponseXml(null, __METHOD__)->xpath($xpath);
if ((bool) $id) {
return (int) $id[0];
return (string) $id[0];
}
return null;
}
Expand Down

0 comments on commit f6f6cfe

Please sign in to comment.