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

[stable10] test authentication on more ocs endpoints #34629

Merged
merged 2 commits into from
Feb 27, 2019
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
188 changes: 164 additions & 24 deletions tests/acceptance/features/apiMain/auth.feature
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,170 @@ Feature: auth


# OCS

Scenario: using OCS anonymously
When a user requests "/ocs/v1.php/apps/files_sharing/api/v1/remote_shares" with "GET" and no authentication
Then the OCS status code should be "997"

Scenario: using OCS with basic auth
When user "user0" requests "/ocs/v1.php/apps/files_sharing/api/v1/remote_shares" with "GET" using basic auth
Then the OCS status code should be "100"

Scenario: using OCS with token auth
When user "user0" requests "/ocs/v1.php/apps/files_sharing/api/v1/remote_shares" with "GET" using basic token auth
Then the OCS status code should be "100"

Scenario: using OCS with client token
When the user requests "/ocs/v1.php/apps/files_sharing/api/v1/remote_shares" with "GET" using the generated client token
Then the OCS status code should be "100"

Scenario: using OCS with browser session
@issue-32068
Scenario Outline: using OCS anonymously
When a user requests "<endpoint>" with "GET" and no authentication
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
|endpoint | ocs-code | http-code |
|/ocs/v1.php/apps/files_external/api/v1/mounts | 997 | 401 |
|/ocs/v2.php/apps/files_external/api/v1/mounts | 997 | 401 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares | 997 | 401 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares | 997 | 401 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending | 997 | 401 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending | 997 | 401 |
|/ocs/v1.php/apps/files_sharing/api/v1/shares | 997 | 401 |
|/ocs/v2.php/apps/files_sharing/api/v1/shares | 997 | 401 |
|/ocs/v1.php/cloud/apps | 997 | 401 |
|/ocs/v2.php/cloud/apps | 997 | 401 |
|/ocs/v1.php/cloud/groups | 997 | 401 |
|/ocs/v2.php/cloud/groups | 997 | 401 |
|/ocs/v1.php/cloud/users | 997 | 401 |
|/ocs/v2.php/cloud/users | 997 | 401 |
|/ocs/v1.php/config | 100 | 200 |
|/ocs/v2.php/config | 200 | 200 |
|/ocs/v1.php/privatedata/getattribute | 997 | 401 |
|/ocs/v2.php/privatedata/getattribute | 997 | 401 |

Scenario Outline: using OCS with non-admin basic auth
When user "user0" requests "<endpoint>" with "GET" using basic auth
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
|endpoint | ocs-code | http-code |
|/ocs/v1.php/apps/files_external/api/v1/mounts | 100 | 200 |
|/ocs/v2.php/apps/files_external/api/v1/mounts | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/shares | 200 | 200 |
|/ocs/v1.php/cloud/apps | 997 | 401 |
|/ocs/v2.php/cloud/apps | 997 | 401 |
|/ocs/v1.php/cloud/groups | 997 | 401 |
|/ocs/v2.php/cloud/groups | 997 | 401 |
|/ocs/v1.php/cloud/users | 997 | 401 |
|/ocs/v2.php/cloud/users | 997 | 401 |
|/ocs/v1.php/config | 100 | 200 |
|/ocs/v2.php/config | 200 | 200 |
|/ocs/v1.php/privatedata/getattribute | 100 | 200 |
|/ocs/v2.php/privatedata/getattribute | 200 | 200 |

Scenario Outline: using OCS with admin basic auth
When the administrator requests "<endpoint>" with "GET" using basic auth
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
|endpoint | ocs-code | http-code |
|/ocs/v1.php/cloud/apps | 100 | 200 |
|/ocs/v2.php/cloud/apps | 200 | 200 |
|/ocs/v1.php/cloud/groups | 100 | 200 |
|/ocs/v2.php/cloud/groups | 200 | 200 |
|/ocs/v1.php/cloud/users | 100 | 200 |
|/ocs/v2.php/cloud/users | 200 | 200 |


Scenario Outline: using OCS with token auth of a normal user
When user "user0" requests "<endpoint>" with "GET" using basic token auth
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
|endpoint | ocs-code | http-code |
|/ocs/v1.php/apps/files_external/api/v1/mounts | 100 | 200 |
|/ocs/v2.php/apps/files_external/api/v1/mounts | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/shares | 200 | 200 |
|/ocs/v1.php/cloud/apps | 997 | 401 |
|/ocs/v2.php/cloud/apps | 997 | 401 |
|/ocs/v1.php/cloud/groups | 997 | 401 |
|/ocs/v2.php/cloud/groups | 997 | 401 |
|/ocs/v1.php/cloud/users | 997 | 401 |
|/ocs/v2.php/cloud/users | 997 | 401 |
|/ocs/v1.php/config | 100 | 200 |
|/ocs/v2.php/config | 200 | 200 |
|/ocs/v1.php/privatedata/getattribute | 100 | 200 |
|/ocs/v2.php/privatedata/getattribute | 200 | 200 |

