Skip to content

Commit

Permalink
Add tests related to different user role manipulating space
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed Mar 20, 2023
1 parent 1443949 commit 31f6bf1
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,8 @@ The expected failures in this file are from features in the owncloud/ocis repo.
#### [Try to add group to a group return 204](https://github.com/owncloud/ocis/issues/5793)
- [apiGraph/addUserToGroup.feature:244](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L244)

#### [Admin user can't restore other user spaces](https://github.com/owncloud/ocis/issues/5872)
- [apiSpaces/restoreSpaces.feature:87](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/restoreSpaces.feature#L87)

Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.
154 changes: 154 additions & 0 deletions tests/acceptance/features/apiSpaces/createSpace.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
@api
Feature: create space
Only user with admin and SpaceAdmin permissions can create new spaces

Background:
Given user "Alice" has been created with default attributes and without skeleton files


Scenario Outline: The user without permissions to create space cannot create a Space via Graph API
Given the administrator has given "Alice" the role "<role>" using the settings api
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 "401"
And the user "Alice" should not have a space called "share space"
Examples:
| role |
| User |
| Guest |


Scenario Outline: An admin or space admin user can create a Space via the Graph API with default quota
Given the administrator has given "Alice" the role "<role>" using the settings api
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 response should contain space called "Project Mars" and match
"""
{
"type": "object",
"required": [
"driveType",
"driveAlias",
"name",
"id",
"quota",
"root",
"webUrl"
],
"properties": {
"name": {
"type": "string",
"enum": ["Project Mars"]
},
"driveType": {
"type": "string",
"enum": ["project"]
},
"driveAlias": {
"type": "string",
"enum": ["project/project-mars"]
},
"id": {
"type": "string",
"enum": ["%space_id%"]
},
"quota": {
"type": "object",
"required": [
"total"
],
"properties": {
"state": {
"type": "number",
"enum": [1000000000]
}
}
},
"root": {
"type": "object",
"required": [
"webDavUrl"
],
"properties": {
"webDavUrl": {
"type": "string",
"enum": ["%base_url%/dav/spaces/%space_id%"]
}
}
},
"webUrl": {
"type": "string",
"enum": ["%base_url%/f/%space_id%"]
}
}
}
"""
Examples:
| role |
| Admin |
| Space Admin |


Scenario Outline: An admin or space admin user can create a Space via the Graph API with certain quota
Given the administrator has given "Alice" the role "<role>" using the settings api
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 response should contain space called "Project Venus" and match
"""
{
"type": "object",
"required": [
"driveType",
"name",
"id",
"quota",
"root",
"webUrl"
],
"properties": {
"name": {
"type": "string",
"enum": ["Project Venus"]
},
"driveType": {
"type": "string",
"enum": ["project"]
},
"id": {
"type": "string",
"enum": ["%space_id%"]
},
"quota": {
"type": "object",
"required": [
"total"
],
"properties": {
"state": {
"type": "number",
"enum": [2000]
}
}
},
"root": {
"type": "object",
"required": [
"webDavUrl"
],
"properties": {
"webDavUrl": {
"type": "string",
"enum": ["%base_url%/dav/spaces/%space_id%"]
}
}
},
"webUrl": {
"type": "string",
"enum": ["%base_url%/f/%space_id%"]
}
}
}
"""
Examples:
| role |
| Admin |
| Space Admin |
142 changes: 123 additions & 19 deletions tests/acceptance/features/apiSpaces/deleteSpaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Feature: Disabling and deleting space
| Alice |
| Brian |
| Bob |
| Carol |
And the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "Project Moon" with the default quota using the GraphApi
And user "Alice" has shared a space "Project Moon" with settings:
Expand All @@ -23,7 +24,8 @@ Feature: Disabling and deleting space
| role | viewer |


Scenario Outline: A space admin user can disable a Space via the Graph API
Scenario Outline: user can disable their own Space via the Graph API
Given the administrator has given "Alice" the role "<role>" using the settings api
When user "Alice" disables a space "Project Moon"
Then the HTTP status code should be "204"
And for user "Alice" the JSON response should contain space called "Project Moon" and match
Expand Down Expand Up @@ -62,17 +64,36 @@ Feature: Disabling and deleting space
}
}
"""
And the user "<user>" should not have a space called "Project Moon"
And the user "Brian" should not have a space called "Project Moon"
And the user "Bob" should not have a space called "Project Moon"
Examples:
| user |
| Brian |
| Bob |
| role |
| Admin |
| Space Admin |
| User |
| Guest |


Scenario Outline: An user without space admin role cannot disable a Space via the Graph API
When user "<user>" disables a space "Project Moon"
Scenario Outline: User with role User and Guest cannot disable others Space via the Graph API
Given the administrator has given "Carol" the role "<role>" using the settings api
When user "Carol" tries to disable a space "Project Moon" owned by user "Alice"
Then the HTTP status code should be "403"
And for user "<user>" the JSON response should contain space called "Project Moon" and match
And for user "Brian" the JSON response should contain space called "Project Moon" and match
"""
{
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"enum": ["Project Moon"]
}
}
}
"""
And for user "Bob" the JSON response should contain space called "Project Moon" and match
"""
{
"type": "object",
Expand All @@ -88,16 +109,9 @@ Feature: Disabling and deleting space
}
"""
Examples:
| user |
| Brian |
| Bob |


Scenario: A space manager can delete a disabled Space via the webDav API
Given user "Alice" has disabled a space "Project Moon"
When user "Alice" deletes a space "Project Moon"
Then the HTTP status code should be "204"
And the user "Alice" should not have a space called "Project Moon"
| role |
| User |
| Guest |


Scenario: An space manager can disable and delete Space in which files and folders exist via the webDav API
Expand All @@ -110,7 +124,8 @@ Feature: Disabling and deleting space
And the user "Alice" should not have a space called "Project Moon"


Scenario: An space manager cannot delete a space via the webDav API without first disabling it
Scenario Outline: user cannot delete their own space without first disabling it
Given the administrator has given "Alice" the role "<role>" using the settings api
When user "Alice" deletes a space "Project Moon"
Then the HTTP status code should be "400"
And for user "Alice" the JSON response should contain space called "Project Moon" and match
Expand All @@ -128,3 +143,92 @@ Feature: Disabling and deleting space
}
}
"""
Examples:
| role |
| Admin |
| Space Admin |
| User |
| Guest |


