Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApiTests. refactoring apiSpace suite #4121

Merged
merged 3 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
297 changes: 178 additions & 119 deletions tests/acceptance/features/apiSpaces/changeSpaces.feature

Large diffs are not rendered by default.

108 changes: 43 additions & 65 deletions tests/acceptance/features/apiSpaces/deleteSpaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Disabling and deleting space
As a manager of space
I want to be able to disable the space first, then delete it.
I want to make sure that a disabled spaces isn't accessible by shared users.
I want to make sure that a disabled spaces isn't accessible by shared users.

Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production
See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839
Expand All @@ -13,80 +13,58 @@ Feature: Disabling and deleting space
| Alice |
| Brian |
| Bob |
And the administrator has given "Alice" the role "Admin" using the settings api
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" to user "Brian" with role "editor"
And user "Alice" has shared a space "Project Moon" to user "Bob" with role "viewer"


Scenario: An owner can disable a Space via the Graph API
Given user "Alice" has created a space "disable a space" of type "project" with quota "10"
And user "Alice" has shared a space "disable a space" to user "Brian" with role "editor"
When user "Alice" disables a space "disable a space"
Scenario Outline: A space admin user can disable a Space via the Graph API
When user "Alice" disables a space "Project Moon"
Then the HTTP status code should be "204"
When user "Alice" lists all available spaces via the GraphApi
Then the json responded should contain a space "disable a space" with these key and value pairs:
| key | value |
| name | disable a space |
| root@@@deleted@@@state | trashed |

And the user "Alice" should have a space called "Project Moon" with these key and value pairs:
| key | value |
| name | Project Moon |
| root@@@deleted@@@state | trashed |
And the user "<user>" should not have a space called "Project Moon"
Examples:
| user |
| Brian |
| Bob |

Scenario: Participants without a manager role cannot see the disabled space
Given user "Alice" has created a space "cannot see space" of type "project" with quota "10"
And user "Alice" has shared a space "cannot see space" to user "Brian" with role "editor"
And user "Alice" has shared a space "cannot see space" to user "Bob" with role "viewer"
And user "Alice" has disabled a space "cannot see space"
When user "Brian" lists all available spaces via the GraphApi
Then the json responded should not contain a space with name "cannot see space"
When user "Bob" lists all available spaces via the GraphApi
Then the json responded should not contain a space with name "cannot see space"

Scenario Outline: An user without space admin role cannot disable a Space via the Graph API
When user "<user>" disables a space "Project Moon"
Then the HTTP status code should be "403"
And the user "<user>" should have a space called "Project Moon" with these key and value pairs:
| key | value |
| name | Project Moon |
Examples:
| user |
| Brian |
| Bob |


Scenario: An owner can delete a disabled Space via the webDav API
Given user "Alice" has created a space "delete a space" of type "project" with quota "10"
And user "Alice" has disabled a space "delete a space"
When user "Alice" deletes a space "delete a space"
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"
When user "Alice" lists all available spaces via the GraphApi
Then the json responded should not contain a space with name "delete a space"

And the user "Alice" should not have a space called "Project Moon"

Scenario: An owner can disable and delete Space in which files and folders exist via the webDav API
Given user "Alice" has created a space "delete a space with content" of type "project" with quota "10"
And user "Alice" has uploaded a file inside space "delete a space with content" with content "test" to "test.txt"
And user "Alice" has created a folder "MainFolder" in space "delete a space with content"
When user "Alice" disables a space "delete a space with content"

Scenario: An space manager can disable and delete Space in which files and folders exist via the webDav API
Given user "Alice" has uploaded a file inside space "Project Moon" with content "test" to "test.txt"
And user "Alice" has created a folder "MainFolder" in space "Project Moon"
When user "Alice" disables a space "Project Moon"
Then the HTTP status code should be "204"
When user "Alice" deletes a space "delete a space with content"
When user "Alice" deletes a space "Project Moon"
Then the HTTP status code should be "204"
When user "Alice" lists all available spaces via the GraphApi
Then the json responded should not contain a space with name "delete a space with content"
And the user "Alice" should not have a space called "Project Moon"


