Skip to content

Commit

Permalink
Custom routes tested
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed May 9, 2022
1 parent 527211a commit 81599c6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
19 changes: 10 additions & 9 deletions tests/symfony/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,18 @@ security:
registration:
enabled: true
# profile: default
# routes:
routes:
# host: null
# options_path: '/register/options'
# result_path: '/register'
options_path: '/api/register/options'
result_path: '/api/register'
# options_handler: DefaultCreationOptionsHandler::class
# authentication:
# enabled: true
authentication:
enabled: true
# profile: default
# routes:
routes:
# host: null
# options_path: '/login/options'
# result_path: '/login'
options_path: '/api/login/options'
result_path: '/api/login'
# options_handler: DefaultRequestOptionsHandler::class
logout:
path: /logout
Expand All @@ -239,7 +239,8 @@ security:
access_control:
- { path: ^/devices/add, roles: ROLE_USER, requires_channel: https }
- { path: ^/logout, roles: PUBLIC_ACCESS , requires_channel: https }
- { path: ^/login, roles: PUBLIC_ACCESS , requires_channel: https }
- { path: ^/api/login, roles: PUBLIC_ACCESS , requires_channel: https }
- { path: ^/api/register, roles: PUBLIC_ACCESS , requires_channel: https }
- { path: ^/admin, roles: 'ROLE_ADMIN', requires_channel: https }
- { path: ^/page, roles: 'ROLE_USER', requires_channel: https }
- { path: ^/, roles: PUBLIC_ACCESS , requires_channel: https }
16 changes: 8 additions & 8 deletions tests/symfony/functional/Firewall/RegistrationAreaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function aRequestWithoutUsernameCannotBeProcessed(): void
$content = [
'displayName' => 'FOO',
];
$this->client->request(Request::METHOD_POST, '/register/options', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register/options', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
], json_encode($content));
Expand All @@ -70,7 +70,7 @@ public function aRequestWithoutDisplayNameCannotBeProcessed(): void
$content = [
'username' => 'foo',
];
$this->client->request(Request::METHOD_POST, '/register/options', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register/options', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
], json_encode($content));
Expand Down Expand Up @@ -99,7 +99,7 @@ public function aValidRequestProcessed(): void
],
'attestation' => 'indirect',
];
$this->client->request(Request::METHOD_POST, '/register/options', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register/options', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
], json_encode($content));
Expand Down Expand Up @@ -135,7 +135,7 @@ public function aValidRequestProcessedOnOtherHost(): void
'requireResidentKey' => true,
],
];
$this->client->request(Request::METHOD_POST, '/register/options', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register/options', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'foo.com',
], json_encode($content));
Expand Down Expand Up @@ -176,7 +176,7 @@ public function aValidRequestProcessedWithExtensions(): void
'def' => '123',
],
];
$this->client->request(Request::METHOD_POST, '/register/options', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register/options', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
], json_encode($content));
Expand Down Expand Up @@ -214,7 +214,7 @@ public function aRegistrationOptionsRequestCanBeAcceptedForExistingUsers(): void
'username' => 'admin',
'displayName' => 'Admin',
];
$this->client->request(Request::METHOD_POST, '/register/options', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register/options', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
], json_encode($content));
Expand All @@ -233,7 +233,7 @@ public function aRegistrationResultRequestCannotBeAcceptedIfNoOptionsAreAvailabl
{
$content = '{"id":"mMihuIx9LukswxBOMjMHDf6EAONOy7qdWhaQQ7dOtViR2cVB_MNbZxURi2cvgSvKSILb3mISe9lPNG9sYgojuY5iNinYOg6hRVxmm0VssuNG2pm1-RIuTF9DUtEJZEEK","type":"public-key","rawId":"mMihuIx9LukswxBOMjMHDf6EAONOy7qdWhaQQ7dOtViR2cVB/MNbZxURi2cvgSvKSILb3mISe9lPNG9sYgojuY5iNinYOg6hRVxmm0VssuNG2pm1+RIuTF9DUtEJZEEK","response":{"clientDataJSON":"eyJjaGFsbGVuZ2UiOiI5V3FncFJJWXZHTUNVWWlGVDIwbzFVN2hTRDE5M2sxMXp1NHRLUDd3UmNyRTI2enMxemM0TEh5UGludlBHUzg2d3U2YkR2cHdidDhYcDJiUTNWQlJTUSIsImNsaWVudEV4dGVuc2lvbnMiOnt9LCJoYXNoQWxnb3JpdGhtIjoiU0hBLTI1NiIsIm9yaWdpbiI6Imh0dHBzOi8vbG9jYWxob3N0Ojg0NDMiLCJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIn0=","attestationObject":"o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVjkSZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2NBAAAAAAAAAAAAAAAAAAAAAAAAAAAAYJjIobiMfS7pLMMQTjIzBw3+hADjTsu6nVoWkEO3TrVYkdnFQfzDW2cVEYtnL4ErykiC295iEnvZTzRvbGIKI7mOYjYp2DoOoUVcZptFbLLjRtqZtfkSLkxfQ1LRCWRBCqUBAgMmIAEhWCAcPxwKyHADVjTgTsat4R/Jax6PWte50A8ZasMm4w6RxCJYILt0FCiGwC6rBrh3ySNy0yiUjZpNGAhW+aM9YYyYnUTJ"}}';

$this->client->request(Request::METHOD_POST, '/register', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
], $content);
Expand Down Expand Up @@ -276,7 +276,7 @@ public function aValidRegistrationResultRequestIsCorrectlyManaged(): void

