-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.x] Fix authorization http code (#501)
* fix: [7.x] Use 401 unathorized http code. * fix: wip * fix: adding test * fix: wip * Fix styling * fix: wip * Fix styling Co-authored-by: binaryk <[email protected]>
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Binaryk\LaravelRestify\Tests\Middleware; | ||
|
||
use Binaryk\LaravelRestify\Restify; | ||
use Binaryk\LaravelRestify\Tests\Fixtures\User\UserRepository; | ||
use Binaryk\LaravelRestify\Tests\IntegrationTest; | ||
|
||
class AuthorizeRestifyTest extends IntegrationTest | ||
{ | ||
public function test_unauthorized_http_code_is_401(): void | ||
{ | ||
Restify::$authUsing = fn () => false; | ||
|
||
$this->getJson(UserRepository::route()) | ||
->assertStatus(401); | ||
|
||
Restify::$authUsing = fn () => true; | ||
|
||
$this->getJson(UserRepository::route()) | ||
->assertStatus(200); | ||
} | ||
} |