Skip to content

Commit

Permalink
add test share space via link
Browse files Browse the repository at this point in the history
  • Loading branch information
ScharfViktor committed Jul 20, 2022
1 parent b698aa6 commit 38d8434
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 6 deletions.
87 changes: 87 additions & 0 deletions tests/acceptance/features/apiSpaces/shareSpacesViaLink.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
@api @skipOnOcV10
Feature: Share spaces via link
As the manager of a space
I want to be able to share a space via public link

Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production
See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839

Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
And the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "share space" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "share space" with content "some content" to "test.txt"


Scenario Outline: A manager can share a space to public via link with different permissions
When user "Alice" creates public link share of the space "share space" with settings:
| shareType | 3 |
| permissions | <permissions> |
| password | <password> |
| name | <linkName> |
| expireDate | <expireDate> |
Then the HTTP status code should be "200"
And the OCS status code should be "200"
And the OCS status message should be "OK"
And the fields of the last response to user "Alice" should include
| item_type | folder |
| mimetype | httpd/unix-directory |
| file_target | / |
| path | / |
| permissions | <permissionsMatching> |
| share_type | public_link |
| displayname_file_owner | %displayname% |
| displayname_owner | %displayname% |
| uid_file_owner | %username% |
| uid_owner | %username% |
| name | <linkName> |
And the public should be able to download file "/test.txt" from inside the last public link shared folder using the new public WebDAV API with password "123"
And the downloaded content should be "some content"
Examples:
| permissions | permissionsMatching | password | linkName | expireDate |
| 1 | read | 123 | link | 2042-03-25T23:59:59+0100 |
| 5 | read,create | 123 | | 2042-03-25T23:59:59+0100 |
| 15 | read,update,create,delete | | link | |


Scenario: An uploader should be abble to upload a file
When user "Alice" creates public link share of the space "share space" with settings:
| shareType | 3 |
| permissions | 4 |
| password | 123 |
| name | forUpload |
| expireDate | 2042-03-25T23:59:59+0100 |
Then the HTTP status code should be "200"
And the OCS status code should be "200"
And the OCS status message should be "OK"
And the fields of the last response to user "Alice" should include
| item_type | folder |
| mimetype | httpd/unix-directory |
| file_target | / |
| path | / |
| permissions | create |
| share_type | public_link |
| displayname_file_owner | %displayname% |
| displayname_owner | %displayname% |
| uid_file_owner | %username% |
| uid_owner | %username% |
| name | forUpload |
And the public should be able to upload file "lorem.txt" into the last public link shared folder using the new public WebDAV API with password "123"
And for user "Alice" the space "share space" should contain these entries:
| lorem.txt |


Scenario Outline: An user without manager role cannot share a space to public via link
Given user "Alice" has shared a space "share space" to user "Brian" with role "<role>"
When user "Brian" creates public link share of the space "share space" with settings:
| permissions | 1 |
Then the HTTP status code should be "404"
And the OCS status code should be "404"
And the OCS status message should be "No share permission"
Examples:
| role |
| viewer |
| editor |
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ Feature: Share a file or folder that is inside a space via public link
| displayname_owner | %displayname% |
| uid_file_owner | %username% |
| uid_owner | %username% |
And the public should be able to download the last publicly shared file using the <webdav_api_version> public WebDAV API without a password and the content should be "Random data"
And the public upload to the last publicly shared file using the <webdav_api_version> public WebDAV API should pass with HTTP status code "204"
And the public should be able to download the last publicly shared file using the new public WebDAV API without a password and the content should be "Random data"
And the public upload to the last publicly shared file using the new public WebDAV API should pass with HTTP status code "204"
Examples:
| ocs_api_version | ocs_status_code | webdav_api_version |
| 1 | 100 | new |
| 2 | 200 | new |
| ocs_api_version | ocs_status_code |
| 1 | 100 |
| 2 | 200 |
57 changes: 56 additions & 1 deletion tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public function setSpaceCreator(string $spaceName, string $spaceCreator): void {
*/
private array $availableSpaces;

/**
* @var array
*/
private array $lastPublicLinkData = [];

/**
* @return array
*/
Expand Down Expand Up @@ -359,7 +364,7 @@ public function getUserIdByUserName(string $userName): string {
}
throw new Exception(__METHOD__ . " user with name $userName not found");
}

/**
* @BeforeScenario
*
Expand Down Expand Up @@ -2652,4 +2657,54 @@ public function userHasStoredEtagOfElementOnPathFromSpace($user, $path, $storePa
throw new Exception("Expected stored etag to be some string but found null!");
}
}

/**
* @When /^user "([^"]*)" creates public link share of the space "([^"]*)" with settings:$/
*
* @param string $user
* @param string $spaceName
* @param TableNode|null $table
*
* @return void
* @throws GuzzleException
*/
public function sendShareSpaceViaLinkRequest(
string $user,
string $spaceName,
?TableNode $table
): void {
$space = $this->getSpaceByName($user, $spaceName);
$rows = $table->getRowsHash();

$rows["shareType"] = \array_key_exists("shareType", $rows) ? $rows["shareType"] : 3;
$rows["permissions"] = \array_key_exists("permissions", $rows) ? $rows["permissions"] : null;
$rows["password"] = \array_key_exists("password", $rows) ? $rows["password"] : null;
$rows["name"] = \array_key_exists("name", $rows) ? $rows["name"] : null;
$rows["expireDate"] = \array_key_exists("expireDate", $rows) ? $rows["expireDate"] : null;

$body = [
"space_ref" => $space['id'],
"shareType" => $rows["shareType"],
"permissions" => $rows["permissions"],
"password" => $rows["password"],
"name" => $rows["name"],
"expireDate" => $rows["expireDate"]
];

$fullUrl = $this->baseUrl . $this->ocsApiUrl;

$this->featureContext->setResponse(
HttpRequestHelper::post(
$fullUrl,
"",
$user,
$this->featureContext->getPasswordForUser($user),
[],
$body
)
);

// set last response as PublicShareData. using method from core
$this->featureContext->setLastPublicShareData($this->featureContext->getResponseXml(null, __METHOD__));
}
}

0 comments on commit 38d8434

Please sign in to comment.