-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6cef9c
commit cf45fd6
Showing
11 changed files
with
159 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,4 @@ | |
|
||
use Exception; | ||
|
||
class MissingCode extends Exception | ||
{ | ||
} | ||
class MissingCode extends Exception {} |
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,45 @@ | ||
<?php | ||
|
||
namespace Empuxa\TotpLogin\Tests\Unit; | ||
|
||
use Empuxa\TotpLogin\Requests\CodeRequest; | ||
use Illuminate\Support\Facades\Config; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class HandleCodeRequestTest extends TestCase | ||
{ | ||
public function test_runs_on_allowed_environment(): void | ||
{ | ||
Config::set('totp-login.superpin.pin', 333333); | ||
Config::set('totp-login.superpin.environments', ['production']); | ||
|
||
$data = [ | ||
'production' => true, | ||
'prod*' => false, | ||
'staging' => false, | ||
'testing' => false, | ||
'local' => false, | ||
]; | ||
|
||
foreach ($data as $environment => $expected) { | ||
$this->assertEquals($expected, CodeRequest::runsOnAllowedEnvironment($environment), $environment); | ||
} | ||
} | ||
|
||
public function test_bypasses_environment(): void | ||
{ | ||
Config::set('totp-login.superpin.pin', 333333); | ||
Config::set('totp-login.superpin.environments', ['non-existing']); | ||
Config::set('totp-login.superpin.bypassing_identifiers', ['test@example.com']); | ||
|
||
$data = [ | ||
'test@example.com' => true, | ||
'test@*' => false, | ||
'test2@example.com' => false, | ||
]; | ||
|
||
foreach ($data as $email => $expected) { | ||
$this->assertEquals($expected, CodeRequest::bypassesEnvironment($email), $email); | ||
} | ||
} | ||
} |