2020-01-17 03:06:28 +13:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\E2E\Services\Teams;
|
|
|
|
|
|
|
|
use Tests\E2E\Client;
|
2022-07-13 04:44:58 +12:00
|
|
|
use Utopia\Database\DateTime;
|
2022-08-15 02:22:38 +12:00
|
|
|
use Utopia\Database\ID;
|
2020-01-17 03:06:28 +13:00
|
|
|
|
|
|
|
trait TeamsBaseClient
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @depends testCreateTeam
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
public function testGetTeamMemberships($data): array
|
2020-01-17 03:06:28 +13:00
|
|
|
{
|
2020-10-15 10:11:12 +13:00
|
|
|
$teamUid = $data['teamUid'] ?? '';
|
2022-05-13 01:20:06 +12:00
|
|
|
$teamName = $data['teamName'] ?? '';
|
2020-01-17 03:06:28 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
2020-01-17 03:06:28 +13:00
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-17 03:06:28 +13:00
|
|
|
], $this->getHeaders()));
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2022-02-27 22:57:09 +13:00
|
|
|
$this->assertIsInt($response['body']['total']);
|
2020-06-08 20:01:11 +12:00
|
|
|
$this->assertNotEmpty($response['body']['memberships'][0]['$id']);
|
2022-05-13 01:20:06 +12:00
|
|
|
$this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['userName']);
|
|
|
|
$this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['userEmail']);
|
|
|
|
$this->assertEquals($teamName, $response['body']['memberships'][0]['teamName']);
|
2022-08-28 11:01:46 +12:00
|
|
|
$this->assertContains('owner', $response['body']['memberships'][0]['roles']);
|
|
|
|
$this->assertContains('player', $response['body']['memberships'][0]['roles']);
|
2020-01-17 03:06:28 +13:00
|
|
|
|
2022-02-17 05:26:05 +13:00
|
|
|
$membershipId = $response['body']['memberships'][0]['$id'];
|
|
|
|
|
2022-08-24 23:55:43 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'queries' => [ 'limit(0)' ]
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
$this->assertCount(0, $response['body']['memberships']);
|
|
|
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'queries' => [ 'offset(1)' ]
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
$this->assertCount(0, $response['body']['memberships']);
|
|
|
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'queries' => [ 'equal("confirm", true)' ]
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
$this->assertCount(1, $response['body']['memberships']);
|
|
|
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'queries' => [ 'equal("confirm", false)' ]
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
$this->assertCount(0, $response['body']['memberships']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
2022-02-17 05:26:05 +13:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'search' => $this->getUser()['$id']
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2022-02-27 22:57:09 +13:00
|
|
|
$this->assertIsInt($response['body']['total']);
|
2022-02-17 05:26:05 +13:00
|
|
|
$this->assertNotEmpty($response['body']['memberships'][0]);
|
2022-05-13 01:20:06 +12:00
|
|
|
$this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['userName']);
|
|
|
|
$this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['userEmail']);
|
|
|
|
$this->assertEquals($teamName, $response['body']['memberships'][0]['teamName']);
|
2022-08-28 11:01:46 +12:00
|
|
|
$this->assertContains('owner', $response['body']['memberships'][0]['roles']);
|
|
|
|
$this->assertContains('player', $response['body']['memberships'][0]['roles']);
|
2022-02-17 05:26:05 +13:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
2022-02-17 05:26:05 +13:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'search' => $membershipId
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2022-02-27 22:57:09 +13:00
|
|
|
$this->assertIsInt($response['body']['total']);
|
2022-02-17 05:26:05 +13:00
|
|
|
$this->assertNotEmpty($response['body']['memberships'][0]);
|
2022-05-13 01:20:06 +12:00
|
|
|
$this->assertEquals($this->getUser()['name'], $response['body']['memberships'][0]['userName']);
|
|
|
|
$this->assertEquals($this->getUser()['email'], $response['body']['memberships'][0]['userEmail']);
|
|
|
|
$this->assertEquals($teamName, $response['body']['memberships'][0]['teamName']);
|
2022-08-28 11:01:46 +12:00
|
|
|
$this->assertContains('owner', $response['body']['memberships'][0]['roles']);
|
|
|
|
$this->assertContains('player', $response['body']['memberships'][0]['roles']);
|
2022-02-17 05:26:05 +13:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
2022-02-17 05:26:05 +13:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'search' => 'unknown'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2022-02-27 22:57:09 +13:00
|
|
|
$this->assertIsInt($response['body']['total']);
|
2022-02-17 05:26:05 +13:00
|
|
|
$this->assertEmpty($response['body']['memberships']);
|
2022-02-27 22:57:09 +13:00
|
|
|
$this->assertEquals(0, $response['body']['total']);
|
2022-02-17 05:26:05 +13:00
|
|
|
|
2020-01-17 03:06:28 +13:00
|
|
|
/**
|
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
|
|
|
|
2020-10-28 08:48:38 +13:00
|
|
|
return $data;
|
2020-01-17 03:06:28 +13:00
|
|
|
}
|
2020-01-19 09:02:47 +13:00
|
|
|
|
2022-09-22 20:06:30 +12:00
|
|
|
/**
|
|
|
|
* @depends testCreateTeamMembership
|
|
|
|
*/
|
|
|
|
public function testGetTeamMembership($data): void
|
|
|
|
{
|
|
|
|
$teamUid = $data['teamUid'] ?? '';
|
|
|
|
$membershipUid = $data['membershipUid'] ?? '';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships/' . $membershipUid, array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()));
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
|
|
|
$this->assertNotEmpty($response['body']['userId']);
|
|
|
|
$this->assertNotEmpty($response['body']['userName']);
|
|
|
|
$this->assertNotEmpty($response['body']['userEmail']);
|
|
|
|
$this->assertNotEmpty($response['body']['teamId']);
|
|
|
|
$this->assertNotEmpty($response['body']['teamName']);
|
|
|
|
$this->assertCount(2, $response['body']['roles']);
|
|
|
|
$this->assertEquals(false, DateTime::isValid($response['body']['joined'])); // is null in DB
|
|
|
|
$this->assertEquals(false, $response['body']['confirm']);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
|
|
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships/' . $membershipUid . 'dasdasd', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()));
|
|
|
|
|
|
|
|
$this->assertEquals(404, $response['headers']['status-code']);
|
|
|
|
|
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships/' . $membershipUid, [
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(401, $response['headers']['status-code']);
|
|
|
|
}
|
|
|
|
|
2020-01-19 09:02:47 +13:00
|
|
|
/**
|
|
|
|
* @depends testCreateTeam
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
public function testCreateTeamMembership($data): array
|
2020-01-19 09:02:47 +13:00
|
|
|
{
|
2020-10-15 10:11:12 +13:00
|
|
|
$teamUid = $data['teamUid'] ?? '';
|
|
|
|
$teamName = $data['teamName'] ?? '';
|
2022-05-24 02:54:50 +12:00
|
|
|
$email = uniqid() . 'friend@localhost.test';
|
2021-05-05 06:52:46 +12:00
|
|
|
$name = 'Friend User';
|
2020-01-19 09:02:47 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([
|
2020-01-19 09:02:47 +13:00
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-19 09:02:47 +13:00
|
|
|
], $this->getHeaders()), [
|
|
|
|
'email' => $email,
|
2021-05-05 06:52:46 +12:00
|
|
|
'name' => $name,
|
2020-01-19 09:02:47 +13:00
|
|
|
'roles' => ['admin', 'editor'],
|
|
|
|
'url' => 'http://localhost:5000/join-us#title'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(201, $response['headers']['status-code']);
|
2020-02-17 20:16:11 +13:00
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
2020-01-19 09:02:47 +13:00
|
|
|
$this->assertNotEmpty($response['body']['userId']);
|
2022-07-23 11:51:58 +12:00
|
|
|
$this->assertEquals($name, $response['body']['userName']);
|
|
|
|
$this->assertEquals($email, $response['body']['userEmail']);
|
2020-01-19 09:02:47 +13:00
|
|
|
$this->assertNotEmpty($response['body']['teamId']);
|
2022-05-13 01:20:06 +12:00
|
|
|
$this->assertNotEmpty($response['body']['teamName']);
|
2020-01-19 09:02:47 +13:00
|
|
|
$this->assertCount(2, $response['body']['roles']);
|
2022-07-13 05:51:00 +12:00
|
|
|
$this->assertEquals(false, DateTime::isValid($response['body']['joined'])); // is null in DB
|
2020-01-19 09:02:47 +13:00
|
|
|
$this->assertEquals(false, $response['body']['confirm']);
|
|
|
|
|
2020-01-20 01:22:54 +13:00
|
|
|
$lastEmail = $this->getLastEmail();
|
|
|
|
|
|
|
|
$this->assertEquals($email, $lastEmail['to'][0]['address']);
|
2021-05-05 06:52:46 +12:00
|
|
|
$this->assertEquals($name, $lastEmail['to'][0]['name']);
|
2022-05-24 02:54:50 +12:00
|
|
|
$this->assertEquals('Invitation to ' . $teamName . ' Team at ' . $this->getProject()['name'], $lastEmail['subject']);
|
2020-01-20 01:22:54 +13:00
|
|
|
|
|
|
|
$secret = substr($lastEmail['text'], strpos($lastEmail['text'], '&secret=', 0) + 8, 256);
|
2021-11-25 05:08:14 +13:00
|
|
|
$membershipUid = substr($lastEmail['text'], strpos($lastEmail['text'], '?membershipId=', 0) + 14, 20);
|
|
|
|
$userUid = substr($lastEmail['text'], strpos($lastEmail['text'], '&userId=', 0) + 8, 20);
|
2020-01-20 01:22:54 +13:00
|
|
|
|
2023-01-09 22:17:45 +13:00
|
|
|
/**
|
|
|
|
* Test with UserId
|
|
|
|
* Create user
|
|
|
|
*/
|
|
|
|
$secondEmail = uniqid() . 'foe@localhost.test';
|
|
|
|
$secondName = 'Another Foe';
|
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/account', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'userId' => 'unique()',
|
|
|
|
'email' => $secondEmail,
|
|
|
|
'password' => 'password',
|
|
|
|
'name' => $secondName
|
|
|
|
]);
|
|
|
|
$this->assertEquals(201, $response['headers']['status-code']);
|
|
|
|
$userId = $response['body']['$id'];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for UserID
|
|
|
|
* Failure
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'userId' => 'abcdefdg',
|
|
|
|
'roles' => ['admin', 'editor'],
|
|
|
|
'url' => 'http://localhost:5000/join-us#title'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(404, $response['headers']['status-code']);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for UserID
|
|
|
|
* SUCCESS
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'userId' => $userId,
|
|
|
|
'roles' => ['admin', 'editor'],
|
|
|
|
'url' => 'http://localhost:5000/join-us#title'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(201, $response['headers']['status-code']);
|
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
|
|
|
$this->assertNotEmpty($response['body']['userId']);
|
|
|
|
$this->assertEquals($secondName, $response['body']['userName']);
|
|
|
|
$this->assertEquals($secondEmail, $response['body']['userEmail']);
|
|
|
|
$this->assertNotEmpty($response['body']['teamId']);
|
|
|
|
$this->assertNotEmpty($response['body']['teamName']);
|
|
|
|
$this->assertCount(2, $response['body']['roles']);
|
|
|
|
$this->assertEquals(false, DateTime::isValid($response['body']['joined'])); // is null in DB
|
|
|
|
$this->assertEquals(false, $response['body']['confirm']);
|
|
|
|
|
|
|
|
$lastEmail = $this->getLastEmail();
|
|
|
|
|
|
|
|
$this->assertEquals($secondEmail, $lastEmail['to'][0]['address']);
|
|
|
|
$this->assertEquals($secondName, $lastEmail['to'][0]['name']);
|
|
|
|
$this->assertEquals('Invitation to ' . $teamName . ' Team at ' . $this->getProject()['name'], $lastEmail['subject']);
|
|
|
|
|
2020-01-19 09:02:47 +13:00
|
|
|
/**
|
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
2021-05-10 06:37:47 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([
|
2021-05-10 06:37:47 +12:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'email' => $email,
|
|
|
|
'name' => 'Friend User',
|
|
|
|
'roles' => ['admin', 'editor'],
|
|
|
|
'url' => 'http://localhost:5000/join-us#title'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(409, $response['headers']['status-code']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([
|
2020-01-19 23:43:06 +13:00
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-19 23:43:06 +13:00
|
|
|
], $this->getHeaders()), [
|
|
|
|
'email' => 'dasdkaskdjaskdjasjkd',
|
2021-05-05 06:52:46 +12:00
|
|
|
'name' => $name,
|
2020-01-19 23:43:06 +13:00
|
|
|
'roles' => ['admin', 'editor'],
|
|
|
|
'url' => 'http://localhost:5000/join-us#title'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(400, $response['headers']['status-code']);
|
2020-01-19 09:02:47 +13:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([
|
2020-01-20 01:22:54 +13:00
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 01:22:54 +13:00
|
|
|
], $this->getHeaders()), [
|
|
|
|
'email' => $email,
|
2021-05-05 06:52:46 +12:00
|
|
|
'name' => $name,
|
2020-01-20 01:22:54 +13:00
|
|
|
'roles' => 'bad string',
|
|
|
|
'url' => 'http://localhost:5000/join-us#title'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(400, $response['headers']['status-code']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([
|
2020-01-20 01:22:54 +13:00
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 01:22:54 +13:00
|
|
|
], $this->getHeaders()), [
|
|
|
|
'email' => $email,
|
2021-05-05 06:52:46 +12:00
|
|
|
'name' => $name,
|
2020-01-20 01:22:54 +13:00
|
|
|
'roles' => ['admin', 'editor'],
|
|
|
|
'url' => 'http://example.com/join-us#title' // bad url
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(400, $response['headers']['status-code']);
|
|
|
|
|
|
|
|
return [
|
|
|
|
'teamUid' => $teamUid,
|
2022-05-13 01:20:06 +12:00
|
|
|
'teamName' => $teamName,
|
2020-01-20 01:22:54 +13:00
|
|
|
'secret' => $secret,
|
2021-05-08 04:54:56 +12:00
|
|
|
'membershipUid' => $membershipUid,
|
2020-01-20 01:22:54 +13:00
|
|
|
'userUid' => $userUid,
|
2021-05-05 06:52:46 +12:00
|
|
|
'email' => $email,
|
|
|
|
'name' => $name
|
2020-01-20 01:22:54 +13:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-08-10 01:04:14 +12:00
|
|
|
/**
|
|
|
|
* @depends testCreateTeamMembership
|
|
|
|
*/
|
|
|
|
public function testListTeamMemberships($data): void
|
|
|
|
{
|
2022-05-24 02:54:50 +12:00
|
|
|
$memberships = $this->client->call(Client::METHOD_GET, '/teams/' . $data['teamUid'] . '/memberships', array_merge([
|
2021-08-10 01:04:14 +12:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()));
|
|
|
|
|
|
|
|
$this->assertEquals(200, $memberships['headers']['status-code']);
|
2022-02-27 22:57:09 +13:00
|
|
|
$this->assertIsInt($memberships['body']['total']);
|
2021-08-10 01:04:14 +12:00
|
|
|
$this->assertNotEmpty($memberships['body']['memberships']);
|
2023-01-09 22:17:45 +13:00
|
|
|
$this->assertCount(3, $memberships['body']['memberships']);
|
2021-08-10 01:04:14 +12:00
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $data['teamUid'] . '/memberships', array_merge([
|
2021-08-10 01:04:14 +12:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
2022-08-24 21:22:13 +12:00
|
|
|
'queries' => [ 'cursorAfter("' . $memberships['body']['memberships'][0]['$id'] . '")' ]
|
2021-08-10 01:04:14 +12:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2022-02-27 22:57:09 +13:00
|
|
|
$this->assertIsInt($response['body']['total']);
|
2021-08-10 01:04:14 +12:00
|
|
|
$this->assertNotEmpty($response['body']['memberships']);
|
2023-01-09 22:17:45 +13:00
|
|
|
$this->assertCount(2, $response['body']['memberships']);
|
2021-08-10 01:04:14 +12:00
|
|
|
$this->assertEquals($memberships['body']['memberships'][1]['$id'], $response['body']['memberships'][0]['$id']);
|
|
|
|
}
|
|
|
|
|
2020-01-20 01:22:54 +13:00
|
|
|
/**
|
|
|
|
* @depends testCreateTeamMembership
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
public function testUpdateTeamMembership($data): array
|
2020-01-20 01:22:54 +13:00
|
|
|
{
|
2020-10-15 10:11:12 +13:00
|
|
|
$teamUid = $data['teamUid'] ?? '';
|
|
|
|
$secret = $data['secret'] ?? '';
|
2021-05-08 04:54:56 +12:00
|
|
|
$membershipUid = $data['membershipUid'] ?? '';
|
2020-10-15 10:11:12 +13:00
|
|
|
$userUid = $data['userUid'] ?? '';
|
2021-05-05 06:52:46 +12:00
|
|
|
$email = $data['email'] ?? '';
|
|
|
|
$name = $data['name'] ?? '';
|
2020-01-20 01:22:54 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid . '/status', array_merge([
|
2020-01-20 01:22:54 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 01:22:54 +13:00
|
|
|
]), [
|
|
|
|
'secret' => $secret,
|
2022-08-15 23:24:31 +12:00
|
|
|
'userId' => $userUid,
|
2020-01-20 01:22:54 +13:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2020-02-17 20:16:11 +13:00
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
2020-01-20 01:22:54 +13:00
|
|
|
$this->assertNotEmpty($response['body']['userId']);
|
|
|
|
$this->assertNotEmpty($response['body']['teamId']);
|
|
|
|
$this->assertCount(2, $response['body']['roles']);
|
2022-07-13 04:44:58 +12:00
|
|
|
$this->assertEquals(true, DateTime::isValid($response['body']['joined']));
|
2020-01-20 01:22:54 +13:00
|
|
|
$this->assertEquals(true, $response['body']['confirm']);
|
2022-05-24 02:54:50 +12:00
|
|
|
$session = $this->client->parseCookie((string)$response['headers']['set-cookie'])['a_session_' . $this->getProject()['$id']];
|
2021-05-14 05:59:54 +12:00
|
|
|
$data['session'] = $session;
|
2021-05-05 06:52:46 +12:00
|
|
|
|
2022-11-25 00:40:17 +13:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
|
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
|
|
|
]));
|
|
|
|
|
|
|
|
$this->assertEquals(true, $response['body']['emailVerification']);
|
|
|
|
|
2021-05-14 06:01:57 +12:00
|
|
|
|
|
|
|
/** [START] TESTS TO CHECK PASSWORD UPDATE OF NEW USER CREATED USING TEAM INVITE */
|
2021-05-05 06:52:46 +12:00
|
|
|
/**
|
|
|
|
* New User tries to update password without old password -> SHOULD PASS
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
|
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2022-05-24 02:54:50 +12:00
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
2021-05-05 06:52:46 +12:00
|
|
|
]), [
|
|
|
|
'password' => 'new-password'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals($response['headers']['status-code'], 200);
|
|
|
|
$this->assertIsArray($response['body']);
|
|
|
|
$this->assertNotEmpty($response['body']);
|
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
2022-07-13 04:44:58 +12:00
|
|
|
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
|
2021-05-05 06:52:46 +12:00
|
|
|
$this->assertEquals($response['body']['email'], $email);
|
|
|
|
$this->assertEquals($response['body']['name'], $name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New User again tries to update password with ONLY new password -> SHOULD FAIL
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
|
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2022-05-24 02:54:50 +12:00
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
2021-05-05 06:52:46 +12:00
|
|
|
]), [
|
|
|
|
'password' => 'new-password',
|
|
|
|
]);
|
|
|
|
$this->assertEquals(401, $response['headers']['status-code']);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New User tries to update password by passing both old and new password -> SHOULD PASS
|
|
|
|
*/
|
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([
|
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2022-05-24 02:54:50 +12:00
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
2021-05-05 06:52:46 +12:00
|
|
|
]), [
|
|
|
|
'password' => 'newer-password',
|
|
|
|
'oldPassword' => 'new-password'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals($response['headers']['status-code'], 200);
|
|
|
|
$this->assertIsArray($response['body']);
|
|
|
|
$this->assertNotEmpty($response['body']);
|
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
2022-07-13 04:44:58 +12:00
|
|
|
$this->assertEquals(true, DateTime::isValid($response['body']['registration']));
|
2021-05-05 06:52:46 +12:00
|
|
|
$this->assertEquals($response['body']['email'], $email);
|
|
|
|
$this->assertEquals($response['body']['name'], $name);
|
2021-05-13 01:44:41 +12:00
|
|
|
|
2021-05-14 06:01:57 +12:00
|
|
|
/** [END] TESTS TO CHECK PASSWORD UPDATE OF NEW USER CREATED USING TEAM INVITE */
|
2020-01-20 01:22:54 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid . '/status', array_merge([
|
2020-01-20 01:22:54 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 01:22:54 +13:00
|
|
|
]), [
|
|
|
|
'secret' => 'sdasdasd',
|
2022-08-15 23:24:31 +12:00
|
|
|
'userId' => $userUid,
|
2020-01-20 01:22:54 +13:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(401, $response['headers']['status-code']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid . '/status', array_merge([
|
2020-01-20 01:22:54 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 01:22:54 +13:00
|
|
|
]), [
|
|
|
|
'secret' => '',
|
2022-08-15 23:24:31 +12:00
|
|
|
'userId' => $userUid,
|
2020-01-20 01:22:54 +13:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(400, $response['headers']['status-code']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid . '/status', array_merge([
|
2020-01-20 01:22:54 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 01:22:54 +13:00
|
|
|
]), [
|
|
|
|
'secret' => $secret,
|
2022-08-14 22:33:36 +12:00
|
|
|
'userId' => ID::custom('sdasd'),
|
2020-01-20 01:22:54 +13:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(401, $response['headers']['status-code']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid . '/status', array_merge([
|
2020-01-20 01:22:54 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 01:22:54 +13:00
|
|
|
]), [
|
|
|
|
'secret' => $secret,
|
2022-08-14 22:33:36 +12:00
|
|
|
'userId' => ID::custom(''),
|
2020-01-20 01:22:54 +13:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(400, $response['headers']['status-code']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid . '/status', array_merge([
|
2022-01-19 11:32:36 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
]), [
|
|
|
|
'secret' => $secret,
|
2022-08-15 23:24:31 +12:00
|
|
|
'userId' => $userUid,
|
2022-01-19 11:32:36 +13:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(409, $response['headers']['status-code']);
|
|
|
|
|
2020-01-20 02:36:30 +13:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testUpdateTeamMembership
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
public function testUpdateTeamMembershipRoles($data): array
|
2020-01-20 02:36:30 +13:00
|
|
|
{
|
2020-10-15 10:11:12 +13:00
|
|
|
$teamUid = $data['teamUid'] ?? '';
|
2021-05-08 04:54:56 +12:00
|
|
|
$membershipUid = $data['membershipUid'] ?? '';
|
2021-05-13 05:00:22 +12:00
|
|
|
$session = $data['session'] ?? '';
|
|
|
|
|
2020-01-20 02:36:30 +13:00
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
2021-05-13 05:00:22 +12:00
|
|
|
$roles = ['admin', 'editor', 'uncle'];
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid, array_merge([
|
2020-01-20 02:36:30 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2021-05-13 05:00:22 +12:00
|
|
|
], $this->getHeaders()), [
|
|
|
|
'roles' => $roles
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
|
|
|
$this->assertNotEmpty($response['body']['$id']);
|
|
|
|
$this->assertNotEmpty($response['body']['userId']);
|
|
|
|
$this->assertNotEmpty($response['body']['teamId']);
|
|
|
|
$this->assertCount(count($roles), $response['body']['roles']);
|
|
|
|
$this->assertEquals($roles[0], $response['body']['roles'][0]);
|
|
|
|
$this->assertEquals($roles[1], $response['body']['roles'][1]);
|
|
|
|
$this->assertEquals($roles[2], $response['body']['roles'][2]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for unknown team
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . 'abc' . '/memberships/' . $membershipUid, array_merge([
|
2021-05-13 05:00:22 +12:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'roles' => $roles
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(404, $response['headers']['status-code']);
|
2020-01-20 02:36:30 +13:00
|
|
|
|
2021-05-13 05:00:22 +12:00
|
|
|
/**
|
|
|
|
* Test for unknown membership ID
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . 'abc', array_merge([
|
2021-05-13 05:00:22 +12:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()), [
|
|
|
|
'roles' => $roles
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(404, $response['headers']['status-code']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-05-13 05:00:22 +12:00
|
|
|
/**
|
|
|
|
* Test for when a user other than the owner tries to update membership
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_PATCH, '/teams/' . $teamUid . '/memberships/' . $membershipUid, [
|
2021-05-13 05:00:22 +12:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2022-05-24 02:54:50 +12:00
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
2021-05-13 05:00:22 +12:00
|
|
|
], [
|
|
|
|
'roles' => $roles
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertEquals(401, $response['headers']['status-code']);
|
|
|
|
$this->assertEquals('User is not allowed to modify roles', $response['body']['message']);
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-05-13 05:10:44 +12:00
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testUpdateTeamMembershipRoles
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
public function testDeleteTeamMembership($data): array
|
2020-01-20 02:36:30 +13:00
|
|
|
{
|
2020-10-15 10:11:12 +13:00
|
|
|
$teamUid = $data['teamUid'] ?? '';
|
2021-05-08 04:54:56 +12:00
|
|
|
$membershipUid = $data['membershipUid'] ?? '';
|
2021-12-07 21:01:09 +13:00
|
|
|
$session = $data['session'] ?? '';
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
2021-12-07 21:01:09 +13:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()));
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2023-01-09 22:17:45 +13:00
|
|
|
$this->assertEquals(3, $response['body']['total']);
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-12-07 21:01:09 +13:00
|
|
|
$ownerMembershipUid = $response['body']['memberships'][0]['$id'];
|
|
|
|
|
2020-01-20 02:36:30 +13:00
|
|
|
/**
|
2021-12-07 21:01:09 +13:00
|
|
|
* Test for FAILURE
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test deleting a membership that does not exists
|
2020-01-20 02:36:30 +13:00
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid . '/memberships/dne', [
|
2020-01-20 02:36:30 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2022-05-24 02:54:50 +12:00
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
2021-12-07 21:01:09 +13:00
|
|
|
]);
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-12-07 21:01:09 +13:00
|
|
|
$this->assertEquals(404, $response['headers']['status-code']);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test deleting another user's membership
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid . '/memberships/' . $ownerMembershipUid, [
|
2021-12-07 21:01:09 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2022-05-24 02:54:50 +12:00
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
2021-12-07 21:01:09 +13:00
|
|
|
]);
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-12-07 21:01:09 +13:00
|
|
|
$this->assertEquals(401, $response['headers']['status-code']);
|
2020-01-20 02:36:30 +13:00
|
|
|
|
2021-12-07 21:01:09 +13:00
|
|
|
/**
|
|
|
|
* Test for SUCCESS
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for when a user other than the owner tries to delete their membership
|
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid . '/memberships/' . $membershipUid, [
|
2021-12-07 21:01:09 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2022-05-24 02:54:50 +12:00
|
|
|
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session,
|
2021-12-07 21:01:09 +13:00
|
|
|
]);
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2020-01-20 02:36:30 +13:00
|
|
|
$this->assertEquals(204, $response['headers']['status-code']);
|
|
|
|
$this->assertEmpty($response['body']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships', array_merge([
|
2021-12-07 21:01:09 +13:00
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()));
|
|
|
|
|
|
|
|
$this->assertEquals(200, $response['headers']['status-code']);
|
2023-01-09 22:17:45 +13:00
|
|
|
$this->assertEquals(2, $response['body']['total']);
|
2021-12-07 21:01:09 +13:00
|
|
|
|
2020-01-20 02:36:30 +13:00
|
|
|
/**
|
2021-12-07 21:01:09 +13:00
|
|
|
* Test for when the owner tries to delete their membership
|
2020-01-20 02:36:30 +13:00
|
|
|
*/
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid . '/memberships/' . $ownerMembershipUid, array_merge([
|
2021-12-07 21:01:09 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
|
|
|
], $this->getHeaders()));
|
|
|
|
|
|
|
|
$this->assertEquals(204, $response['headers']['status-code']);
|
|
|
|
$this->assertEmpty($response['body']);
|
|
|
|
|
2022-05-24 02:54:50 +12:00
|
|
|
$response = $this->client->call(Client::METHOD_GET, '/teams/' . $teamUid . '/memberships/' . $ownerMembershipUid, array_merge([
|
2020-01-20 02:36:30 +13:00
|
|
|
'origin' => 'http://localhost',
|
|
|
|
'content-type' => 'application/json',
|
2020-02-17 20:16:11 +13:00
|
|
|
'x-appwrite-project' => $this->getProject()['$id'],
|
2020-01-20 02:36:30 +13:00
|
|
|
], $this->getHeaders()));
|
|
|
|
|
2021-08-05 16:29:43 +12:00
|
|
|
$this->assertEquals(404, $response['headers']['status-code']);
|
2020-01-20 02:36:30 +13:00
|
|
|
|
2020-01-19 09:02:47 +13:00
|
|
|
return [];
|
|
|
|
}
|
2022-05-24 02:54:50 +12:00
|
|
|
}
|