Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-12-02 18:03:54 +0300
committerJoas Schilling <coding@schilljs.com>2020-12-07 16:19:38 +0300
commit689e3a502d02801f99f8d44676268c499972c909 (patch)
tree868a203ac70561cd1d136ca9989397a2616bd325 /build
parent9e04e6f99ad7a8d78b0bf09a414ed0f1aac3e5db (diff)
Add an integration test for the phone search API
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'build')
-rw-r--r--build/integration/features/bootstrap/Provisioning.php44
-rw-r--r--build/integration/features/provisioning-v1.feature25
2 files changed, 65 insertions, 4 deletions
diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php
index 56d75c058aa..a856e47ef2b 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";
@@ -561,6 +592,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 ecc33c657f4..eefaa574e03 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