Scenario: An owner cannot delete a space via the webDav API without first disabling it
Given user "Alice" has created a space "delete without disabling" of type "project" with quota "10"
When user "Alice" deletes a space "delete without disabling"
Scenario: An space manager cannot delete a space via the webDav API without first disabling it
When user "Alice" deletes a space "Project Moon"
Then the HTTP status code should be "400"
When user "Alice" lists all available spaces via the GraphApi
Then the json responded should contain a space "delete without disabling" with these key and value pairs:
| key | value |
| name | delete without disabling |


Scenario: An user with editor role cannot disable a Space via the Graph API
Given user "Alice" has created a space "editor tries to disable a space" of type "project" with quota "10"
And user "Alice" has shared a space "editor tries to disable a space" to user "Brian" with role "editor"
When user "Brian" disables a space "editor tries to disable a space"
Then the HTTP status code should be "403"
When user "Brian" lists all available spaces via the GraphApi
Then the json responded should contain a space "editor tries to disable a space" with these key and value pairs:
| key | value |
| name | editor tries to disable a space |


Scenario: An user with viewer role cannot disable a Space via the Graph API
Given user "Alice" has created a space "viewer tries to disable a space" of type "project" with quota "10"
And user "Alice" has shared a space "viewer tries to disable a space" to user "Brian" with role "viewer"
When user "Brian" disables a space "viewer tries to disable a space"
Then the HTTP status code should be "403"
When user "Brian" lists all available spaces via the GraphApi
Then the json responded should contain a space "viewer tries to disable a space" with these key and value pairs:
| key | value |
| name | viewer tries to disable a space |
And the user "Alice" should have a space called "Project Moon" with these key and value pairs:
| key | value |
| name | Project Moon |
27 changes: 20 additions & 7 deletions tests/acceptance/features/apiSpaces/download.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@api @skipOnOcV10
Feature: Download file in project space
As a user, I want to be able to download files
As a user with different role, I want to be able to download files

Note - this feature is run in CI with ACCOUNTS_HASH_DIFFICULTY set to the default for production
See https://github.com/owncloud/ocis/issues/1542 and https://github.com/owncloud/ocis/pull/839
Expand All @@ -10,29 +10,42 @@ Feature: Download file in project space
| username |
| Alice |
| Brian |
And the administrator has given "Alice" the role "Admin" using the settings api
| Bob |
And the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "download file" with the default quota using the GraphApi
And user "Alice" has uploaded a file inside space "download file" with content "some content" to "file.txt"
And user "Alice" has shared a space "download file" to user "Brian" with role "editor"
And user "Alice" has shared a space "download file" to user "Bob" with role "viewer"


Scenario: An user downloads a file in the project space
When user "Alice" downloads the file "file.txt" of the space "download file" using the WebDAV API
Scenario Outline: An user downloads a file in the project space
When user "<user>" downloads the file "file.txt" of the space "download file" using the WebDAV API
Then the HTTP status code should be "200"
And the following headers should be set
| header | value |
| Content-Length | 12 |
Examples:
| user |
| Alice |
| Brian |
| Bob |


Scenario: An user downloads an old version of the file in the project space
Scenario Outline: An user downloads an old version of the file in the project space
Given user "Alice" has uploaded a file inside space "download file" with content "new content" to "file.txt"
And user "Alice" has uploaded a file inside space "download file" with content "newest content" to "file.txt"
When user "Alice" downloads version of the file "file.txt" with the index "1" of the space "download file" using the WebDAV API
When user "<user>" downloads version of the file "file.txt" with the index "1" of the space "download file" using the WebDAV API
Then the HTTP status code should be "200"
And the following headers should be set
| header | value |
| Content-Length | 11 |
When user "Alice" downloads version of the file "file.txt" with the index "2" of the space "download file" using the WebDAV API
When user "<user>" downloads version of the file "file.txt" with the index "2" of the space "download file" using the WebDAV API
Then the HTTP status code should be "200"
And the following headers should be set
| header | value |
| Content-Length | 12 |
Examples:
| user |
| Alice |
| Brian |
| Bob |
3 changes: 1 addition & 2 deletions tests/acceptance/features/apiSpaces/filePreviews.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ Feature: Preview file in project space
Given these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
And the administrator has given "Alice" the role "Admin" using the settings api
And the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "previews of the files" with the default quota using the GraphApi


Expand Down
48 changes: 36 additions & 12 deletions tests/acceptance/features/apiSpaces/listSpaces.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,67 @@ Feature: List and create spaces
Background:
Given user "Alice" has been created with default attributes and without skeleton files


Scenario: An ordinary user can request information about their Space via the Graph API
When user "Alice" lists all available spaces via the GraphApi
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 |
| driveAlias | personal/alice |
| id | %space_id% |
| name | Alice Hansen |
| quota@@@state | normal |
| key | value |
| driveType | personal |
| driveAlias | personal/alice |
| id | %space_id% |
| name | Alice Hansen |
| quota@@@state | normal |
| 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
Given user "Brian" has been created with default attributes and without skeleton files
And user "Brian" has created folder "folder"
And user "Brian" has shared folder "folder" with user "Alice" with permissions "31"
And user "Alice" has accepted share "/folder" offered by user "Brian"
Then the user "Alice" should have a space called "Shares Jail" with these key and value pairs:
| key | value |
| driveType | virtual |
| id | %space_id% |
| name | Shares Jail |
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 |
| 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 only contain spaces of type "personal"


Scenario: An ordinary user will not see any space when using a filter for project
Given the administrator has given "Alice" the role "Space Admin" using the settings api
And user "Alice" has created a space "my project" of type "project" with quota "20"
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 contain a space "my project" with these key and value pairs:
| key | value |
| driveType | project |
| id | %space_id% |
| name | my project |
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
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: An ordinary user cannot create a Space via Graph 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"


Scenario: An admin user can create a Space via the Graph API with default quota
Given the administrator has given "Alice" the role "Admin" using the settings api
When user "Alice" creates a space "Project Mars" of type "project" with the default quota using the GraphApi
Expand All @@ -61,6 +82,7 @@ Feature: List and create spaces
| quota@@@total | 1000000000 |
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |


Scenario: An admin user can create a Space via the Graph API with certain quota
Given the administrator has given "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
Expand All @@ -72,6 +94,7 @@ Feature: List and create spaces
| quota@@@total | 2000 |
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |


Scenario: A user can list his personal space via multiple endpoints
When user "Alice" lists all available spaces via the GraphApi with query "$filter=driveType eq 'personal'"
Then the json responded should contain a space "Alice Hansen" owned by "Alice" with these key and value pairs:
Expand All @@ -87,6 +110,7 @@ Feature: List and create spaces
| name | Alice Hansen |
| root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |


Scenario: A user can list his created spaces via multiple endpoints
Given the administrator has given "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
Expand Down
7 changes: 3 additions & 4 deletions tests/acceptance/features/apiSpaces/quota.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ Feature: State of the quota

Background:
Given user "Alice" has been created with default attributes and without skeleton files
And the administrator has given "Alice" the role "Admin" using the settings api
And the administrator has given "Alice" the role "Space Admin" using the settings api


Scenario Outline: Quota information is returned in the list of spaces returned via the Graph API
Given user "Alice" has created a space "<spaceName>" of type "project" with quota "<total>"
And user "Alice" has uploaded a file inside space "<spaceName>" with content "<fileContent>" to "test.txt"
When user "Alice" lists all available spaces via the GraphApi
Then the json responded should contain a space "<spaceName>" with these key and value pairs:
When user "Alice" uploads a file inside space "<spaceName>" with content "<fileContent>" to "test.txt" using the WebDAV API
Then the user "Alice" should have a space called "<spaceName>" with these key and value pairs:
| key | value |
| name | <spaceName> |
| quota@@@state | <state> |
Expand Down
Loading