CakeDC\Users\Test\TestCase\Auth\SimpleRbacAuthorizeTest::providerAuthorize PHP Method

providerAuthorize() public method

public providerAuthorize ( )
    public function providerAuthorize()
    {
        $trueRuleMock = $this->getMockBuilder(Rule::class)->setMethods(['allowed'])->getMock();
        $trueRuleMock->expects($this->any())->method('allowed')->willReturn(true);
        return ['discard-first' => [[['role' => 'test', 'controller' => 'Tests', 'action' => 'three', function () {
            throw new \Exception();
        }], ['plugin' => ['Tests'], 'role' => ['test'], 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'one'], true], 'deny-first-discard-after' => [[['role' => 'test', 'controller' => 'Tests', 'action' => 'one', 'allowed' => function () {
            return false;
            // Deny here since under 'allowed' key
        }], [function () {
            throw new \Exception();
        }, 'plugin' => ['Tests'], 'role' => ['test'], 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'one'], false], 'star-invert' => [[['*plugin' => 'Tests', '*role' => 'test', '*controller' => 'Tests', '*action' => 'test']], ['id' => 1, 'username' => 'luke', 'role' => 'something'], ['plugin' => 'something', 'controller' => 'something', 'action' => 'something'], true], 'star-invert-deny' => [[['*plugin' => 'Tests', '*role' => 'test', '*controller' => 'Tests', '*action' => 'test']], ['id' => 1, 'username' => 'luke', 'role' => 'something'], ['plugin' => 'something', 'controller' => 'something', 'action' => 'test'], false], 'user-arr' => [[['username' => 'luke', 'user.id' => 1, 'profile.id' => 256, 'user.profile.signature' => "Hi I'm luke", 'user.allowed' => false, 'controller' => 'Tests', 'action' => 'one']], ['id' => 1, 'username' => 'luke', 'role' => 'test', 'profile' => ['id' => 256, 'signature' => "Hi I'm luke"], 'allowed' => false], ['controller' => 'Tests', 'action' => 'one'], true], 'evaluate-order' => [[['allowed' => false, function () {
            throw new \Exception();
        }, 'controller' => 'Tests', 'action' => 'one']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['controller' => 'Tests', 'action' => 'one'], false], 'multiple-callables' => [[[function () {
            return true;
        }, clone $trueRuleMock, function () {
            return true;
        }, 'controller' => 'Tests', 'action' => 'one']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['controller' => 'Tests', 'action' => 'one'], true], 'happy-strict-all' => [[['plugin' => 'Tests', 'role' => 'test', 'controller' => 'Tests', 'action' => 'test', 'allowed' => true]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'test'], true], 'happy-strict-all-deny' => [[['plugin' => 'Tests', 'role' => 'test', 'controller' => 'Tests', 'action' => 'test', 'allowed' => false]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'test'], false], 'happy-plugin-null-allowed-null' => [[['role' => 'test', 'controller' => 'Tests', 'action' => 'test']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => null, 'controller' => 'Tests', 'action' => 'test'], true], 'happy-plugin-asterisk' => [[['plugin' => '*', 'role' => 'test', 'controller' => 'Tests', 'action' => 'test']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Any', 'controller' => 'Tests', 'action' => 'test'], true], 'happy-plugin-asterisk-main-app' => [[['plugin' => '*', 'role' => 'test', 'controller' => 'Tests', 'action' => 'test']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => null, 'controller' => 'Tests', 'action' => 'test'], true], 'happy-role-asterisk' => [[['role' => '*', 'controller' => 'Tests', 'action' => 'test']], ['id' => 1, 'username' => 'luke', 'role' => 'any-role'], ['plugin' => null, 'controller' => 'Tests', 'action' => 'test'], true], 'happy-controller-asterisk' => [[['plugin' => 'Tests', 'role' => 'test', 'controller' => '*', 'action' => 'test']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'test'], true], 'happy-action-asterisk' => [[['plugin' => 'Tests', 'role' => 'test', 'controller' => 'Tests', 'action' => '*']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'any'], true], 'happy-some-asterisk-allowed' => [[['plugin' => '*', 'role' => 'test', 'controller' => '*', 'action' => '*']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'any'], true], 'happy-some-asterisk-deny' => [[['plugin' => '*', 'role' => 'test', 'controller' => '*', 'action' => '*', 'allowed' => false]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'any'], false], 'all-deny' => [[['plugin' => '*', 'role' => '*', 'controller' => '*', 'action' => '*', 'allowed' => false]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Any', 'controller' => 'Any', 'action' => 'any'], false], 'dasherized' => [[['plugin' => 'Tests', 'role' => 'test', 'controller' => 'TestTests', 'action' => 'TestAction', 'allowed' => true]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'tests', 'controller' => 'test-tests', 'action' => 'test-action'], true], 'happy-array' => [[['plugin' => ['Tests'], 'role' => ['test'], 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'one'], true], 'happy-array-deny' => [[['plugin' => ['Tests'], 'role' => ['test'], 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'three'], false], 'happy-callback-check-params' => [[['plugin' => ['Tests'], 'role' => ['test'], 'controller' => ['Tests'], 'action' => ['one', 'two'], 'allowed' => function ($user, $role, $request) {
            return $user['id'] === 1 && ($role = 'test' && $request->plugin == 'Tests');
        }]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'one'], true], 'happy-callback-deny' => [[['plugin' => ['*'], 'role' => ['test'], 'controller' => ['Tests'], 'action' => ['one', 'two'], 'allowed' => function ($user, $role, $request) {
            return false;
        }]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['plugin' => 'Tests', 'controller' => 'Tests', 'action' => 'one'], false], 'happy-prefix' => [[['role' => ['test'], 'prefix' => ['admin'], 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['prefix' => 'admin', 'controller' => 'Tests', 'action' => 'one'], true], 'deny-prefix' => [[['role' => ['test'], 'prefix' => ['admin'], 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['controller' => 'Tests', 'action' => 'one'], false], 'star-prefix' => [[['role' => ['test'], 'prefix' => '*', 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['prefix' => 'admin', 'controller' => 'Tests', 'action' => 'one'], true], 'array-prefix' => [[['role' => ['test'], 'prefix' => ['one', 'admin'], 'controller' => '*', 'action' => '*']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['prefix' => 'admin', 'controller' => 'Tests', 'action' => 'one'], true], 'array-prefix-deny' => [[['role' => ['test'], 'prefix' => ['one', 'admin'], 'controller' => '*', 'action' => 'one', 'allowed' => false]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['prefix' => 'admin', 'controller' => 'Tests', 'action' => 'one'], false], 'happy-ext' => [[['role' => ['test'], 'prefix' => ['admin'], 'extension' => ['csv'], 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['prefix' => 'admin', '_ext' => 'csv', 'controller' => 'Tests', 'action' => 'one'], true], 'deny-ext' => [[['role' => ['test'], 'extension' => ['csv'], 'controller' => ['Tests'], 'action' => ['one', 'two'], 'allowed' => false]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['controller' => 'Tests', '_ext' => 'csv', 'action' => 'one'], false], 'star-ext' => [[['role' => ['test'], 'prefix' => '*', 'extension' => '*', 'controller' => ['Tests'], 'action' => ['one', 'two']]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['prefix' => 'admin', '_ext' => 'other', 'controller' => 'Tests', 'action' => 'one'], true], 'array-ext' => [[['role' => ['test'], 'extension' => ['csv', 'pdf'], 'controller' => '*', 'action' => '*']], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['_ext' => 'csv', 'controller' => 'Tests', 'action' => 'one'], true], 'array-ext-deny' => [[['role' => ['test'], 'extension' => ['csv', 'docx'], 'controller' => '*', 'action' => 'one', 'allowed' => false]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['prefix' => 'csv', 'controller' => 'Tests', 'action' => 'one'], false], 'rule-class' => [[['role' => ['test'], 'controller' => '*', 'action' => 'one', 'allowed' => $trueRuleMock]], ['id' => 1, 'username' => 'luke', 'role' => 'test'], ['controller' => 'Tests', 'action' => 'one'], true]];
    }