$this->storage->store(Item::create($publicKeyCredentialCreationOptions, $publicKeyCredentialUserEntity));

$this->client->request(Request::METHOD_POST, '/register', [], [], [
$this->client->request(Request::METHOD_POST, '/api/register', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'localhost',
], $content);
Expand Down
6 changes: 3 additions & 3 deletions tests/symfony/functional/Firewall/SecuredAreaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function aClientCanSubmitUsernameToGetWebauthnOptions(): void
$body = [
'username' => 'admin',
];
$this->client->request('POST', '/login/options', [], [], [
$this->client->request('POST', '/api/login/options', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
'HTTPS' => 'on',
Expand All @@ -76,7 +76,7 @@ public function aUserCannotBeBeAuthenticatedInAbsenceOfOptions(): void
{
$assertion = '{"id":"eHouz_Zi7-BmByHjJ_tx9h4a1WZsK4IzUmgGjkhyOodPGAyUqUp_B9yUkflXY3yHWsNtsrgCXQ3HjAIFUeZB-w","type":"public-key","rawId":"eHouz/Zi7+BmByHjJ/tx9h4a1WZsK4IzUmgGjkhyOodPGAyUqUp/B9yUkflXY3yHWsNtsrgCXQ3HjAIFUeZB+w==","response":{"authenticatorData":"SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAAew==","clientDataJSON":"eyJjaGFsbGVuZ2UiOiJHMEpiTExuZGVmM2EwSXkzUzJzU1FBOHVPNFNPX3plNkZaTUF1UEk2LXhJIiwiY2xpZW50RXh0ZW5zaW9ucyI6e30sImhhc2hBbGdvcml0aG0iOiJTSEEtMjU2Iiwib3JpZ2luIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6ODQ0MyIsInR5cGUiOiJ3ZWJhdXRobi5nZXQifQ==","signature":"MEUCIEY/vcNkbo/LdMTfLa24ZYLlMMVMRd8zXguHBvqud9AJAiEAwCwpZpvcMaqCrwv85w/8RGiZzE+gOM61ffxmgEDeyhM=","userHandle":null}}';

$this->client->request('POST', '/login', [], [], [
$this->client->request('POST', '/api/login', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'test.com',
], $assertion);
Expand Down Expand Up @@ -114,7 +114,7 @@ public function aUserCanBeAuthenticatedAndAccessToTheProtectedResource(): void

$assertion = '{"id":"eHouz_Zi7-BmByHjJ_tx9h4a1WZsK4IzUmgGjkhyOodPGAyUqUp_B9yUkflXY3yHWsNtsrgCXQ3HjAIFUeZB-w","type":"public-key","rawId":"eHouz/Zi7+BmByHjJ/tx9h4a1WZsK4IzUmgGjkhyOodPGAyUqUp/B9yUkflXY3yHWsNtsrgCXQ3HjAIFUeZB+w==","response":{"authenticatorData":"SZYN5YgOjGh0NBcPZHZgW4/krrmihjLHmVzzuoMdl2MBAAAAew==","clientDataJSON":"eyJjaGFsbGVuZ2UiOiJHMEpiTExuZGVmM2EwSXkzUzJzU1FBOHVPNFNPX3plNkZaTUF1UEk2LXhJIiwiY2xpZW50RXh0ZW5zaW9ucyI6e30sImhhc2hBbGdvcml0aG0iOiJTSEEtMjU2Iiwib3JpZ2luIjoiaHR0cHM6Ly9sb2NhbGhvc3Q6ODQ0MyIsInR5cGUiOiJ3ZWJhdXRobi5nZXQifQ==","signature":"MEUCIEY/vcNkbo/LdMTfLa24ZYLlMMVMRd8zXguHBvqud9AJAiEAwCwpZpvcMaqCrwv85w/8RGiZzE+gOM61ffxmgEDeyhM=","userHandle":null}}';

$this->client->request('POST', '/login', [], [], [
$this->client->request('POST', '/api/login', [], [], [
'CONTENT_TYPE' => 'application/json',
'HTTP_HOST' => 'localhost',
], $assertion);
Expand Down

0 comments on commit 81599c6

Please sign in to comment.