From 13ff5ca45e0a0f7a63de5799e7b7ab60b7e8b173 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 14 Jul 2022 15:58:17 +1200 Subject: [PATCH] Add malformed request body tests --- .../GraphQL/GraphQLContentTypeTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/e2e/Services/GraphQL/GraphQLContentTypeTest.php b/tests/e2e/Services/GraphQL/GraphQLContentTypeTest.php index f718586036..bde4f3557b 100644 --- a/tests/e2e/Services/GraphQL/GraphQLContentTypeTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLContentTypeTest.php @@ -118,4 +118,26 @@ class GraphQLContentTypeTest extends Scope $this->assertArrayNotHasKey('errors', $file['body']); $this->assertIsArray($file['body']['data']['storageCreateFile']); } + + public function testEmptyBody() + { + $projectId = $this->getProject()['$id']; + $response = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ], $this->getHeaders())); + + $this->assertEquals('No query supplied.', $response['body']['message']); + } + + public function testRandomBody() + { + $projectId = $this->getProject()['$id']; + $response = $this->client->call(Client::METHOD_POST, '/graphql', \array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $projectId, + ], $this->getHeaders()), ['foo' => 'bar']); + + $this->assertEquals('Invalid query.', $response['body']['message']); + } }