1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

Added spec test

This commit is contained in:
Eldad Fux 2020-11-12 00:03:27 +02:00
parent d9957e13ff
commit 2750267712

View file

@ -2,10 +2,13 @@
namespace Tests\E2E\Services\Account;
use CURLFile;
use Exception;
use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectNone;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideNone;
use Utopia\CLI\Console;
class HTTPTest extends Scope
{
@ -92,4 +95,32 @@ class HTTPTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertStringContainsString('# robotstxt.org/', $response['body']);
}
public function testSpecSwagger()
{
$response = $this->client->call(Client::METHOD_GET, '/specs/swagger2?platform=client', [
'content-type' => 'application/json',
], []);
if(!file_put_contents(__DIR__ . '/../../resources/swagger2.json', json_encode($response['body']))) {
throw new Exception('Failed to save spec file');
}
$client = new Client();
$client->setEndpoint('https://validator.swagger.io');
/**
* Test for SUCCESS
*/
$response = $client->call(Client::METHOD_POST, '/validator/debug', [
'content-type' => 'application/json',
], json_decode(file_get_contents(realpath(__DIR__ . '/../../resources/swagger2.json')), true));
$response['body'] = json_decode($response['body'], true);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEmpty($response['body']);
unlink(realpath(__DIR__ . '/../../resources/swagger2.json'));
}
}