public function setUp() { parent::setUp(); if (!setUpStorageBackend()) { $this->markTestSkipped('No storage backend specified; all tests depending on the storage backend are skipped'); return; } $sponsorA = new \BeeHub_Sponsor('/system/sponsors/sponsor_a'); $sponsorA->change_memberships(array('jane'), \BeeHub_Sponsor::ADMIN_ACCEPT); $sponsorA->change_memberships(array('jane'), \BeeHub_Sponsor::SET_ADMIN); $jane = new \BeeHub_User('/system/users/jane'); $jane->user_set_sponsor('/system/sponsors/sponsor_a'); $jane->storeProperties(); $foo = new \BeeHub_Group('/system/groups/foo'); $foo->change_memberships(array('jane'), \BeeHub_Group::USER_ACCEPT); $foo->change_memberships(array('jane'), \BeeHub_Group::ADMIN_ACCEPT); $foo->change_memberships(array('jane'), \BeeHub_Group::SET_ADMIN); $this->obj = new \BeeHub_File('/foo/file.txt'); $_SERVER['REQUEST_URI'] = '/foo/file.txt'; }
public function testUser_set_sponsorWithoutSponsors() { $user = new \BeeHub_User('/system/users/jane'); $this->setExpectedException('\\DAV_Status', null, \DAV::HTTP_CONFLICT); $user->user_set_sponsor(\BeeHub::SPONSORS_PATH . 'sponsor_a'); }
public function testMethod_MKCOL() { $sponsorB = new \BeeHub_Sponsor('/system/sponsors/sponsor_b'); $sponsorB->change_memberships(array('jane'), \BeeHub_Sponsor::ADMIN_ACCEPT); $sponsorB->change_memberships(array('jane'), \BeeHub_Sponsor::SET_ADMIN); $jane = new \BeeHub_User('/system/users/jane'); $jane->user_set_sponsor('/system/sponsors/sponsor_b'); $jane->storeProperties(); $this->setCurrentUser('/system/users/jane'); $this->obj->method_MKCOL('subdirectory'); $subdirectory = \DAV::$REGISTRY->resource($this->obj->path . 'subdirectory'); $this->assertSame('/system/sponsors/sponsor_a', $subdirectory->user_prop_sponsor()); $this->assertSame('/system/users/jane', $subdirectory->user_prop_owner()); $this->assertNull($subdirectory->user_prop(\DAV::PROP_GETETAG)); // And now it already exists, we should not be able to create it again $this->setExpectedException('DAV_Status', null, \DAV::HTTP_FORBIDDEN); $this->obj->method_MKCOL('subdirectory'); }
public function testBecomeOwner() { // Make sure Jane has write privilege on the resource, but not on the collection $this->setCurrentUser('/system/users/john'); $this->obj->user_set(\BeeHub::PROP_SPONSOR, '/system/sponsors/sponsor_b'); $this->obj->collection()->user_set_acl(array(new \DAVACL_Element_ace('/system/users/jane', false, array(\DAVACL::PRIV_READ, \DAVACL::PRIV_WRITE), false))); $this->obj->user_set_acl(array(new \DAVACL_Element_ace('/system/users/jane', false, array(\DAVACL::PRIV_READ, \DAVACL::PRIV_WRITE), false))); $sponsorA = new \BeeHub_Sponsor('/system/sponsors/sponsor_a'); $sponsorA->change_memberships(array('jane'), \BeeHub_Sponsor::ADMIN_ACCEPT); $sponsorA->change_memberships(array('jane'), \BeeHub_Sponsor::SET_ADMIN); $sponsorB = new \BeeHub_Sponsor('/system/sponsors/sponsor_b'); $sponsorB->change_memberships(array('jane'), \BeeHub_Sponsor::ADMIN_ACCEPT); $sponsorB->change_memberships(array('jane'), \BeeHub_Sponsor::SET_ADMIN); $jane = new \BeeHub_User('/system/users/jane'); $jane->user_set_sponsor('/system/sponsors/sponsor_a'); $jane->storeProperties(); $this->setCurrentUser('/system/users/jane'); $this->obj->method_PROPPATCH(\DAV::PROP_OWNER, '<D:href>/system/users/jane</D:href>'); // Both Jane and the object are sponsored by sponsor B, so no need to change it $this->assertSame('/system/sponsors/sponsor_b', $this->obj->user_prop_sponsor()); $this->assertSame('/system/users/jane', $this->obj->user_prop_owner()); }