[test-only]Api test. check that link or share exist for space members (#4348)
Co-authored-by: Saw-jan <saw.jan.grg3e@gmail.com>
This commit is contained in:
Vendored
+5
@@ -1,6 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Listen for Xdebug",
|
||||
"type": "php",
|
||||
"request": "launch"
|
||||
},
|
||||
{
|
||||
"name": "oCIS server",
|
||||
"type": "go",
|
||||
|
||||
@@ -52,18 +52,18 @@ Feature: A manager of the space can edit public link
|
||||
| 15 | read,update,create,delete | | newName | 2042-03-25T23:59:59+0100 |
|
||||
|
||||
|
||||
Scenario Outline: Only users with manager role can see a created public link
|
||||
Scenario Outline: All members can see a created public link
|
||||
Given using OCS API version "2"
|
||||
When user "Alice" shares a space "edit space" to user "Brian" with role "<role>"
|
||||
Then the HTTP status code should be "200"
|
||||
And the OCS status code should be "200"
|
||||
And for user "Alice" the space "edit space" should contain the last created public link
|
||||
And for user "Brian" the space "edit space" <shouldOrNot> contain the last created public link
|
||||
And for user "Brian" the space "edit space" should contain the last created public link
|
||||
Examples:
|
||||
| role | shouldOrNot |
|
||||
| manager | should |
|
||||
| editor | should |
|
||||
| viewer | should |
|
||||
| role |
|
||||
| manager |
|
||||
| editor |
|
||||
| viewer |
|
||||
|
||||
|
||||
Scenario Outline: Members of the space try to edit a public link
|
||||
|
||||
@@ -62,3 +62,15 @@ Feature: Share a file or folder that is inside a space
|
||||
| file.txt | editor | 404 | No share permission |
|
||||
| file.txt | viewer | 404 | No share permission |
|
||||
| folder | viewer | 404 | No share permission |
|
||||
|
||||
|
||||
Scenario Outline: An user participant of the project space can see the created resources share
|
||||
Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "<spaceRole>"
|
||||
When user "Alice" shares the following entity "file.txt" inside of space "share sub-item" with user "Bob" with role "editor"
|
||||
Then for user "Alice" the space "share sub-item" should contain the last created share of the file "file.txt"
|
||||
And for user "Brian" the space "share sub-item" should contain the last created share of the file "file.txt"
|
||||
Examples:
|
||||
| spaceRole |
|
||||
| editor |
|
||||
| viewer |
|
||||
| manager |
|
||||
|
||||
@@ -117,3 +117,17 @@ Feature: Share a file or folder that is inside a space via public link
|
||||
| ocs_api_version | ocs_status_code |
|
||||
| 1 | 100 |
|
||||
| 2 | 200 |
|
||||
|
||||
|
||||
Scenario Outline: An user participant of the project space can see the created public resources link
|
||||
Given user "Alice" has shared a space "share sub-item" to user "Brian" with role "<spaceRole>"
|
||||
When user "Alice" creates a public link share inside of space "share sub-item" with settings:
|
||||
| path | folder/file.txt |
|
||||
| shareType | 3 |
|
||||
| permissions | 1 |
|
||||
Then for user "Brian" the space "share sub-item" should contain the last created public link of the file "folder/file.txt"
|
||||
Examples:
|
||||
| spaceRole |
|
||||
| editor |
|
||||
| viewer |
|
||||
| manager |
|
||||
|
||||
@@ -376,6 +376,20 @@ class SpacesContext implements Context {
|
||||
throw new Exception(__METHOD__ . " user with name $userName not found");
|
||||
}
|
||||
|
||||
/**
|
||||
* using method from core to set share data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setLastShareData(): void {
|
||||
// set last response as PublicShareData
|
||||
$this->featureContext->setLastPublicShareData($this->featureContext->getResponseXml(null, __METHOD__));
|
||||
// set last shareId if ShareData exists
|
||||
if (isset($this->featureContext->getLastPublicShareData()->data)) {
|
||||
$this->featureContext->setLastPublicLinkShareId((string) $this->featureContext->getLastPublicShareData()->data[0]->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @BeforeScenario
|
||||
*
|
||||
@@ -2055,6 +2069,7 @@ class SpacesContext implements Context {
|
||||
$body
|
||||
)
|
||||
);
|
||||
$this->setLastShareData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2062,7 +2077,7 @@ class SpacesContext implements Context {
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
* @param TableNode|null $table
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
@@ -2070,7 +2085,7 @@ class SpacesContext implements Context {
|
||||
public function createPublicLinkToEntityInsideOfSpaceRequest(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
?TableNode $table
|
||||
TableNode $table
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$rows = $table->getRowsHash();
|
||||
@@ -2101,6 +2116,32 @@ class SpacesContext implements Context {
|
||||
$body
|
||||
)
|
||||
);
|
||||
|
||||
$this->setLastShareData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^user "([^"]*)" has created a public link share inside of space "([^"]*)" with settings:$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userHasCreatedPublicLinkToEntityInsideOfSpaceRequest(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
TableNode $table
|
||||
): void {
|
||||
$this->createPublicLinkToEntityInsideOfSpaceRequest($user, $spaceName, $table);
|
||||
|
||||
$expectedHTTPStatus = "200";
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
$expectedHTTPStatus,
|
||||
"Expected response status code should be $expectedHTTPStatus"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2917,12 +2958,7 @@ class SpacesContext implements Context {
|
||||
)
|
||||
);
|
||||
|
||||
// set last response as PublicShareData. using method from core
|
||||
$this->featureContext->setLastPublicShareData($this->featureContext->getResponseXml(null, __METHOD__));
|
||||
// set last shareId if ShareData exists. using method from core
|
||||
if (isset($this->featureContext->getLastPublicShareData()->data)) {
|
||||
$this->featureContext->setLastPublicLinkShareId((string) $this->featureContext->getLastPublicShareData()->data[0]->id);
|
||||
}
|
||||
$this->setLastShareData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2952,10 +2988,13 @@ class SpacesContext implements Context {
|
||||
|
||||
/**
|
||||
* @Then /^for user "([^"]*)" the space "([^"]*)" should (not|)\s?contain the last created public link$/
|
||||
* @Then /^for user "([^"]*)" the space "([^"]*)" should (not|)\s?contain the last created public link of the file "([^"]*)"$/
|
||||
* @Then /^for user "([^"]*)" the space "([^"]*)" should (not|)\s?contain the last created share of the file "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
* @param string $shouldOrNot (not|)
|
||||
* @param string $fileName
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -2964,10 +3003,18 @@ class SpacesContext implements Context {
|
||||
public function forUserSpaceShouldContainLinks(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $shouldOrNot
|
||||
string $shouldOrNot,
|
||||
string $fileName = ''
|
||||
): void {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$url = "/apps/files_sharing/api/v1/shares?reshares=true&space_ref=" . $space['id'];
|
||||
$body = '';
|
||||
if (!empty ($fileName)) {
|
||||
$body = $this->getFileId($user, $spaceName, $fileName);
|
||||
} else {
|
||||
$space = $this->getSpaceByName($user, $spaceName);
|
||||
$body = $space['id'];
|
||||
}
|
||||
|
||||
$url = "/apps/files_sharing/api/v1/shares?reshares=true&space_ref=" . $body;
|
||||
|
||||
$this->ocsContext->userSendsHTTPMethodToOcsApiEndpointWithBody(
|
||||
$user,
|
||||
|
||||
Reference in New Issue
Block a user