You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
|
2 days ago
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Feature;
|
||
|
|
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class SwaggerExposureTest extends TestCase
|
||
|
|
{
|
||
|
|
public function test_documentation_routes_are_hidden_when_disabled(): void
|
||
|
|
{
|
||
|
|
config([
|
||
|
|
'app.debug' => false,
|
||
|
|
'app.swagger_enabled' => true,
|
||
|
|
]);
|
||
|
|
|
||
|
|
foreach ([
|
||
|
|
'/swagger/json',
|
||
|
|
'/api/documentation',
|
||
|
|
'/docs',
|
||
|
|
'/docs/asset/swagger-ui.css',
|
||
|
|
'/docs/api-docs.json',
|
||
|
|
'/docs/api-docs.yaml',
|
||
|
|
'/swagger/index.html',
|
||
|
|
'/swagger/swagger-ui.js',
|
||
|
|
'/storage/api-docs/api-docs.json',
|
||
|
|
] as $path) {
|
||
|
|
$response = $this->get($path);
|
||
|
|
|
||
|
|
$response->assertNotFound();
|
||
|
|
$this->assertStringNotContainsString('openapi', strtolower($response->getContent()));
|
||
|
|
$this->assertStringNotContainsString('swagger', strtolower($response->getContent()));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_documentation_can_be_enabled_in_a_debug_test_environment(): void
|
||
|
|
{
|
||
|
|
config([
|
||
|
|
'app.debug' => true,
|
||
|
|
'app.swagger_enabled' => true,
|
||
|
|
]);
|
||
|
|
|
||
|
|
$response = $this->get('/swagger/json');
|
||
|
|
|
||
|
|
$response->assertOk();
|
||
|
|
$response->assertJsonStructure(['openapi', 'paths']);
|
||
|
|
}
|
||
|
|
}
|