Exemplo n.º 1
0
    function testSuccessComplex()
    {
        $oldACL = [['principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true], ['principal' => 'principals/bar', 'privilege' => '{DAV:}read']];
        $tree = [$node = new MockACLNode('test', $oldACL), new DAV\SimpleCollection('principals', [new MockPrincipal('foo', 'principals/foo'), new MockPrincipal('baz', 'principals/baz')])];
        $acl = new Plugin();
        $server = new DAV\Server($tree);
        $server->httpRequest = new HTTP\Request('ACL', '/test');
        $body = '<?xml version="1.0"?>
<d:acl xmlns:d="DAV:">
    <d:ace>
        <d:grant><d:privilege><d:write /></d:privilege></d:grant>
        <d:principal><d:href>/principals/foo</d:href></d:principal>
        <d:protected />
    </d:ace>
    <d:ace>
        <d:grant><d:privilege><d:write /></d:privilege></d:grant>
        <d:principal><d:href>/principals/baz</d:href></d:principal>
    </d:ace>
</d:acl>';
        $server->httpRequest->setBody($body);
        $server->addPlugin(new DAV\Auth\Plugin());
        $server->addPlugin($acl);
        $this->assertFalse($acl->httpAcl($server->httpRequest, $server->httpResponse));
        $this->assertEquals([['principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true], ['principal' => 'principals/baz', 'privilege' => '{DAV:}write', 'protected' => false]], $node->getACL());
    }
Exemplo n.º 2
0
    function testSuccessComplex()
    {
        $oldACL = array(array('principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true), array('principal' => 'principals/bar', 'privilege' => '{DAV:}read'));
        $tree = array($node = new MockACLNode('test', $oldACL), new DAV\SimpleCollection('principals', array(new MockPrincipal('foo', 'principals/foo'), new MockPrincipal('baz', 'principals/baz'))));
        $acl = new Plugin();
        $server = new DAV\Server($tree);
        $server->httpRequest = new HTTP\Request();
        $body = '<?xml version="1.0"?>
<d:acl xmlns:d="DAV:">
    <d:ace>
        <d:grant><d:privilege><d:write /></d:privilege></d:grant>
        <d:principal><d:href>/principals/foo</d:href></d:principal>
        <d:protected />
    </d:ace>
    <d:ace>
        <d:grant><d:privilege><d:write /></d:privilege></d:grant>
        <d:principal><d:href>/principals/baz</d:href></d:principal>
    </d:ace>
</d:acl>';
        $server->httpRequest->setBody($body);
        $server->addPlugin($acl);
        $this->assertFalse($acl->unknownMethod('ACL', 'test'));
        $this->assertEquals(array(array('principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true), array('principal' => 'principals/baz', 'privilege' => '{DAV:}write', 'protected' => false)), $node->getACL());
    }