Scenario Outline: user can delete their own disabled Space via the Graph API
Given the administrator has given "Alice" the role "<role>" using the settings api
And user "Alice" has disabled a space "Project Moon"
When user "Alice" deletes a space "Project Moon"
Then the HTTP status code should be "204"
And the user "Alice" should not have a space called "Project Moon"
Examples:
| role |
| Admin |
| Space Admin |
| User |
| Guest |


Scenario Outline: Admin and Space manager can disable others Space via the Graph API
Given the administrator has given "Carol" the role "<role>" using the settings api
When user "Carol" tries to disable a space "Project Moon" owned by user "Alice"
Then the HTTP status code should be "204"
And for user "Alice" the JSON response should contain space called "Project Moon" and match
"""
{
"type": "object",
"required": [
"name",
"root"
],
"properties": {
"name": {
"type": "string",
"enum": ["Project Moon"]
},
"root": {
"type": "object",
"required": [
"deleted"
],
"properties": {
"deleted": {
"type": "object",
"required": [
"state"
],
"properties": {
"state": {
"type": "string",
"enum": ["trashed"]
}
}
}
}
}
}
}
"""
Examples:
| role |
| Admin |
| Space Admin |


Scenario Outline: Admin and Space manager can delete others disabled Space
Given the administrator has given "Carol" the role "<role>" using the settings api
And user "Alice" has disabled a space "Project Moon"
When user "Carol" tries to delete a space "Project Moon" owned by user "Alice"
Then the HTTP status code should be "204"
And the user "Alice" should not have a space called "Project Moon"
Examples:
| role |
| Admin |
| Space Admin |


Scenario Outline: User with role User and Guest cannot delete others disabled Space via the Graph API
Given the administrator has given "Carol" the role "<role>" using the settings api
And user "Alice" has disabled a space "Project Moon"
When user "Carol" tries to delete a space "Project Moon" owned by user "Alice"
Then the HTTP status code should be "403"
Examples:
| role |
| User |
| Guest |
Loading

0 comments on commit 31f6bf1

Please sign in to comment.