-
-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.x] Ability to disable CP authentication (#8960)
Co-authored-by: edalzell <[email protected]> Co-authored-by: Jason Varga <[email protected]>
- Loading branch information
1 parent
a53391d
commit 7ace3c1
Showing
7 changed files
with
84 additions
and
12 deletions.
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
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
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
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,37 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use PHPUnit\Framework\Attributes\Test; | ||
use Tests\TestCase; | ||
|
||
class AuthenticationTest extends TestCase | ||
{ | ||
#[Test] | ||
public function it_responds_with_a_401_when_requesting_json() | ||
{ | ||
$this->getJson('/cp/anything')->assertStatus(401)->assertJson(['message' => 'Unauthenticated.']); | ||
} | ||
|
||
#[Test] | ||
public function redirects_to_login_page() | ||
{ | ||
$this->get('/cp/anything')->assertRedirect('/cp/auth/login'); | ||
} | ||
|
||
#[Test] | ||
public function redirects_to_defined_login_page_when_auth_is_disabled() | ||
{ | ||
config(['statamic.cp.auth' => ['enabled' => false, 'redirect_to' => '/my-login-page']]); | ||
|
||
$this->get('/cp/anything')->assertRedirect('/my-login-page'); | ||
} | ||
|
||
#[Test] | ||
public function responds_with_401_when_auth_is_disabled_and_no_redirect_is_defined() | ||
{ | ||
config(['statamic.cp.auth' => ['enabled' => false]]); | ||
|
||
$this->get('/cp/anything')->assertStatus(401); | ||
} | ||
} |