Merge pull request #9864 from owncloud/tests/adjust-expected-failure-list

[tests-only] adjust expected-failure list and archive related tests
This commit is contained in:
Sawjan Gurung
2024-08-23 16:23:33 +05:45
committed by GitHub
7 changed files with 135 additions and 91 deletions
@@ -150,13 +150,6 @@ _ocdav: api compatibility, return correct status code_
- [coreApiWebdavUploadTUS/optionsRequest.feature:40](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUploadTUS/optionsRequest.feature#L40)
- [coreApiWebdavUploadTUS/optionsRequest.feature:55](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavUploadTUS/optionsRequest.feature#L55)
### Won't fix
Not everything needs to be implemented for ocis. While the oc10 testsuite covers these things we are not looking at them right now.
- _The `OC-LazyOps` header is [no longer supported by the client](https://github.com/owncloud/client/pull/8398), implementing this is not necessary for a first production release. We plan to have an upload state machine to visualize the state of a file, see https://github.com/owncloud/ocis/issues/214_
- _Blacklisted ignored files are no longer required because ocis can handle `.htaccess` files without security implications introduced by serving user provided files with apache._
#### [Renaming resource to banned name is allowed in spaces webdav](https://github.com/owncloud/ocis/issues/3099)
- [coreApiWebdavMove2/moveFile.feature:143](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavMove2/moveFile.feature#L143)
@@ -168,7 +161,7 @@ Not everything needs to be implemented for ocis. While the oc10 testsuite covers
- [coreApiTrashbin/trashbinDelete.feature:92](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinDelete.feature#L92)
### [MOVE a file into same folder with same name returns 404 instead of 403](https://github.com/owncloud/ocis/issues/1976)
#### [MOVE a file into same folder with same name returns 404 instead of 403](https://github.com/owncloud/ocis/issues/1976)
- [coreApiWebdavMove2/moveFile.feature:100](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavMove2/moveFile.feature#L100)
- [coreApiWebdavMove2/moveFile.feature:101](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavMove2/moveFile.feature#L101)
@@ -179,12 +172,19 @@ Not everything needs to be implemented for ocis. While the oc10 testsuite covers
- [coreApiWebdavMove2/moveShareOnOcis.feature:307](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavMove2/moveShareOnOcis.feature#L307)
- [coreApiWebdavMove2/moveShareOnOcis.feature:310](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavMove2/moveShareOnOcis.feature#L310)
### [COPY file/folder to same name is possible (but 500 code error for folder with spaces path)](https://github.com/owncloud/ocis/issues/8711)
#### [COPY file/folder to same name is possible (but 500 code error for folder with spaces path)](https://github.com/owncloud/ocis/issues/8711)
- [coreApiSharePublicLink2/copyFromPublicLink.feature:198](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiSharePublicLink2/copyFromPublicLink.feature#L198)
- [coreApiWebdavProperties/copyFile.feature:1067](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L1067)
- [coreApiWebdavProperties/copyFile.feature:1068](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L1068)
- [coreApiWebdavProperties/copyFile.feature:1069](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiWebdavProperties/copyFile.feature#L1069)
### Won't fix
Not everything needs to be implemented for ocis. While the oc10 testsuite covers these things we are not looking at them right now.
- _The `OC-LazyOps` header is [no longer supported by the client](https://github.com/owncloud/client/pull/8398), implementing this is not necessary for a first production release. We plan to have an upload state machine to visualize the state of a file, see https://github.com/owncloud/ocis/issues/214_
- _Blacklisted ignored files are no longer required because ocis can handle `.htaccess` files without security implications introduced by serving user provided files with apache._
Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
@@ -13,23 +13,13 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiArchiver/downloadByPath.feature:171](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadByPath.feature#L171)
- [apiArchiver/downloadByPath.feature:172](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadByPath.feature#L172)
### [Downloaded /Shares tar contains resource (files|folder) with leading / in Response](https://github.com/owncloud/ocis/issues/4636)
- [apiArchiver/downloadById.feature:173](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadById.feature#L173)
- [apiArchiver/downloadById.feature:174](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiArchiver/downloadById.feature#L174)
### [Shared mount folder gets deleted when overwritten by a file from personal space](https://github.com/owncloud/ocis/issues/7208)
- [apiSpacesShares/copySpaces.feature:696](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/copySpaces.feature#L696)
- [apiSpacesShares/copySpaces.feature:715](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/copySpaces.feature#L715)
#### [PATCH request for TUS upload with wrong checksum gives incorrect response](https://github.com/owncloud/ocis/issues/1755)
- [apiSpacesShares/shareUploadTUS.feature:283](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareUploadTUS.feature#L283)
- [apiSpacesShares/shareUploadTUS.feature:303](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareUploadTUS.feature#L303)
- [apiSpacesShares/shareUploadTUS.feature:384](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/shareUploadTUS.feature#L384)
### [Settings service user can list other peoples assignments](https://github.com/owncloud/ocis/issues/5032)
#### [Settings service user can list other peoples assignments](https://github.com/owncloud/ocis/issues/5032)
- [apiAccountsHashDifficulty/assignRole.feature:27](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature#L27)
- [apiAccountsHashDifficulty/assignRole.feature:28](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiAccountsHashDifficulty/assignRole.feature#L28)
@@ -83,16 +73,16 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiGraphUserGroup/addUserToGroup.feature:295](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/addUserToGroup.feature#L295)
### [Users are added in a group with wrong host in host-part of user](https://github.com/owncloud/ocis/issues/5871)
#### [Users are added in a group with wrong host in host-part of user](https://github.com/owncloud/ocis/issues/5871)
- [apiGraphUserGroup/addUserToGroup.feature:379](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/addUserToGroup.feature#L379)
- [apiGraphUserGroup/addUserToGroup.feature:393](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/addUserToGroup.feature#L393)
### [Adding the same user as multiple members in a single request results in listing the same user twice in the group](https://github.com/owncloud/ocis/issues/5855)
#### [Adding the same user as multiple members in a single request results in listing the same user twice in the group](https://github.com/owncloud/ocis/issues/5855)
- [apiGraphUserGroup/addUserToGroup.feature:430](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraphUserGroup/addUserToGroup.feature#L430)
### [Shared file locking is not possible using different path](https://github.com/owncloud/ocis/issues/7599)
#### [Shared file locking is not possible using different path](https://github.com/owncloud/ocis/issues/7599)
- [apiLocks/lockFiles.feature:188](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L188)
- [apiLocks/lockFiles.feature:189](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L189)
@@ -170,7 +160,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiLocks/lockFiles.feature:423](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L423)
- [apiLocks/lockFiles.feature:424](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L424)
### [Anonymous users can unlock a file shared to them through a public link if they get the lock token](https://github.com/owncloud/ocis/issues/7761)
#### [Anonymous users can unlock a file shared to them through a public link if they get the lock token](https://github.com/owncloud/ocis/issues/7761)
- [apiLocks/unlockFiles.feature:42](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L42)
- [apiLocks/unlockFiles.feature:43](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L43)
@@ -179,7 +169,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiLocks/unlockFiles.feature:46](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L46)
- [apiLocks/unlockFiles.feature:47](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L47)
### [Trying to unlock a shared file with sharer's lock token gives 500](https://github.com/owncloud/ocis/issues/7767)
#### [Trying to unlock a shared file with sharer's lock token gives 500](https://github.com/owncloud/ocis/issues/7767)
- [apiLocks/unlockFiles.feature:115](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L115)
- [apiLocks/unlockFiles.feature:116](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L116)
@@ -194,7 +184,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiLocks/unlockFiles.feature:147](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L147)
- [apiLocks/unlockFiles.feature:148](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/unlockFiles.feature#L148)
### [Anonymous user trying lock a file shared to them through a public link gives 405](https://github.com/owncloud/ocis/issues/7790)
#### [Anonymous user trying lock a file shared to them through a public link gives 405](https://github.com/owncloud/ocis/issues/7790)
- [apiLocks/lockFiles.feature:538](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L538)
- [apiLocks/lockFiles.feature:539](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L539)
@@ -209,7 +199,7 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiLocks/lockFiles.feature:566](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L566)
- [apiLocks/lockFiles.feature:567](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiLocks/lockFiles.feature#L567)
### [blocksDownload link type is not implemented yet (sharing-ng)](https://github.com/owncloud/ocis/issues/7879)
#### [blocksDownload link type is not implemented yet (sharing-ng)](https://github.com/owncloud/ocis/issues/7879)
- [apiSharingNgLinkSharePermission/createLinkShare.feature:72](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgLinkSharePermission/createLinkShare.feature#L72)
- [apiSharingNgLinkSharePermission/createLinkShare.feature:202](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNgLinkSharePermission/createLinkShare.feature#L202)
@@ -262,14 +252,14 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSharingNg1/removeAccessToDrive.feature:206](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg1/removeAccessToDrive.feature#L206)
- [apiSharingNg1/removeAccessToDrive.feature:236](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg1/removeAccessToDrive.feature#L236)
### [sharee (editor role) MOVE a file by file-id into shared sub-folder returns 502](https://github.com/owncloud/ocis/issues/7617)
#### [sharee (editor role) MOVE a file by file-id into shared sub-folder returns 502](https://github.com/owncloud/ocis/issues/7617)
- [apiSpacesDavOperation/moveByFileId.feature:469](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L469)
- [apiSpacesDavOperation/moveByFileId.feature:470](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L470)
- [apiSpacesDavOperation/moveByFileId.feature:732](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L732)
- [apiSpacesDavOperation/moveByFileId.feature:733](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L733)
### [MOVE a file into same folder with same name returns 404 instead of 403](https://github.com/owncloud/ocis/issues/1976)
#### [MOVE a file into same folder with same name returns 404 instead of 403](https://github.com/owncloud/ocis/issues/1976)
- [apiSpacesShares/moveSpaces.feature:69](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/moveSpaces.feature#L69)
- [apiSpacesShares/moveSpaces.feature:70](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/moveSpaces.feature#L70)
@@ -285,19 +275,21 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSpacesDavOperation/moveByFileId.feature:492](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L492)
- [apiSpacesDavOperation/moveByFileId.feature:493](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L493)
### [OCM. sharing issues](https://github.com/owncloud/ocis/issues/9534)
#### [OCM. sharing issues](https://github.com/owncloud/ocis/issues/9534)
- [apiOcm/share.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L12)
- [apiOcm/share.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L91)
### [OCM. user cannot see invite description and inviteUser email](https://github.com/owncloud/ocis/issues/9591)
#### [OCM. user cannot see invite description and inviteUser email](https://github.com/owncloud/ocis/issues/9591)
- [apiOcm/createInvitation.feature:63](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/createInvitation.feature#L63)
### [OCM. admin cannot get federated users if he hasn't connection with them ](https://github.com/owncloud/ocis/issues/9829)
#### [OCM. admin cannot get federated users if he hasn't connection with them ](https://github.com/owncloud/ocis/issues/9829)
tests/acceptance/features/apiOcm/searchFederationUsers.feature
- [apiOcm/searchFederationUsers.feature:429](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/searchFederationUsers.feature#L429)
- [apiOcm/searchFederationUsers.feature:601](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/searchFederationUsers.feature#L601)
- Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
@@ -13,7 +13,7 @@ Feature: download multiple resources bundled into an archive
Scenario Outline: download a single file
Given user "Alice" has uploaded file with content "some data" to "/textfile0.txt"
When user "Alice" downloads the archive of "/textfile0.txt" using the resource id and setting these headers
When user "Alice" downloads the <archive-type> archive of "/textfile0.txt" using the resource id and setting these headers:
| header | value |
| User-Agent | <user-agent> |
Then the HTTP status code should be "200"
@@ -22,7 +22,7 @@ Feature: download multiple resources bundled into an archive
| textfile0.txt | some data |
Examples:
| user-agent | archive-type |
| Linux | zip |
| Linux | tar |
| Windows NT | zip |
@@ -30,7 +30,7 @@ Feature: download multiple resources bundled into an archive
Given user "Alice" has created folder "my_data"
And user "Alice" has uploaded file with content "some data" to "/my_data/textfile0.txt"
And user "Alice" has uploaded file with content "more data" to "/my_data/an_other_file.txt"
When user "Alice" downloads the archive of "/my_data" using the resource id and setting these headers
When user "Alice" downloads the <archive-type> archive of "/my_data" using the resource id and setting these headers:
| header | value |
| User-Agent | <user-agent> |
Then the HTTP status code should be "200"
@@ -41,7 +41,7 @@ Feature: download multiple resources bundled into an archive
Examples:
| user-agent | archive-type |
| Linux | zip |
| Windows NT | zip |
| Windows NT | tar |
Scenario: download multiple files and folders
@@ -158,16 +158,16 @@ Feature: download multiple resources bundled into an archive
| shareType | user |
| permissionsRole | Viewer |
And user "Brian" has a share "more_data" synced
When user "Brian" downloads the archive of "/Shares" using the resource id and setting these headers
When user "Brian" downloads the <archive-type> archive of "/Shares" using the resource id and setting these headers:
| header | value |
| User-Agent | <user-agent> |
Then the HTTP status code should be "200"
And the downloaded <archive-type> archive should contain these files:
| name | content |
| Shares/textfile0.txt | some data |
| Shares/textfile1.txt | other data |
| Shares/my_data/textfile2.txt | some data |
| Shares/more_data/an_other_file.txt | more data |
| name | content |
| textfile0.txt | some data |
| textfile1.txt | other data |
| my_data/textfile2.txt | some data |
| more_data/an_other_file.txt | more data |
Examples:
| user-agent | archive-type |
| Linux | tar |
@@ -13,7 +13,7 @@ Feature: download multiple resources bundled into an archive
@issue-4637
Scenario Outline: download a single file
Given user "Alice" has uploaded file with content "some data" to "/textfile0.txt"
When user "Alice" downloads the archive of "/home/textfile0.txt" using the resource path and setting these headers
When user "Alice" downloads the <archive-type> archive of "/home/textfile0.txt" using the resource path and setting these headers:
| header | value |
| User-Agent | <user-agent> |
Then the HTTP status code should be "200"
@@ -30,7 +30,7 @@ Feature: download multiple resources bundled into an archive
Given user "Alice" has created folder "my_data"
And user "Alice" has uploaded file with content "some data" to "/my_data/textfile0.txt"
And user "Alice" has uploaded file with content "more data" to "/my_data/an_other_file.txt"
When user "Alice" downloads the archive of "/home/my_data" using the resource path and setting these headers
When user "Alice" downloads the <archive-type> archive of "/home/my_data" using the resource path and setting these headers:
| header | value |
| User-Agent | <user-agent> |
Then the HTTP status code should be "200"
@@ -156,7 +156,7 @@ Feature: download multiple resources bundled into an archive
| shareType | user |
| permissionsRole | Viewer |
And user "Brian" has a share "more_data" synced
When user "Brian" downloads the archive of "/home/Shares" using the resource path and setting these headers
When user "Brian" downloads the <archive-type> archive of "/home/Shares" using the resource path and setting these headers:
| header | value |
| User-Agent | <user-agent> |
Then the HTTP status code should be "200"
@@ -706,10 +706,12 @@ Feature: copy file
| permissionsRole | Editor |
And user "Alice" has a share "BRIAN-Folder" synced
When user "Alice" copies file "/textfile1.txt" from space "Personal" to "/BRIAN-Folder" inside space "Shares" using the WebDAV API
Then the HTTP status code should be "204"
And for user "Alice" the content of the file "/BRIAN-Folder" of the space "Shares" should be "ownCloud test text file 1"
And as "Alice" file "/textfile1.txt" should exist
And user "Alice" should not have any received shares
Then the HTTP status code should be "400"
And as "Alice" folder "Shares/BRIAN-Folder/sample-folder" should exist
And as "Brian" folder "BRIAN-Folder/sample-folder" should exist
But as "Alice" file "Shares/BRIAN-Folder" should not exist
And as "Alice" file "Shares/textfile1.txt" should not exist
And user "Alice" should have a share "BRIAN-Folder" shared by user "Brian"
@issue-7208
Scenario: copy a folder over the top of an existing file received as a user share
@@ -725,11 +727,11 @@ Feature: copy file
| permissionsRole | File Editor |
And user "Alice" has a share "sharedfile1.txt" synced
When user "Alice" copies folder "/FOLDER" from space "Personal" to "/sharedfile1.txt" inside space "Shares" using the WebDAV API
Then the HTTP status code should be "204"
And as "Alice" folder "/FOLDER/sample-folder" should exist
And for user "Alice" folder "/sharedfile1.txt" of the space "Shares" should contain these files:
| /sample-folder |
And user "Alice" should not have any received shares
Then the HTTP status code should be "400"
And for user "Alice" the content of the file "sharedfile1.txt" of the space "Shares" should be "file to share"
And for user "Brian" the content of the file "sharedfile1.txt" of the space "Personal" should be "file to share"
But as "Alice" folder "Shares/FOLDER/sample-folder" should not exist
And user "Alice" should have a share "sharedfile1.txt" shared by user "Brian"
Scenario: copy a folder into another folder at different level which is received as a user share
@@ -28,6 +28,9 @@ use TestHelpers\HttpRequestHelper;
use TestHelpers\SetupHelper;
use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface;
use splitbrain\PHPArchive\Tar;
use splitbrain\PHPArchive\Zip;
use splitbrain\PHPArchive\Archive;
require_once 'bootstrap.php';
@@ -62,6 +65,39 @@ class ArchiverContext implements Context {
);
}
/**
* @param string $type
*
* @return Archive
*/
public function getArchiveClass(string $type): Archive {
if ($type === 'zip') {
return new Zip();
} elseif ($type === 'tar') {
return new Tar();
} else {
throw new Exception('Unknown archive type: ' . $type);
}
}
/**
* @param string $dir
*
* @return void
*/
public function removeDir(string $dir): void {
$items = array_diff(scandir($dir), ['.', '..']);
foreach ($items as $item) {
$itemPath = $dir . DIRECTORY_SEPARATOR . $item;
if (\is_dir($itemPath)) {
$this->removeDir($itemPath);
} else {
\unlink($itemPath);
}
}
\rmdir($dir);
}
/**
* @param string $user
* @param string $resource
@@ -92,9 +128,10 @@ class ArchiverContext implements Context {
}
/**
* @When user :user downloads the archive of :resource using the resource :addressType and setting these headers
* @When /^user "([^"]*)" downloads the (zip|tar) archive of "([^"]*)" using the resource (id|ids|path|paths) and setting these headers:$/
*
* @param string $user
* @param string $archiveType
* @param string $resource
* @param string $addressType id|path
* @param TableNode $headersTable
@@ -104,8 +141,9 @@ class ArchiverContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function userDownloadsTheArchive(
public function userDownloadsTheZipOrTarArchiveOfResourceUsingResourceIdOrPathAndSettingTheseHeaders(
string $user,
string $archiveType,
string $resource,
string $addressType,
TableNode $headersTable
@@ -118,7 +156,7 @@ class ArchiverContext implements Context {
foreach ($headersTable as $row) {
$headers[$row['header']] = $row ['value'];
}
$this->featureContext->setResponse($this->downloadArchive($user, $resource, $addressType, null, $headers));
$this->featureContext->setResponse($this->downloadArchive($user, $resource, $addressType, $archiveType, null, $headers));
}
/**
@@ -140,13 +178,14 @@ class ArchiverContext implements Context {
string $owner,
string $addressType
): void {
$this->featureContext->setResponse($this->downloadArchive($downloader, $resource, $addressType, $owner));
$this->featureContext->setResponse($this->downloadArchive($downloader, $resource, $addressType, null, $owner));
}
/**
* @param string $downloader
* @param string $resource
* @param string $addressType
* @param string|null $archiveType
* @param string|null $owner
* @param array|null $headers
*
@@ -158,12 +197,16 @@ class ArchiverContext implements Context {
string $downloader,
string $resource,
string $addressType,
?string $archiveType = null,
?string $owner = null,
?array $headers = null
): ResponseInterface {
$owner = $owner ?? $downloader;
$downloader = $this->featureContext->getActualUsername($downloader);
$queryString = $this->getArchiverQueryString($owner, $resource, $addressType);
if ($archiveType !== null) {
$queryString .= '&output-format=' . $archiveType;
}
return HttpRequestHelper::get(
$this->featureContext->getBaseUrl() . '/archiver?' . $queryString,
$this->featureContext->getStepLineRef(),
@@ -220,28 +263,34 @@ class ArchiverContext implements Context {
$this->featureContext->verifyTableNodeColumns($expectedFiles, ['name', 'content']);
$contents = $this->featureContext->getResponse()->getBody()->getContents();
$tempFile = \tempnam(\sys_get_temp_dir(), 'OcAcceptanceTests_');
$tempExtractFolder = $tempFile;
\unlink($tempFile); // we only need the name
$tempFile = $tempFile . '.' . $type; // it needs the extension
\file_put_contents($tempFile, $contents);
// open the archive
$archiveData = new RecursiveIteratorIterator(
new PharData($tempFile),
RecursiveIteratorIterator::SELF_FIRST
);
$tar = $this->getArchiveClass($type);
$tar->open($tempFile);
$archiveData = $tar->contents();
// extract the archive
$tar->open($tempFile);
$tar->extract($tempExtractFolder);
$tar->close();
foreach ($expectedFiles->getHash() as $expectedItem) {
$expectedPath = trim($expectedItem['name'], "/");
$found = false;
foreach ($archiveData as $info) {
// get only the parent folder path for the given item
$actualPath = explode(".$type", $info->getPathname())[1];
$actualPath = trim($actualPath, "/");
$actualPath = $info->getPath();
if ($expectedPath === $actualPath) {
if (!$info->isDir()) {
if (!$info->getIsdir()) {
$fileContent = \file_get_contents("$tempExtractFolder/$actualPath");
Assert::assertEquals(
$expectedItem['content'],
$info->getContent(),
$fileContent,
__METHOD__ .
" content of '" . $expectedPath . "' not as expected"
);
@@ -255,5 +304,6 @@ class ArchiverContext implements Context {
}
}
\unlink($tempFile);
$this->removeDir($tempExtractFolder);
}
}
+23 -23
View File
@@ -1,27 +1,27 @@
{
"config" : {
"platform": {
"php": "8.2"
},
"allow-plugins": {
"composer/package-versions-deprecated": true
}
"config": {
"platform": {
"php": "8.2"
},
"require": {
"behat/behat": "^3.13",
"behat/gherkin": "^4.9",
"behat/mink": "1.7.1",
"friends-of-behat/mink-extension": "^2.7",
"ciaranmcnulty/behat-stepthroughextension" : "dev-master",
"rdx/behat-variables": "^1.2",
"sensiolabs/behat-page-object-extension": "^2.3",
"symfony/translation": "^5.4",
"sabre/xml": "^2.2",
"guzzlehttp/guzzle": "^7.7",
"phpunit/phpunit": "^9.6",
"laminas/laminas-ldap": "^2.15",
"ankitpokhrel/tus-php": "^2.3",
"wapmorgan/unified-archive": "^1.1.10",
"swaggest/json-schema": "^0.12.42"
"allow-plugins": {
"composer/package-versions-deprecated": true
}
},
"require": {
"behat/behat": "^3.13",
"behat/gherkin": "^4.9",
"behat/mink": "1.7.1",
"friends-of-behat/mink-extension": "^2.7",
"ciaranmcnulty/behat-stepthroughextension": "dev-master",
"rdx/behat-variables": "^1.2",
"sensiolabs/behat-page-object-extension": "^2.3",
"symfony/translation": "^5.4",
"sabre/xml": "^2.2",
"guzzlehttp/guzzle": "^7.7",
"phpunit/phpunit": "^9.6",
"laminas/laminas-ldap": "^2.15",
"ankitpokhrel/tus-php": "^2.3",
"swaggest/json-schema": "^0.12.42",
"splitbrain/php-archive": "^1.3"
}
}