[tests-only][full-ci]Forwardport json drill apispacesshares (#5965)

* Replace the key and value paris step with the current json assertion step

* Fix red CI for undefined step

---------

Co-authored-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
This commit is contained in:
Prajwol Amatya
2023-04-03 09:46:01 +05:45
committed by GitHub
parent 12d67440b8
commit 16f8c49de9
4 changed files with 194 additions and 35 deletions

View File

@@ -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

View File

@@ -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 "<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 | <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

View File

@@ -3135,6 +3135,14 @@ class FeatureContext extends BehatVariablesContext {
],
"parameter" => []
],
[
"code" => "%space_id_pattern%",
"function" => [
__NAMESPACE__ . '\TestHelpers\GraphHelper',
"getSpaceIdRegex"
],
"parameter" => []
],
[
"code" => "%user_id%",
"function" => [

View File

@@ -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