41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api;
|
|
|
|
use Tests\TestCase;
|
|
|
|
class PublicApiDocumentationTest extends TestCase
|
|
{
|
|
public function test_scalar_api_docs_are_public(): void
|
|
{
|
|
$this->get('/api/docs')
|
|
->assertOk()
|
|
->assertSee('"hideClientButton":true', false)
|
|
->assertSee('"hideTestRequestButton":true', false)
|
|
->assertSee('"mcp":{"name":"KanbanGit MCP","url":"\/mcp\/kanbangit"}', false);
|
|
}
|
|
|
|
public function test_openapi_document_is_publicly_served(): void
|
|
{
|
|
$response = $this->get('/api/docs/openapi.json')
|
|
->assertOk();
|
|
|
|
$this->assertStringStartsWith(
|
|
'application/vnd.oai.openapi+json',
|
|
(string) $response->headers->get('Content-Type'),
|
|
);
|
|
|
|
$document = json_decode((string) $response->getContent(), true, 512, JSON_THROW_ON_ERROR);
|
|
|
|
$this->assertSame('3.1.0', $document['openapi']);
|
|
$this->assertSame([['ApplicationKey' => []]], $document['security']);
|
|
$this->assertArrayHasKey('/projects', $document['paths']);
|
|
}
|
|
|
|
public function test_application_api_still_requires_an_authenticated_user(): void
|
|
{
|
|
$this->getJson('/api/projects')
|
|
->assertUnauthorized();
|
|
}
|
|
}
|