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

Test for speeding up CI #35434

Merged
merged 1 commit into from
Jun 18, 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
46 changes: 20 additions & 26 deletions tests/acceptance/features/apiAuthOcs/ocsDELETEAuth.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,23 @@
Feature: auth

@issue-32068
Scenario Outline: send DELETE requests to OCS endpoints as admin with wrong password
Given using OCS API version "<ocs_api_version>"
And group "group1" has been created
When the administrator sends HTTP method "DELETE" to OCS API endpoint "<endpoint>" using password "invalid"
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
| ocs_api_version |endpoint | ocs-code | http-code |
| 1 |/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 |
| 1 |/apps/files_sharing/api/v1/remote_shares/123 | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/remote_shares/123 | 997 | 401 |
| 1 |/apps/files_sharing/api/v1/shares/123 | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/shares/123 | 997 | 401 |
| 1 |/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 |
| 1 |/cloud/apps/testing | 997 | 401 |
| 2 |/cloud/apps/testing | 997 | 401 |
| 1 |/cloud/groups/group1 | 997 | 401 |
| 2 |/cloud/groups/group1 | 997 | 401 |
| 1 |/cloud/users/user0 | 997 | 401 |
| 2 |/cloud/users/user0 | 997 | 401 |
| 1 |/cloud/users/user0/groups | 997 | 401 |
| 2 |/cloud/users/user0/groups | 997 | 401 |
| 1 |/cloud/users/user0/subadmins | 997 | 401 |
| 2 |/cloud/users/user0/subadmins | 997 | 401 |
Scenario: send DELETE requests to OCS endpoints as admin with wrong password
When the administrator requests these endpoints with "DELETE" using password "invalid" then the status codes should be as listed
| endpoint | ocs-code | http-code |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/123 | 997 | 401 |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/123 | 997 | 401 |
| /ocs/v2.php/apps/files_sharing/api/v1/shares/123 | 997 | 401 |
| /ocs/v1.php/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 |
| /ocs/v2.php/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 |
| /ocs/v1.php/cloud/apps/testing | 997 | 401 |
| /ocs/v2.php/cloud/apps/testing | 997 | 401 |
| /ocs/v1.php/cloud/groups/group1 | 997 | 401 |
| /ocs/v2.php/cloud/groups/group1 | 997 | 401 |
| /ocs/v1.php/cloud/users/user0 | 997 | 401 |
| /ocs/v2.php/cloud/users/user0 | 997 | 401 |
| /ocs/v1.php/cloud/users/user0/groups | 997 | 401 |
| /ocs/v2.php/cloud/users/user0/groups | 997 | 401 |
| /ocs/v1.php/cloud/users/user0/subadmins | 997 | 401 |
| /ocs/v2.php/cloud/users/user0/subadmins | 997 | 401 |
58 changes: 25 additions & 33 deletions tests/acceptance/features/apiAuthOcs/ocsPOSTAuth.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,28 @@ Feature: auth
Background:
Given user "user0" has been created with default attributes and skeleton files

@issue-32068
Scenario Outline: send POST requests to OCS endpoints as normal user with wrong password
Given using OCS API version "<ocs_api_version>"
And user "user1" has been created with default attributes and skeleton files
When user "user0" sends HTTP method "POST" to OCS API endpoint "<endpoint>" with body using password "invalid"
| data | doesnotmatter |
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
| ocs_api_version |endpoint | ocs-code | http-code |
| 1 |/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 |
| 1 |/apps/files_sharing/api/v1/shares | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/shares | 997 | 401 |
| 1 |/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 |
| 1 |/cloud/apps/testing | 997 | 401 |
| 2 |/cloud/apps/testing | 997 | 401 |
| 1 |/cloud/groups | 997 | 401 |
| 2 |/cloud/groups | 997 | 401 |
| 1 |/cloud/users | 997 | 401 |
| 2 |/cloud/users | 997 | 401 |
| 1 |/cloud/users/user0/groups | 997 | 401 |
| 2 |/cloud/users/user0/groups | 997 | 401 |
| 1 |/cloud/users/user0/subadmins | 997 | 401 |
| 2 |/cloud/users/user0/subadmins | 997 | 401 |
| 1 |/person/check | 101 | 200 |
| 2 |/person/check | 400 | 400 |
| 1 |/privatedata/deleteattribute/testing/test | 997 | 401 |
| 2 |/privatedata/deleteattribute/testing/test | 997 | 401 |
| 1 |/privatedata/setattribute/testing/test | 997 | 401 |
| 2 |/privatedata/setattribute/testing/test | 997 | 401 |

Scenario: send POST requests to OCS endpoints as normal user with wrong password
When user "user0" requests these endpoints with "POST" including body using password "invalid" then the status codes should be as listed
| endpoint | ocs-code | http-code | body |
| /ocs/v1.php/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 | doesnotmatter |
| /ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/123 | 997 | 401 | doesnotmatter |
| /ocs/v1.php/apps/files_sharing/api/v1/shares | 997 | 401 | doesnotmatter |
| /ocs/v2.php/apps/files_sharing/api/v1/shares | 997 | 401 | doesnotmatter |
| /ocs/v1.php/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 | doesnotmatter |
| /ocs/v2.php/apps/files_sharing/api/v1/shares/pending/123 | 997 | 401 | doesnotmatter |
| /ocs/v1.php/cloud/apps/testing | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/apps/testing | 997 | 401 | doesnotmatter |
| /ocs/v1.php/cloud/groups | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/groups | 997 | 401 | doesnotmatter |
| /ocs/v1.php/cloud/users | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/users | 997 | 401 | doesnotmatter |
| /ocs/v1.php/cloud/users/user0/groups | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/users/user0/groups | 997 | 401 | doesnotmatter |
| /ocs/v1.php/cloud/users/user0/subadmins | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/users/user0/subadmins | 997 | 401 | doesnotmatter |
| /ocs/v1.php/person/check | 101 | 200 | doesnotmatter |
| /ocs/v2.php/person/check | 400 | 400 | doesnotmatter |
| /ocs/v1.php/privatedata/deleteattribute/testing/test | 997 | 401 | doesnotmatter |
| /ocs/v2.php/privatedata/deleteattribute/testing/test | 997 | 401 | doesnotmatter |
| /ocs/v1.php/privatedata/setattribute/testing/test | 997 | 401 | doesnotmatter |
| /ocs/v2.php/privatedata/setattribute/testing/test | 997 | 401 | doesnotmatter |
31 changes: 12 additions & 19 deletions tests/acceptance/features/apiAuthOcs/ocsPUTAuth.feature
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
@api @TestAlsoOnExternalUserBackend
Feature: auth

@issue-32068
Scenario Outline: send PUT requests to OCS endpoints as admin with wrong password
Given using OCS API version "<ocs_api_version>"
When the administrator sends HTTP method "PUT" to OCS API endpoint "<endpoint>" with body using password "invalid"
| data | doesnotmatter |
Then the OCS status code should be "<ocs-code>"
And the HTTP status code should be "<http-code>"
Examples:
| ocs_api_version |endpoint | ocs-code | http-code |
| 1 |/cloud/users/user0 | 997 | 401 |
| 2 |/cloud/users/user0 | 997 | 401 |
| 1 |/cloud/users/user0/disable | 997 | 401 |
| 2 |/cloud/users/user0/disable | 997 | 401 |
| 1 |/cloud/users/user0/enable | 997 | 401 |
| 2 |/cloud/users/user0/enable | 997 | 401 |
| 1 |/apps/files_sharing/api/v1/shares/123 | 997 | 401 |
| 2 |/apps/files_sharing/api/v1/shares/123 | 997 | 401 |


Scenario: send PUT request to OCS endpoints as admin with wrong password
When the administrator requests these endpoints with "PUT" with body using password "invalid" then the status codes should be as listed
| endpoint | ocs-code | http-code | body |
| /ocs/v1.php/cloud/users/user0 | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/users/user0 | 997 | 401 | doesnotmatter |
| /ocs/v1.php/cloud/users/user0/disable | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/users/user0/disable | 997 | 401 | doesnotmatter |
| /ocs/v1.php/cloud/users/user0/enable | 997 | 401 | doesnotmatter |
| /ocs/v2.php/cloud/users/user0/enable | 997 | 401 | doesnotmatter |
| /ocs/v1.php/apps/files_sharing/api/v1/shares/123 | 997 | 401 | doesnotmatter |
| /ocs/v2.php/apps/files_sharing/api/v1/shares/123 | 997 | 401 | doesnotmatter |
22 changes: 16 additions & 6 deletions tests/acceptance/features/bootstrap/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,17 @@ public function adminRequestsEndpoint($method, TableNode $table) {
*
* @return void
*/
public function adminRequestsEndpointsWithPassword($method, $password, TableNode $table) {
public function adminRequestsEndpointsWithPassword(
$method,
$password,
TableNode $table
) {
foreach ($table->getHash() as $row) {
$this->administratorRequestsURLWithUsingBasicAuth($row['endpoint'], $method, $password);
$this->administratorRequestsURLWithUsingBasicAuth(
$row['endpoint'],
$method,
$password
);
$this->verifyStatusCode($row['ocs-code'], $row['http-code'], $row['endpoint']);
}
}
Expand Down Expand Up @@ -241,11 +249,12 @@ public function userRequestsEndpointsUsingTheGeneratedAppPassword($method, Table
* @param string $method
* @param string|null $authHeader
* @param bool $useCookies
* @param string $body
*
* @return void
*/
public function sendRequest(
$url, $method, $authHeader = null, $useCookies = false
$url, $method, $authHeader = null, $useCookies = false, $body = null
) {
// reset responseXml
$this->responseXml = '';
Expand All @@ -266,7 +275,7 @@ public function sendRequest(
$headers['requesttoken'] = $this->requestToken;
}
$this->response = HttpRequestHelper::sendRequest(
$fullUrl, $method, null, null, $headers, null, null, $cookies
$fullUrl, $method, null, null, $headers, $body, null, $cookies
);
}

Expand Down Expand Up @@ -346,17 +355,18 @@ public function aNewClientTokenForTheAdministratorHasBeenGenerated() {
* @param string $url
* @param string $method
* @param string $password
* @param string $body
*
* @return void
*/
public function userRequestsURLWithUsingBasicAuth($user, $url, $method, $password=null) {
public function userRequestsURLWithUsingBasicAuth($user, $url, $method, $password=null, $body=null) {
if ($password === null) {
$authString = "$user:" . $this->getPasswordForUser($user);
} else {
$authString = $password;
}
$this->sendRequest(
$url, $method, 'basic ' . \base64_encode($authString)
$url, $method, 'basic ' . \base64_encode($authString), false, $body
);
}

Expand Down
47 changes: 46 additions & 1 deletion tests/acceptance/features/bootstrap/OCSContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public function userSendsToOcsApiEndpoint($user, $verb, $url, $password = null)
public function userSendsHTTPMethodToOcsApiEndpointWithBody(
$user, $verb, $url, $body = null, $password = null
) {

/**
* array of the data to be sent in the body.
* contains $body data converted to an array
Expand Down Expand Up @@ -275,6 +274,29 @@ public function theAdministratorSendsHttpMethodToOcsApiWithBodyAndPassword(
);
}

/**
* @When the administrator requests these endpoints with :method with body using password :password then the status codes should be as listed
*
* @param string $method
* @param string $password
* @param TableNode $table
*
* @return void
*/
public function administratorSendsRequestToTheseEndpointsWithPassword(
$method,
$password,
TableNode $table
) {
$admin = $this->featureContext->getAdminUsername();
$this->userSendsRequestToTheseEndpointsWithBodyUsingPassword(
$admin,
$method,
$password,
$table
);
}

/**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to OCS API endpoint "([^"]*)" with body using password "([^"]*)"$/
*
Expand All @@ -294,6 +316,29 @@ public function userSendsHTTPMethodToOcsApiEndpointWithBodyAndPassword(
);
}

/**
* @When user :user requests these endpoints with :method including body using password :password then the status codes should be as listed
*
* @param string $user
* @param string $method
* @param string $password
* @param TableNode $table
*
* @return void
*/
public function userSendsRequestToTheseEndpointsWithBodyUsingPassword($user, $method, $password, TableNode $table) {
foreach ($table->getHash() as $row) {
$this->featureContext->userRequestsURLWithUsingBasicAuth(
$user,
$row['endpoint'],
$method,
$password,
$row['body']
);
$this->featureContext->verifyStatusCode($row['ocs-code'], $row['http-code'], $row['endpoint']);
}
}

/**
* @Then /^the OCS status code should be "([^"]*)"$/
*
Expand Down