This repository has been archived by the owner on Jun 13, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed credential persistence and retrieval.
- Loading branch information
1 parent
c83f063
commit 84f7422
Showing
12 changed files
with
171 additions
and
134 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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace Tests\Auth; | ||
|
||
use Base64Url\Base64Url; | ||
use Tests\RegistersPackage; | ||
use Illuminate\Support\Str; | ||
use Tests\Stubs\TestWebAuthnUser; | ||
|
@@ -46,27 +47,27 @@ public function test_retrieves_user_using_credential_id() | |
$user->save(); | ||
|
||
DB::table('web_authn_credentials')->insert([ | ||
'id' => 'test_credential_id', | ||
'user_id' => 1, | ||
'is_enabled' => true, | ||
'type' => 'public_key', | ||
'transports' => json_encode([]), | ||
'attestation_type' => 'none', | ||
'trust_path' => json_encode(['type' => EmptyTrustPath::class]), | ||
'aaguid' => Str::uuid()->toString(), | ||
'public_key' => 'public_key', | ||
'counter' => 0, | ||
'user_handle' => 'test_user_handle', | ||
'created_at' => now()->toDateTimeString(), | ||
'updated_at' => now()->toDateTimeString(), | ||
'id' => 'test_credential_id', | ||
'user_id' => 1, | ||
'is_enabled' => true, | ||
'type' => 'public_key', | ||
'transports' => json_encode([]), | ||
'attestation_type' => 'none', | ||
'trust_path' => json_encode(['type' => EmptyTrustPath::class]), | ||
'aaguid' => Str::uuid()->toString(), | ||
'public_key' => 'public_key', | ||
'counter' => 0, | ||
'user_handle' => 'test_user_handle', | ||
'created_at' => now()->toDateTimeString(), | ||
'updated_at' => now()->toDateTimeString(), | ||
]); | ||
|
||
$retrieved = Auth::createUserProvider('users') | ||
->retrieveByCredentials([ | ||
'id' => 'test_credential_id', | ||
'rawId' => 'something', | ||
'id' => 'test_credential_id', | ||
'rawId' => Base64Url::encode('test_credential_id'), | ||
'response' => ['something'], | ||
'type' => 'public-key' | ||
'type' => 'public-key', | ||
]); | ||
|
||
$this->assertTrue($user->is($retrieved)); | ||
|
@@ -84,7 +85,7 @@ public function test_retrieves_user_using_classic_credentials() | |
|
||
$retrieved = Auth::createUserProvider('users') | ||
->retrieveByCredentials([ | ||
'email' => '[email protected]' | ||
'email' => '[email protected]', | ||
]); | ||
|
||
$this->assertTrue($user->is($retrieved)); | ||
|
@@ -104,7 +105,7 @@ public function test_fails_retrieving_user_using_classic_credentials_without_fal | |
|
||
$retrieved = Auth::createUserProvider('users') | ||
->retrieveByCredentials([ | ||
'email' => '[email protected]' | ||
'email' => '[email protected]', | ||
]); | ||
|
||
$this->assertNull($retrieved); | ||
|
@@ -122,8 +123,8 @@ public function test_validates_user_using_password_fallback() | |
|
||
$result = Auth::createUserProvider('users') | ||
->validateCredentials($user, [ | ||
'name' => 'john', | ||
'password' => 'secret' | ||
'name' => 'john', | ||
'password' => 'secret', | ||
]); | ||
|
||
$this->assertTrue($result); | ||
|
@@ -143,8 +144,8 @@ public function test_fails_using_password_and_fallback_disabled() | |
|
||
$result = Auth::createUserProvider('users') | ||
->validateCredentials($user, [ | ||
'name' => 'john', | ||
'password' => 'secret' | ||
'name' => 'john', | ||
'password' => 'secret', | ||
]); | ||
|
||
$this->assertFalse($result); | ||
|
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
Oops, something went wrong.