diff --git a/tests/TestHelpers/GraphHelper.php b/tests/TestHelpers/GraphHelper.php index 2bebc45bb7..8ea3c03b76 100644 --- a/tests/TestHelpers/GraphHelper.php +++ b/tests/TestHelpers/GraphHelper.php @@ -54,6 +54,13 @@ class GraphHelper { return (bool)preg_match($regex, $spaceId); } + /** + * @return string + */ + public static function getSpaceIdRegex(): string { + return self::getUUIDv4Regex() . '\\\$' . self::getUUIDv4Regex(); + } + /** * Key name can consist of @@@ * This function separate such key and return its actual value from actual drive response which can be used for assertion diff --git a/tests/acceptance/features/apiSpacesShares/shareSpaces.feature b/tests/acceptance/features/apiSpacesShares/shareSpaces.feature index a7c9284388..6ec32d273f 100644 --- a/tests/acceptance/features/apiSpacesShares/shareSpaces.feature +++ b/tests/acceptance/features/apiSpacesShares/shareSpaces.feature @@ -24,11 +24,31 @@ Feature: Share spaces 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 user "Brian" should have a space called "share space" with these key and value pairs: - | key | value | - | driveType | project | - | id | %space_id% | - | name | share space | + And for user "Brian" the JSON response should contain space called "share space" and match + """ + { + "type": "object", + "required": [ + "name", + "driveType", + "id" + ], + "properties": { + "name": { + "type": "string", + "enum": ["share space"] + }, + "driveType": { + "type": "string", + "enum": ["project"] + }, + "id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + } + } + } + """ Examples: | role | | manager | @@ -69,14 +89,34 @@ Feature: Share spaces Given user "Alice" has shared a space "share space" with settings: | shareWith | Brian | | role | viewer | - And the user "Brian" should have a space called "share space" with these key and value pairs: - | key | value | - | driveType | project | - | id | %space_id% | - | name | share space | + And for user "Brian" the JSON response should contain space called "share space" and match + """ + { + "type": "object", + "required": [ + "name", + "driveType", + "id" + ], + "properties": { + "name": { + "type": "string", + "enum": ["share space"] + }, + "driveType": { + "type": "string", + "enum": ["project"] + }, + "id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + } + } + } + """ When user "Alice" unshares a space "share space" to user "Brian" Then the HTTP status code should be "200" - And the user "Brian" should not have a space called "share space" + But the user "Brian" should not have a space called "share space" Scenario Outline: Owner of a space cannot see the space after removing his access to the space @@ -85,11 +125,31 @@ Feature: Share spaces | role | manager | When user "" unshares a space "share space" to user "Alice" Then the HTTP status code should be "200" - And the user "Brian" should have a space called "share space" owned by "Alice" with these key and value pairs: - | key | value | - | driveType | project | - | id | %space_id% | - | name | share space | + And for user "Brian" the JSON response should contain space called "share space" owned by "Alice" and match + """ + { + "type": "object", + "required": [ + "name", + "driveType", + "id" + ], + "properties": { + "name": { + "type": "string", + "enum": ["share space"] + }, + "driveType": { + "type": "string", + "enum": ["project"] + }, + "id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + } + } + } + """ But the user "Alice" should not have a space called "share space" Examples: | user | @@ -119,7 +179,7 @@ Feature: Share spaces Then the HTTP status code should be "404" And the OCS status code should be "404" And the OCS status message should be "Wrong path, file/folder doesn't exist" - And the user "Brian" should not have a space called "share space" + But the user "Brian" should not have a space called "share space" Examples: | role | | manager | @@ -137,11 +197,31 @@ Feature: Share spaces 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 user "Bob" should have a space called "share space" with these key and value pairs: - | key | value | - | driveType | project | - | id | %space_id% | - | name | share space | + And for user "Brian" the JSON response should contain space called "share space" and match + """ + { + "type": "object", + "required": [ + "name", + "driveType", + "id" + ], + "properties": { + "name": { + "type": "string", + "enum": ["share space"] + }, + "driveType": { + "type": "string", + "enum": ["project"] + }, + "id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + } + } + } + """ Examples: | role | | manager | @@ -220,14 +300,56 @@ Feature: Share spaces | shareType | 8 | | role | | Then the HTTP status code should be "200" - And the user "Brian" should have a space called "share space" with these key and value pairs: - | key | value | - | driveType | project | - | name | share space | - And the user "Bob" should have a space called "share space" with these key and value pairs: - | key | value | - | driveType | project | - | name | share space | + And for user "Brian" the JSON response should contain space called "share space" and match + """ + { + "type": "object", + "required": [ + "name", + "driveType", + "id" + ], + "properties": { + "name": { + "type": "string", + "enum": ["share space"] + }, + "driveType": { + "type": "string", + "enum": ["project"] + }, + "id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + } + } + } + """ + And for user "Bob" the JSON response should contain space called "share space" and match + """ + { + "type": "object", + "required": [ + "name", + "driveType", + "id" + ], + "properties": { + "name": { + "type": "string", + "enum": ["share space"] + }, + "driveType": { + "type": "string", + "enum": ["project"] + }, + "id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + } + } + } + """ Examples: | role | | manager | @@ -265,10 +387,31 @@ Feature: Share spaces | Brian | group2 | Then the HTTP status code of responses on all endpoints should be "204" And the user "Brian" should not have a space called "share space" - But the user "Bob" should have a space called "share space" with these key and value pairs: - | key | value | - | driveType | project | - | name | share space | + But for user "Bob" the JSON response should contain space called "share space" and match + """ + { + "type": "object", + "required": [ + "name", + "driveType", + "id" + ], + "properties": { + "name": { + "type": "string", + "enum": ["share space"] + }, + "driveType": { + "type": "string", + "enum": ["project"] + }, + "id": { + "type": "string", + "pattern": "^%space_id_pattern%$" + } + } + } + """ @skipOnStable2.0 Scenario: Users don't have access to the space if the group has been deleted @@ -281,8 +424,8 @@ Feature: Share spaces | role | editor | When the administrator deletes group "group2" using the Graph API Then the HTTP status code should be "204" - And the user "Brian" should not have a space called "share space" And the user "Bob" should not have a space called "share space" + And the user "Brian" should not have a space called "share space" @skipOnStable2.0 Scenario: User increases permissions for one member of the group or for the entire group diff --git a/tests/acceptance/features/bootstrap/FeatureContext.php b/tests/acceptance/features/bootstrap/FeatureContext.php index f2b8e19544..a47f807737 100644 --- a/tests/acceptance/features/bootstrap/FeatureContext.php +++ b/tests/acceptance/features/bootstrap/FeatureContext.php @@ -3135,6 +3135,14 @@ class FeatureContext extends BehatVariablesContext { ], "parameter" => [] ], + [ + "code" => "%space_id_pattern%", + "function" => [ + __NAMESPACE__ . '\TestHelpers\GraphHelper', + "getSpaceIdRegex" + ], + "parameter" => [] + ], [ "code" => "%user_id%", "function" => [ diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index 7c87b50335..386b68cfcf 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1105,6 +1105,7 @@ class SpacesContext implements Context { /** * @Then /^for user "([^"]*)" the JSON response of space project should match$/ * @Then /^for user "([^"]*)" the JSON response should contain space called "([^"]*)" and match$/ + * @Then /^for user "([^"]*)" the JSON response should contain space called "([^"]*)" (?:owned by|granted to) "([^"]*)" and match$/ * @Then /^for user "([^"]*)" the JSON response should contain space called "([^"]*)" (?:owned by|granted to) "([^"]*)" (?:with description file|with space image) "([^"]*)" and match$/ * * @param string $user