Exemple #1
0
 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';
 }
Exemple #2
0
 public function testVerify_email_address()
 {
     $user = new \BeeHub_User('/system/users/jane');
     $this->assertSame('*****@*****.**', $user->user_prop(\BeeHub::PROP_EMAIL));
     $this->assertFalse($user->verify_email_address('The wrong e-mail verification code'));
     $this->assertTrue($user->verify_email_address('somesecretcode'));
     $this->assertSame('*****@*****.**', $user->user_prop(\BeeHub::PROP_EMAIL));
 }
 public function testMethod_POST()
 {
     if (!setUpStorageBackend()) {
         $this->markTestSkipped('No storage backend specified; all tests depending on the storage backend are skipped');
         return;
     }
     $_POST['user_name'] = 'jdoe';
     $_POST['displayname'] = 'J Doe';
     $_POST['email'] = "*****@*****.**";
     $_POST['password'] = '******';
     $headers = array();
     $obj = $this->getMock('\\BeeHub_Users', array('include_view'), array('/system/users/'));
     $obj->expects($this->any())->method('include_view')->with($this->equalTo('new_user_confirmation'), $this->equalTo(array('email_address' => $_POST['email'])));
     $emailer = $this->getMock('\\BeeHub_Emailer', array('email'));
     $emailer->expects($this->once())->method('email');
     \BeeHub::setEmailer($emailer);
     $this->expectOutputRegex('/html/');
     $this->obj->method_POST($headers);
     $user = new \BeeHub_User('/system/users/jdoe');
     $this->assertSame($_POST['displayname'], $user->user_prop(\DAV::PROP_DISPLAYNAME));
     $this->assertTrue($user->check_password($_POST['password']));
     $userFolder = \DAV::$REGISTRY->resource('/home/' . $_POST['user_name']);
     $beehubConfig = \BeeHub::config();
     $this->assertSame($user->path, $userFolder->user_prop(\DAV::PROP_OWNER));
     \BeeHub::setEmailer(new \BeeHub_Emailer());
 }
 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());
 }