Skip to content

Commit

Permalink
add custom resource owner service to functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Jan 10, 2022
1 parent e643a20 commit 2114ac9
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/App/ResourceOwner/CustomResourceOwner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the HWIOAuthBundle package.
*
* (c) Hardware Info <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace HWI\Bundle\OAuthBundle\Tests\App\ResourceOwner;

use HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner;

class CustomResourceOwner extends GenericOAuth2ResourceOwner
{
}
15 changes: 15 additions & 0 deletions tests/App/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ services:
class: Symfony\Contracts\HttpClient\HttpClientInterface
public: true

app.custom_resource_owner:
class: HWI\Bundle\OAuthBundle\Tests\App\ResourceOwner\CustomResourceOwner
arguments:
$options: {
access_token_url: 'http://custom/token',
authorization_url: 'http://custom/auth',
infos_url: 'http://custom/info',
client_id: 'client_id',
client_secret: 'client_secret',
}
$name: 'custom'
$storage: '@hwi_oauth.storage.session'

doctrine:
dbal:
driver: pdo_sqlite
Expand Down Expand Up @@ -61,6 +74,8 @@ hwi_oauth:
scope: 'scope=mail-r sdct-r'
options:
refresh_on_expire: true
custom:
service: 'app.custom_resource_owner'

twig:
strict_variables: '%kernel.debug%'
Expand Down
3 changes: 3 additions & 0 deletions tests/App/config/routing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ google_login:

yahoo_login:
path: /check-login/yahoo

custom_login:
path: /check-login/custom
1 change: 1 addition & 0 deletions tests/App/config/security_v4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ security:
resource_owners:
google: '/check-login/google'
yahoo: '/check-login/yahoo'
custom: '/check-login/custom'
login_path: /login
use_forward: false
failure_path: /login
Expand Down
1 change: 1 addition & 0 deletions tests/App/config/security_v5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ security:
resource_owners:
google: '/check-login/google'
yahoo: '/check-login/yahoo'
custom: '/check-login/custom'
login_path: /login
use_forward: false
failure_path: /login
Expand Down
1 change: 1 addition & 0 deletions tests/App/config/security_v5_bc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ security:
resource_owners:
google: '/check-login/google'
yahoo: '/check-login/yahoo'
custom: '/check-login/custom'
login_path: /login
use_forward: false
failure_path: /login
Expand Down
1 change: 1 addition & 0 deletions tests/App/config/security_v6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ security:
resource_owners:
google: '/check-login/google'
yahoo: '/check-login/yahoo'
custom: '/check-login/custom'
login_path: /login
use_forward: false
failure_path: /login
Expand Down
4 changes: 3 additions & 1 deletion tests/Functional/Controller/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function testLoginPage(): void
$response = $client->getResponse();

$this->assertSame(200, $response->getStatusCode(), $response->getContent());
$this->assertSame('google', $crawler->filter('a')->text(), $response->getContent());
$this->assertSame('google', $crawler->filter('a:nth-child(1)')->text(), $response->getContent());
$this->assertSame('yahoo', $crawler->filter('a:nth-child(3)')->text(), $response->getContent());
$this->assertSame('custom', $crawler->filter('a:nth-child(5)')->text(), $response->getContent());
}

public function testRedirectingToRegistrationFormWithError(): void
Expand Down

0 comments on commit 2114ac9

Please sign in to comment.