Skip to content

Commit

Permalink
update with authbucket/oauth2-php:dev-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed Dec 10, 2016
1 parent 232e457 commit db4cb88
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 41 deletions.
23 changes: 10 additions & 13 deletions .php_cs
@@ -1,16 +1,14 @@
<?php

$fixers = [
'-no_empty_lines_after_phpdocs',
'-psr0',
'ordered_use',
'php_unit_construct',
'php_unit_strict',
'phpdoc_order',
'short_array_syntax',
$rules = [
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'no_blank_lines_after_phpdoc' => false,
'ordered_class_elements' => true,
'phpdoc_order' => true,
];

$finder = Symfony\CS\Finder\DefaultFinder::create()
$finder = PhpCsFixer\Finder::create()
->exclude('build')
->exclude('var/cache')
->exclude('var/log')
Expand All @@ -24,8 +22,7 @@ $finder = Symfony\CS\Finder\DefaultFinder::create()
->notName('composer.*')
->notName('phpunit.xml*');

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
return PhpCsFixer\Config::create()
->setUsingCache(false)
->fixers($fixers)
->finder($finder);
->setRules($rules)
->setFinder($finder);
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -35,7 +35,7 @@
"license": "MIT",
"name": "authbucket/oauth2-symfony-bundle",
"require": {
"authbucket/oauth2-php": "~4.1",
"authbucket/oauth2-php": "dev-develop",
"php": ">=5.5.9",
"symfony/framework-bundle": "~2.8|~3.0",
"symfony/monolog-bundle": "~2.8|~3.0",
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/AuthBucketOAuth2Extension.php
Expand Up @@ -49,8 +49,8 @@ public function load(array $configs, ContainerBuilder $container)

$userProvider = $config['user_provider'] ?: null;
if ($userProvider) {
$container->getDefinition('authbucket_oauth2.grant_handler.factory')
->replaceArgument(5, new Reference($userProvider));
$container->getDefinition('security.authentication.listener.token')
->replaceArgument(6, new Reference($userProvider));
}
unset($config['user_provider']);

Expand Down
8 changes: 3 additions & 5 deletions src/Resources/config/services.yml
Expand Up @@ -28,7 +28,6 @@ services:
authbucket_oauth2.response_handler.factory:
class: AuthBucket\OAuth2\ResponseType\ResponseTypeHandlerFactory
arguments:
- "@security.token_storage"
- "@validator"
- "@authbucket_oauth2.model_manager.factory"
- "@authbucket_oauth2.token_handler.factory"
Expand All @@ -37,12 +36,9 @@ services:
authbucket_oauth2.grant_handler.factory:
class: AuthBucket\OAuth2\GrantType\GrantTypeHandlerFactory
arguments:
- "@security.token_storage"
- "@security.encoder_factory"
- "@validator"
- "@authbucket_oauth2.model_manager.factory"
- "@authbucket_oauth2.token_handler.factory"
- ~
- "%authbucket_oauth2.grant_handler%"

authbucket_oauth2.token_handler.factory:
Expand All @@ -62,11 +58,11 @@ services:
authbucket_oauth2.oauth2_controller:
class: AuthBucket\OAuth2\Controller\OAuth2Controller
arguments:
- "@security.token_storage"
- "@validator"
- "@authbucket_oauth2.model_manager.factory"
- "@authbucket_oauth2.response_handler.factory"
- "@authbucket_oauth2.grant_handler.factory"
- "@authbucket_oauth2.token_handler.factory"

security.authentication.provider.token:
class: AuthBucket\OAuth2\Security\Authentication\Provider\TokenProvider
Expand All @@ -82,6 +78,8 @@ services:
- "@security.authentication.manager"
- "@validator"
- "@logger"
- "@security.encoder_factory"
- ~

security.authentication.provider.resource:
class: AuthBucket\OAuth2\Security\Authentication\Provider\ResourceProvider
Expand Down
12 changes: 0 additions & 12 deletions tests/GrantType/GrantTypeHandlerFactoryTest.php
Expand Up @@ -23,12 +23,9 @@ public function testNonExistsGrantTypeHandler()
{
$classes = ['foo' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\GrantType\\NonExistsGrantTypeHandler'];
$factory = new GrantTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('security.encoder_factory'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
null,
$classes
);
}
Expand All @@ -40,12 +37,9 @@ public function testBadAddGrantTypeHandler()
{
$classes = ['foo' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\GrantType\\FooGrantTypeHandler'];
$factory = new GrantTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('security.encoder_factory'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
null,
$classes
);
}
Expand All @@ -57,12 +51,9 @@ public function testBadGetGrantTypeHandler()
{
$classes = ['bar' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\GrantType\\BarGrantTypeHandler'];
$factory = new GrantTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('security.encoder_factory'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
null,
$classes
);
$handler = $factory->getGrantTypeHandler('foo');
Expand All @@ -72,12 +63,9 @@ public function testGoodGetGrantTypeHandler()
{
$classes = ['bar' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\GrantType\\BarGrantTypeHandler'];
$factory = new GrantTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('security.encoder_factory'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
null,
$classes
);
$handler = $factory->getGrantTypeHandler('bar');
Expand Down
7 changes: 5 additions & 2 deletions tests/ResponseType/CodeResponseTypeHandlerTest.php
Expand Up @@ -12,6 +12,7 @@
namespace AuthBucket\Bundle\OAuth2Bundle\Tests\ResponseType;

use AuthBucket\Bundle\OAuth2Bundle\Tests\WebTestCase;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
Expand Down Expand Up @@ -330,6 +331,8 @@ public function testGoodCodeFormSubmit()
'_password' => 'demopassword3',
]);
$client->submit($form);
$cookie = new Cookie($session->getName(), $session->getId());
$client->getCookieJar()->set($cookie);

$parameters = [
'response_type' => 'code',
Expand Down Expand Up @@ -359,7 +362,7 @@ public function testGoodCodeFormSubmitRememberMe()
'_remember_me' => true,
]);
$client->submit($form);
$rememberMe = $client->getCookieJar()->get('REMEMBERME');
$cookie = $client->getCookieJar()->get('REMEMBERME');

// Reuse cookie REMEMBERME for second client.
$parameters = [
Expand All @@ -371,7 +374,7 @@ public function testGoodCodeFormSubmitRememberMe()
];
$server = [];
$client = $this->createClient();
$client->getCookieJar()->get($rememberMe);
$client->getCookieJar()->get($cookie);
$crawler = $client->request('GET', '/demo/authorize', $parameters, [], $server);
$this->assertTrue($client->getResponse()->isRedirect());
}
Expand Down
4 changes: 0 additions & 4 deletions tests/ResponseType/ResponseTypeHandlerFactoryTest.php
Expand Up @@ -23,7 +23,6 @@ public function testNonExistsResponseTypeHandler()
{
$classes = ['foo' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\ResponseType\\NonExistsResponseTypeHandler'];
$factory = new ResponseTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
Expand All @@ -38,7 +37,6 @@ public function testBadAddResponseTypeHandler()
{
$classes = ['foo' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\ResponseType\\FooResponseTypeHandler'];
$factory = new ResponseTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
Expand All @@ -53,7 +51,6 @@ public function testBadGetResponseTypeHandler()
{
$classes = ['bar' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\ResponseType\\BarResponseTypeHandler'];
$factory = new ResponseTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
Expand All @@ -66,7 +63,6 @@ public function testGoodGetResponseTypeHandler()
{
$classes = ['bar' => 'AuthBucket\\Bundle\\OAuth2Bundle\\Tests\\ResponseType\\BarResponseTypeHandler'];
$factory = new ResponseTypeHandlerFactory(
$this->get('security.token_storage'),
$this->get('validator'),
$this->get('authbucket_oauth2.model_manager.factory'),
$this->get('authbucket_oauth2.token_handler.factory'),
Expand Down
7 changes: 5 additions & 2 deletions tests/ResponseType/TokenResponseTypeHandlerTest.php
Expand Up @@ -12,6 +12,7 @@
namespace AuthBucket\Bundle\OAuth2Bundle\Tests\ResponseType;

use AuthBucket\Bundle\OAuth2Bundle\Tests\WebTestCase;
use Symfony\Component\BrowserKit\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage;
Expand Down Expand Up @@ -319,6 +320,8 @@ public function testGoodTokenFormSubmit()
'_password' => 'demopassword3',
]);
$client->submit($form);
$cookie = new Cookie($session->getName(), $session->getId());
$client->getCookieJar()->set($cookie);

$parameters = [
'response_type' => 'token',
Expand Down Expand Up @@ -348,7 +351,7 @@ public function testGoodTokenFormSubmitRememberMe()
'_remember_me' => true,
]);
$client->submit($form);
$rememberMe = $client->getCookieJar()->get('REMEMBERME');
$cookie = $client->getCookieJar()->get('REMEMBERME');

// Reuse cookie REMEMBERME for second client.
$parameters = [
Expand All @@ -360,7 +363,7 @@ public function testGoodTokenFormSubmitRememberMe()
];
$server = [];
$client = $this->createClient();
$client->getCookieJar()->get($rememberMe);
$client->getCookieJar()->get($cookie);
$crawler = $client->request('GET', '/demo/authorize', $parameters, [], $server);
$this->assertTrue($client->getResponse()->isRedirect());
}
Expand Down

0 comments on commit db4cb88

Please sign in to comment.