diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php index 56d75c058a..a856e47ef2 100644 --- a/build/integration/features/bootstrap/Provisioning.php +++ b/build/integration/features/bootstrap/Provisioning.php @@ -173,6 +173,37 @@ trait Provisioning { } } + /** + * @Then /^search users by phone for region "([^"]*)" with$/ + * + * @param string $user + * @param \Behat\Gherkin\Node\TableNode|null $settings + */ + public function searchUserByPhone($region, \Behat\Gherkin\Node\TableNode $searchTable) { + $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/search/by-phone"; + $client = new Client(); + $options = []; + $options['auth'] = $this->adminUser; + $options['headers'] = [ + 'OCS-APIREQUEST' => 'true', + ]; + + $search = []; + foreach ($searchTable->getRows() as $row) { + if (!isset($search[$row[0]])) { + $search[$row[0]] = []; + } + $search[$row[0]][] = $row[1]; + } + + $options['form_params'] = [ + 'location' => $region, + 'search' => $search, + ]; + + $this->response = $client->post($fullUrl, $options); + } + public function createUser($user) { $previous_user = $this->currentUser; $this->currentUser = "admin"; @@ -560,6 +591,19 @@ trait Provisioning { } } + /** + * @Then /^phone matches returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $usersList + */ + public function thePhoneUsersShouldBe($usersList) { + if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { + $users = $usersList->getRowsHash(); + $listCheckedElements = simplexml_load_string($this->response->getBody())->data; + $respondedArray = json_decode(json_encode($listCheckedElements), true); + Assert::assertEquals($users, $respondedArray); + } + } + /** * @Then /^detailed users returned are$/ * @param \Behat\Gherkin\Node\TableNode|null $usersList diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature index ecc33c657f..eefaa574e0 100644 --- a/build/integration/features/provisioning-v1.feature +++ b/build/integration/features/provisioning-v1.feature @@ -71,12 +71,12 @@ Feature: provisioning And the HTTP status code should be "200" And sending "PUT" to "/cloud/users/brand-new-user" with | key | email | - | value | brand-new-user@gmail.com | + | value | no-reply@nextcloud.com | And the OCS status code should be "100" And the HTTP status code should be "200" And sending "PUT" to "/cloud/users/brand-new-user" with | key | phone | - | value | 0123 456 789 | + | value | 0711 / 25 24 28-90 | And the OCS status code should be "100" And the HTTP status code should be "200" And sending "PUT" to "/cloud/users/brand-new-user" with @@ -97,12 +97,29 @@ Feature: provisioning Then user "brand-new-user" has | id | brand-new-user | | displayname | Brand New User | - | email | brand-new-user@gmail.com | - | phone | 0123 456 789 | + | email | no-reply@nextcloud.com | + | phone | +4971125242890 | | address | Foo Bar Town | | website | https://nextcloud.com | | twitter | Nextcloud | + Scenario: Search by phone number + Given As an "admin" + And user "phone-user" exists + And sending "PUT" to "/cloud/users/phone-user" with + | key | phone | + | value | 0711 / 25 24 28-90 | + And the OCS status code should be "100" + And the HTTP status code should be "200" + Then search users by phone for region "DE" with + | random-string1 | 0711 / 123 456 78 | + | random-string1 | 0711 / 252 428-90 | + | random-string2 | 0711 / 90-824 252 | + And the OCS status code should be "100" + And the HTTP status code should be "200" + Then phone matches returned are + | random-string1 | phone-user@http://localhost:8080/ | + Scenario: Create a group Given As an "admin" And group "new-group" does not exist