-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Showing
12 changed files
with
97 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,6 @@ jobs: | |
operating-system: | ||
- "ubuntu-latest" | ||
php-version: | ||
- "8.1" | ||
- "8.2" | ||
- "8.3" | ||
dependencies: | ||
|
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
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 |
---|---|---|
|
@@ -35,28 +35,16 @@ | |
*/ | ||
final class AdditionalAuthenticatorTest extends WebTestCase | ||
{ | ||
private KernelBrowser $client; | ||
|
||
private OptionsStorage $storage; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->client = static::createClient([], [ | ||
'HTTPS' => 'on', | ||
]); | ||
|
||
$this->storage = static::getContainer()->get(CustomSessionStorage::class); | ||
} | ||
|
||
#[Test] | ||
public function anExistingUserCanAskForOptionsUsingTheDedicatedController(): void | ||
{ | ||
$this->logIn(); | ||
$this->client->request(Request::METHOD_POST, '/devices/add/options', [], [], [ | ||
$client = static::createClient([], ['HTTPS' => 'on']); | ||
$this->logIn($client); | ||
$client->request(Request::METHOD_POST, '/devices/add/options', [], [], [ | ||
'CONTENT_TYPE' => 'application/json', | ||
'HTTP_HOST' => 'test.com', | ||
], json_encode([], JSON_THROW_ON_ERROR)); | ||
$response = $this->client->getResponse(); | ||
$response = $client->getResponse(); | ||
$data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); | ||
|
||
static::assertResponseIsSuccessful(); | ||
|
@@ -92,11 +80,12 @@ public function thePublicKeyCredentialDataCanBeLoaded(): void | |
#[Depends('thePublicKeyCredentialDataCanBeLoaded')] | ||
public function withTheOptionAnExistingUserCanRegisterNewAnotherAuthenticator(): void | ||
{ | ||
$client = static::createClient([], ['HTTPS' => 'on']); | ||
/** @var PublicKeyCredentialSourceRepository $publicKeyCredentialSourceRepository */ | ||
$publicKeyCredentialSourceRepository = self::$kernel | ||
->getContainer() | ||
->get(PublicKeyCredentialSourceRepository::class); | ||
$this->logIn(); | ||
$this->logIn($client); | ||
|
||
$publicKeyCredentialUserEntity = PublicKeyCredentialUserEntity::create('[email protected]', random_bytes( | ||
64 | ||
|
@@ -112,7 +101,8 @@ public function withTheOptionAnExistingUserCanRegisterNewAnotherAuthenticator(): | |
[PublicKeyCredentialParameters::create('public-key', Algorithms::COSE_ALGORITHM_ES256)] | ||
); | ||
|
||
$this->storage->store(Item::create( | ||
$storage = static::getContainer()->get(CustomSessionStorage::class); | ||
$storage->store(Item::create( | ||
$publicKeyCredentialCreationOptions, | ||
$publicKeyCredentialCreationOptions->user | ||
)); | ||
|
@@ -124,7 +114,7 @@ public function withTheOptionAnExistingUserCanRegisterNewAnotherAuthenticator(): | |
$publicKeyCredentialSourceRepository->findAllForUserEntity($publicKeyCredentialCreationOptions->user) | ||
); | ||
$body = '{"id":"mMihuIx9LukswxBOMjMHDf6EAONOy7qdWhaQQ7dOtViR2cVB_MNbZxURi2cvgSvKSILb3mISe9lPNG9sYgojuY5iNinYOg6hRVxmm0VssuNG2pm1-RIuTF9DUtEJZEEK","type":"public-key","rawId":"mMihuIx9LukswxBOMjMHDf6EAONOy7qdWhaQQ7dOtViR2cVB/MNbZxURi2cvgSvKSILb3mISe9lPNG9sYgojuY5iNinYOg6hRVxmm0VssuNG2pm1+RIuTF9DUtEJZEEK","response":{"clientDataJSON":"eyJjaGFsbGVuZ2UiOiI5V3FncFJJWXZHTUNVWWlGVDIwbzFVN2hTRDE5M2sxMXp1NHRLUDd3UmNyRTI2enMxemM0TEh5UGludlBHUzg2d3U2YkR2cHdidDhYcDJiUTNWQlJTUSIsImNsaWVudEV4dGVuc2lvbnMiOnt9LCJoYXNoQWxnb3JpdGhtIjoiU0hBLTI1NiIsIm9yaWdpbiI6Imh0dHBzOi8vbG9jYWxob3N0Ojg0NDMiLCJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0","attestationObject":"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjkSZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2NBAAAAAAAAAAAAAAAAAAAAAAAAAAAAYJjIobiMfS7pLMMQTjIzBw3+hADjTsu6nVoWkEO3TrVYkdnFQfzDW2cVEYtnL4ErykiC295iEnvZTzRvbGIKI7mOYjYp2DoOoUVcZptFbLLjRtqZtfkSLkxfQ1LRCWRBCqUBAgMmIAEhWCAcPxwKyHADVjTgTsat4R/Jax6PWte50A8ZasMm4w6RxCJYILt0FCiGwC6rBrh3ySNy0yiUjZpNGAhW+aM9YYyYnUTJ"}}'; | ||
$this->client->request( | ||
$client->request( | ||
Request::METHOD_POST, | ||
'/devices/add', | ||
[], | ||
|
@@ -135,7 +125,7 @@ public function withTheOptionAnExistingUserCanRegisterNewAnotherAuthenticator(): | |
], | ||
$body | ||
); | ||
$response = $this->client->getResponse(); | ||
$response = $client->getResponse(); | ||
$data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); | ||
|
||
static::assertResponseStatusCodeSame(201); | ||
|
@@ -155,12 +145,13 @@ public function withTheOptionAnExistingUserCanRegisterNewAnotherAuthenticator(): | |
#[Test] | ||
public function anExistingUserCanGetOptionsTestItsAuthenticators(): void | ||
{ | ||
$this->logIn(); | ||
$this->client->request(Request::METHOD_POST, '/devices/test/options', [], [], [ | ||
$client = static::createClient([], ['HTTPS' => 'on']); | ||
$this->logIn($client); | ||
$client->request(Request::METHOD_POST, '/devices/test/options', [], [], [ | ||
'CONTENT_TYPE' => 'application/json', | ||
'HTTP_HOST' => 'test.com', | ||
], json_encode([], JSON_THROW_ON_ERROR)); | ||
$response = $this->client->getResponse(); | ||
$response = $client->getResponse(); | ||
$data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); | ||
|
||
static::assertResponseIsSuccessful(); | ||
|
@@ -172,7 +163,7 @@ public function anExistingUserCanGetOptionsTestItsAuthenticators(): void | |
static::assertSame('ok', $data['status']); | ||
} | ||
|
||
private function logIn(): void | ||
private function logIn(KernelBrowser $client): void | ||
{ | ||
/** @var SerializerInterface $serializer */ | ||
$serializer = static::getContainer()->get(SerializerInterface::class); | ||
|
@@ -231,13 +222,13 @@ private function logIn(): void | |
$domains = array_unique( | ||
array_map( | ||
static fn (Cookie $cookie) => $cookie->getName() === $session->getName() ? $cookie->getDomain() : '', | ||
$this->client->getCookieJar() | ||
$client->getCookieJar() | ||
->all() | ||
) | ||
) ?: ['']; | ||
foreach ($domains as $domain) { | ||
$cookie = new Cookie($session->getName(), $session->getId(), null, null, $domain); | ||
$this->client->getCookieJar() | ||
$client->getCookieJar() | ||
->set($cookie); | ||
} | ||
} | ||
|
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.