From e438d735f87c20451ef51423d2249fe70fccd3e0 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 24 Feb 2015 21:35:09 +0100 Subject: [PATCH 01/22] branch v2.3 --- composer.json | 7 +------ readme.md | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 993cb4d3..c18338c0 100644 --- a/composer.json +++ b/composer.json @@ -28,10 +28,5 @@ "autoload": { "classmap": ["src/"] }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.3-dev" - } - } + "minimum-stability": "dev" } diff --git a/readme.md b/readme.md index 29a17251..09abb8d0 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ Nette Security: Access Control ============================== [![Downloads this Month](https://img.shields.io/packagist/dm/nette/security.svg)](https://packagist.org/packages/nette/security) -[![Build Status](https://travis-ci.org/nette/security.svg?branch=master)](https://travis-ci.org/nette/security) +[![Build Status](https://travis-ci.org/nette/security.svg?branch=v2.3)](https://travis-ci.org/nette/security) - user login and logout - verifying user privileges From 77a02c62029fee26e2bfb603ce8c5614fa012e26 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 9 Feb 2015 15:44:21 +0100 Subject: [PATCH 02/22] UserPanel: used vector icon --- src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml b/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml index 38a461a1..cbf9afc3 100644 --- a/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml +++ b/src/Bridges/SecurityTracy/templates/UserPanel.tab.phtml @@ -5,8 +5,6 @@ namespace Nette\Bridges\SecurityTracy; use Nette; ?> -isLoggedIn()): ?> -  - -  - + + + From 2b16f39378c1592488b257eedbde92e72d913290 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 16 Mar 2015 14:30:51 +0100 Subject: [PATCH 03/22] typo --- src/Security/IUserStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Security/IUserStorage.php b/src/Security/IUserStorage.php index f1ed7cbc..62c9dec0 100644 --- a/src/Security/IUserStorage.php +++ b/src/Security/IUserStorage.php @@ -46,7 +46,7 @@ function setIdentity(IIdentity $identity = NULL); /** * Returns current user identity, if any. - * @return Nette\Security\IIdentity|NULL + * @return IIdentity|NULL */ function getIdentity(); From cc53793a42b4731fa3422f6cabe74c2daf6e346d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kar=C3=A1sek?= Date: Sat, 28 Feb 2015 20:33:31 +0100 Subject: [PATCH 04/22] readme.md: md5() replaced with Nette\Security\Passwords::verify() --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 09abb8d0..982b7bb4 100644 --- a/readme.md +++ b/readme.md @@ -120,7 +120,7 @@ class MyAuthenticator extends Nette\Object implements NS\IAuthenticator throw new NS\AuthenticationException('User not found.'); } - if ($row->password !== md5($password)) { + if (!NS\Passwords::verify($password, $row->password)) { throw new NS\AuthenticationException('Invalid password.'); } @@ -129,7 +129,7 @@ class MyAuthenticator extends Nette\Object implements NS\IAuthenticator } ``` -Class `MyAuthenticator` communicates with the database using [Nette\Database |database] layer and works with table `users`, where it grabs `username` and md5 hash of `password` in the appropriate columns. If the password check is successful, it returns new identity with user ID and role, which we will mention [later | #roles]; +Class `MyAuthenticator` communicates with the database using [Nette\Database |database] layer and works with table `users`, where it grabs `username` and hash of `password` in the appropriate columns. If the password check is successful, it returns new identity with user ID and role, which we will mention [later | #roles]; This authenticator would be configured in the `config.neon` file like this: From 6637c417a59a299cae687a28c8e8b64d117b7026 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 27 Mar 2015 18:26:06 +0100 Subject: [PATCH 05/22] travis: added PHP 7.0 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d67b6911..42f64863 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,12 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm matrix: allow_failures: + - php: 7.0 - php: hhvm script: From 0de327cf3077d23ba702c0f74d32fde15ee7400b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 1 Apr 2015 19:22:24 +0200 Subject: [PATCH 06/22] composer: removed --dev --- .travis.yml | 2 +- tests/bootstrap.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 42f64863..e686d783 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,5 +22,5 @@ after_failure: before_script: # Install Nette Tester & Code Checker - - composer install --no-interaction --dev --prefer-source + - composer install --no-interaction --prefer-source - composer create-project nette/code-checker code-checker ~2.3 --no-interaction --prefer-source diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 85f7726f..e333db3d 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,7 +4,7 @@ // invoked through the command: ../vendor/bin/tester . if (@!include __DIR__ . '/../vendor/autoload.php') { - echo 'Install Nette Tester using `composer update --dev`'; + echo 'Install Nette Tester using `composer install`'; exit(1); } From 412275737c520f79cb7f8ff7e10d4fc844b3c10d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 18 Jun 2015 21:26:17 +0200 Subject: [PATCH 07/22] improved coding style --- src/Bridges/SecurityDI/SecurityExtension.php | 2 +- src/Bridges/SecurityTracy/UserPanel.php | 4 +- src/Security/Permission.php | 12 +- src/Security/User.php | 4 +- .../SecurityExtension.authenticator.phpt | 10 +- tests/Security.DI/SecurityExtension.user.phpt | 10 +- tests/Security/Identity.phpt | 8 +- tests/Security/MockUserStorage.php | 7 +- tests/Security/Passwords.hash().phpt | 12 +- tests/Security/Passwords.needsRehash().phpt | 4 +- tests/Security/Passwords.verify().phpt | 4 +- tests/Security/Permission.CMSExample.phpt | 174 +++++++++--------- tests/Security/Permission.DefaultAssert.phpt | 6 +- tests/Security/Permission.DefaultDeny.phpt | 12 +- tests/Security/Permission.DefaultRuleSet.phpt | 12 +- .../Permission.IsAllowedNonExistent.phpt | 8 +- tests/Security/Permission.PrivilegeAllow.phpt | 6 +- .../Security/Permission.PrivilegeAssert.phpt | 8 +- tests/Security/Permission.PrivilegeDeny.phpt | 6 +- tests/Security/Permission.Privileges.phpt | 18 +- .../Permission.RemoveDefaultAllow.phpt | 8 +- ...mission.RemoveDefaultAllowNonExistent.phpt | 6 +- .../Permission.RemoveDefaultDeny.phpt | 8 +- .../Permission.RemoveDefaultDenyAssert.phpt | 8 +- ...rmission.RemoveDefaultDenyNonExistent.phpt | 6 +- ...AfterItWasAllowedAccessToAllResources.phpt | 6 +- .../Permission.ResourceAddAndGetOne.phpt | 10 +- ...ission.ResourceAddInheritsNonExistent.phpt | 6 +- .../Permission.ResourceDuplicate.phpt | 6 +- .../Security/Permission.ResourceInherits.phpt | 22 +-- ...ermission.ResourceInheritsNonExistent.phpt | 8 +- .../Permission.ResourceRemoveAll.phpt | 6 +- ...rmission.ResourceRemoveOneNonExistent.phpt | 6 +- ...DefaultAllowRuleWithPrivilegeDenyRule.phpt | 6 +- ...eDefaultAllowRuleWithResourceDenyRule.phpt | 8 +- .../Permission.RoleDefaultRuleSet.phpt | 8 +- ...ermission.RoleDefaultRuleSetPrivilege.phpt | 8 +- .../Permission.RolePrivilegeAllow.phpt | 6 +- .../Permission.RolePrivilegeAssert.phpt | 8 +- .../Permission.RolePrivilegeDeny.phpt | 6 +- tests/Security/Permission.RolePrivileges.phpt | 18 +- .../Permission.RoleRegistryAddAndGetOne.phpt | 10 +- ...on.RoleRegistryAddInheritsNonExistent.phpt | 6 +- .../Permission.RoleRegistryDuplicate.phpt | 6 +- .../Permission.RoleRegistryInherits.phpt | 30 +-- ...rmission.RoleRegistryInheritsMultiple.phpt | 16 +- ...ssion.RoleRegistryInheritsNonExistent.phpt | 8 +- .../Permission.RoleRegistryRemoveAll.phpt | 6 +- ...sion.RoleRegistryRemoveOneNonExistent.phpt | 6 +- tests/Security/Permission.RuleRoleRemove.phpt | 10 +- .../Permission.RuleRoleRemoveAll.phpt | 10 +- tests/Security/Permission.RulesRemove.phpt | 14 +- .../Permission.RulesResourceRemove.phpt | 10 +- .../Permission.RulesResourceRemoveAll.phpt | 10 +- tests/Security/SimpleAuthenticator.Roles.phpt | 14 +- tests/Security/SimpleAuthenticator.phpt | 12 +- tests/Security/User.authentication.phpt | 52 +++--- tests/Security/User.authorization.phpt | 32 ++-- 58 files changed, 377 insertions(+), 376 deletions(-) diff --git a/src/Bridges/SecurityDI/SecurityExtension.php b/src/Bridges/SecurityDI/SecurityExtension.php index 82c6713d..bf260c90 100644 --- a/src/Bridges/SecurityDI/SecurityExtension.php +++ b/src/Bridges/SecurityDI/SecurityExtension.php @@ -48,7 +48,7 @@ public function loadConfiguration() if ($this->debugMode && $config['debugger']) { $user->addSetup('@Tracy\Bar::addPanel', array( - new Nette\DI\Statement('Nette\Bridges\SecurityTracy\UserPanel') + new Nette\DI\Statement('Nette\Bridges\SecurityTracy\UserPanel'), )); } diff --git a/src/Bridges/SecurityTracy/UserPanel.php b/src/Bridges/SecurityTracy/UserPanel.php index e25f40a5..63fe63c8 100644 --- a/src/Bridges/SecurityTracy/UserPanel.php +++ b/src/Bridges/SecurityTracy/UserPanel.php @@ -7,8 +7,8 @@ namespace Nette\Bridges\SecurityTracy; -use Nette, - Tracy; +use Nette; +use Tracy; /** diff --git a/src/Security/Permission.php b/src/Security/Permission.php index ca1ace7d..26c120d1 100644 --- a/src/Security/Permission.php +++ b/src/Security/Permission.php @@ -84,7 +84,7 @@ public function addRole($role, $parents = NULL) } $this->roles[$role] = array( - 'parents' => $roleParents, + 'parents' => $roleParents, 'children' => array(), ); @@ -264,8 +264,8 @@ public function addResource($resource, $parent = NULL) } $this->resources[$resource] = array( - 'parent' => $parent, - 'children' => array() + 'parent' => $parent, + 'children' => array(), ); return $this; @@ -552,10 +552,10 @@ protected function setRule($toAdd, $type, $roles, $resources, $privileges, $asse $rules = array( 'allPrivileges' => array( 'type' => self::DENY, - 'assert' => NULL + 'assert' => NULL, ), - 'byPrivilege' => array() - ); + 'byPrivilege' => array(), + ); } continue; } diff --git a/src/Security/User.php b/src/Security/User.php index e96209de..1a0989b9 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -37,10 +37,10 @@ class User extends Nette\Object /** @var string default role for authenticated user without own identity */ public $authenticatedRole = 'authenticated'; - /** @var callable[] function(User $sender); Occurs when the user is successfully logged in */ + /** @var callable[] function (User $sender); Occurs when the user is successfully logged in */ public $onLoggedIn; - /** @var callable[] function(User $sender); Occurs when the user is logged out */ + /** @var callable[] function (User $sender); Occurs when the user is logged out */ public $onLoggedOut; /** @var IUserStorage Session storage for current user */ diff --git a/tests/Security.DI/SecurityExtension.authenticator.phpt b/tests/Security.DI/SecurityExtension.authenticator.phpt index 46938f13..ef6e98d4 100644 --- a/tests/Security.DI/SecurityExtension.authenticator.phpt +++ b/tests/Security.DI/SecurityExtension.authenticator.phpt @@ -4,11 +4,11 @@ * Test: SecurityExtension */ -use Nette\DI, - Nette\Bridges\HttpDI\HttpExtension, - Nette\Bridges\HttpDI\SessionExtension, - Nette\Bridges\SecurityDI\SecurityExtension, - Tester\Assert; +use Nette\DI; +use Nette\Bridges\HttpDI\HttpExtension; +use Nette\Bridges\HttpDI\SessionExtension; +use Nette\Bridges\SecurityDI\SecurityExtension; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Security.DI/SecurityExtension.user.phpt b/tests/Security.DI/SecurityExtension.user.phpt index 4690919e..b93d92e5 100644 --- a/tests/Security.DI/SecurityExtension.user.phpt +++ b/tests/Security.DI/SecurityExtension.user.phpt @@ -4,11 +4,11 @@ * Test: SecurityExtension */ -use Nette\DI, - Nette\Bridges\HttpDI\HttpExtension, - Nette\Bridges\HttpDI\SessionExtension, - Nette\Bridges\SecurityDI\SecurityExtension, - Tester\Assert; +use Nette\DI; +use Nette\Bridges\HttpDI\HttpExtension; +use Nette\Bridges\HttpDI\SessionExtension; +use Nette\Bridges\SecurityDI\SecurityExtension; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Security/Identity.phpt b/tests/Security/Identity.phpt index 62ab3671..942250f5 100644 --- a/tests/Security/Identity.phpt +++ b/tests/Security/Identity.phpt @@ -4,14 +4,14 @@ * Test: Nette\Security\Identity. */ -use Nette\Security\Identity, - Tester\Assert; +use Nette\Security\Identity; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -test(function() { +test(function () { $id = new Identity(12, 'admin', array('name' => 'John')); Assert::same(12, $id->getId()); @@ -23,7 +23,7 @@ test(function() { }); -test(function() { +test(function () { $id = new Identity('12'); Assert::same(12, $id->getId()); diff --git a/tests/Security/MockUserStorage.php b/tests/Security/MockUserStorage.php index 4a9824c7..57dc6b97 100644 --- a/tests/Security/MockUserStorage.php +++ b/tests/Security/MockUserStorage.php @@ -26,9 +26,10 @@ function getIdentity() } function setExpiration($time, $flags = 0) - {} + { + } function getLogoutReason() - {} - + { + } } diff --git a/tests/Security/Passwords.hash().phpt b/tests/Security/Passwords.hash().phpt index af1e511c..6d016b3c 100644 --- a/tests/Security/Passwords.hash().phpt +++ b/tests/Security/Passwords.hash().phpt @@ -5,8 +5,8 @@ * @phpversion 5.3.7 */ -use Nette\Security\Passwords, - Tester\Assert; +use Nette\Security\Passwords; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -24,17 +24,17 @@ Assert::truthy( echo $h; $hash = Passwords::hash('dg'); -Assert::same( $hash, crypt('dg', $hash) ); +Assert::same($hash, crypt('dg', $hash)); -Assert::exception(function() { +Assert::exception(function () { Passwords::hash('dg', array('cost' => 3)); }, 'Nette\InvalidArgumentException', 'Cost must be in range 4-31, 3 given.'); -Assert::exception(function() { +Assert::exception(function () { Passwords::hash('dg', array('cost' => 32)); }, 'Nette\InvalidArgumentException', 'Cost must be in range 4-31, 32 given.'); -Assert::exception(function() { +Assert::exception(function () { Passwords::hash('dg', array('salt' => 'abc')); }, 'Nette\InvalidArgumentException', 'Salt must be 22 characters long, 3 given.'); diff --git a/tests/Security/Passwords.needsRehash().phpt b/tests/Security/Passwords.needsRehash().phpt index d86a4ce5..261a481b 100644 --- a/tests/Security/Passwords.needsRehash().phpt +++ b/tests/Security/Passwords.needsRehash().phpt @@ -5,8 +5,8 @@ * @phpversion 5.3.7 */ -use Nette\Security\Passwords, - Tester\Assert; +use Nette\Security\Passwords; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Security/Passwords.verify().phpt b/tests/Security/Passwords.verify().phpt index e2ad0ddf..ec6d16fc 100644 --- a/tests/Security/Passwords.verify().phpt +++ b/tests/Security/Passwords.verify().phpt @@ -5,8 +5,8 @@ * @phpversion 5.3.7 */ -use Nette\Security\Passwords, - Tester\Assert; +use Nette\Security\Passwords; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; diff --git a/tests/Security/Permission.CMSExample.phpt b/tests/Security/Permission.CMSExample.phpt index b99598f4..2e43790e 100644 --- a/tests/Security/Permission.CMSExample.phpt +++ b/tests/Security/Permission.CMSExample.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that an example for a content management system is operable. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -31,45 +31,45 @@ $acl->allow('administrator'); // Access control checks based on above permission sets -Assert::true( $acl->isAllowed('guest', NULL, 'view') ); -Assert::false( $acl->isAllowed('guest', NULL, 'edit') ); -Assert::false( $acl->isAllowed('guest', NULL, 'submit') ); -Assert::false( $acl->isAllowed('guest', NULL, 'revise') ); -Assert::false( $acl->isAllowed('guest', NULL, 'publish') ); -Assert::false( $acl->isAllowed('guest', NULL, 'archive') ); -Assert::false( $acl->isAllowed('guest', NULL, 'delete') ); -Assert::false( $acl->isAllowed('guest', NULL, 'unknown') ); -Assert::false( $acl->isAllowed('guest') ); - -Assert::true( $acl->isAllowed('staff', NULL, 'view') ); -Assert::true( $acl->isAllowed('staff', NULL, 'edit') ); -Assert::true( $acl->isAllowed('staff', NULL, 'submit') ); -Assert::true( $acl->isAllowed('staff', NULL, 'revise') ); -Assert::false( $acl->isAllowed('staff', NULL, 'publish') ); -Assert::false( $acl->isAllowed('staff', NULL, 'archive') ); -Assert::false( $acl->isAllowed('staff', NULL, 'delete') ); -Assert::false( $acl->isAllowed('staff', NULL, 'unknown') ); -Assert::false( $acl->isAllowed('staff') ); - -Assert::true( $acl->isAllowed('editor', NULL, 'view') ); -Assert::true( $acl->isAllowed('editor', NULL, 'edit') ); -Assert::true( $acl->isAllowed('editor', NULL, 'submit') ); -Assert::true( $acl->isAllowed('editor', NULL, 'revise') ); -Assert::true( $acl->isAllowed('editor', NULL, 'publish') ); -Assert::true( $acl->isAllowed('editor', NULL, 'archive') ); -Assert::true( $acl->isAllowed('editor', NULL, 'delete') ); -Assert::false( $acl->isAllowed('editor', NULL, 'unknown') ); -Assert::false( $acl->isAllowed('editor') ); - -Assert::true( $acl->isAllowed('administrator', NULL, 'view') ); -Assert::true( $acl->isAllowed('administrator', NULL, 'edit') ); -Assert::true( $acl->isAllowed('administrator', NULL, 'submit') ); -Assert::true( $acl->isAllowed('administrator', NULL, 'revise') ); -Assert::true( $acl->isAllowed('administrator', NULL, 'publish') ); -Assert::true( $acl->isAllowed('administrator', NULL, 'archive') ); -Assert::true( $acl->isAllowed('administrator', NULL, 'delete') ); -Assert::true( $acl->isAllowed('administrator', NULL, 'unknown') ); -Assert::true( $acl->isAllowed('administrator') ); +Assert::true($acl->isAllowed('guest', NULL, 'view')); +Assert::false($acl->isAllowed('guest', NULL, 'edit')); +Assert::false($acl->isAllowed('guest', NULL, 'submit')); +Assert::false($acl->isAllowed('guest', NULL, 'revise')); +Assert::false($acl->isAllowed('guest', NULL, 'publish')); +Assert::false($acl->isAllowed('guest', NULL, 'archive')); +Assert::false($acl->isAllowed('guest', NULL, 'delete')); +Assert::false($acl->isAllowed('guest', NULL, 'unknown')); +Assert::false($acl->isAllowed('guest')); + +Assert::true($acl->isAllowed('staff', NULL, 'view')); +Assert::true($acl->isAllowed('staff', NULL, 'edit')); +Assert::true($acl->isAllowed('staff', NULL, 'submit')); +Assert::true($acl->isAllowed('staff', NULL, 'revise')); +Assert::false($acl->isAllowed('staff', NULL, 'publish')); +Assert::false($acl->isAllowed('staff', NULL, 'archive')); +Assert::false($acl->isAllowed('staff', NULL, 'delete')); +Assert::false($acl->isAllowed('staff', NULL, 'unknown')); +Assert::false($acl->isAllowed('staff')); + +Assert::true($acl->isAllowed('editor', NULL, 'view')); +Assert::true($acl->isAllowed('editor', NULL, 'edit')); +Assert::true($acl->isAllowed('editor', NULL, 'submit')); +Assert::true($acl->isAllowed('editor', NULL, 'revise')); +Assert::true($acl->isAllowed('editor', NULL, 'publish')); +Assert::true($acl->isAllowed('editor', NULL, 'archive')); +Assert::true($acl->isAllowed('editor', NULL, 'delete')); +Assert::false($acl->isAllowed('editor', NULL, 'unknown')); +Assert::false($acl->isAllowed('editor')); + +Assert::true($acl->isAllowed('administrator', NULL, 'view')); +Assert::true($acl->isAllowed('administrator', NULL, 'edit')); +Assert::true($acl->isAllowed('administrator', NULL, 'submit')); +Assert::true($acl->isAllowed('administrator', NULL, 'revise')); +Assert::true($acl->isAllowed('administrator', NULL, 'publish')); +Assert::true($acl->isAllowed('administrator', NULL, 'archive')); +Assert::true($acl->isAllowed('administrator', NULL, 'delete')); +Assert::true($acl->isAllowed('administrator', NULL, 'unknown')); +Assert::true($acl->isAllowed('administrator')); // Some checks on specific areas, which inherit access controls from the root ACL node $acl->addResource('newsletter'); @@ -78,14 +78,14 @@ $acl->addResource('gallery'); $acl->addResource('profiles', 'gallery'); $acl->addResource('config'); $acl->addResource('hosts', 'config'); -Assert::true( $acl->isAllowed('guest', 'pending', 'view') ); -Assert::true( $acl->isAllowed('staff', 'profiles', 'revise') ); -Assert::true( $acl->isAllowed('staff', 'pending', 'view') ); -Assert::true( $acl->isAllowed('staff', 'pending', 'edit') ); -Assert::false( $acl->isAllowed('staff', 'pending', 'publish') ); -Assert::false( $acl->isAllowed('staff', 'pending') ); -Assert::false( $acl->isAllowed('editor', 'hosts', 'unknown') ); -Assert::true( $acl->isAllowed('administrator', 'pending') ); +Assert::true($acl->isAllowed('guest', 'pending', 'view')); +Assert::true($acl->isAllowed('staff', 'profiles', 'revise')); +Assert::true($acl->isAllowed('staff', 'pending', 'view')); +Assert::true($acl->isAllowed('staff', 'pending', 'edit')); +Assert::false($acl->isAllowed('staff', 'pending', 'publish')); +Assert::false($acl->isAllowed('staff', 'pending')); +Assert::false($acl->isAllowed('editor', 'hosts', 'unknown')); +Assert::true($acl->isAllowed('administrator', 'pending')); // Add a new group, marketing, which bases its permissions on staff $acl->addRole('marketing', 'staff'); @@ -109,35 +109,35 @@ $acl->deny(NULL, 'announcement', 'archive'); // Access control checks for the above refined permission sets -Assert::true( $acl->isAllowed('marketing', NULL, 'view') ); -Assert::true( $acl->isAllowed('marketing', NULL, 'edit') ); -Assert::true( $acl->isAllowed('marketing', NULL, 'submit') ); -Assert::true( $acl->isAllowed('marketing', NULL, 'revise') ); -Assert::false( $acl->isAllowed('marketing', NULL, 'publish') ); -Assert::false( $acl->isAllowed('marketing', NULL, 'archive') ); -Assert::false( $acl->isAllowed('marketing', NULL, 'delete') ); -Assert::false( $acl->isAllowed('marketing', NULL, 'unknown') ); -Assert::false( $acl->isAllowed('marketing') ); - -Assert::true( $acl->isAllowed('marketing', 'newsletter', 'publish') ); -Assert::false( $acl->isAllowed('staff', 'pending', 'publish') ); -Assert::true( $acl->isAllowed('marketing', 'pending', 'publish') ); -Assert::true( $acl->isAllowed('marketing', 'newsletter', 'archive') ); -Assert::false( $acl->isAllowed('marketing', 'newsletter', 'delete') ); -Assert::false( $acl->isAllowed('marketing', 'newsletter') ); - -Assert::true( $acl->isAllowed('marketing', 'latest', 'publish') ); -Assert::true( $acl->isAllowed('marketing', 'latest', 'archive') ); -Assert::false( $acl->isAllowed('marketing', 'latest', 'delete') ); -Assert::false( $acl->isAllowed('marketing', 'latest', 'revise') ); -Assert::false( $acl->isAllowed('marketing', 'latest') ); - -Assert::false( $acl->isAllowed('marketing', 'announcement', 'archive') ); -Assert::false( $acl->isAllowed('staff', 'announcement', 'archive') ); -Assert::false( $acl->isAllowed('administrator', 'announcement', 'archive') ); - -Assert::false( $acl->isAllowed('staff', 'latest', 'publish') ); -Assert::false( $acl->isAllowed('editor', 'announcement', 'archive') ); +Assert::true($acl->isAllowed('marketing', NULL, 'view')); +Assert::true($acl->isAllowed('marketing', NULL, 'edit')); +Assert::true($acl->isAllowed('marketing', NULL, 'submit')); +Assert::true($acl->isAllowed('marketing', NULL, 'revise')); +Assert::false($acl->isAllowed('marketing', NULL, 'publish')); +Assert::false($acl->isAllowed('marketing', NULL, 'archive')); +Assert::false($acl->isAllowed('marketing', NULL, 'delete')); +Assert::false($acl->isAllowed('marketing', NULL, 'unknown')); +Assert::false($acl->isAllowed('marketing')); + +Assert::true($acl->isAllowed('marketing', 'newsletter', 'publish')); +Assert::false($acl->isAllowed('staff', 'pending', 'publish')); +Assert::true($acl->isAllowed('marketing', 'pending', 'publish')); +Assert::true($acl->isAllowed('marketing', 'newsletter', 'archive')); +Assert::false($acl->isAllowed('marketing', 'newsletter', 'delete')); +Assert::false($acl->isAllowed('marketing', 'newsletter')); + +Assert::true($acl->isAllowed('marketing', 'latest', 'publish')); +Assert::true($acl->isAllowed('marketing', 'latest', 'archive')); +Assert::false($acl->isAllowed('marketing', 'latest', 'delete')); +Assert::false($acl->isAllowed('marketing', 'latest', 'revise')); +Assert::false($acl->isAllowed('marketing', 'latest')); + +Assert::false($acl->isAllowed('marketing', 'announcement', 'archive')); +Assert::false($acl->isAllowed('staff', 'announcement', 'archive')); +Assert::false($acl->isAllowed('administrator', 'announcement', 'archive')); + +Assert::false($acl->isAllowed('staff', 'latest', 'publish')); +Assert::false($acl->isAllowed('editor', 'announcement', 'archive')); // Remove some previous permission specifications @@ -152,19 +152,19 @@ $acl->removeDeny('staff', 'latest', 'revise'); // Access control checks for the above refinements -Assert::false( $acl->isAllowed('marketing', 'newsletter', 'publish') ); -Assert::false( $acl->isAllowed('marketing', 'newsletter', 'archive') ); +Assert::false($acl->isAllowed('marketing', 'newsletter', 'publish')); +Assert::false($acl->isAllowed('marketing', 'newsletter', 'archive')); -Assert::false( $acl->isAllowed('marketing', 'latest', 'archive') ); +Assert::false($acl->isAllowed('marketing', 'latest', 'archive')); -Assert::true( $acl->isAllowed('staff', 'latest', 'revise') ); -Assert::true( $acl->isAllowed('marketing', 'latest', 'revise') ); +Assert::true($acl->isAllowed('staff', 'latest', 'revise')); +Assert::true($acl->isAllowed('marketing', 'latest', 'revise')); // Grant marketing all permissions on the latest news $acl->allow('marketing', 'latest'); // Access control checks for the above refinement -Assert::true( $acl->isAllowed('marketing', 'latest', 'archive') ); -Assert::true( $acl->isAllowed('marketing', 'latest', 'publish') ); -Assert::true( $acl->isAllowed('marketing', 'latest', 'edit') ); -Assert::true( $acl->isAllowed('marketing', 'latest') ); +Assert::true($acl->isAllowed('marketing', 'latest', 'archive')); +Assert::true($acl->isAllowed('marketing', 'latest', 'publish')); +Assert::true($acl->isAllowed('marketing', 'latest', 'edit')); +Assert::true($acl->isAllowed('marketing', 'latest')); diff --git a/tests/Security/Permission.DefaultAssert.phpt b/tests/Security/Permission.DefaultAssert.phpt index 97646b69..b0d3315e 100644 --- a/tests/Security/Permission.DefaultAssert.phpt +++ b/tests/Security/Permission.DefaultAssert.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that the default rule obeys its assertion. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -19,4 +19,4 @@ function falseAssertion() $acl = new Permission; $acl->deny(NULL, NULL, NULL, 'falseAssertion'); -Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.DefaultDeny.phpt b/tests/Security/Permission.DefaultDeny.phpt index 31003737..2ac4a182 100644 --- a/tests/Security/Permission.DefaultDeny.phpt +++ b/tests/Security/Permission.DefaultDeny.phpt @@ -4,17 +4,17 @@ * Test: Nette\Security\Permission Ensures that by default denies access to everything by all. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::false( $acl->isAllowed() ); -Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed()); +Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege')); $acl->addRole('guest'); -Assert::false( $acl->isAllowed('guest') ); -Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed('guest')); +Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.DefaultRuleSet.phpt b/tests/Security/Permission.DefaultRuleSet.phpt index 6a2e612b..063218b1 100644 --- a/tests/Security/Permission.DefaultRuleSet.phpt +++ b/tests/Security/Permission.DefaultRuleSet.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that ACL-wide rules (all Roles, Resources, and privileges) work properly. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,9 +13,9 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->allow(); -Assert::true( $acl->isAllowed() ); -Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::true($acl->isAllowed()); +Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege')); $acl->deny(); -Assert::false( $acl->isAllowed() ); -Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed()); +Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.IsAllowedNonExistent.phpt b/tests/Security/Permission.IsAllowedNonExistent.phpt index fd2b129f..e7f3b9f7 100644 --- a/tests/Security/Permission.IsAllowedNonExistent.phpt +++ b/tests/Security/Permission.IsAllowedNonExistent.phpt @@ -4,19 +4,19 @@ * Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role and Resource parameters are specified to isAllowed(). */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -Assert::exception(function() { +Assert::exception(function () { $acl = new Permission; $acl->isAllowed('nonexistent'); }, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist."); -Assert::exception(function() { +Assert::exception(function () { $acl = new Permission; $acl->isAllowed(NULL, 'nonexistent'); }, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist."); diff --git a/tests/Security/Permission.PrivilegeAllow.phpt b/tests/Security/Permission.PrivilegeAllow.phpt index f93bd1ca..a5dd2141 100644 --- a/tests/Security/Permission.PrivilegeAllow.phpt +++ b/tests/Security/Permission.PrivilegeAllow.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that a privilege allowed for all Roles upon all Resources works properly. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,4 +13,4 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->allow(NULL, NULL, 'somePrivilege'); -Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.PrivilegeAssert.phpt b/tests/Security/Permission.PrivilegeAssert.phpt index 5a157bd6..557db609 100644 --- a/tests/Security/Permission.PrivilegeAssert.phpt +++ b/tests/Security/Permission.PrivilegeAssert.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that assertions on privileges work properly. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -24,7 +24,7 @@ function trueAssertion() $acl = new Permission; $acl->allow(NULL, NULL, 'somePrivilege', 'trueAssertion'); -Assert::true( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::true($acl->isAllowed(NULL, NULL, 'somePrivilege')); $acl->allow(NULL, NULL, 'somePrivilege', 'falseAssertion'); -Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.PrivilegeDeny.phpt b/tests/Security/Permission.PrivilegeDeny.phpt index 9d82d8cc..01d59d92 100644 --- a/tests/Security/Permission.PrivilegeDeny.phpt +++ b/tests/Security/Permission.PrivilegeDeny.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that a privilege denied for all Roles upon all Resources works properly. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->allow(); $acl->deny(NULL, NULL, 'somePrivilege'); -Assert::false( $acl->isAllowed(NULL, NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed(NULL, NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.Privileges.phpt b/tests/Security/Permission.Privileges.phpt index 172990f7..31eb5be7 100644 --- a/tests/Security/Permission.Privileges.phpt +++ b/tests/Security/Permission.Privileges.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that multiple privileges work properly. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,12 +13,12 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->allow(NULL, NULL, array('p1', 'p2', 'p3')); -Assert::true( $acl->isAllowed(NULL, NULL, 'p1') ); -Assert::true( $acl->isAllowed(NULL, NULL, 'p2') ); -Assert::true( $acl->isAllowed(NULL, NULL, 'p3') ); -Assert::false( $acl->isAllowed(NULL, NULL, 'p4') ); +Assert::true($acl->isAllowed(NULL, NULL, 'p1')); +Assert::true($acl->isAllowed(NULL, NULL, 'p2')); +Assert::true($acl->isAllowed(NULL, NULL, 'p3')); +Assert::false($acl->isAllowed(NULL, NULL, 'p4')); $acl->deny(NULL, NULL, 'p1'); -Assert::false( $acl->isAllowed(NULL, NULL, 'p1') ); +Assert::false($acl->isAllowed(NULL, NULL, 'p1')); $acl->deny(NULL, NULL, array('p2', 'p3')); -Assert::false( $acl->isAllowed(NULL, NULL, 'p2') ); -Assert::false( $acl->isAllowed(NULL, NULL, 'p3') ); +Assert::false($acl->isAllowed(NULL, NULL, 'p2')); +Assert::false($acl->isAllowed(NULL, NULL, 'p3')); diff --git a/tests/Security/Permission.RemoveDefaultAllow.phpt b/tests/Security/Permission.RemoveDefaultAllow.phpt index 5745c4dc..975f04ab 100644 --- a/tests/Security/Permission.RemoveDefaultAllow.phpt +++ b/tests/Security/Permission.RemoveDefaultAllow.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removing the default allow rule results in default deny rule being assigned. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,6 +13,6 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->allow(); -Assert::true( $acl->isAllowed() ); +Assert::true($acl->isAllowed()); $acl->removeAllow(); -Assert::false( $acl->isAllowed() ); +Assert::false($acl->isAllowed()); diff --git a/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt b/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt index 21d0617d..72f58318 100644 --- a/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt +++ b/tests/Security/Permission.RemoveDefaultAllowNonExistent.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removing non-existent default allow rule does nothing. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,4 +13,4 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->removeAllow(); -Assert::false( $acl->isAllowed() ); +Assert::false($acl->isAllowed()); diff --git a/tests/Security/Permission.RemoveDefaultDeny.phpt b/tests/Security/Permission.RemoveDefaultDeny.phpt index 4a031214..291150b0 100644 --- a/tests/Security/Permission.RemoveDefaultDeny.phpt +++ b/tests/Security/Permission.RemoveDefaultDeny.phpt @@ -4,14 +4,14 @@ * Test: Nette\Security\Permission Ensures that removing the default deny rule results in default deny rule. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::false( $acl->isAllowed() ); +Assert::false($acl->isAllowed()); $acl->removeDeny(); -Assert::false( $acl->isAllowed() ); +Assert::false($acl->isAllowed()); diff --git a/tests/Security/Permission.RemoveDefaultDenyAssert.phpt b/tests/Security/Permission.RemoveDefaultDenyAssert.phpt index b8ecd180..4fd7fe45 100644 --- a/tests/Security/Permission.RemoveDefaultDenyAssert.phpt +++ b/tests/Security/Permission.RemoveDefaultDenyAssert.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removing the default deny rule results in assertion method being removed. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -19,6 +19,6 @@ function falseAssertion() $acl = new Permission; $acl->deny(NULL, NULL, NULL, 'falseAssertion'); -Assert::true( $acl->isAllowed() ); +Assert::true($acl->isAllowed()); $acl->removeDeny(); -Assert::false( $acl->isAllowed() ); +Assert::false($acl->isAllowed()); diff --git a/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt b/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt index 713d464a..76e88fcd 100644 --- a/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt +++ b/tests/Security/Permission.RemoveDefaultDenyNonExistent.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removing non-existent default deny rule does nothing. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->allow(); $acl->removeDeny(); -Assert::true( $acl->isAllowed() ); +Assert::true($acl->isAllowed()); diff --git a/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt b/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt index d3ce326a..e5b5c1d4 100644 --- a/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt +++ b/tests/Security/Permission.RemovingRoleAfterItWasAllowedAccessToAllResources.phpt @@ -5,8 +5,8 @@ * raise undefined index error. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -24,4 +24,4 @@ $acl->allow(NULL,'Test','xxx'); $acl->removeRole('test0'); // Check after fix -Assert::false( $acl->hasRole('test0') ); +Assert::false($acl->hasRole('test0')); diff --git a/tests/Security/Permission.ResourceAddAndGetOne.phpt b/tests/Security/Permission.ResourceAddAndGetOne.phpt index c34b6d93..92106ca6 100644 --- a/tests/Security/Permission.ResourceAddAndGetOne.phpt +++ b/tests/Security/Permission.ResourceAddAndGetOne.phpt @@ -4,18 +4,18 @@ * Test: Nette\Security\Permission Ensures that basic addition and retrieval of a single Resource works. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::false( $acl->hasResource('area') ); +Assert::false($acl->hasResource('area')); $acl->addResource('area'); -Assert::true( $acl->hasResource('area') ); +Assert::true($acl->hasResource('area')); $acl->removeResource('area'); -Assert::false( $acl->hasResource('area') ); +Assert::false($acl->hasResource('area')); diff --git a/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt b/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt index 1d599129..fc6836de 100644 --- a/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt +++ b/tests/Security/Permission.ResourceAddInheritsNonExistent.phpt @@ -4,14 +4,14 @@ * Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Resource is specified as a parent upon Resource addition. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->addResource('area', 'nonexistent'); }, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist."); diff --git a/tests/Security/Permission.ResourceDuplicate.phpt b/tests/Security/Permission.ResourceDuplicate.phpt index ea92f2e1..7e071875 100644 --- a/tests/Security/Permission.ResourceDuplicate.phpt +++ b/tests/Security/Permission.ResourceDuplicate.phpt @@ -4,14 +4,14 @@ * Test: Nette\Security\Permission Ensures that the same Resource cannot be added more than once. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; -Assert::exception(function() { +Assert::exception(function () { $acl = new Permission; $acl->addResource('area'); $acl->addResource('area'); diff --git a/tests/Security/Permission.ResourceInherits.phpt b/tests/Security/Permission.ResourceInherits.phpt index 46f12a8c..753c9422 100644 --- a/tests/Security/Permission.ResourceInherits.phpt +++ b/tests/Security/Permission.ResourceInherits.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Tests basic Resource inheritance. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -16,14 +16,14 @@ $acl->addResource('city'); $acl->addResource('building', 'city'); $acl->addResource('room', 'building'); -Assert::same( array('city', 'building', 'room'), $acl->getResources() ); -Assert::true( $acl->resourceInheritsFrom('building', 'city', TRUE) ); -Assert::true( $acl->resourceInheritsFrom('room', 'building', TRUE) ); -Assert::true( $acl->resourceInheritsFrom('room', 'city') ); -Assert::false( $acl->resourceInheritsFrom('room', 'city', TRUE) ); -Assert::false( $acl->resourceInheritsFrom('city', 'building') ); -Assert::false( $acl->resourceInheritsFrom('building', 'room') ); -Assert::false( $acl->resourceInheritsFrom('city', 'room') ); +Assert::same(array('city', 'building', 'room'), $acl->getResources()); +Assert::true($acl->resourceInheritsFrom('building', 'city', TRUE)); +Assert::true($acl->resourceInheritsFrom('room', 'building', TRUE)); +Assert::true($acl->resourceInheritsFrom('room', 'city')); +Assert::false($acl->resourceInheritsFrom('room', 'city', TRUE)); +Assert::false($acl->resourceInheritsFrom('city', 'building')); +Assert::false($acl->resourceInheritsFrom('building', 'room')); +Assert::false($acl->resourceInheritsFrom('city', 'room')); $acl->removeResource('building'); -Assert::false( $acl->hasResource('room') ); +Assert::false($acl->hasResource('room')); diff --git a/tests/Security/Permission.ResourceInheritsNonExistent.phpt b/tests/Security/Permission.ResourceInheritsNonExistent.phpt index 1ae3545b..8e8569c6 100644 --- a/tests/Security/Permission.ResourceInheritsNonExistent.phpt +++ b/tests/Security/Permission.ResourceInheritsNonExistent.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Resource is specified to each parameter of inherits(). */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,10 +13,10 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addResource('area'); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->resourceInheritsFrom('nonexistent', 'area'); }, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist."); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->resourceInheritsFrom('area', 'nonexistent'); }, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist."); diff --git a/tests/Security/Permission.ResourceRemoveAll.phpt b/tests/Security/Permission.ResourceRemoveAll.phpt index 16401b61..15578931 100644 --- a/tests/Security/Permission.ResourceRemoveAll.phpt +++ b/tests/Security/Permission.ResourceRemoveAll.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removal of all Resources works. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addResource('area'); $acl->removeAllResources(); -Assert::false( $acl->hasResource('area') ); +Assert::false($acl->hasResource('area')); diff --git a/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt b/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt index 2819116a..ae996b31 100644 --- a/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt +++ b/tests/Security/Permission.ResourceRemoveOneNonExistent.phpt @@ -4,14 +4,14 @@ * Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Resource is specified for removal. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->removeResource('nonexistent'); }, 'Nette\InvalidStateException', "Resource 'nonexistent' does not exist."); diff --git a/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt b/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt index c655c63d..8e2b265d 100644 --- a/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt +++ b/tests/Security/Permission.RoleDefaultAllowRuleWithPrivilegeDenyRule.phpt @@ -5,8 +5,8 @@ * rule on the entire ACL. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -18,4 +18,4 @@ $acl->addRole('staff', 'guest'); $acl->deny(); $acl->allow('staff'); $acl->deny('staff', NULL, array('privilege1', 'privilege2')); -Assert::false( $acl->isAllowed('staff', NULL, 'privilege1') ); +Assert::false($acl->isAllowed('staff', NULL, 'privilege1')); diff --git a/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt b/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt index ccfa447f..49d34e00 100644 --- a/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt +++ b/tests/Security/Permission.RoleDefaultAllowRuleWithResourceDenyRule.phpt @@ -2,11 +2,11 @@ /** * Test: Nette\Security\Permission Ensures that for a particular Role, a deny rule on a specific Resource is honored before an allow rule -* on the entire ACL. + * on the entire ACL. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -20,4 +20,4 @@ $acl->addResource('area2'); $acl->deny(); $acl->allow('staff'); $acl->deny('staff', array('area1', 'area2')); -Assert::false( $acl->isAllowed('staff', 'area1') ); +Assert::false($acl->isAllowed('staff', 'area1')); diff --git a/tests/Security/Permission.RoleDefaultRuleSet.phpt b/tests/Security/Permission.RoleDefaultRuleSet.phpt index bc84c751..05fe4234 100644 --- a/tests/Security/Permission.RoleDefaultRuleSet.phpt +++ b/tests/Security/Permission.RoleDefaultRuleSet.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that ACL-wide rules (all Resources and privileges) work properly for a particular Role. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,6 +14,6 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest'); -Assert::true( $acl->isAllowed('guest') ); +Assert::true($acl->isAllowed('guest')); $acl->deny('guest'); -Assert::false( $acl->isAllowed('guest') ); +Assert::false($acl->isAllowed('guest')); diff --git a/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt b/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt index fc1c39e5..2e49c9e1 100644 --- a/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt +++ b/tests/Security/Permission.RoleDefaultRuleSetPrivilege.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that ACL-wide rules apply to privileges for a particular Role. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,6 +14,6 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest'); -Assert::true( $acl->isAllowed('guest', NULL, 'somePrivilege') ); +Assert::true($acl->isAllowed('guest', NULL, 'somePrivilege')); $acl->deny('guest'); -Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.RolePrivilegeAllow.phpt b/tests/Security/Permission.RolePrivilegeAllow.phpt index a1602693..61bcc179 100644 --- a/tests/Security/Permission.RolePrivilegeAllow.phpt +++ b/tests/Security/Permission.RolePrivilegeAllow.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that a privilege allowed for a particular Role upon all Resources works properly. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest', NULL, 'somePrivilege'); -Assert::true( $acl->isAllowed('guest', NULL, 'somePrivilege') ); +Assert::true($acl->isAllowed('guest', NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.RolePrivilegeAssert.phpt b/tests/Security/Permission.RolePrivilegeAssert.phpt index 0751f135..0b31e0f2 100644 --- a/tests/Security/Permission.RolePrivilegeAssert.phpt +++ b/tests/Security/Permission.RolePrivilegeAssert.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that assertions on privileges work properly for a particular Role. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -25,6 +25,6 @@ function trueAssertion() $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest', NULL, 'somePrivilege', 'trueAssertion'); -Assert::true( $acl->isAllowed('guest', NULL, 'somePrivilege') ); +Assert::true($acl->isAllowed('guest', NULL, 'somePrivilege')); $acl->allow('guest', NULL, 'somePrivilege', 'falseAssertion'); -Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.RolePrivilegeDeny.phpt b/tests/Security/Permission.RolePrivilegeDeny.phpt index 06a91395..03988147 100644 --- a/tests/Security/Permission.RolePrivilegeDeny.phpt +++ b/tests/Security/Permission.RolePrivilegeDeny.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that a privilege denied for a particular Role upon all Resources works properly. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -15,4 +15,4 @@ $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest'); $acl->deny('guest', NULL, 'somePrivilege'); -Assert::false( $acl->isAllowed('guest', NULL, 'somePrivilege') ); +Assert::false($acl->isAllowed('guest', NULL, 'somePrivilege')); diff --git a/tests/Security/Permission.RolePrivileges.phpt b/tests/Security/Permission.RolePrivileges.phpt index 04538715..f58a9a0c 100644 --- a/tests/Security/Permission.RolePrivileges.phpt +++ b/tests/Security/Permission.RolePrivileges.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that multiple privileges work properly for a particular Role. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,12 +14,12 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest', NULL, array('p1', 'p2', 'p3')); -Assert::true( $acl->isAllowed('guest', NULL, 'p1') ); -Assert::true( $acl->isAllowed('guest', NULL, 'p2') ); -Assert::true( $acl->isAllowed('guest', NULL, 'p3') ); -Assert::false( $acl->isAllowed('guest', NULL, 'p4') ); +Assert::true($acl->isAllowed('guest', NULL, 'p1')); +Assert::true($acl->isAllowed('guest', NULL, 'p2')); +Assert::true($acl->isAllowed('guest', NULL, 'p3')); +Assert::false($acl->isAllowed('guest', NULL, 'p4')); $acl->deny('guest', NULL, 'p1'); -Assert::false( $acl->isAllowed('guest', NULL, 'p1') ); +Assert::false($acl->isAllowed('guest', NULL, 'p1')); $acl->deny('guest', NULL, array('p2', 'p3')); -Assert::false( $acl->isAllowed('guest', NULL, 'p2') ); -Assert::false( $acl->isAllowed('guest', NULL, 'p3') ); +Assert::false($acl->isAllowed('guest', NULL, 'p2')); +Assert::false($acl->isAllowed('guest', NULL, 'p3')); diff --git a/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt b/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt index c7617fc5..82f5f03a 100644 --- a/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt +++ b/tests/Security/Permission.RoleRegistryAddAndGetOne.phpt @@ -4,18 +4,18 @@ * Test: Nette\Security\Permission Ensures that basic addition and retrieval of a single Role works. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::false( $acl->hasRole('guest') ); +Assert::false($acl->hasRole('guest')); $acl->addRole('guest'); -Assert::true( $acl->hasRole('guest') ); +Assert::true($acl->hasRole('guest')); $acl->removeRole('guest'); -Assert::false( $acl->hasRole('guest') ); +Assert::false($acl->hasRole('guest')); diff --git a/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt b/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt index 928a54e0..974ca66b 100644 --- a/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt +++ b/tests/Security/Permission.RoleRegistryAddInheritsNonExistent.phpt @@ -4,14 +4,14 @@ * Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role is specified as a parent upon Role addition. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->addRole('guest', 'nonexistent'); }, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist."); diff --git a/tests/Security/Permission.RoleRegistryDuplicate.phpt b/tests/Security/Permission.RoleRegistryDuplicate.phpt index 97adde8c..621f66f0 100644 --- a/tests/Security/Permission.RoleRegistryDuplicate.phpt +++ b/tests/Security/Permission.RoleRegistryDuplicate.phpt @@ -4,15 +4,15 @@ * Test: Nette\Security\Permission Ensures that the same Role cannot be registered more than once to the registry. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->addRole('guest'); $acl->addRole('guest'); }, 'Nette\InvalidStateException', "Role 'guest' already exists in the list."); diff --git a/tests/Security/Permission.RoleRegistryInherits.phpt b/tests/Security/Permission.RoleRegistryInherits.phpt index bd2866d3..a9e5ce55 100644 --- a/tests/Security/Permission.RoleRegistryInherits.phpt +++ b/tests/Security/Permission.RoleRegistryInherits.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Tests basic Role inheritance. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -15,20 +15,20 @@ $acl = new Permission; $acl->addRole('guest'); $acl->addRole('member', 'guest'); $acl->addRole('editor', 'member'); -Assert::same( array('guest', 'member', 'editor'), $acl->getRoles() ); -Assert::same( array(), $acl->getRoleParents('guest') ); -Assert::same( array('guest'), $acl->getRoleParents('member') ); -Assert::same( array('member'), $acl->getRoleParents('editor') ); +Assert::same(array('guest', 'member', 'editor'), $acl->getRoles()); +Assert::same(array(), $acl->getRoleParents('guest')); +Assert::same(array('guest'), $acl->getRoleParents('member')); +Assert::same(array('member'), $acl->getRoleParents('editor')); -Assert::true( $acl->roleInheritsFrom('member', 'guest', TRUE) ); -Assert::true( $acl->roleInheritsFrom('editor', 'member', TRUE) ); -Assert::true( $acl->roleInheritsFrom('editor', 'guest') ); -Assert::false( $acl->roleInheritsFrom('editor', 'guest', TRUE) ); -Assert::false( $acl->roleInheritsFrom('guest', 'member') ); -Assert::false( $acl->roleInheritsFrom('member', 'editor') ); -Assert::false( $acl->roleInheritsFrom('guest', 'editor') ); +Assert::true($acl->roleInheritsFrom('member', 'guest', TRUE)); +Assert::true($acl->roleInheritsFrom('editor', 'member', TRUE)); +Assert::true($acl->roleInheritsFrom('editor', 'guest')); +Assert::false($acl->roleInheritsFrom('editor', 'guest', TRUE)); +Assert::false($acl->roleInheritsFrom('guest', 'member')); +Assert::false($acl->roleInheritsFrom('member', 'editor')); +Assert::false($acl->roleInheritsFrom('guest', 'editor')); $acl->removeRole('member'); -Assert::same( array(), $acl->getRoleParents('editor') ); -Assert::false( $acl->roleInheritsFrom('editor', 'guest') ); +Assert::same(array(), $acl->getRoleParents('editor')); +Assert::false($acl->roleInheritsFrom('editor', 'guest')); diff --git a/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt b/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt index 2d64ffc1..00c52d68 100644 --- a/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt +++ b/tests/Security/Permission.RoleRegistryInheritsMultiple.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Tests basic Role multiple inheritance. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -16,15 +16,15 @@ $acl->addRole('parent1'); $acl->addRole('parent2'); $acl->addRole('child', array('parent1', 'parent2')); -Assert::same( array( +Assert::same(array( 'parent1', 'parent2', -), $acl->getRoleParents('child') ); +), $acl->getRoleParents('child')); -Assert::true( $acl->roleInheritsFrom('child', 'parent1') ); -Assert::true( $acl->roleInheritsFrom('child', 'parent2') ); +Assert::true($acl->roleInheritsFrom('child', 'parent1')); +Assert::true($acl->roleInheritsFrom('child', 'parent2')); $acl->removeRole('parent1'); -Assert::same( array('parent2'), $acl->getRoleParents('child') ); -Assert::true( $acl->roleInheritsFrom('child', 'parent2') ); +Assert::same(array('parent2'), $acl->getRoleParents('child')); +Assert::true($acl->roleInheritsFrom('child', 'parent2')); diff --git a/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt b/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt index 462f980c..765196cb 100644 --- a/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt +++ b/tests/Security/Permission.RoleRegistryInheritsNonExistent.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role is specified to each parameter of inherits(). */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,10 +13,10 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->roleInheritsFrom('nonexistent', 'guest'); }, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist."); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->roleInheritsFrom('guest', 'nonexistent'); }, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist."); diff --git a/tests/Security/Permission.RoleRegistryRemoveAll.phpt b/tests/Security/Permission.RoleRegistryRemoveAll.phpt index 9fbc25af..d7334f94 100644 --- a/tests/Security/Permission.RoleRegistryRemoveAll.phpt +++ b/tests/Security/Permission.RoleRegistryRemoveAll.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removal of all Roles works. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,4 +14,4 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); $acl->removeAllRoles(); -Assert::false( $acl->hasRole('guest') ); +Assert::false($acl->hasRole('guest')); diff --git a/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt b/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt index a232ba27..0ecc4207 100644 --- a/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt +++ b/tests/Security/Permission.RoleRegistryRemoveOneNonExistent.phpt @@ -4,14 +4,14 @@ * Test: Nette\Security\Permission Ensures that an exception is thrown when a non-existent Role is specified for removal. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $acl = new Permission; -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->removeRole('nonexistent'); }, 'Nette\InvalidStateException', "Role 'nonexistent' does not exist."); diff --git a/tests/Security/Permission.RuleRoleRemove.phpt b/tests/Security/Permission.RuleRoleRemove.phpt index 26ecb1cd..466a1312 100644 --- a/tests/Security/Permission.RuleRoleRemove.phpt +++ b/tests/Security/Permission.RuleRoleRemove.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removal of a Role results in its rules being removed. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest'); -Assert::true( $acl->isAllowed('guest') ); +Assert::true($acl->isAllowed('guest')); $acl->removeRole('guest'); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->isAllowed('guest'); }, 'Nette\InvalidStateException', "Role 'guest' does not exist."); $acl->addRole('guest'); -Assert::false( $acl->isAllowed('guest') ); +Assert::false($acl->isAllowed('guest')); diff --git a/tests/Security/Permission.RuleRoleRemoveAll.phpt b/tests/Security/Permission.RuleRoleRemoveAll.phpt index 00719d58..9b428477 100644 --- a/tests/Security/Permission.RuleRoleRemoveAll.phpt +++ b/tests/Security/Permission.RuleRoleRemoveAll.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removal of all Roles results in Role-specific rules being removed. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addRole('guest'); $acl->allow('guest'); -Assert::true( $acl->isAllowed('guest') ); +Assert::true($acl->isAllowed('guest')); $acl->removeAllRoles(); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->isAllowed('guest'); }, 'Nette\InvalidStateException', "Role 'guest' does not exist."); $acl->addRole('guest'); -Assert::false( $acl->isAllowed('guest') ); +Assert::false($acl->isAllowed('guest')); diff --git a/tests/Security/Permission.RulesRemove.phpt b/tests/Security/Permission.RulesRemove.phpt index 91910a01..5fb67994 100644 --- a/tests/Security/Permission.RulesRemove.phpt +++ b/tests/Security/Permission.RulesRemove.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensure that basic rule removal works. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -13,9 +13,9 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->allow(NULL, NULL, array('privilege1', 'privilege2')); -Assert::false( $acl->isAllowed() ); -Assert::true( $acl->isAllowed(NULL, NULL, 'privilege1') ); -Assert::true( $acl->isAllowed(NULL, NULL, 'privilege2') ); +Assert::false($acl->isAllowed()); +Assert::true($acl->isAllowed(NULL, NULL, 'privilege1')); +Assert::true($acl->isAllowed(NULL, NULL, 'privilege2')); $acl->removeAllow(NULL, NULL, 'privilege1'); -Assert::false( $acl->isAllowed(NULL, NULL, 'privilege1') ); -Assert::true( $acl->isAllowed(NULL, NULL, 'privilege2') ); +Assert::false($acl->isAllowed(NULL, NULL, 'privilege1')); +Assert::true($acl->isAllowed(NULL, NULL, 'privilege2')); diff --git a/tests/Security/Permission.RulesResourceRemove.phpt b/tests/Security/Permission.RulesResourceRemove.phpt index 078ded22..560cd9db 100644 --- a/tests/Security/Permission.RulesResourceRemove.phpt +++ b/tests/Security/Permission.RulesResourceRemove.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removal of a Resource results in its rules being removed. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addResource('area'); $acl->allow(NULL, 'area'); -Assert::true( $acl->isAllowed(NULL, 'area') ); +Assert::true($acl->isAllowed(NULL, 'area')); $acl->removeResource('area'); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->isAllowed(NULL, 'area'); }, 'Nette\InvalidStateException', "Resource 'area' does not exist."); $acl->addResource('area'); -Assert::false( $acl->isAllowed(NULL, 'area') ); +Assert::false($acl->isAllowed(NULL, 'area')); diff --git a/tests/Security/Permission.RulesResourceRemoveAll.phpt b/tests/Security/Permission.RulesResourceRemoveAll.phpt index c11b4c6b..a1b7bc6b 100644 --- a/tests/Security/Permission.RulesResourceRemoveAll.phpt +++ b/tests/Security/Permission.RulesResourceRemoveAll.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\Permission Ensures that removal of all Resources results in Resource-specific rules being removed. */ -use Nette\Security\Permission, - Tester\Assert; +use Nette\Security\Permission; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -14,11 +14,11 @@ require __DIR__ . '/../bootstrap.php'; $acl = new Permission; $acl->addResource('area'); $acl->allow(NULL, 'area'); -Assert::true( $acl->isAllowed(NULL, 'area') ); +Assert::true($acl->isAllowed(NULL, 'area')); $acl->removeAllResources(); -Assert::exception(function() use ($acl) { +Assert::exception(function () use ($acl) { $acl->isAllowed(NULL, 'area'); }, 'Nette\InvalidStateException', "Resource 'area' does not exist."); $acl->addResource('area'); -Assert::false( $acl->isAllowed(NULL, 'area') ); +Assert::false($acl->isAllowed(NULL, 'area')); diff --git a/tests/Security/SimpleAuthenticator.Roles.phpt b/tests/Security/SimpleAuthenticator.Roles.phpt index 4ce3174a..00bab572 100644 --- a/tests/Security/SimpleAuthenticator.Roles.phpt +++ b/tests/Security/SimpleAuthenticator.Roles.phpt @@ -4,26 +4,26 @@ * Test: Nette\Security\SimpleAuthenticator and roles */ -use Nette\Security\SimpleAuthenticator, - Tester\Assert; +use Nette\Security\SimpleAuthenticator; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $users = array( - 'john' => 'john123', + 'john' => 'john123', 'admin' => 'admin123', - 'user' => 'user123', + 'user' => 'user123', ); $usersRoles = array( 'admin' => array('admin', 'user'), - 'user' => 'user', + 'user' => 'user', ); $expectedRoles = array( 'admin' => array('admin', 'user'), - 'user' => array('user'), - 'john' => array(), + 'user' => array('user'), + 'john' => array(), ); $authenticator = new SimpleAuthenticator($users, $usersRoles); diff --git a/tests/Security/SimpleAuthenticator.phpt b/tests/Security/SimpleAuthenticator.phpt index 94c7e86a..c6af7d56 100644 --- a/tests/Security/SimpleAuthenticator.phpt +++ b/tests/Security/SimpleAuthenticator.phpt @@ -4,8 +4,8 @@ * Test: Nette\Security\SimpleAuthenticator */ -use Nette\Security\SimpleAuthenticator, - Tester\Assert; +use Nette\Security\SimpleAuthenticator; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -19,17 +19,17 @@ $users = array( $authenticator = new SimpleAuthenticator($users); $identity = $authenticator->authenticate(array('john', 'password123!')); -Assert::type( 'Nette\Security\IIdentity', $identity ); +Assert::type('Nette\Security\IIdentity', $identity); Assert::equal('john', $identity->getId()); $identity = $authenticator->authenticate(array('admin', 'admin')); -Assert::type( 'Nette\Security\IIdentity', $identity ); +Assert::type('Nette\Security\IIdentity', $identity); Assert::equal('admin', $identity->getId()); -Assert::exception(function() use ($authenticator) { +Assert::exception(function () use ($authenticator) { $authenticator->authenticate(array('admin', 'wrong password')); }, 'Nette\Security\AuthenticationException', 'Invalid password.'); -Assert::exception(function() use ($authenticator) { +Assert::exception(function () use ($authenticator) { $authenticator->authenticate(array('nobody', 'password')); }, 'Nette\Security\AuthenticationException', "User 'nobody' not found."); diff --git a/tests/Security/User.authentication.phpt b/tests/Security/User.authentication.phpt index d945a0d9..d37c63da 100644 --- a/tests/Security/User.authentication.phpt +++ b/tests/Security/User.authentication.phpt @@ -4,9 +4,9 @@ * Test: Nette\Security\User authentication. */ -use Nette\Security\IAuthenticator, - Nette\Security\Identity, - Tester\Assert; +use Nette\Security\IAuthenticator; +use Nette\Security\Identity; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -57,13 +57,13 @@ $user->onLoggedOut[] = function () use ($counter) { }; -Assert::false( $user->isLoggedIn() ); -Assert::null( $user->getIdentity() ); -Assert::null( $user->getId() ); +Assert::false($user->isLoggedIn()); +Assert::null($user->getIdentity()); +Assert::null($user->getId()); // authenticate -Assert::exception(function() use ($user) { +Assert::exception(function () use ($user) { // login without handler $user->login('jane', ''); }, 'Nette\InvalidStateException', 'Authenticator has not been set.'); @@ -71,51 +71,51 @@ Assert::exception(function() use ($user) { $handler = new Authenticator; $user->setAuthenticator($handler); -Assert::exception(function() use ($user) { +Assert::exception(function () use ($user) { // login as jane $user->login('jane', ''); }, 'Nette\Security\AuthenticationException', 'Unknown user'); -Assert::exception(function() use ($user) { +Assert::exception(function () use ($user) { // login as john $user->login('john', ''); }, 'Nette\Security\AuthenticationException', 'Password not match'); // login as john#2 $user->login('john', 'xxx'); -Assert::same( 1, $counter->login ); -Assert::true( $user->isLoggedIn() ); -Assert::equal( new Identity('John Doe', 'admin'), $user->getIdentity() ); -Assert::same( 'John Doe', $user->getId() ); +Assert::same(1, $counter->login); +Assert::true($user->isLoggedIn()); +Assert::equal(new Identity('John Doe', 'admin'), $user->getIdentity()); +Assert::same('John Doe', $user->getId()); // login as john#3 $user->logout(TRUE); -Assert::same( 1, $counter->logout ); -$user->login( new Identity('John Doe', 'admin') ); -Assert::same( 2, $counter->login ); -Assert::true( $user->isLoggedIn() ); -Assert::equal( new Identity('John Doe', 'admin'), $user->getIdentity() ); +Assert::same(1, $counter->logout); +$user->login(new Identity('John Doe', 'admin')); +Assert::same(2, $counter->login); +Assert::true($user->isLoggedIn()); +Assert::equal(new Identity('John Doe', 'admin'), $user->getIdentity()); // log out // logging out... $user->logout(FALSE); -Assert::same( 2, $counter->logout ); +Assert::same(2, $counter->logout); -Assert::false( $user->isLoggedIn() ); -Assert::equal( new Identity('John Doe', 'admin'), $user->getIdentity() ); +Assert::false($user->isLoggedIn()); +Assert::equal(new Identity('John Doe', 'admin'), $user->getIdentity()); // logging out and clearing identity... $user->logout(TRUE); -Assert::same( 2, $counter->logout ); // not logged in -> logout event not triggered +Assert::same(2, $counter->logout); // not logged in -> logout event not triggered -Assert::false( $user->isLoggedIn() ); -Assert::null( $user->getIdentity() ); +Assert::false($user->isLoggedIn()); +Assert::null($user->getIdentity()); // namespace // login as john#2? $user->login('john', 'xxx'); -Assert::same( 3, $counter->login ); -Assert::true( $user->isLoggedIn() ); +Assert::same(3, $counter->login); +Assert::true($user->isLoggedIn()); diff --git a/tests/Security/User.authorization.phpt b/tests/Security/User.authorization.phpt index ecc91371..7e044c8c 100644 --- a/tests/Security/User.authorization.phpt +++ b/tests/Security/User.authorization.phpt @@ -4,10 +4,10 @@ * Test: Nette\Security\User authorization. */ -use Nette\Security\IAuthenticator, - Nette\Security\Identity, - Nette\Security\IAuthorizator, - Tester\Assert; +use Nette\Security\IAuthenticator; +use Nette\Security\Identity; +use Nette\Security\IAuthorizator; +use Tester\Assert; require __DIR__ . '/../bootstrap.php'; @@ -62,12 +62,12 @@ class Authorizator implements IAuthorizator $user = new Nette\Security\User(new MockUserStorage); // guest -Assert::false( $user->isLoggedIn() ); +Assert::false($user->isLoggedIn()); -Assert::same( array('guest'), $user->getRoles() ); -Assert::false( $user->isInRole('admin') ); -Assert::true( $user->isInRole('guest') ); +Assert::same(array('guest'), $user->getRoles()); +Assert::false($user->isInRole('admin')); +Assert::true($user->isInRole('guest')); // authenticated @@ -77,26 +77,26 @@ $user->setAuthenticator($handler); // login as john $user->login('john', 'xxx'); -Assert::true( $user->isLoggedIn() ); -Assert::same( array('admin'), $user->getRoles() ); -Assert::true( $user->isInRole('admin') ); -Assert::false( $user->isInRole('guest') ); +Assert::true($user->isLoggedIn()); +Assert::same(array('admin'), $user->getRoles()); +Assert::true($user->isInRole('admin')); +Assert::false($user->isInRole('guest')); // authorization -Assert::exception(function() use ($user) { +Assert::exception(function () use ($user) { $user->isAllowed('delete_file'); }, 'Nette\InvalidStateException', 'Authorizator has not been set.'); $handler = new Authorizator; $user->setAuthorizator($handler); -Assert::true( $user->isAllowed('delete_file') ); -Assert::false( $user->isAllowed('sleep_with_jany') ); +Assert::true($user->isAllowed('delete_file')); +Assert::false($user->isAllowed('sleep_with_jany')); // log out // logging out... $user->logout(FALSE); -Assert::false( $user->isAllowed('delete_file') ); +Assert::false($user->isAllowed('delete_file')); From e892a4b77712dc4a9dd765bddf2ef55ff1de1c40 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 29 Jun 2015 14:47:20 +0200 Subject: [PATCH 08/22] removed @author --- src/Bridges/SecurityDI/SecurityExtension.php | 2 -- src/Bridges/SecurityTracy/UserPanel.php | 2 -- src/Security/AuthenticationException.php | 2 -- src/Security/IAuthenticator.php | 2 -- src/Security/IAuthorizator.php | 2 -- src/Security/IIdentity.php | 2 -- src/Security/IResource.php | 2 -- src/Security/IRole.php | 2 -- src/Security/IUserStorage.php | 2 -- src/Security/Identity.php | 2 -- src/Security/Passwords.php | 2 -- src/Security/Permission.php | 1 - src/Security/SimpleAuthenticator.php | 2 -- src/Security/User.php | 2 -- 14 files changed, 27 deletions(-) diff --git a/src/Bridges/SecurityDI/SecurityExtension.php b/src/Bridges/SecurityDI/SecurityExtension.php index bf260c90..afc27cbc 100644 --- a/src/Bridges/SecurityDI/SecurityExtension.php +++ b/src/Bridges/SecurityDI/SecurityExtension.php @@ -12,8 +12,6 @@ /** * Security extension for Nette DI. - * - * @author David Grudl */ class SecurityExtension extends Nette\DI\CompilerExtension { diff --git a/src/Bridges/SecurityTracy/UserPanel.php b/src/Bridges/SecurityTracy/UserPanel.php index 63fe63c8..931156d3 100644 --- a/src/Bridges/SecurityTracy/UserPanel.php +++ b/src/Bridges/SecurityTracy/UserPanel.php @@ -13,8 +13,6 @@ /** * User panel for Debugger Bar. - * - * @author David Grudl */ class UserPanel extends Nette\Object implements Tracy\IBarPanel { diff --git a/src/Security/AuthenticationException.php b/src/Security/AuthenticationException.php index 7dee689c..b6333145 100644 --- a/src/Security/AuthenticationException.php +++ b/src/Security/AuthenticationException.php @@ -12,8 +12,6 @@ /** * Authentication exception. - * - * @author David Grudl */ class AuthenticationException extends \Exception { diff --git a/src/Security/IAuthenticator.php b/src/Security/IAuthenticator.php index 2727605c..4ce9c60d 100644 --- a/src/Security/IAuthenticator.php +++ b/src/Security/IAuthenticator.php @@ -12,8 +12,6 @@ /** * Performs authentication. - * - * @author David Grudl */ interface IAuthenticator { diff --git a/src/Security/IAuthorizator.php b/src/Security/IAuthorizator.php index c3517678..e87981bc 100644 --- a/src/Security/IAuthorizator.php +++ b/src/Security/IAuthorizator.php @@ -13,8 +13,6 @@ /** * Authorizator checks if a given role has authorization * to access a given resource. - * - * @author David Grudl */ interface IAuthorizator { diff --git a/src/Security/IIdentity.php b/src/Security/IIdentity.php index 1385643d..a44f4b94 100644 --- a/src/Security/IIdentity.php +++ b/src/Security/IIdentity.php @@ -12,8 +12,6 @@ /** * Represents the user of application. - * - * @author David Grudl */ interface IIdentity { diff --git a/src/Security/IResource.php b/src/Security/IResource.php index 7be0bac9..4a546ec7 100644 --- a/src/Security/IResource.php +++ b/src/Security/IResource.php @@ -12,8 +12,6 @@ /** * Represents resource, an object to which access is controlled. - * - * @author David Grudl */ interface IResource { diff --git a/src/Security/IRole.php b/src/Security/IRole.php index 91257d29..eab29bfa 100644 --- a/src/Security/IRole.php +++ b/src/Security/IRole.php @@ -12,8 +12,6 @@ /** * Represents role, an object that may request access to an IResource. - * - * @author David Grudl */ interface IRole { diff --git a/src/Security/IUserStorage.php b/src/Security/IUserStorage.php index 62c9dec0..1ccab129 100644 --- a/src/Security/IUserStorage.php +++ b/src/Security/IUserStorage.php @@ -12,8 +12,6 @@ /** * Interface for persistent storage for user object data. - * - * @author David Grudl, Jan Tichý */ interface IUserStorage { diff --git a/src/Security/Identity.php b/src/Security/Identity.php index 4beaba03..0a358af5 100644 --- a/src/Security/Identity.php +++ b/src/Security/Identity.php @@ -13,8 +13,6 @@ /** * Default implementation of IIdentity. * - * @author David Grudl - * * @property mixed $id * @property array $roles * @property-read array $data diff --git a/src/Security/Passwords.php b/src/Security/Passwords.php index cbb771e9..f1eb0d42 100644 --- a/src/Security/Passwords.php +++ b/src/Security/Passwords.php @@ -12,8 +12,6 @@ /** * Passwords tools. Requires PHP >= 5.3.7. - * - * @author David Grudl */ class Passwords { diff --git a/src/Security/Permission.php b/src/Security/Permission.php index 26c120d1..d1db73a9 100644 --- a/src/Security/Permission.php +++ b/src/Security/Permission.php @@ -16,7 +16,6 @@ * This solution is mostly based on Zend_Acl (c) Zend Technologies USA Inc. (http://www.zend.com), new BSD license * * @copyright Copyright (c) 2005, 2007 Zend Technologies USA Inc. - * @author David Grudl * * @property-read array $roles * @property-read array $resources diff --git a/src/Security/SimpleAuthenticator.php b/src/Security/SimpleAuthenticator.php index 44492fd6..3b44ac3f 100644 --- a/src/Security/SimpleAuthenticator.php +++ b/src/Security/SimpleAuthenticator.php @@ -12,8 +12,6 @@ /** * Trivial implementation of IAuthenticator. - * - * @author David Grudl */ class SimpleAuthenticator extends Nette\Object implements IAuthenticator { diff --git a/src/Security/User.php b/src/Security/User.php index 1a0989b9..77099c7d 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -13,8 +13,6 @@ /** * User authentication and authorization. * - * @author David Grudl - * * @property-read bool $loggedIn * @property-read IIdentity $identity * @property-read mixed $id From 42b1bf649c8fef9fb558fb7a17d6bacdfb7e2c12 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 29 Jun 2015 16:00:35 +0200 Subject: [PATCH 09/22] typo: removed unused use --- src/Security/AuthenticationException.php | 2 -- src/Security/IAuthenticator.php | 2 -- src/Security/IAuthorizator.php | 2 -- src/Security/IIdentity.php | 2 -- src/Security/IResource.php | 2 -- src/Security/IRole.php | 2 -- src/Security/IUserStorage.php | 2 -- 7 files changed, 14 deletions(-) diff --git a/src/Security/AuthenticationException.php b/src/Security/AuthenticationException.php index b6333145..3cb18db1 100644 --- a/src/Security/AuthenticationException.php +++ b/src/Security/AuthenticationException.php @@ -7,8 +7,6 @@ namespace Nette\Security; -use Nette; - /** * Authentication exception. diff --git a/src/Security/IAuthenticator.php b/src/Security/IAuthenticator.php index 4ce9c60d..810d0d8a 100644 --- a/src/Security/IAuthenticator.php +++ b/src/Security/IAuthenticator.php @@ -7,8 +7,6 @@ namespace Nette\Security; -use Nette; - /** * Performs authentication. diff --git a/src/Security/IAuthorizator.php b/src/Security/IAuthorizator.php index e87981bc..5f37050f 100644 --- a/src/Security/IAuthorizator.php +++ b/src/Security/IAuthorizator.php @@ -7,8 +7,6 @@ namespace Nette\Security; -use Nette; - /** * Authorizator checks if a given role has authorization diff --git a/src/Security/IIdentity.php b/src/Security/IIdentity.php index a44f4b94..cc316509 100644 --- a/src/Security/IIdentity.php +++ b/src/Security/IIdentity.php @@ -7,8 +7,6 @@ namespace Nette\Security; -use Nette; - /** * Represents the user of application. diff --git a/src/Security/IResource.php b/src/Security/IResource.php index 4a546ec7..d2d87ae5 100644 --- a/src/Security/IResource.php +++ b/src/Security/IResource.php @@ -7,8 +7,6 @@ namespace Nette\Security; -use Nette; - /** * Represents resource, an object to which access is controlled. diff --git a/src/Security/IRole.php b/src/Security/IRole.php index eab29bfa..aed8e0b8 100644 --- a/src/Security/IRole.php +++ b/src/Security/IRole.php @@ -7,8 +7,6 @@ namespace Nette\Security; -use Nette; - /** * Represents role, an object that may request access to an IResource. diff --git a/src/Security/IUserStorage.php b/src/Security/IUserStorage.php index 1ccab129..7ecf6c09 100644 --- a/src/Security/IUserStorage.php +++ b/src/Security/IUserStorage.php @@ -7,8 +7,6 @@ namespace Nette\Security; -use Nette; - /** * Interface for persistent storage for user object data. From 4097789f727f889b6407f4494759e1379f4325fa Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 21 Jun 2015 17:25:56 +0200 Subject: [PATCH 10/22] travis: testing with lowest dependencies --- .travis.yml | 6 +++++- composer.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e686d783..2411a043 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,10 @@ matrix: - php: 7.0 - php: hhvm + include: + - php: 5.6 + env: dependencies="--prefer-lowest --prefer-stable" + script: - vendor/bin/tester tests -s -p php - php code-checker/src/code-checker.php @@ -22,5 +26,5 @@ after_failure: before_script: # Install Nette Tester & Code Checker - - composer install --no-interaction --prefer-source + - composer update --no-interaction --prefer-source $dependencies - composer create-project nette/code-checker code-checker ~2.3 --no-interaction --prefer-source diff --git a/composer.json b/composer.json index c18338c0..93ac73ca 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "require-dev": { "nette/di": "~2.3", "nette/http": "~2.3", - "nette/tester": "~1.0" + "nette/tester": "~1.4" }, "conflict": { "nette/nette": "<2.2" From 744264a42b506d63009d7e3853ed72b04c99e964 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 11 Jul 2015 22:59:23 +0200 Subject: [PATCH 11/22] travis: migrating to container-based infrastructure --- .travis.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2411a043..f48ac6af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,5 +26,11 @@ after_failure: before_script: # Install Nette Tester & Code Checker - - composer update --no-interaction --prefer-source $dependencies - - composer create-project nette/code-checker code-checker ~2.3 --no-interaction --prefer-source + - travis_retry composer update --no-interaction --prefer-dist $dependencies + - travis_retry composer create-project nette/code-checker code-checker ~2.5 --no-interaction + +sudo: false + +cache: + directories: + - $HOME/.composer/cache From d5bf182b625aa4a0ab842a621799b2563c87e9ab Mon Sep 17 00:00:00 2001 From: Jan Tvrdik Date: Sun, 23 Aug 2015 21:14:00 +0200 Subject: [PATCH 12/22] fixed using undefined classes in typehints --- src/Security/IUserStorage.php | 2 +- src/Security/User.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Security/IUserStorage.php b/src/Security/IUserStorage.php index 7ecf6c09..2ee6e49f 100644 --- a/src/Security/IUserStorage.php +++ b/src/Security/IUserStorage.php @@ -48,7 +48,7 @@ function getIdentity(); /** * Enables log out from the persistent storage after inactivity. - * @param string|int|DateTime number of seconds or timestamp + * @param string|int|\DateTime number of seconds or timestamp * @param int Log out when the browser is closed | Clear the identity from persistent storage? * @return void */ diff --git a/src/Security/User.php b/src/Security/User.php index 77099c7d..160929c9 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -164,7 +164,7 @@ public function getAuthenticator($need = TRUE) /** * Enables log out after inactivity. - * @param string|int|DateTime number of seconds or timestamp + * @param string|int|\DateTime number of seconds or timestamp * @param bool log out when the browser is closed? * @param bool clear the identity from persistent storage? * @return self From 865d8c7971422023136b551e560de0a689e7b549 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 23 Sep 2015 18:28:49 +0200 Subject: [PATCH 13/22] removed rarely used @property phpDoc --- src/Security/Identity.php | 1 - src/Security/Permission.php | 5 ----- src/Security/User.php | 1 - 3 files changed, 7 deletions(-) diff --git a/src/Security/Identity.php b/src/Security/Identity.php index 0a358af5..85f744ee 100644 --- a/src/Security/Identity.php +++ b/src/Security/Identity.php @@ -15,7 +15,6 @@ * * @property mixed $id * @property array $roles - * @property-read array $data */ class Identity extends Nette\Object implements IIdentity { diff --git a/src/Security/Permission.php b/src/Security/Permission.php index d1db73a9..0e6c6380 100644 --- a/src/Security/Permission.php +++ b/src/Security/Permission.php @@ -16,11 +16,6 @@ * This solution is mostly based on Zend_Acl (c) Zend Technologies USA Inc. (http://www.zend.com), new BSD license * * @copyright Copyright (c) 2005, 2007 Zend Technologies USA Inc. - * - * @property-read array $roles - * @property-read array $resources - * @property-read mixed $queriedRole - * @property-read mixed $queriedResource */ class Permission extends Nette\Object implements IAuthorizator { diff --git a/src/Security/User.php b/src/Security/User.php index 160929c9..1346d9db 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -18,7 +18,6 @@ * @property-read mixed $id * @property-read array $roles * @property-read int $logoutReason - * @property-read IUserStorage $storage * @property IAuthenticator $authenticator * @property IAuthorizator $authorizator */ From 5ad0a20ea7e73d99e7d4cf19b090dd20cc8a1db5 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 5 Oct 2015 14:35:47 +0200 Subject: [PATCH 14/22] used https --- composer.json | 6 +++--- contributing.md | 4 ++-- license.md | 2 +- src/Bridges/SecurityDI/SecurityExtension.php | 4 ++-- src/Bridges/SecurityTracy/UserPanel.php | 4 ++-- src/Security/AuthenticationException.php | 4 ++-- src/Security/IAuthenticator.php | 4 ++-- src/Security/IAuthorizator.php | 4 ++-- src/Security/IIdentity.php | 4 ++-- src/Security/IResource.php | 4 ++-- src/Security/IRole.php | 4 ++-- src/Security/IUserStorage.php | 4 ++-- src/Security/Identity.php | 4 ++-- src/Security/Passwords.php | 4 ++-- src/Security/Permission.php | 4 ++-- src/Security/SimpleAuthenticator.php | 4 ++-- src/Security/User.php | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/composer.json b/composer.json index 93ac73ca..c95cdb1d 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,16 @@ { "name": "nette/security", "description": "Nette Security: Access Control Component", - "homepage": "http://nette.org", + "homepage": "https://nette.org", "license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"], "authors": [ { "name": "David Grudl", - "homepage": "http://davidgrudl.com" + "homepage": "https://davidgrudl.com" }, { "name": "Nette Community", - "homepage": "http://nette.org/contributors" + "homepage": "https://nette.org/contributors" } ], "require": { diff --git a/contributing.md b/contributing.md index a1cbbd53..860882bf 100644 --- a/contributing.md +++ b/contributing.md @@ -5,7 +5,7 @@ The issue tracker is the preferred channel for bug reports, features requests and submitting pull requests, but please respect the following restrictions: * Please **do not** use the issue tracker for personal support requests (use - [Nette forum](http://forum.nette.org) or [Stack Overflow](http://stackoverflow.com)). + [Nette forum](https://forum.nette.org) or [Stack Overflow](http://stackoverflow.com)). * Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. @@ -21,7 +21,7 @@ fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Nette welcomes **pull requests**. If you'd like to contribute, please take a moment -to [read the guidelines](http://nette.org/en/contributing) in order to make +to [read the guidelines](https://nette.org/en/contributing) in order to make the contribution process easy and effective for everyone involved. Thanks! diff --git a/license.md b/license.md index af571d59..cf741bd0 100644 --- a/license.md +++ b/license.md @@ -21,7 +21,7 @@ If your stuff is good, it will not take long to establish a reputation for yours New BSD License --------------- -Copyright (c) 2004, 2014 David Grudl (http://davidgrudl.com) +Copyright (c) 2004, 2014 David Grudl (https://davidgrudl.com) All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/src/Bridges/SecurityDI/SecurityExtension.php b/src/Bridges/SecurityDI/SecurityExtension.php index afc27cbc..dde3ffed 100644 --- a/src/Bridges/SecurityDI/SecurityExtension.php +++ b/src/Bridges/SecurityDI/SecurityExtension.php @@ -1,8 +1,8 @@ Date: Mon, 5 Oct 2015 14:36:12 +0200 Subject: [PATCH 15/22] travis: removed PHP 7 from allowed failures --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f48ac6af..3dd7ea8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ php: matrix: allow_failures: - - php: 7.0 - php: hhvm include: From ffc476ff770c8c41db006b763888e5709e63a02c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 6 Feb 2016 23:08:59 +0100 Subject: [PATCH 16/22] typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3dd7ea8e..ff138b1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ before_script: # Install Nette Tester & Code Checker - travis_retry composer update --no-interaction --prefer-dist $dependencies - travis_retry composer create-project nette/code-checker code-checker ~2.5 --no-interaction - + sudo: false cache: From e9f3954df255c5f0be1a53a03962972aa8ba2021 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 23 Feb 2016 14:12:39 +0100 Subject: [PATCH 17/22] UserPanel: ob_start() is protected against flush when error occurs --- src/Bridges/SecurityTracy/UserPanel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bridges/SecurityTracy/UserPanel.php b/src/Bridges/SecurityTracy/UserPanel.php index ea0e76c1..46ca603a 100644 --- a/src/Bridges/SecurityTracy/UserPanel.php +++ b/src/Bridges/SecurityTracy/UserPanel.php @@ -36,7 +36,7 @@ public function getTab() return; } - ob_start(); + ob_start(function () {}); $user = $this->user; require __DIR__ . '/templates/UserPanel.tab.phtml'; return ob_get_clean(); @@ -49,7 +49,7 @@ public function getTab() */ public function getPanel() { - ob_start(); + ob_start(function () {}); $user = $this->user; require __DIR__ . '/templates/UserPanel.panel.phtml'; return ob_get_clean(); From 1c07769838546f91ec54153848f3807bb4420f2f Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 21 Apr 2016 11:36:22 +0200 Subject: [PATCH 18/22] travis: fixed PHP 5.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff138b1e..36aea1df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php php: - - 5.3.3 + - 5.3 - 5.4 - 5.5 - 5.6 From bcba3db577e7eac81435267ea9ac16343f875490 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 17 May 2016 12:16:09 +0200 Subject: [PATCH 19/22] tests: compatible with master nette/di --- tests/Security.DI/SecurityExtension.authenticator.phpt | 2 +- tests/Security.DI/SecurityExtension.user.phpt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Security.DI/SecurityExtension.authenticator.phpt b/tests/Security.DI/SecurityExtension.authenticator.phpt index ef6e98d4..657b75df 100644 --- a/tests/Security.DI/SecurityExtension.authenticator.phpt +++ b/tests/Security.DI/SecurityExtension.authenticator.phpt @@ -29,7 +29,7 @@ security: moderator: {password: moderator123, roles: moderator} ', 'neon')); -eval($compiler->compile($config, 'Container1')); +eval(@$compiler->compile($config, 'Container1')); // @ compatibility with DI 2.4 $container = new Container1; $authenticator = $container->getService('security.authenticator'); diff --git a/tests/Security.DI/SecurityExtension.user.phpt b/tests/Security.DI/SecurityExtension.user.phpt index b93d92e5..aa897f16 100644 --- a/tests/Security.DI/SecurityExtension.user.phpt +++ b/tests/Security.DI/SecurityExtension.user.phpt @@ -19,7 +19,7 @@ $compiler->addExtension('foo', new HttpExtension); $compiler->addExtension('bar', new SessionExtension); $compiler->addExtension('security', new SecurityExtension); -eval($compiler->compile(array(), 'Container1')); +eval(@$compiler->compile(array(), 'Container1')); // @ compatibility with DI 2.4 $container = new Container1; Assert::type('Nette\Http\UserStorage', $container->getService('security.userStorage')); From 779254a5484a106344a81c8cb9ce2b8570e38f34 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 17 May 2016 17:37:18 +0200 Subject: [PATCH 20/22] travis: removed HHVM --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36aea1df..934553b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,8 @@ php: - 5.5 - 5.6 - 7.0 - - hhvm matrix: - allow_failures: - - php: hhvm - include: - php: 5.6 env: dependencies="--prefer-lowest --prefer-stable" From eda00eff5659913cf0f908d6db9ac2c59dd1079b Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 12 Dec 2016 12:59:10 +0100 Subject: [PATCH 21/22] @return self -> static --- src/Security/Identity.php | 4 ++-- src/Security/Permission.php | 22 +++++++++++----------- src/Security/User.php | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Security/Identity.php b/src/Security/Identity.php index de975659..fc4f6e9d 100644 --- a/src/Security/Identity.php +++ b/src/Security/Identity.php @@ -44,7 +44,7 @@ public function __construct($id, $roles = NULL, $data = NULL) /** * Sets the ID of user. * @param mixed - * @return self + * @return static */ public function setId($id) { @@ -66,7 +66,7 @@ public function getId() /** * Sets a list of roles that the user is a member of. * @param array - * @return self + * @return static */ public function setRoles(array $roles) { diff --git a/src/Security/Permission.php b/src/Security/Permission.php index 67add876..56ce0939 100644 --- a/src/Security/Permission.php +++ b/src/Security/Permission.php @@ -54,7 +54,7 @@ class Permission extends Nette\Object implements IAuthorizator * @param string|array * @throws Nette\InvalidArgumentException * @throws Nette\InvalidStateException - * @return self + * @return static */ public function addRole($role, $parents = NULL) { @@ -173,7 +173,7 @@ public function roleInheritsFrom($role, $inherit, $onlyParents = FALSE) * * @param string * @throws Nette\InvalidStateException - * @return self + * @return static */ public function removeRole($role) { @@ -212,7 +212,7 @@ public function removeRole($role) /** * Removes all Roles from the list. * - * @return self + * @return static */ public function removeAllRoles() { @@ -242,7 +242,7 @@ public function removeAllRoles() * @param string * @throws Nette\InvalidArgumentException * @throws Nette\InvalidStateException - * @return self + * @return static */ public function addResource($resource, $parent = NULL) { @@ -349,7 +349,7 @@ public function resourceInheritsFrom($resource, $inherit, $onlyParent = FALSE) * * @param string * @throws Nette\InvalidStateException - * @return self + * @return static */ public function removeResource($resource) { @@ -381,7 +381,7 @@ public function removeResource($resource) /** * Removes all Resources. - * @return self + * @return static */ public function removeAllResources() { @@ -409,7 +409,7 @@ public function removeAllResources() * @param string|array|Permission::ALL resources * @param string|array|Permission::ALL privileges * @param callable assertion - * @return self + * @return static */ public function allow($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL) { @@ -426,7 +426,7 @@ public function allow($roles = self::ALL, $resources = self::ALL, $privileges = * @param string|array|Permission::ALL resources * @param string|array|Permission::ALL privileges * @param callable assertion - * @return self + * @return static */ public function deny($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL, $assertion = NULL) { @@ -441,7 +441,7 @@ public function deny($roles = self::ALL, $resources = self::ALL, $privileges = s * @param string|array|Permission::ALL roles * @param string|array|Permission::ALL resources * @param string|array|Permission::ALL privileges - * @return self + * @return static */ public function removeAllow($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL) { @@ -456,7 +456,7 @@ public function removeAllow($roles = self::ALL, $resources = self::ALL, $privile * @param string|array|Permission::ALL roles * @param string|array|Permission::ALL resources * @param string|array|Permission::ALL privileges - * @return self + * @return static */ public function removeDeny($roles = self::ALL, $resources = self::ALL, $privileges = self::ALL) { @@ -474,7 +474,7 @@ public function removeDeny($roles = self::ALL, $resources = self::ALL, $privileg * @param string|array|Permission::ALL privileges * @param callable assertion * @throws Nette\InvalidStateException - * @return self + * @return static */ protected function setRule($toAdd, $type, $roles, $resources, $privileges, $assertion = NULL) { diff --git a/src/Security/User.php b/src/Security/User.php index 5f70d0ce..e207a34d 100644 --- a/src/Security/User.php +++ b/src/Security/User.php @@ -139,7 +139,7 @@ public function getId() /** * Sets authentication handler. - * @return self + * @return static */ public function setAuthenticator(IAuthenticator $handler) { @@ -166,7 +166,7 @@ public function getAuthenticator($need = TRUE) * @param string|int|\DateTime number of seconds or timestamp * @param bool log out when the browser is closed? * @param bool clear the identity from persistent storage? - * @return self + * @return static */ public function setExpiration($time, $whenBrowserIsClosed = TRUE, $clearIdentity = FALSE) { @@ -236,7 +236,7 @@ public function isAllowed($resource = IAuthorizator::ALL, $privilege = IAuthoriz /** * Sets authorization handler. - * @return self + * @return static */ public function setAuthorizator(IAuthorizator $handler) { From 0d9f18bde3c9dc7a5c6990de1de9db75d39b4620 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 12 Dec 2016 13:19:04 +0100 Subject: [PATCH 22/22] travis: added PHP 7.1 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 934553b7..7a3995b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 matrix: include: