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

Refactor sends HTTP method to use specific methods #33676

Merged
merged 1 commit into from
Nov 30, 2018
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
12 changes: 8 additions & 4 deletions tests/TestHelpers/UserHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,17 @@ public static function deleteGroup(
* @param string $group
* @param string $adminUser
* @param string $adminPassword
* @param integer $ocsApiVersion (1|2)
*
* @return ResponseInterface
*/
public static function addUserToGroup(
$baseUrl, $user, $group, $adminUser, $adminPassword
$baseUrl, $user, $group, $adminUser, $adminPassword, $ocsApiVersion = 2
) {
return OcsApiHelper::sendRequest(
$baseUrl, $adminUser, $adminPassword, "POST",
"/cloud/users/" . $user . "/groups", ['groupid' => $group]
"/cloud/users/" . $user . "/groups", ['groupid' => $group],
$ocsApiVersion
);
}

Expand All @@ -215,15 +217,17 @@ public static function addUserToGroup(
* @param string $group
* @param string $adminUser
* @param string $adminPassword
* @param integer $ocsApiVersion (1|2)
*
* @return ResponseInterface
*/
public static function removeUserFromGroup(
$baseUrl, $user, $group, $adminUser, $adminPassword
$baseUrl, $user, $group, $adminUser, $adminPassword, $ocsApiVersion = 2
) {
return OcsApiHelper::sendRequest(
$baseUrl, $adminUser, $adminPassword, "DELETE",
"/cloud/users/" . $user . "/groups", ['groupid' => $group]
"/cloud/users/" . $user . "/groups", ['groupid' => $group],
$ocsApiVersion
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/features/apiFederation/federated.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Feature: federated

Scenario: Remote sharee can see the pending share
Given user "user0" from server "REMOTE" has shared "/textfile0.txt" with user "user1" from server "LOCAL"
When user "user1" sends HTTP method "GET" to OCS API endpoint "/apps/files_sharing/api/v1/remote_shares/pending"
When user "user1" gets the list of pending federated cloud shares using the sharing API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the fields of the last response should include
Expand Down Expand Up @@ -150,7 +150,7 @@ Feature: federated
Scenario: Trusted server handshake does not require authenticated requests - we force 403 by sending an empty body
Given using server "LOCAL"
And using OCS API version "2"
When user "UNAUTHORIZED_USER" sends HTTP method "POST" to OCS API endpoint "/apps/federation/api/v1/request-shared-secret"
When user "UNAUTHORIZED_USER" requests shared secret using the federation API
Then the HTTP status code should be "403"

Scenario: Overwrite a federated shared folder as recipient propagates etag for recipient
Expand Down
6 changes: 2 additions & 4 deletions tests/acceptance/features/apiProvisioning-v1/addGroup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ Feature: add groups

Scenario: normal user tries to create a group
Given user "brand-new-user" has been created with default attributes
When user "brand-new-user" sends HTTP method "POST" to OCS API endpoint "/cloud/groups" with body
| groupid | new-group |
When user "brand-new-user" tries to send a group creation request for group "new-group" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And group "new-group" should not exist
Expand All @@ -87,8 +86,7 @@ Feature: add groups
Given user "subadmin" has been created with default attributes
And group "new-group" has been created
And user "subadmin" has been made a subadmin of group "new-group"
When user "subadmin" sends HTTP method "POST" to OCS API endpoint "/cloud/groups" with body
| groupid | another-group |
When user "subadmin" tries to send a group creation request for group "another-group" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And group "another-group" should not exist
27 changes: 9 additions & 18 deletions tests/acceptance/features/apiProvisioning-v1/addToGroup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Feature: add users to group
Scenario Outline: adding a user to a group
Given user "brand-new-user" has been created with default attributes
And group "<group_id>" has been created
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | <group_id> |
When the administrator adds user "brand-new-user" to group "<group_id>" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
Examples:
Expand All @@ -24,8 +23,7 @@ Feature: add users to group
Scenario Outline: adding a user to a group
Given user "brand-new-user" has been created with default attributes
And group "<group_id>" has been created
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | <group_id> |
When the administrator adds user "brand-new-user" to group "<group_id>" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
Examples:
Expand All @@ -51,8 +49,7 @@ Feature: add users to group
Scenario Outline: adding a user to a group that has a forward-slash in the group name
Given user "brand-new-user" has been created with default attributes
And group "<group_id>" has been created
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | <group_id> |
When the administrator adds user "brand-new-user" to group "<group_id>" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
Examples:
Expand All @@ -64,34 +61,30 @@ Feature: add users to group

Scenario: normal user tries to add himself to a group
Given user "brand-new-user" has been created with default attributes
When user "brand-new-user" sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | new-group |
When user "brand-new-user" tries to add himself to group "new-group" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And the API should not return any data

Scenario: admin tries to add user to a group which does not exist
Given user "brand-new-user" has been created with default attributes
And group "not-group" has been deleted
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | not-group |
When the administrator tries to add user "brand-new-user" to group "not-group" using the provisioning API
Then the OCS status code should be "102"
And the HTTP status code should be "200"
And the API should not return any data

Scenario: admin tries to add user to a group without sending the group
Given user "brand-new-user" has been created with default attributes
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | |
When the administrator tries to add user "brand-new-user" to group "" using the provisioning API
Then the OCS status code should be "101"
And the HTTP status code should be "200"
And the API should not return any data

Scenario: admin tries to add a user which does not exist to a group
Given user "not-user" has been deleted
And group "new-group" has been created
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/not-user/groups" with body
| groupid | new-group |
When the administrator tries to add user "not-user" to group "new-group" using the provisioning API
Then the OCS status code should be "103"
And the HTTP status code should be "200"
And the API should not return any data
Expand All @@ -101,8 +94,7 @@ Feature: add users to group
And user "brand-new-user" has been created with default attributes
And group "new-group" has been created
And user "subadmin" has been made a subadmin of group "new-group"
When user "subadmin" sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | new-group |
When user "subadmin" tries to add user "brand-new-user" to group "new-group" using the provisioning API
Then the OCS status code should be "104"
And the HTTP status code should be "200"
And user "brand-new-user" should not belong to group "new-group"
Expand All @@ -113,8 +105,7 @@ Feature: add users to group
And group "new-group" has been created
And group "other-group" has been created
And user "other-subadmin" has been made a subadmin of group "other-group"
When user "other-subadmin" sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | new-group |
When user "other-subadmin" tries to add user "brand-new-user" to group "new-group" using the provisioning API
Then the OCS status code should be "104"
And the HTTP status code should be "200"
And user "brand-new-user" should not belong to group "new-group"
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,23 @@ Feature: create a subadmin
Scenario: admin creates a subadmin
Given user "brand-new-user" has been created with default attributes
And group "new-group" has been created
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/subadmins" with body
| groupid | new-group |
When the administrator makes user "brand-new-user" a subadmin of group "new-group" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "brand-new-user" should be a subadmin of group "new-group"

Scenario: admin tries to create a subadmin using a user which does not exist
Given user "not-user" has been deleted
And group "new-group" has been created
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/not-user/subadmins" with body
| groupid | new-group |
When the administrator makes user "not-user" a subadmin of group "new-group" using the provisioning API
Then the OCS status code should be "101"
And the HTTP status code should be "200"
And user "not-user" should not be a subadmin of group "new-group"

Scenario: admin tries to create a subadmin using a group which does not exist
Given user "brand-new-user" has been created with default attributes
And group "not-group" has been deleted
When the administrator sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/subadmins" with body
| groupid | not-group |
When the administrator makes user "brand-new-user" a subadmin of group "not-group" using the provisioning API
Then the OCS status code should be "102"
And the HTTP status code should be "200"
And the API should not return any data
Expand All @@ -40,10 +37,8 @@ Feature: create a subadmin
And user "brand-new-user" has been created with default attributes
And group "new-group" has been created
And user "subadmin" has been made a subadmin of group "new-group"
And the administrator has sent HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/groups" with body
| groupid | new-group |
When user "subadmin" sends HTTP method "POST" to OCS API endpoint "/cloud/users/brand-new-user/subadmins" with body
| groupid | new-group |
And user "brand-new-user" has been added to group "new-group"
When user "subadmin" makes user "brand-new-user" a subadmin of group "new-group" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And user "brand-new-user" should not be a subadmin of group "new-group"
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Feature: delete groups
Given user "brand-new-user" has been created with default attributes
And group "new-group" has been created
And user "brand-new-user" has been added to group "new-group"
When user "brand-new-user" sends HTTP method "DELETE" to OCS API endpoint "/cloud/groups/new-group"
When user "brand-new-user" tries to delete group "new-group" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And group "new-group" should exist
Expand All @@ -72,7 +72,7 @@ Feature: delete groups
Given user "subadmin" has been created with default attributes
And group "new-group" has been created
And user "subadmin" has been made a subadmin of group "new-group"
When user "subamin" sends HTTP method "DELETE" to OCS API endpoint "/cloud/groups/new-group"
When user "subadmin" tries to delete group "new-group" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And group "new-group" should exist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: delete users
@smokeTest
Scenario: Delete a user
Given user "brand-new-user" has been created with default attributes
When the administrator sends a user deletion request for user "brand-new-user" using the provisioning API
When the administrator deletes user "brand-new-user" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "brand-new-user" should not exist
Expand All @@ -22,15 +22,15 @@ Feature: delete users
And group "new-group" has been created
And user "brand-new-user" has been added to group "new-group"
And user "subadmin" has been made a subadmin of group "new-group"
When the subadmin "subadmin" sends a user deletion request for user "brand-new-user" using the provisioning API
When user "subadmin" deletes user "brand-new-user" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "brand-new-user" should not exist

Scenario: normal user tries to delete a user
Given user "user1" has been created with default attributes
And user "user2" has been created with default attributes
When user "user1" sends HTTP method "DELETE" to OCS API endpoint "/cloud/users/user2"
When user "user1" deletes user "user2" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And user "user2" should exist
18 changes: 9 additions & 9 deletions tests/acceptance/features/apiProvisioning-v1/disableUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Feature: disable user
@smokeTest
Scenario: admin disables an user
Given user "user1" has been created with default attributes
When the administrator sends HTTP method "PUT" to OCS API endpoint "/cloud/users/user1/disable"
When the administrator disables user "user1" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "user1" should be disabled
Expand All @@ -23,7 +23,7 @@ Feature: disable user
And user "subadmin" has been added to group "new-group"
And user "user1" has been added to group "new-group"
And user "subadmin" has been made a subadmin of group "new-group"
When user "subadmin" sends HTTP method "PUT" to OCS API endpoint "/cloud/users/user1/disable"
When user "subadmin" disables user "user1" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "user1" should be disabled
Expand All @@ -36,7 +36,7 @@ Feature: disable user
And user "subadmin" has been added to group "new-group"
And user "user1" has been added to group "another-group"
And user "subadmin" has been made a subadmin of group "new-group"
When user "subadmin" sends HTTP method "PUT" to OCS API endpoint "/cloud/users/user1/disable"
When user "subadmin" disables user "user1" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And user "user1" should be enabled
Expand All @@ -49,15 +49,15 @@ Feature: disable user
And user "subadmin" has been added to group "new-group"
And user "another-admin" has been added to group "new-group"
And user "subadmin" has been made a subadmin of group "new-group"
When user "subadmin" sends HTTP method "PUT" to OCS API endpoint "/cloud/users/another-admin/disable"
When user "subadmin" disables user "another-admin" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And user "another-admin" should be enabled

Scenario: Admin can disable another admin user
Given user "another-admin" has been created with default attributes
And user "another-admin" has been added to group "admin"
When the administrator sends HTTP method "PUT" to OCS API endpoint "/cloud/users/another-admin/disable"
When the administrator disables user "another-admin" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "another-admin" should be disabled
Expand All @@ -68,23 +68,23 @@ Feature: disable user
And user "subadmin" has been added to group "new-group"
And the administrator has been added to group "new-group"
And user "subadmin" has been made a subadmin of group "new-group"
When the administrator sends HTTP method "PUT" to OCS API endpoint "/cloud/users/subadmin/disable"
When the administrator disables user "subadmin" using the provisioning API
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And user "subadmin" should be disabled

Scenario: Admin user cannot disable himself
Given user "another-admin" has been created with default attributes
And user "another-admin" has been added to group "admin"
When user "another-admin" sends HTTP method "PUT" to OCS API endpoint "/cloud/users/another-admin/disable"
When user "another-admin" disables user "another-admin" using the provisioning API
Then the OCS status code should be "101"
And the HTTP status code should be "200"
And user "another-admin" should be enabled

Scenario: disable an user with a regular user
Given user "user1" has been created with default attributes
And user "user2" has been created with default attributes
When user "user1" sends HTTP method "PUT" to OCS API endpoint "/cloud/users/user2/disable"
When user "user1" disables user "user2" using the provisioning API
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And user "user2" should be enabled
Expand All @@ -94,7 +94,7 @@ Feature: disable user
And group "new-group" has been created
And user "subadmin" has been added to group "new-group"
And user "subadmin" has been made a subadmin of group "new-group"
When user "subadmin" sends HTTP method "PUT" to OCS API endpoint "/cloud/users/subadmin/disable"
When user "subadmin" disables user "subadmin" using the provisioning API
Then the OCS status code should be "101"
And the HTTP status code should be "200"
And user "subadmin" should be enabled
Expand Down
Loading