fix after review
This commit is contained in:
committed by
Michael Barz
parent
a59d44c2ef
commit
4664e578ca
@@ -13,13 +13,14 @@ Feature: List and create spaces
|
||||
When user "Alice" lists all available spaces via the GraphApi
|
||||
Then the HTTP status code should be "200"
|
||||
And the json responded should contain these key and value pairs
|
||||
| key | value |
|
||||
| driveType | personal |
|
||||
| name | Alice Hansen |
|
||||
| key | value |
|
||||
| driveType | personal |
|
||||
| name | Alice Hansen |
|
||||
| quota@@@used | 0 |
|
||||
|
||||
Scenario: Alice requests her space via webDav api, she expects a 207 code
|
||||
When user "Alice" lists all available spaces via the GraphApi
|
||||
And user "Alice" lists the content of the space with the name "Alice Hansen" using the WebDav Api
|
||||
And user "Alice" lists the content of the space with the name "Alice Hansen" using the WebDav Api
|
||||
Then the HTTP status code should be "207"
|
||||
|
||||
Scenario: Alice tryes to create Space via Graph api without right, she expects a response of 401
|
||||
@@ -31,10 +32,11 @@ Feature: List and create spaces
|
||||
When user "Alice" creates a space "Project Mars" of type "project" with the default quota using the GraphApi
|
||||
Then the HTTP status code should be "201"
|
||||
And the json responded should contain these key and value pairs
|
||||
| key | value |
|
||||
| driveType | project |
|
||||
| name | Project Mars |
|
||||
| total | 1000000000 |
|
||||
| key | value |
|
||||
| driveType | project |
|
||||
| name | Project Mars |
|
||||
| quota@@@total | 1000000000 |
|
||||
|
||||
When user "Alice" lists all available spaces via the GraphApi
|
||||
And user "Alice" lists the content of the space with the name "Project Mars" using the WebDav Api
|
||||
Then the propfind result of the space should contain these entries:
|
||||
@@ -45,16 +47,16 @@ Feature: List and create spaces
|
||||
When user "Alice" creates a space "Project Venus" of type "project" with quota "2000" using the GraphApi
|
||||
Then the HTTP status code should be "201"
|
||||
And the json responded should contain these key and value pairs
|
||||
| key | value |
|
||||
| driveType | project |
|
||||
| name | Project Venus |
|
||||
| total | 2000 |
|
||||
| key | value |
|
||||
| driveType | project |
|
||||
| name | Project Venus |
|
||||
| quota@@@total | 2000 |
|
||||
|
||||
Scenario: Alice creates folder via Graph api in space, she expects a 201 code and she checks that folder exists
|
||||
Scenario: Alice creates folder via WebDav api in space, she expects a 201 code and she checks that folder exists
|
||||
Given the administrator gives "Alice" the role "Admin" using the settings api
|
||||
When user "Alice" creates a space "Project Venus" of type "project" with quota "2000" using the GraphApi
|
||||
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
|
||||
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:
|
||||
|
||||
@@ -412,38 +412,35 @@ class SpacesContext implements Context {
|
||||
*/
|
||||
public function jsonRespondedShouldContain(TableNode $table) {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
||||
$responseJson = json_decode($this->featureContext->getResponse()->getBody(), true);
|
||||
|
||||
foreach ($table->getHash() as $row) {
|
||||
if (empty($this->searchKeyValueInArray($responseJson, $row["key"], $row["value"]))){
|
||||
Assert::assertFalse($row["value"], ($row["value"] . ' not found'));
|
||||
$responseJson = json_decode($this->featureContext->getResponse()->getBody(), true);
|
||||
$segments = explode("@@@", $row["key"]);
|
||||
foreach ($segments as $segment) {
|
||||
$arrayKeyExists = array_key_exists($segment, $responseJson);
|
||||
if ($arrayKeyExists) {
|
||||
$responseJson = $responseJson[$segment];
|
||||
}
|
||||
else {
|
||||
foreach($responseJson as $firstLevelArray) {
|
||||
if (array_key_exists($segment, $firstLevelArray)){
|
||||
$responseJson = $firstLevelArray[$segment];
|
||||
} else {
|
||||
foreach($firstLevelArray as $secondLevelArray) {
|
||||
if (array_key_exists($segment, $secondLevelArray)){
|
||||
$responseJson = $secondLevelArray[$segment];
|
||||
}
|
||||
else {
|
||||
$key = $row["key"];
|
||||
Assert::assertTrue(array_key_exists($segment, $secondLevelArray), "The key $key does not exist on the response");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Assert::assertEquals($row["value"], $responseJson);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method search for a match $key->$value
|
||||
*
|
||||
* @param array $array
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @return array $results
|
||||
*/
|
||||
public function searchKeyValueInArray($array, $key, $value)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
if (is_array($array)) {
|
||||
if (isset($array[$key]) && $array[$key] == $value) {
|
||||
$results[] = $array;
|
||||
}
|
||||
|
||||
foreach ($array as $subarray) {
|
||||
$results = array_merge($results, $this->searchKeyValueInArray($subarray, $key, $value));
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $shouldOrNot (not|)
|
||||
@@ -571,7 +568,7 @@ class SpacesContext implements Context {
|
||||
* @return void
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function theUserCreatesAFolderUsingTheGraphApi($user, $folder, $spaceName): void
|
||||
public function theUserCreatesAFolderUsingTheWebDavApi($user, $folder, $spaceName): void
|
||||
{
|
||||
$this->featureContext->setResponse(
|
||||
$this->sendCreateFolderRequest(
|
||||
@@ -587,7 +584,7 @@ class SpacesContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send Graph Create Space Request
|
||||
* Send Webdav Create Folder Request
|
||||
*
|
||||
* @param $baseUrl
|
||||
* @param $user
|
||||
|
||||
Reference in New Issue
Block a user