From 53e2f2fcc1b3d8ccdbc355cb39af93c153e2a4d5 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Fri, 20 Nov 2020 23:03:14 +0200 Subject: [PATCH] Added test webhook --- tests/e2e/Scopes/ProjectCustom.php | 20 +++++++------------- tests/e2e/Scopes/Scope.php | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/e2e/Scopes/ProjectCustom.php b/tests/e2e/Scopes/ProjectCustom.php index e900e4e74f..43ae3721e7 100644 --- a/tests/e2e/Scopes/ProjectCustom.php +++ b/tests/e2e/Scopes/ProjectCustom.php @@ -85,10 +85,12 @@ trait ProjectCustom $this->assertNotEmpty($key['body']); $this->assertNotEmpty($key['body']['secret']); - $webhook = $this->client->call(Client::METHOD_POST, '/projects/'.$project['body']['$id'].'/webhooks', array_merge([ + $webhook = $this->client->call(Client::METHOD_POST, '/projects/'.$project['body']['$id'].'/webhooks', [ + 'origin' => 'http://localhost', 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + 'x-appwrite-project' => 'console', + ], [ 'name' => 'Webhook Test', 'events' => [ 'account.create', @@ -98,6 +100,8 @@ trait ProjectCustom 'account.update.prefs', 'account.recovery.create', 'account.recovery.update', + 'account.verification.create', + 'account.verification.update', 'account.delete', 'account.sessions.create', 'account.sessions.delete', @@ -123,16 +127,6 @@ trait ProjectCustom $this->assertEquals(201, $webhook['headers']['status-code']); $this->assertNotEmpty($webhook['body']); - $this->assertNotEmpty($webhook['body']['secret']); - - // return [ - // 'email' => $this->demoEmail, - // 'password' => $this->demoPassword, - // 'session' => $session, - // 'projectUid' => $project['body']['$id'], - // 'projectAPIKeySecret' => $key['body']['secret'], - // 'projectSession' => $this->client->parseCookie($user['headers']['set-cookie'])['a_session_' . $project['body']['$id']], - // ]; self::$project = [ '$id' => $project['body']['$id'], diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index 36832b5d25..fae34a87fb 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -46,7 +46,7 @@ abstract class Scope extends TestCase protected function getLastRequest():array { - sleep(10); + sleep(5); $resquest = json_decode(file_get_contents('http://request-catcher:5000/__last_request__'), true); $resquest['data'] = json_decode($resquest['data'], true);