-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from prolic/master
Implementation, tests, and docs
- Loading branch information
Showing
9 changed files
with
320 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
$finder = Symfony\CS\Finder\DefaultFinder::create() | ||
->in('src') | ||
->in('tests'); | ||
$config = Symfony\CS\Config\Config::create(); | ||
$config->level(null); | ||
$config->fixers( | ||
array( | ||
'braces', | ||
'duplicate_semicolon', | ||
'elseif', | ||
'empty_return', | ||
'encoding', | ||
'eof_ending', | ||
'function_call_space', | ||
'function_declaration', | ||
'indentation', | ||
'join_function', | ||
'line_after_namespace', | ||
'linefeed', | ||
'lowercase_keywords', | ||
'parenthesis', | ||
'multiple_use', | ||
'method_argument_space', | ||
'object_operator', | ||
'php_closing_tag', | ||
'remove_lines_between_uses', | ||
'short_array_syntax', | ||
'short_tag', | ||
'standardize_not_equal', | ||
'trailing_spaces', | ||
'unused_use', | ||
'visibility', | ||
'whitespacy_lines', | ||
) | ||
); | ||
$config->finder($finder); | ||
return $config; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/service-bus. | ||
* (c) 2014-2015 prooph software GmbH <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 09/13/15 - 20:18 | ||
*/ | ||
|
||
namespace Prooph\ServiceBusZfcRbacBridge; | ||
|
||
return [ | ||
'factories' => [ | ||
'\Prooph\ServiceBus\Plugin\Guard\AuthorizationService' => Container\AuthorizationServiceFactory::class | ||
] | ||
]; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="false" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="vendor/autoload.php" | ||
> | ||
<testsuite name="Prooph Service Bus Zfc Rbac Bridge Test Suite"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/service-bus. | ||
* (c) 2014-2015 prooph software GmbH <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 09/13/15 - 19:57 | ||
*/ | ||
|
||
namespace Prooph\ServiceBusZfcRbacBridge; | ||
|
||
use Prooph\ServiceBus\Plugin\Guard\AuthorizationService as AuthorizationServiceInterface; | ||
use ZfcRbac\Service\AuthorizationServiceInterface as ZfcRbacAuthorizationServiceInterface; | ||
|
||
/** | ||
* Class AuthorizationService | ||
* @package Prooph\ServiceBusZfcRbacBridge | ||
*/ | ||
final class AuthorizationService implements AuthorizationServiceInterface | ||
{ | ||
/** | ||
* @var ZfcRbacAuthorizationServiceInterface | ||
*/ | ||
private $zfcRbacAuthorizationService; | ||
|
||
/** | ||
* @param ZfcRbacAuthorizationServiceInterface $zfcRbacAuthorizationService | ||
*/ | ||
public function __construct(ZfcRbacAuthorizationServiceInterface $zfcRbacAuthorizationService) | ||
{ | ||
$this->zfcRbacAuthorizationService = $zfcRbacAuthorizationService; | ||
} | ||
|
||
/** | ||
* Check if the permission is granted to the current identity | ||
* | ||
* @param string $messageName | ||
* @param mixed $context | ||
* @return bool | ||
*/ | ||
public function isGranted($messageName, $context = null) | ||
{ | ||
return $this->zfcRbacAuthorizationService->isGranted($messageName, $context); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/service-bus. | ||
* (c) 2014-2015 prooph software GmbH <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 09/13/15 - 20:00 | ||
*/ | ||
|
||
namespace Prooph\ServiceBusZfcRbacBridge\Container; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use Prooph\ServiceBusZfcRbacBridge\AuthorizationService; | ||
|
||
/** | ||
* Class AuthorizationServiceFactory | ||
* @package Prooph\ServiceBusZfcRbacBridge\Container | ||
*/ | ||
final class AuthorizationServiceFactory | ||
{ | ||
/** | ||
* @param ContainerInterface $container | ||
* @return AuthorizationService | ||
*/ | ||
public function __invoke(ContainerInterface $container) | ||
{ | ||
$zfcRbacAuthorizationService = $container->get('ZfcRbac\Service\AuthorizationService'); | ||
|
||
return new AuthorizationService($zfcRbacAuthorizationService); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/service-bus. | ||
* (c) 2014-2015 prooph software GmbH <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 09/13/15 - 20:16 | ||
*/ | ||
|
||
namespace Prooph\ServiceBusZfcRbacBridgeTest; | ||
|
||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Prooph\ServiceBusZfcRbacBridge\AuthorizationService; | ||
use ZfcRbac\Service\AuthorizationServiceInterface; | ||
|
||
/** | ||
* Class AuthorizationServiceTest | ||
* @package Prooph\ServiceBusZfcRbacBridgeTest | ||
*/ | ||
final class AuthorizationServiceTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_delegates_to_zfc_rbac_authorization_service() | ||
{ | ||
$zfcRbacAuthorizationService = $this->prophesize(AuthorizationServiceInterface::class); | ||
$zfcRbacAuthorizationService->isGranted('foo', 'bar')->willReturn(true); | ||
|
||
$authorizationService = new AuthorizationService($zfcRbacAuthorizationService->reveal()); | ||
|
||
$this->assertTrue($authorizationService->isGranted('foo', 'bar')); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/service-bus. | ||
* (c) 2014-2015 prooph software GmbH <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 09/13/15 - 20:14 | ||
*/ | ||
|
||
namespace Prooph\ServiceBusZfcRbacBridge\Container; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Prooph\ServiceBusZfcRbacBridge\AuthorizationService; | ||
use ZfcRbac\Service\AuthorizationServiceInterface as ZfcRbacAuthorizationService; | ||
|
||
/** | ||
* Class AuthorizationServiceFactoryTest | ||
* @package Prooph\ServiceBusZfcRbacBridge\Container | ||
*/ | ||
final class AuthorizationServiceFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_creates_authorization_service() | ||
{ | ||
$zfcRbacAuthorizationService = $this->prophesize(ZfcRbacAuthorizationService::class); | ||
|
||
$container = $this->prophesize(ContainerInterface::class); | ||
$container->get('ZfcRbac\Service\AuthorizationService')->willReturn($zfcRbacAuthorizationService->reveal()); | ||
|
||
$factory = new AuthorizationServiceFactory(); | ||
|
||
$authorizationService = $factory($container->reveal()); | ||
|
||
$this->assertInstanceOf(AuthorizationService::class, $authorizationService); | ||
} | ||
} |