mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-03 19:00:05 -06:00
add tests
This commit is contained in:
@@ -69,7 +69,7 @@ func (g Graph) GetDrives(w http.ResponseWriter, r *http.Request) {
|
||||
filters, err := generateCs3Filters(odataReq)
|
||||
if err != nil {
|
||||
g.logger.Err(err).Interface("query", r.URL.Query()).Msg("query error")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error())
|
||||
errorcode.NotSupported.Render(w, r, http.StatusNotImplemented, err.Error())
|
||||
return
|
||||
}
|
||||
res, err := client.ListStorageSpaces(ctx, &storageprovider.ListStorageSpacesRequest{
|
||||
|
||||
@@ -19,6 +19,35 @@ Feature: List and create spaces
|
||||
| name | Alice Hansen |
|
||||
| quota@@@state | normal |
|
||||
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
|
||||
And the json responded should contain a space "Shares Jail" with these key and value pairs:
|
||||
| key | value |
|
||||
| driveType | virtual |
|
||||
| id | %space_id% |
|
||||
| name | Shares Jail |
|
||||
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
|
||||
|
||||
Scenario: An ordinary user can request information about their Space via the Graph API using a filter
|
||||
When user "Alice" lists all available spaces via the GraphApi with query "$filter=driveType eq 'personal'"
|
||||
Then the HTTP status code should be "200"
|
||||
And the json responded should contain a space "Alice Hansen" with these key and value pairs:
|
||||
| key | value |
|
||||
| driveType | personal |
|
||||
| id | %space_id% |
|
||||
| name | Alice Hansen |
|
||||
| quota@@@state | normal |
|
||||
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
|
||||
And the json responded should not contain a space with name "Shares Jail"
|
||||
And the json responded should contain spaces of type "personal"
|
||||
And the json responded should only contain spaces of type "personal"
|
||||
And the json responded should not contain spaces of type "project"
|
||||
And the json responded should not contain spaces of type "virtual"
|
||||
And the json responded should not contain spaces of type "public"
|
||||
|
||||
Scenario: An ordinary user will not see any space when using a filter for project
|
||||
When user "Alice" lists all available spaces via the GraphApi with query "$filter=driveType eq 'project'"
|
||||
Then the HTTP status code should be "200"
|
||||
And the json responded should not contain a space with name "Alice Hansen"
|
||||
And the json responded should not contain spaces of type "personal"
|
||||
|
||||
Scenario: An ordinary user can access their Space via the webDav API
|
||||
When user "Alice" lists all available spaces via the GraphApi
|
||||
|
||||
@@ -350,6 +350,26 @@ class SpacesContext implements Context {
|
||||
$this->rememberTheAvailableSpaces();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" lists all available spaces via the GraphApi with query "([^"]*)"$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $query
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function theUserListsAllHisAvailableSpacesUsingTheGraphApiWithFilter(string $user, string $query): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->listSpacesRequest(
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user),
|
||||
"?". $query
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^user "([^"]*)" creates a space "([^"]*)" of type "([^"]*)" with the default quota using the GraphApi$/
|
||||
*
|
||||
@@ -659,7 +679,7 @@ class SpacesContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the json responded should not contain a space "([^"]*)"$/
|
||||
* @Then /^the json responded should not contain a space with name "([^"]*)"$/
|
||||
*
|
||||
* @param string $spaceName
|
||||
*
|
||||
@@ -672,6 +692,45 @@ class SpacesContext implements Context {
|
||||
Assert::assertEmpty($this->getSpaceByNameFromResponse($spaceName), "space $spaceName should not be available for a user");
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the json responded should (not|only|)\s?contain spaces of type "([^"]*)"$/
|
||||
*
|
||||
* @param string $shoulOrNot (not|only|)
|
||||
* @param string $type
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function jsonRespondedShouldNotContainSpaceType(
|
||||
string $onlyOrNot,
|
||||
string $type
|
||||
): void {
|
||||
Assert::assertNotEmpty(
|
||||
$spaces = json_decode(
|
||||
(string)$this->featureContext
|
||||
->getResponse()->getBody(),
|
||||
true,
|
||||
512,
|
||||
JSON_THROW_ON_ERROR
|
||||
)
|
||||
);
|
||||
$matches = [];
|
||||
foreach($spaces["value"] as $space) {
|
||||
if($onlyOrNot === "not") {
|
||||
Assert::assertNotEquals($space["driveType"], $type);
|
||||
}
|
||||
if($onlyOrNot === "only") {
|
||||
Assert::assertEquals($space["driveType"], $type);
|
||||
}
|
||||
if($onlyOrNot === "" && $space["driveType"] === $type) {
|
||||
$matches[] = $space;
|
||||
}
|
||||
}
|
||||
if($onlyOrNot === "") {
|
||||
Assert::assertNotEmpty($matches);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $shouldOrNot (not|)
|
||||
* @param TableNode $expectedFiles
|
||||
|
||||
Reference in New Issue
Block a user