Skip to content

Commit

Permalink
Less dumb v2 (#118)
Browse files Browse the repository at this point in the history
* Swagger up

* Publish swagger

* API redirect and cleanup

* API double prefix

* Revert the stupid

* v2

* Testing v2

* More v2
  • Loading branch information
annejan authored Jun 24, 2022
1 parent 2b14449 commit 6b464f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/MchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MchController extends Controller
* List the available devices.
*
* @OA\Get(
* path="/devices",
* path="/mch2022/devices",
* tags={"MCH2022"},
* @OA\Response(response="default",ref="#/components/responses/undocumented")
* )
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function mapWebRoutes()
->group(base_path('routes/weather.php'));
Route::middleware('web')
->namespace($this->namespace)
->prefix('mch2022')
->prefix('v2')
->group(base_path('routes/mch2022.php'));
}
}
30 changes: 15 additions & 15 deletions tests/Feature/Mch20222Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Mch20222Test extends TestCase
*/
public function testMchDevices(): void
{
$response = $this->json('GET', '/mch2022/devices');
$response = $this->json('GET', '/v2/devices');
$response->assertStatus(200)
->assertExactJson([]);

Expand All @@ -36,7 +36,7 @@ public function testMchDevices(): void
/** @var Badge $badge */
$badge = Badge::factory()->create();

$response = $this->json('GET', '/mch2022/devices');
$response = $this->json('GET', '/v2/devices');
$response->assertStatus(200)
->assertExactJson([
[
Expand All @@ -51,7 +51,7 @@ public function testMchDevices(): void
*/
public function testMchDeviceTypes(): void
{
$response = $this->json('GET', '/mch2022/random_device/types');
$response = $this->json('GET', '/v2/random_device/types');
$response->assertStatus(404);

/** @var User $user */
Expand All @@ -60,7 +60,7 @@ public function testMchDeviceTypes(): void
/** @var Badge $badge */
$badge = Badge::factory()->create();

$response = $this->json('GET', '/mch2022/' . $badge->slug . '/types');
$response = $this->json('GET', '/v2/' . $badge->slug . '/types');
$response->assertStatus(200)
->assertExactJson([
[
Expand All @@ -83,7 +83,7 @@ public function testMchDeviceTypes(): void
*/
public function testMchCategories(): void
{
$response = $this->json('GET', '/mch2022/iets/esp32/categories');
$response = $this->json('GET', '/v2/iets/esp32/categories');
$response->assertStatus(404);

/** @var User $user */
Expand All @@ -92,7 +92,7 @@ public function testMchCategories(): void
/** @var Badge $badge */
$badge = Badge::factory()->create();

$response = $this->json('GET', '/mch2022/' . $badge->slug . '/esp32/categories');
$response = $this->json('GET', '/v2/' . $badge->slug . '/esp32/categories');
$response->assertStatus(200)
->assertExactJson([]);

Expand All @@ -105,11 +105,11 @@ public function testMchCategories(): void
/** @var Category $category */
$category = $version->project->category()->first();

$response = $this->json('GET', '/mch2022/' . $badge->slug . '/esp32/categories');
$response = $this->json('GET', '/v2/' . $badge->slug . '/esp32/categories');
$response->assertStatus(200)
->assertExactJson([]);

$response = $this->json('GET', '/mch2022/' . $badge->slug . '/python/categories');
$response = $this->json('GET', '/v2/' . $badge->slug . '/python/categories');
$response->assertStatus(200)
->assertExactJson([
[
Expand All @@ -125,7 +125,7 @@ public function testMchCategories(): void
*/
public function testMchApps(): void
{
$response = $this->json('GET', '/mch2022/iets/app/some_app');
$response = $this->json('GET', '/v2/iets/app/some_app');
$response->assertStatus(404);

/** @var User $user */
Expand All @@ -142,20 +142,20 @@ public function testMchApps(): void
/** @var Category $category */
$category = $version->project->category()->first();

$response = $this->json('GET', '/mch2022/' . $badge->slug . '/python/' . $category->slug . '/iets');
$response = $this->json('GET', '/v2/' . $badge->slug . '/python/' . $category->slug . '/iets');
$response->assertStatus(404);

$response = $this->json(
'GET',
'/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug
'/v2/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug
);
$response->assertStatus(200)
->assertJson([]);
/** @var File $file */
$file = File::factory()->create(['version_id' => $version->id]);
$response = $this->json(
'GET',
'/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug
'/v2/' . $badge->slug . '/python/' . $category->slug . '/' . $version->project->slug
);
$response->assertStatus(200)
->assertJson([
Expand All @@ -168,7 +168,7 @@ public function testMchApps(): void
[
'name' => $file->name,
'url' => url(
'mch2022/' . $badge->slug . '/python/' . $category->slug . '/' .
'v2/' . $badge->slug . '/python/' . $category->slug . '/' .
$version->project->slug . '/' . $file->name
),
'size' => $file->size_of_content
Expand Down Expand Up @@ -199,15 +199,15 @@ public function testMchFile(): void

$response = $this->json(
'GET',
'/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' .
'/v2/' . $badge->slug . '/python/' . $category->slug . '/' .
$version->project->slug . '/random.txt'
);
$response->assertStatus(404)
->assertExactJson(['message' => 'File not found']);

$response = $this->json(
'GET',
'/mch2022/' . $badge->slug . '/python/' . $category->slug . '/' .
'/v2/' . $badge->slug . '/python/' . $category->slug . '/' .
$version->project->slug . '/' . $file->name
);
$response->assertStatus(200)
Expand Down

0 comments on commit 6b464f0

Please sign in to comment.