funcional a parte de token
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -9,10 +10,6 @@ class DocumentationRoutesTest extends TestCase
|
||||
{
|
||||
public function test_openapi_documentation_matches_public_api_routes(): void
|
||||
{
|
||||
$response = $this->get('/docs.openapi');
|
||||
|
||||
$response->assertOk();
|
||||
|
||||
$openApi = Yaml::parse(file_get_contents(storage_path('app/scribe/openapi.yaml')));
|
||||
$paths = array_keys($openApi['paths']);
|
||||
|
||||
@@ -20,14 +17,31 @@ class DocumentationRoutesTest extends TestCase
|
||||
'/api/v1/rankings/weekly',
|
||||
'/api/v1/rankings/monthly',
|
||||
'/api/v1/rankings/yearly',
|
||||
'/api/v1/rankings/history',
|
||||
'/api/v1/rankings/history/{id}',
|
||||
'/api/v1/rankings/platforms/{platform}',
|
||||
'/api/v1/games',
|
||||
'/api/v1/games/most-played',
|
||||
], $paths);
|
||||
|
||||
$this->assertNotContains('/api/test-auth', $paths);
|
||||
$this->assertNotContains('/api/health', $paths);
|
||||
$this->assertNotContains('/api/v1/games', $paths);
|
||||
$this->assertNotContains('/api/v1/rankings/platforms/{platform}', $paths);
|
||||
$this->assertNotContains('/api/v1/rankings/history', $paths);
|
||||
}
|
||||
|
||||
public function test_registered_api_v1_routes_are_only_the_requested_endpoints(): void
|
||||
{
|
||||
$routes = collect(Route::getRoutes())
|
||||
->filter(fn ($route) => str_starts_with($route->uri(), 'api/v1/'))
|
||||
->map(fn ($route) => $route->uri())
|
||||
->values()
|
||||
->all();
|
||||
|
||||
$this->assertSame([
|
||||
'api/v1/rankings/weekly',
|
||||
'api/v1/rankings/monthly',
|
||||
'api/v1/rankings/yearly',
|
||||
'api/v1/rankings/history/{id}',
|
||||
'api/v1/games/most-played',
|
||||
], $routes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_the_application_returns_a_successful_response(): void
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
@@ -55,15 +55,6 @@ class GameRankingApiTest extends TestCase
|
||||
->assertJsonPath('9.name', 'Game 3');
|
||||
}
|
||||
|
||||
public function test_games_route_returns_ids_for_frontend_selection(): void
|
||||
{
|
||||
$this->getJsonWithJwt('/api/v1/games')
|
||||
->assertOk()
|
||||
->assertJsonCount(12)
|
||||
->assertJsonPath('0.id', 1)
|
||||
->assertJsonPath('0.name', 'Game 1');
|
||||
}
|
||||
|
||||
public function test_history_returns_score_evolution_for_a_game(): void
|
||||
{
|
||||
$this->getJsonWithJwt('/api/v1/rankings/history/5')
|
||||
@@ -77,31 +68,6 @@ class GameRankingApiTest extends TestCase
|
||||
->assertJsonPath('history.2.points', 50000);
|
||||
}
|
||||
|
||||
public function test_history_can_be_requested_with_query_string_id(): void
|
||||
{
|
||||
$this->getJsonWithJwt('/api/v1/rankings/history?id=6')
|
||||
->assertOk()
|
||||
->assertJsonPath('game', 'Game 6')
|
||||
->assertJsonPath('history.0.points', 600);
|
||||
}
|
||||
|
||||
public function test_platform_ranking_returns_only_requested_platform_ordered_by_active_players(): void
|
||||
{
|
||||
$this->getJsonWithJwt('/api/v1/rankings/platforms/Steam')
|
||||
->assertOk()
|
||||
->assertJsonCount(6)
|
||||
->assertJsonPath('0.name', 'Game 12')
|
||||
->assertJsonPath('5.name', 'Game 2')
|
||||
->assertJsonMissing(['platform' => 'Riot Launcher']);
|
||||
}
|
||||
|
||||
public function test_test_auth_route_returns_authenticated_subject(): void
|
||||
{
|
||||
$this->getJsonWithJwt('/api/test-auth')
|
||||
->assertOk()
|
||||
->assertJson(['userId' => 'consumer-project']);
|
||||
}
|
||||
|
||||
public function test_accepts_token_with_audience_array_containing_expected_audience(): void
|
||||
{
|
||||
$this->jwt = $this->makeJwt($this->privateKey, ['other-api', 'ranking-api']);
|
||||
|
||||
Reference in New Issue
Block a user