mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-04 15:27:17 -05:00
Merge pull request #2749 from owncloud/refactor-spaces-api-tests
[tests-only] Refactor spaces API tests
This commit is contained in:
@@ -16,19 +16,16 @@ Feature: Upload files into a space
|
||||
And user "Alice" lists all available spaces via the GraphApi
|
||||
And user "Alice" creates a folder "mainFolder" in space "Project Venus" using the WebDav Api
|
||||
Then the HTTP status code should be "201"
|
||||
When user "Alice" lists the content of the space with the name "Project Venus" using the WebDav Api
|
||||
Then the propfind result of the space should contain these entries:
|
||||
And the space "Project Venus" should contain these entries:
|
||||
| mainFolder |
|
||||
|
||||
Scenario: Bob creates a folder via the Graph api in a space, he expects a 404 code and
|
||||
Alice checks that this folder does not exist
|
||||
Scenario: Bob creates a folder via the Graph api in a space, he expects a 404 code and Alice checks that this folder does not exist
|
||||
Given the administrator gives "Alice" the role "Admin" using the settings api
|
||||
When user "Alice" creates a space "Project Merkur" of type "project" with quota "2000" using the GraphApi
|
||||
And user "Alice" lists all available spaces via the GraphApi
|
||||
And user "Bob" creates a folder "forAlice" in space "Project Merkur" using the WebDav Api
|
||||
Then the HTTP status code should be "404"
|
||||
When user "Alice" lists the content of the space with the name "Project Merkur" using the WebDav Api
|
||||
Then the propfind result of the space should not contain these entries:
|
||||
And the space "Project Merkur" should not contain these entries:
|
||||
| forAlice |
|
||||
|
||||
Scenario: Alice creates a folder via Graph api and uploads a file
|
||||
@@ -39,20 +36,17 @@ Feature: Upload files into a space
|
||||
Then the HTTP status code should be "201"
|
||||
And user "Alice" uploads a file inside space "Project Moon" with content "Test" to "test.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "201"
|
||||
When user "Alice" lists the content of the space with the name "Project Moon" using the WebDav Api
|
||||
Then the propfind result of the space should contain these entries:
|
||||
And the space "Project Moon" should contain these entries:
|
||||
| NewFolder |
|
||||
| test.txt |
|
||||
|
||||
Scenario: Bob uploads a file via the Graph api in a space, he expects a 404 code and
|
||||
Alice checks that this file does not exist
|
||||
Scenario: Bob uploads a file via the Graph api in a space, he expects a 404 code and Alice checks that this file does not exist
|
||||
Given the administrator gives "Alice" the role "Admin" using the settings api
|
||||
When user "Alice" creates a space "Project Pluto" of type "project" with quota "2000" using the GraphApi
|
||||
And user "Alice" lists all available spaces via the GraphApi
|
||||
And user "Bob" uploads a file inside space "Project Pluto" with content "Test" to "test.txt" using the WebDAV API
|
||||
Then the HTTP status code should be "404"
|
||||
When user "Alice" lists the content of the space with the name "Project Pluto" using the WebDav Api
|
||||
Then the propfind result of the space should not contain these entries:
|
||||
And the space "Project Pluto" should not contain these entries:
|
||||
| test.txt |
|
||||
|
||||
Scenario: Alice creates uploads a file and checks her quota
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
*
|
||||
*/
|
||||
use Behat\Behat\Context\Context;
|
||||
use Behat\Behat\Hook\Scope\AfterScenarioScope;
|
||||
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
@@ -41,6 +40,34 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
private FeatureContext $featureContext;
|
||||
|
||||
/**
|
||||
* @var array key is space name and value is the username that created the space
|
||||
*/
|
||||
private array $createdSpaces;
|
||||
|
||||
/**
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return string name of the user that created the space
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getSpaceCreator(string $spaceName): string {
|
||||
if (!\array_key_exists($spaceName, $this->createdSpaces)) {
|
||||
throw new Exception(__METHOD__ . " space '$spaceName' has not been created in this scenario");
|
||||
}
|
||||
return $this->createdSpaces[$spaceName];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $spaceName
|
||||
* @param string $spaceCreator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setSpaceCreator(string $spaceName, string $spaceCreator): void {
|
||||
$this->createdSpaces[$spaceName] = $spaceCreator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -344,6 +371,7 @@ class SpacesContext implements Context {
|
||||
""
|
||||
)
|
||||
);
|
||||
$this->setSpaceCreator($spaceName, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -376,6 +404,7 @@ class SpacesContext implements Context {
|
||||
""
|
||||
)
|
||||
);
|
||||
$this->setSpaceCreator($spaceName, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -480,7 +509,7 @@ class SpacesContext implements Context {
|
||||
* @When /^user "([^"]*)" lists the content of the space with the name "([^"]*)" using the WebDav Api$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $name
|
||||
* @param string $spaceName
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
@@ -488,9 +517,9 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
public function theUserListsTheContentOfAPersonalSpaceRootUsingTheWebDAvApi(
|
||||
string $user,
|
||||
string $name
|
||||
string $spaceName
|
||||
): void {
|
||||
$space = $this->getSpaceByName($name);
|
||||
$space = $this->getSpaceByName($spaceName);
|
||||
Assert::assertIsArray($space);
|
||||
Assert::assertNotEmpty($spaceId = $space["id"]);
|
||||
Assert::assertNotEmpty($spaceWebDavUrl = $space["root"]["webDavUrl"]);
|
||||
@@ -529,6 +558,32 @@ class SpacesContext implements Context {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the space "([^"]*)" should (not|)\s?contain these (?:files|entries):$/
|
||||
*
|
||||
* @param string $spaceName
|
||||
* @param string $shouldOrNot (not|)
|
||||
* @param TableNode $expectedFiles
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception|GuzzleException
|
||||
*/
|
||||
public function theSpaceShouldContainEntries(
|
||||
string $spaceName,
|
||||
string $shouldOrNot,
|
||||
TableNode $expectedFiles
|
||||
):void {
|
||||
$this->theUserListsTheContentOfAPersonalSpaceRootUsingTheWebDAvApi(
|
||||
$this->getSpaceCreator($spaceName),
|
||||
$spaceName
|
||||
);
|
||||
$this->propfindResultShouldContainEntries(
|
||||
$shouldOrNot,
|
||||
$expectedFiles,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the json responded should contain a space "([^"]*)" with these key and value pairs:$/
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user