Scenario Outline: using OCS with client token of a normal user
When the user requests "<endpoint>" with "GET" using the generated client token
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
|endpoint | ocs-code | http-code |
|/ocs/v1.php/apps/files_external/api/v1/mounts | 100 | 200 |
|/ocs/v2.php/apps/files_external/api/v1/mounts | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/shares | 200 | 200 |
|/ocs/v1.php/cloud/apps | 997 | 401 |
|/ocs/v2.php/cloud/apps | 997 | 401 |
|/ocs/v1.php/cloud/groups | 997 | 401 |
|/ocs/v2.php/cloud/groups | 997 | 401 |
|/ocs/v1.php/cloud/users | 997 | 401 |
|/ocs/v2.php/cloud/users | 997 | 401 |
|/ocs/v1.php/config | 100 | 200 |
|/ocs/v2.php/config | 200 | 200 |
|/ocs/v1.php/privatedata/getattribute | 100 | 200 |
|/ocs/v2.php/privatedata/getattribute | 200 | 200 |

Scenario Outline: using OCS with browser session of a normal user
Given a new browser session for "user0" has been started
When the user requests "/ocs/v1.php/apps/files_sharing/api/v1/remote_shares" with "GET" using the browser session
Then the OCS status code should be "100"

Scenario: using OCS with an app password
When the user requests "<endpoint>" with "GET" using the browser session
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
|endpoint | ocs-code | http-code |
|/ocs/v1.php/apps/files_external/api/v1/mounts | 100 | 200 |
|/ocs/v2.php/apps/files_external/api/v1/mounts | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/shares | 200 | 200 |
|/ocs/v1.php/cloud/apps | 997 | 401 |
|/ocs/v2.php/cloud/apps | 997 | 401 |
|/ocs/v1.php/cloud/groups | 997 | 401 |
|/ocs/v2.php/cloud/groups | 997 | 401 |
|/ocs/v1.php/cloud/users | 997 | 401 |
|/ocs/v2.php/cloud/users | 997 | 401 |
|/ocs/v1.php/config | 100 | 200 |
|/ocs/v2.php/config | 200 | 200 |
|/ocs/v1.php/privatedata/getattribute | 100 | 200 |
|/ocs/v2.php/privatedata/getattribute | 200 | 200 |

Scenario Outline: using OCS with an app password of a normal user
Given a new browser session for "user0" has been started
And the user has generated a new app password named "my-client"
When the user requests "/ocs/v1.php/apps/files_sharing/api/v1/remote_shares" with "GET" using the generated app password
Then the HTTP status code should be "200"
When the user requests "<endpoint>" with "GET" using the generated app password
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
|endpoint | ocs-code | http-code |
|/ocs/v1.php/apps/files_external/api/v1/mounts | 100 | 200 |
|/ocs/v2.php/apps/files_external/api/v1/mounts | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending | 200 | 200 |
|/ocs/v1.php/apps/files_sharing/api/v1/shares | 100 | 200 |
|/ocs/v2.php/apps/files_sharing/api/v1/shares | 200 | 200 |
|/ocs/v1.php/cloud/apps | 997 | 401 |
|/ocs/v2.php/cloud/apps | 997 | 401 |
|/ocs/v1.php/cloud/groups | 997 | 401 |
|/ocs/v2.php/cloud/groups | 997 | 401 |
|/ocs/v1.php/cloud/users | 997 | 401 |
|/ocs/v2.php/cloud/users | 997 | 401 |
|/ocs/v1.php/config | 100 | 200 |
|/ocs/v2.php/config | 200 | 200 |
|/ocs/v1.php/privatedata/getattribute | 100 | 200 |
|/ocs/v2.php/privatedata/getattribute | 200 | 200 |
14 changes: 14 additions & 0 deletions tests/acceptance/features/bootstrap/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ public function userRequestsURLWithUsingBasicAuth($user, $url, $method) {
);
}

/**
* @When the administrator requests :url with :method using basic auth
*
* @param string $url
* @param string $method
*
* @return void
*/
public function administratorRequestsURLWithUsingBasicAuth($url, $method) {
$this->userRequestsURLWithUsingBasicAuth(
$this->getAdminUsername(), $url, $method
);
}

/**
* @When user :user requests :url with :method using basic token auth
* @Given user :user has requested :url with :method using basic token auth
Expand Down