Skip to content

Commit

Permalink
feat(auth): add logout route (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasalexandre9 authored May 17, 2022
1 parent 0eac7ca commit 369394a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions routes/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Route;

Route::get('forest/', [ApiMapsController::class, 'index']);
Route::post('forest/authentication/logout', [AuthController::class, 'logout']);
Route::group(
[
'prefix' => 'forest',
Expand Down
8 changes: 8 additions & 0 deletions src/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public function login()
);
}

/**
* @return \Illuminate\Http\Response
*/
public function logout()
{
return response()->noContent();
}

/**
* @return JsonResponse
* @throws GuzzleException
Expand Down
16 changes: 16 additions & 0 deletions tests/Feature/AuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
Expand All @@ -30,6 +31,8 @@ class AuthControllerTest extends TestCase

/**
* @return void
* @throws \JsonException
* @throws \ReflectionException
*/
public function setUp(): void
{
Expand All @@ -42,6 +45,18 @@ public function setUp(): void
*/
private AuthController $authController;

/**
* @throws GuzzleException
* @throws \JsonException
* @return void
*/
public function testLogout(): void
{
$call = $this->post('forest/authentication/logout');

$this->assertEquals($call->getStatusCode(), Response::HTTP_NO_CONTENT);
}

/**
* @throws GuzzleException
* @throws \JsonException
Expand All @@ -66,6 +81,7 @@ public function testLogin(): void
$this->assertEquals($return, json_decode($login->getContent(), true)['authorizationUrl']);
}


/**
* @throws GuzzleException
* @throws \JsonException
Expand Down

0 comments on commit 369394a

Please sign in to comment.