]> source.dussan.org Git - nextcloud-server.git/commitdiff
Int tests for provisioning API scopes
authorVincent Petry <vincent@nextcloud.com>
Thu, 25 Mar 2021 14:30:41 +0000 (15:30 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 29 Mar 2021 07:03:37 +0000 (07:03 +0000)
Added integration tests for the scope attributes in the provisioning
API.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
build/integration/features/bootstrap/Provisioning.php
build/integration/features/provisioning-v1.feature

index 0ec19f27c60868d14e8b9c02cffe28da385cb4b1..cbe11403ba820af16d05b7360b39c1ec952121d2 100644 (file)
@@ -157,7 +157,11 @@ trait Provisioning {
                $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user";
                $client = new Client();
                $options = [];
-               $options['auth'] = $this->adminUser;
+               if ($this->currentUser === 'admin') {
+                       $options['auth'] = $this->adminUser;
+               } else {
+                       $options['auth'] = [$this->currentUser, $this->regularUser];
+               }
                $options['headers'] = [
                        'OCS-APIREQUEST' => 'true',
                ];
index 717aa04e4bdbc6c06c56caac6ce11cf40a0376ee..03aaad4b857242760732459456fc841f46582c54 100644 (file)
@@ -103,6 +103,82 @@ Feature: provisioning
                        | website | https://nextcloud.com |
                        | twitter | Nextcloud |
 
+       Scenario: Edit a user account properties scopes
+               Given user "brand-new-user" exists
+    And As an "brand-new-user"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | phoneScope |
+                       | value | v2-private |
+               Then the OCS status code should be "100"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | twitterScope |
+                       | value | v2-local |
+               Then the OCS status code should be "100"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | addressScope |
+                       | value | v2-federated |
+               Then the OCS status code should be "100"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | emailScope |
+                       | value | v2-published |
+               Then the OCS status code should be "100"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | websiteScope |
+                       | value | public |
+               Then the OCS status code should be "100"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | displaynameScope |
+                       | value | contacts |
+               Then the OCS status code should be "100"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | avatarScope |
+                       | value | private |
+               Then the OCS status code should be "100"
+               And the HTTP status code should be "200"
+               Then user "brand-new-user" has
+                       | id | brand-new-user |
+                       | phoneScope | v2-private |
+                       | twitterScope | v2-local |
+                       | addressScope | v2-federated |
+                       | emailScope | v2-published |
+                       | websiteScope | v2-published |
+                       | displaynameScope | v2-federated |
+                       | avatarScope | v2-local |
+
+       Scenario: Edit a user account properties scopes with invalid or unsupported value
+               Given user "brand-new-user" exists
+    And As an "brand-new-user"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | phoneScope |
+                       | value | invalid |
+               Then the OCS status code should be "102"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | displaynameScope |
+                       | value | v2-private |
+               Then the OCS status code should be "102"
+               And the HTTP status code should be "200"
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | emailScope |
+                       | value | v2-private |
+               Then the OCS status code should be "102"
+               And the HTTP status code should be "200"
+
+       Scenario: An admin cannot edit user account property scopes
+    Given As an "admin"
+               And user "brand-new-user" exists
+               When sending "PUT" to "/cloud/users/brand-new-user" with
+                       | key | phoneScope |
+                       | value | v2-private |
+               Then the OCS status code should be "997"
+               And the HTTP status code should be "401"
+
        Scenario: Search by phone number
                Given As an "admin"
                And user "phone-user" exists
@@ -612,4 +688,3 @@ Feature: provisioning
                And As an "user0"
                When sending "GET" with exact url to "/index.php/apps/files"
                And the HTTP status code should be "403"
-