1
0
Fork 0
mirror of synced 2024-09-06 12:51:43 +12:00
appwrite/tests/e2e/Services/Users/UsersBase.php

1117 lines
46 KiB
PHP
Raw Normal View History

2020-01-14 07:30:13 +13:00
<?php
namespace Tests\E2E\Services\Users;
use Tests\E2E\Client;
2022-08-14 22:33:36 +12:00
use Utopia\Database\ID;
2020-01-14 07:30:13 +13:00
trait UsersBase
{
2022-05-24 02:54:50 +12:00
public function testCreateUser(): array
2020-01-14 07:30:13 +13:00
{
/**
* Test for SUCCESS
*/
2020-01-14 07:55:57 +13:00
$user = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()), [
2022-08-14 22:33:36 +12:00
'userId' => ID::unique(),
2021-10-06 10:15:43 +13:00
'email' => 'cristiano.ronaldo@manchester-united.co.uk',
2020-01-14 07:55:57 +13:00
'password' => 'password',
2021-10-06 10:15:43 +13:00
'name' => 'Cristiano Ronaldo',
2021-12-30 21:09:23 +13:00
], false);
// Test empty prefs is object not array
$bodyString = $user['body'];
2022-05-24 02:54:50 +12:00
$prefs = substr($bodyString, strpos($bodyString, '"prefs":') + 8, 2);
2021-12-30 21:09:23 +13:00
$this->assertEquals('{}', $prefs);
2022-05-13 01:20:06 +12:00
2021-12-30 21:09:23 +13:00
$body = json_decode($bodyString, true);
2020-01-14 07:55:57 +13:00
$this->assertEquals($user['headers']['status-code'], 201);
2021-12-30 21:09:23 +13:00
$this->assertEquals($body['name'], 'Cristiano Ronaldo');
$this->assertEquals($body['email'], 'cristiano.ronaldo@manchester-united.co.uk');
$this->assertEquals($body['status'], true);
2022-07-04 21:55:11 +12:00
$this->assertGreaterThan('2000-01-01 00:00:00', $body['registration']);
2020-01-14 07:55:57 +13:00
2021-07-05 23:03:52 +12:00
/**
* Test Create with Custom ID for SUCCESS
*/
$res = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-08-14 22:33:36 +12:00
'userId' => ID::custom('user1'),
2021-10-06 10:15:43 +13:00
'email' => 'lionel.messi@psg.fr',
2021-07-05 23:03:52 +12:00
'password' => 'password',
2021-10-06 10:15:43 +13:00
'name' => 'Lionel Messi',
2021-07-05 23:03:52 +12:00
]);
$this->assertEquals($res['headers']['status-code'], 201);
$this->assertEquals($res['body']['$id'], 'user1');
2021-10-06 10:15:43 +13:00
$this->assertEquals($res['body']['name'], 'Lionel Messi');
$this->assertEquals($res['body']['email'], 'lionel.messi@psg.fr');
2021-07-30 00:14:40 +12:00
$this->assertEquals(true, $res['body']['status']);
2022-07-04 21:55:11 +12:00
$this->assertGreaterThan('2000-01-01 00:00:00', $res['body']['registration']);
2021-07-05 23:03:52 +12:00
2022-06-14 22:40:51 +12:00
/**
* Test Create with hashed passwords
*/
2022-08-15 04:29:07 +12:00
$res = $this->client->call(Client::METHOD_POST, '/users/md5', array_merge([
2022-06-14 22:40:51 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-06-14 22:49:46 +12:00
'userId' => 'md5',
2022-06-14 22:40:51 +12:00
'email' => 'md5@appwrite.io',
'password' => '144fa7eaa4904e8ee120651997f70dcc', // appwrite
'name' => 'MD5 User',
]);
2022-08-15 04:29:07 +12:00
$res = $this->client->call(Client::METHOD_POST, '/users/bcrypt', array_merge([
2022-06-14 22:40:51 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-06-14 22:49:46 +12:00
'userId' => 'bcrypt',
2022-06-14 22:40:51 +12:00
'email' => 'bcrypt@appwrite.io',
'password' => '$2a$15$xX/myGbFU.ZSKHSi6EHdBOySTdYm8QxBLXmOPHrYMwV0mHRBBSBOq', // appwrite (15 rounds)
2022-06-17 21:25:28 +12:00
'name' => 'Bcrypt User',
2022-06-14 22:40:51 +12:00
]);
$this->assertEquals($res['headers']['status-code'], 201);
$this->assertEquals($res['body']['password'], '$2a$15$xX/myGbFU.ZSKHSi6EHdBOySTdYm8QxBLXmOPHrYMwV0mHRBBSBOq');
$this->assertEquals($res['body']['hash'], 'bcrypt');
2022-08-15 04:29:07 +12:00
$res = $this->client->call(Client::METHOD_POST, '/users/argon2', array_merge([
2022-06-14 22:40:51 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-06-14 22:49:46 +12:00
'userId' => 'argon2',
'email' => 'argon2@appwrite.io',
2022-06-14 22:40:51 +12:00
'password' => '$argon2i$v=19$m=20,t=3,p=2$YXBwd3JpdGU$A/54i238ed09ZR4NwlACU5XnkjNBZU9QeOEuhjLiexI', // appwrite (salt appwrite, parallel 2, memory 20, iterations 3, length 32)
2022-06-14 22:49:46 +12:00
'name' => 'Argon2 User',
2022-06-14 22:40:51 +12:00
]);
$this->assertEquals($res['headers']['status-code'], 201);
$this->assertEquals($res['body']['password'], '$argon2i$v=19$m=20,t=3,p=2$YXBwd3JpdGU$A/54i238ed09ZR4NwlACU5XnkjNBZU9QeOEuhjLiexI');
$this->assertEquals($res['body']['hash'], 'argon2');
2022-08-15 04:29:07 +12:00
$res = $this->client->call(Client::METHOD_POST, '/users/sha', array_merge([
2022-06-14 22:40:51 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-06-14 22:49:46 +12:00
'userId' => 'sha512',
'email' => 'sha512@appwrite.io',
2022-06-14 22:40:51 +12:00
'password' => '4243da0a694e8a2f727c8060fe0507c8fa01ca68146c76d2c190805b638c20c6bf6ba04e21f11ae138785d0bff63c416e6f87badbffad37f6dee50094cc38c70', // appwrite (sha512)
2022-06-14 22:49:46 +12:00
'name' => 'SHA512 User',
2022-06-14 22:40:51 +12:00
'passwordVersion' => 'sha512'
]);
$this->assertEquals($res['headers']['status-code'], 201);
$this->assertEquals($res['body']['password'], '4243da0a694e8a2f727c8060fe0507c8fa01ca68146c76d2c190805b638c20c6bf6ba04e21f11ae138785d0bff63c416e6f87badbffad37f6dee50094cc38c70');
$this->assertEquals($res['body']['hash'], 'sha');
$this->assertEquals($res['body']['hashOptions']['version'], 'sha512');
2022-08-15 04:29:07 +12:00
$res = $this->client->call(Client::METHOD_POST, '/users/scrypt', array_merge([
2022-06-14 22:40:51 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-06-14 22:49:46 +12:00
'userId' => 'scrypt',
2022-06-14 22:40:51 +12:00
'email' => 'scrypt@appwrite.io',
'password' => '3fdef49701bc4cfaacd551fe017283513284b4731e6945c263246ef948d3cf63b5d269c31fd697246085111a428245e24a4ddc6b64c687bc60a8910dbafc1d5b', // appwrite (salt appwrite, cpu 16384, memory 13, parallel 2, length 64)
2022-06-17 21:25:28 +12:00
'name' => 'Scrypt User',
2022-06-14 22:40:51 +12:00
'passwordSalt' => 'appwrite',
'passwordCpu' => 16384,
'passwordMemory' => 13,
'passwordParallel' => 2,
'passwordLength' => 64
]);
$this->assertEquals($res['headers']['status-code'], 201);
$this->assertEquals($res['body']['password'], '3fdef49701bc4cfaacd551fe017283513284b4731e6945c263246ef948d3cf63b5d269c31fd697246085111a428245e24a4ddc6b64c687bc60a8910dbafc1d5b');
$this->assertEquals($res['body']['hash'], 'scrypt');
$this->assertEquals($res['body']['hashOptions']['salt'], 'appwrite');
2022-06-16 21:21:35 +12:00
$this->assertEquals($res['body']['hashOptions']['costCpu'], 16384);
$this->assertEquals($res['body']['hashOptions']['costMemory'], 13);
$this->assertEquals($res['body']['hashOptions']['costParallel'], 2);
2022-06-14 22:40:51 +12:00
$this->assertEquals($res['body']['hashOptions']['length'], 64);
2022-08-15 04:29:07 +12:00
$res = $this->client->call(Client::METHOD_POST, '/users/phpass', array_merge([
2022-06-14 22:40:51 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-06-14 22:49:46 +12:00
'userId' => 'phpass',
2022-06-14 22:40:51 +12:00
'email' => 'phpass@appwrite.io',
2022-06-22 20:00:12 +12:00
'password' => '$P$Br387rwferoKN7uwHZqNMu98q3U8RO.',
2022-06-14 22:40:51 +12:00
'name' => 'PHPass User',
]);
$this->assertEquals($res['headers']['status-code'], 201);
2022-06-22 20:00:12 +12:00
$this->assertEquals($res['body']['password'], '$P$Br387rwferoKN7uwHZqNMu98q3U8RO.');
2022-06-14 22:40:51 +12:00
2022-08-15 04:29:07 +12:00
$res = $this->client->call(Client::METHOD_POST, '/users/scrypt-modified', array_merge([
2022-06-14 22:40:51 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-06-14 22:49:46 +12:00
'userId' => 'scrypt-modified',
2022-06-14 22:40:51 +12:00
'email' => 'scrypt-modified@appwrite.io',
'password' => 'UlM7JiXRcQhzAGlaonpSqNSLIz475WMddOgLjej5De9vxTy48K6WtqlEzrRFeK4t0COfMhWCb8wuMHgxOFCHFQ==', // appwrite
2022-06-17 21:25:28 +12:00
'name' => 'Scrypt Modified User',
2022-06-14 22:40:51 +12:00
'passwordSalt' => 'UxLMreBr6tYyjQ==',
'passwordSaltSeparator' => 'Bw==',
'passwordSignerKey' => 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==',
]);
$this->assertEquals($res['headers']['status-code'], 201);
$this->assertEquals($res['body']['password'], 'UlM7JiXRcQhzAGlaonpSqNSLIz475WMddOgLjej5De9vxTy48K6WtqlEzrRFeK4t0COfMhWCb8wuMHgxOFCHFQ==');
2022-06-16 21:21:35 +12:00
$this->assertEquals($res['body']['hash'], 'scryptMod');
2022-06-14 22:40:51 +12:00
$this->assertEquals($res['body']['hashOptions']['salt'], 'UxLMreBr6tYyjQ==');
2022-06-16 21:21:35 +12:00
$this->assertEquals($res['body']['hashOptions']['signerKey'], 'XyEKE9RcTDeLEsL/RjwPDBv/RqDl8fb3gpYEOQaPihbxf1ZAtSOHCjuAAa7Q3oHpCYhXSN9tizHgVOwn6krflQ==');
$this->assertEquals($res['body']['hashOptions']['saltSeparator'], 'Bw==');
2022-06-14 22:40:51 +12:00
2021-12-30 21:09:23 +13:00
return ['userId' => $body['$id']];
2020-01-14 07:55:57 +13:00
}
2022-06-14 22:49:46 +12:00
/**
* Tries to login into all accounts created with hashed password. Ensures hash veifying logic.
2022-06-14 23:08:54 +12:00
*
2022-06-14 22:49:46 +12:00
* @depends testCreateUser
*/
public function testCreateUserSessionHashed(array $data): void
{
2022-06-22 20:00:12 +12:00
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
2022-06-14 22:49:46 +12:00
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'md5@appwrite.io',
'password' => 'appwrite',
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals($response['body']['userId'], 'md5');
2022-06-22 20:00:12 +12:00
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
2022-06-14 22:49:46 +12:00
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'bcrypt@appwrite.io',
'password' => 'appwrite',
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals($response['body']['userId'], 'bcrypt');
2022-06-22 20:00:12 +12:00
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
2022-06-14 22:49:46 +12:00
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'argon2@appwrite.io',
'password' => 'appwrite',
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals($response['body']['userId'], 'argon2');
2022-06-22 20:00:12 +12:00
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
2022-06-14 22:49:46 +12:00
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'sha512@appwrite.io',
'password' => 'appwrite',
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals($response['body']['userId'], 'sha512');
2022-06-22 20:00:12 +12:00
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
2022-06-14 22:49:46 +12:00
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'scrypt@appwrite.io',
'password' => 'appwrite',
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals($response['body']['userId'], 'scrypt');
2022-06-22 20:00:12 +12:00
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
2022-06-14 22:49:46 +12:00
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'phpass@appwrite.io',
'password' => 'appwrite',
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals($response['body']['userId'], 'phpass');
2022-06-22 20:00:12 +12:00
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
2022-06-14 22:49:46 +12:00
'origin' => 'http://localhost',
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
]), [
'email' => 'scrypt-modified@appwrite.io',
'password' => 'appwrite',
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals($response['body']['userId'], 'scrypt-modified');
}
/**
* Tests all optional parameters of createUser (email, phone, anonymous..)
*
* @depends testCreateUser
*/
2022-08-17 01:03:38 +12:00
public function testCreateUserTypes(array $data): void
{
/**
* Test for SUCCESS
*/
// Email + password
$response = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
'email' => 'emailuser@appwrite.io',
'password' => 'emailUserPassword',
]);
$this->assertNotEmpty($response['body']['email']);
$this->assertNotEmpty($response['body']['password']);
$this->assertEmpty($response['body']['phone']);
// Phone
$response = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
'phone' => '+123456789012',
]);
$this->assertEmpty($response['body']['email']);
$this->assertEmpty($response['body']['password']);
$this->assertNotEmpty($response['body']['phone']);
// Anonymous
$response = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
]);
2022-08-17 01:03:38 +12:00
$this->assertEmpty($response['body']['email']);
$this->assertEmpty($response['body']['password']);
$this->assertEmpty($response['body']['phone']);
// Email-only
$response = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
'email' => 'emailonlyuser@appwrite.io',
]);
2022-08-17 01:03:38 +12:00
$this->assertNotEmpty($response['body']['email']);
$this->assertEmpty($response['body']['password']);
$this->assertEmpty($response['body']['phone']);
// Password-only
$response = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
'password' => 'passwordOnlyUser',
]);
2022-08-17 01:03:38 +12:00
$this->assertEmpty($response['body']['email']);
$this->assertNotEmpty($response['body']['password']);
$this->assertEmpty($response['body']['phone']);
// Password and phone
$response = $this->client->call(Client::METHOD_POST, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'userId' => 'unique()',
'password' => 'passwordOnlyUser',
'phone' => '+123456789013',
]);
2022-08-17 01:03:38 +12:00
$this->assertEmpty($response['body']['email']);
$this->assertNotEmpty($response['body']['password']);
$this->assertNotEmpty($response['body']['phone']);
}
2021-08-10 00:55:30 +12:00
/**
* @depends testCreateUser
*/
public function testListUsers(array $data): void
{
$totalUsers = 15;
2021-08-10 00:55:30 +12:00
/**
2021-09-21 20:22:13 +12:00
* Test for SUCCESS listUsers
2021-08-10 00:55:30 +12:00
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount($totalUsers, $response['body']['users']);
2021-08-10 00:55:30 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$this->assertEquals($response['body']['users'][1]['$id'], 'user1');
$user1 = $response['body']['users'][1];
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("name", "' . $user1['name'] . '")']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['name'], $user1['name']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("email", "' . $user1['email'] . '")']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['email'], $user1['email']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("status", true)']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
2022-08-20 09:09:50 +12:00
$this->assertCount($totalUsers, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$this->assertEquals($response['body']['users'][0]['status'], $user1['status']);
$this->assertEquals($response['body']['users'][1]['$id'], $user1['$id']);
$this->assertEquals($response['body']['users'][1]['status'], $user1['status']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("status", false)']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertEmpty($response['body']['users']);
$this->assertCount(0, $response['body']['users']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("passwordUpdate", "' . $user1['passwordUpdate'] . '")']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['passwordUpdate'], $user1['passwordUpdate']);
2021-08-10 00:55:30 +12:00
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("registration", "' . $user1['registration'] . '")']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['registration'], $user1['registration']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("emailVerification", false)']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
2022-08-20 09:09:50 +12:00
$this->assertCount($totalUsers, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$this->assertEquals($response['body']['users'][0]['status'], $user1['status']);
$this->assertEquals($response['body']['users'][1]['$id'], $user1['$id']);
$this->assertEquals($response['body']['users'][1]['status'], $user1['status']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("emailVerification", true)']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertEmpty($response['body']['users']);
$this->assertCount(0, $response['body']['users']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("phoneVerification", false)']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
2022-08-20 09:09:50 +12:00
$this->assertIsArray($response['body']['users']);
$this->assertCount($totalUsers, $response['body']['users']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("phoneVerification", true)']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertEmpty($response['body']['users']);
$this->assertCount(0, $response['body']['users']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['cursorAfter("' . $data['userId'] . '")']
2021-08-10 00:55:30 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount($totalUsers - 1, $response['body']['users']);
2021-08-10 00:55:30 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], 'user1');
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['cursorBefore("user1")']
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
/**
2021-09-21 20:22:13 +12:00
* Test for SUCCESS searchUsers
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => "Ronaldo",
2021-09-21 20:22:13 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
2022-03-16 01:04:24 +13:00
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => "cristiano.ronaldo@manchester-united.co.uk",
2022-03-16 01:04:24 +13:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
2021-09-21 20:22:13 +12:00
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => "cristiano.ronaldo",
2021-09-21 20:22:13 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => "manchester",
2021-09-21 20:22:13 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => "united.co.uk",
2022-02-22 10:53:23 +13:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertIsArray($response['body']);
$this->assertIsArray($response['body']['users']);
2022-03-02 00:09:34 +13:00
$this->assertIsInt($response['body']['total']);
$this->assertEquals(1, $response['body']['total']);
2022-02-22 10:53:23 +13:00
$this->assertCount(1, $response['body']['users']);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => "man",
]);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['headers']['status-code'], 200);
2021-10-06 10:15:43 +13:00
$this->assertIsArray($response['body']);
$this->assertIsArray($response['body']['users']);
2022-02-27 22:57:09 +13:00
$this->assertIsInt($response['body']['total']);
$this->assertEquals(1, $response['body']['total']);
2021-09-23 19:01:10 +12:00
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $data['userId'],
2021-09-21 20:22:13 +12:00
]);
2022-02-22 22:39:33 +13:00
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
2021-09-23 19:01:10 +12:00
$this->assertCount(1, $response['body']['users']);
2021-09-21 20:22:13 +12:00
$this->assertEquals($response['body']['users'][0]['$id'], $data['userId']);
2021-10-08 04:49:47 +13:00
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['cursorAfter("unknown")']
2021-10-08 04:49:47 +13:00
]);
$this->assertEquals(400, $response['headers']['status-code']);
2021-08-10 00:55:30 +12:00
}
2020-01-14 07:55:57 +13:00
/**
* @depends testCreateUser
*/
2022-05-24 02:54:50 +12:00
public function testGetUser(array $data): array
2020-01-14 07:55:57 +13:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
2021-10-06 10:15:43 +13:00
$this->assertEquals($user['body']['name'], 'Cristiano Ronaldo');
$this->assertEquals($user['body']['email'], 'cristiano.ronaldo@manchester-united.co.uk');
$this->assertEquals($user['body']['status'], true);
2022-07-04 21:55:11 +12:00
$this->assertGreaterThan('2000-01-01 00:00:00', $user['body']['registration']);
2020-01-14 07:55:57 +13:00
$sessions = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/sessions', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($sessions['headers']['status-code'], 200);
$this->assertIsArray($sessions['body']);
$users = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($users['headers']['status-code'], 200);
$this->assertIsArray($users['body']);
$this->assertIsArray($users['body']['users']);
2022-02-27 22:57:09 +13:00
$this->assertIsInt($users['body']['total']);
$this->assertGreaterThan(0, $users['body']['total']);
2020-01-14 07:55:57 +13:00
return $data;
}
2021-08-29 22:30:48 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserName(array $data): array
2021-08-29 22:30:48 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/name', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'Updated name',
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['name'], 'Updated name');
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['name'], 'Updated name');
return $data;
}
2022-04-26 22:07:33 +12:00
/**
* @depends testUpdateUserName
*/
public function testUpdateUserNameSearch($data): void
{
$id = $data['userId'] ?? '';
$newName = 'Updated name';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $newName,
2022-04-26 22:07:33 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $id,
2022-04-26 22:07:33 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
}
2021-08-29 22:30:48 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserEmail(array $data): array
2021-08-29 22:30:48 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/email', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'email' => 'users.service@updated.com',
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['email'], 'users.service@updated.com');
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['email'], 'users.service@updated.com');
return $data;
}
2022-04-26 22:07:33 +12:00
/**
* @depends testUpdateUserEmail
*/
public function testUpdateUserEmailSearch($data): void
{
$id = $data['userId'] ?? '';
$newEmail = '"users.service@updated.com"';
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $newEmail,
2022-04-26 22:07:33 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
$response = $this->client->call(Client::METHOD_GET, '/users', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'search' => $id,
2022-04-26 22:07:33 +12:00
]);
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['users']);
$this->assertCount(1, $response['body']['users']);
$this->assertEquals($response['body']['users'][0]['$id'], $id);
}
2021-08-29 22:30:48 +12:00
/**
* @depends testUpdateUserEmail
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserPassword(array $data): array
2021-08-29 22:30:48 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/password', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'password' => 'password2',
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertNotEmpty($user['body']['$id']);
2022-06-14 20:17:50 +12:00
$session = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [
2021-08-29 22:30:48 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'email' => 'users.service@updated.com',
'password' => 'password2'
]);
$this->assertEquals($session['headers']['status-code'], 201);
return $data;
}
2020-01-14 07:55:57 +13:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateUserStatus(array $data): array
2020-01-14 07:55:57 +13:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/status', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()), [
'status' => false,
2020-01-14 07:55:57 +13:00
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['status'], false);
2020-01-14 07:55:57 +13:00
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['status'], false);
2020-01-14 07:55:57 +13:00
return $data;
}
2021-05-31 17:50:52 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateEmailVerification(array $data): array
2021-05-31 17:50:52 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/verification', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'emailVerification' => true,
]);
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['emailVerification'], true);
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body']['emailVerification'], true);
return $data;
}
2020-01-14 07:55:57 +13:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testUpdateAndGetUserPrefs(array $data): array
2020-01-14 07:55:57 +13:00
{
/**
* Test for SUCCESS
*/
2022-05-24 02:54:50 +12:00
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
2020-01-14 07:55:57 +13:00
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-14 07:55:57 +13:00
], $this->getHeaders()), [
'prefs' => [
2020-10-31 08:53:27 +13:00
'funcKey1' => 'funcValue1',
'funcKey2' => 'funcValue2',
2020-01-14 07:55:57 +13:00
],
]);
$this->assertEquals($user['headers']['status-code'], 200);
2020-10-31 08:53:27 +13:00
$this->assertEquals($user['body']['funcKey1'], 'funcValue1');
$this->assertEquals($user['body']['funcKey2'], 'funcValue2');
2020-01-14 07:55:57 +13:00
2022-05-24 02:54:50 +12:00
$user = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/prefs', array_merge([
2021-01-11 00:56:48 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 200);
$this->assertEquals($user['body'], [
'funcKey1' => 'funcValue1',
'funcKey2' => 'funcValue2',
]);
2020-01-20 09:38:00 +13:00
/**
* Test for FAILURE
*/
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-20 09:38:00 +13:00
], $this->getHeaders()), [
'prefs' => 'bad-string',
]);
$this->assertEquals($user['headers']['status-code'], 400);
$user = $this->client->call(Client::METHOD_PATCH, '/users/' . $data['userId'] . '/prefs', array_merge([
'content-type' => 'application/json',
2020-02-17 20:16:11 +13:00
'x-appwrite-project' => $this->getProject()['$id'],
2020-01-20 09:38:00 +13:00
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 400);
2020-01-14 07:55:57 +13:00
return $data;
2020-01-14 07:30:13 +13:00
}
/**
* @depends testGetUser
*/
public function testGetLogs(array $data): void
{
/**
* Test for SUCCESS
*/
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
2022-08-20 11:31:02 +12:00
], $this->getHeaders()));
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
2022-08-20 11:31:02 +12:00
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-08-20 11:31:02 +12:00
'limit' => 1
]);
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
2022-08-20 11:31:02 +12:00
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-08-20 11:31:02 +12:00
'offset' => 1
]);
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
2022-08-20 11:31:02 +12:00
$this->assertIsNumeric($logs['body']['total']);
$logs = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2022-08-20 11:31:02 +12:00
'offset' => 1,
'limit' => 1
]);
$this->assertEquals($logs['headers']['status-code'], 200);
$this->assertIsArray($logs['body']['logs']);
2022-08-20 11:31:02 +12:00
$this->assertLessThanOrEqual(1, count($logs['body']['logs']));
$this->assertIsNumeric($logs['body']['total']);
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['limit(-1)']
]);
$this->assertEquals($response['headers']['status-code'], 400);
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['limit(101)']
]);
$this->assertEquals($response['headers']['status-code'], 400);
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['offset(-1)']
]);
$this->assertEquals($response['headers']['status-code'], 400);
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['offset(5001)']
]);
$this->assertEquals($response['headers']['status-code'], 400);
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['equal("$id", "asdf")']
]);
$this->assertEquals($response['headers']['status-code'], 400);
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['orderAsc("$id")']
]);
$this->assertEquals($response['headers']['status-code'], 400);
$response = $this->client->call(Client::METHOD_GET, '/users/' . $data['userId'] . '/logs', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['cursorAsc("$id")']
]);
$this->assertEquals($response['headers']['status-code'], 400);
}
2020-08-29 09:56:22 +12:00
/**
* @depends testGetUser
*/
2022-05-24 02:54:50 +12:00
public function testDeleteUser(array $data): array
2020-08-29 09:56:22 +12:00
{
/**
* Test for SUCCESS
*/
$user = $this->client->call(Client::METHOD_DELETE, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 204);
/**
* Test for FAILURE
*/
$user = $this->client->call(Client::METHOD_DELETE, '/users/' . $data['userId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals($user['headers']['status-code'], 404);
return $data;
}
2020-01-14 07:55:57 +13:00
// TODO add test for session delete
// TODO add test for all sessions delete
2022-05-24 02:54:50 +12:00
}