Exemplo n.º 1
0
 public function testResource()
 {
     if (!setUpStorageBackend()) {
         $this->markTestSkipped('No storage backend specified; all tests depending on the storage backend are skipped');
         return;
     }
     $registry = \BeeHub_Registry::inst();
     $resourceFile = $registry->resource('/foo/file.txt');
     $this->assertInstanceOf('\\BeeHub_File', $resourceFile);
     $resourceDir = $registry->resource('/foo/');
     $this->assertInstanceOf('\\BeeHub_Directory', $resourceDir);
     $resourceSystem = $registry->resource('/system/');
     $this->assertInstanceOf('\\BeeHub_System_Collection', $resourceSystem);
     $resourceUsers = $registry->resource('/system/users/');
     $this->assertInstanceOf('\\BeeHub_Users', $resourceUsers);
     $resourceUser = $registry->resource('/system/users/john');
     $this->assertInstanceOf('\\BeeHub_User', $resourceUser);
     $resourceGroups = $registry->resource('/system/groups/');
     $this->assertInstanceOf('\\BeeHub_Groups', $resourceGroups);
     $resourceGroup = $registry->resource('/system/groups/foo');
     $this->assertInstanceOf('\\BeeHub_Group', $resourceGroup);
     $resourceSponsors = $registry->resource('/system/sponsors/');
     $this->assertInstanceOf('\\BeeHub_Sponsors', $resourceSponsors);
     $resourceSponsor = $registry->resource('/system/sponsors/sponsor_a');
     $this->assertInstanceOf('\\BeeHub_Sponsor', $resourceSponsor);
 }
Exemplo n.º 2
0
 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());
 }
Exemplo n.º 3
0
 public function setUp()
 {
     parent::setUp();
     if (!setUpStorageBackend()) {
         $this->markTestSkipped('No storage backend specified; all tests depending on the storage backend are skipped');
         return;
     }
     $this->obj = new \BeeHub_MongoResource('/foo/file.txt');
 }
Exemplo n.º 4
0
 public function setUp()
 {
     parent::setUp();
     if (!setUpStorageBackend()) {
         $this->markTestSkipped('No storage backend specified; all tests depending on the storage backend are skipped');
         return;
     }
     $this->setCurrentUser('/system/users/john');
 }
Exemplo n.º 5
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();
     $directory = new \BeeHub_Directory('/foo/directory/');
     $this->setCurrentUser('/system/users/john');
     $directory->user_set_acl(array(new \DAVACL_Element_ace('/system/users/jane', false, array(\DAVACL::PRIV_READ, \DAVACL::PRIV_WRITE), false)));
     // I need to reload the directory to avoid cache polution
     $this->obj = new \BeeHub_Directory('/foo/directory/');
 }
Exemplo n.º 6
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';
 }
Exemplo n.º 7
0
 public function testMethod_POST()
 {
     if (!setUpStorageBackend()) {
         $this->markTestSkipped('No storage backend specified; all tests depending on the storage backend are skipped');
         return;
     }
     $this->setCurrentUser('/system/users/john');
     $_POST['displayname'] = 'Some test group of John';
     $_POST['description'] = "This is the description of John's test group";
     $_POST['group_name'] = 'johngroup';
     $headers = array();
     $this->expectOutputRegex('/https 303 See Other/');
     $this->obj->method_POST($headers);
     $group = new \BeeHub_Group('/system/groups/johngroup');
     $this->assertSame($_POST['displayname'], $group->user_prop(\DAV::PROP_DISPLAYNAME));
     $this->assertSame($_POST['description'], $group->user_prop(\BeeHub::PROP_DESCRIPTION));
     $groupFolder = \DAV::$REGISTRY->resource('/' . $_POST['group_name']);
     $beehubConfig = \BeeHub::config();
     $expectedAcl = array(new \DAVACL_Element_ace($group->path, false, array(\DAVACL::PRIV_READ, \DAVACL::PRIV_WRITE), false, false));
     $this->assertNull($groupFolder->user_prop(\DAV::PROP_OWNER));
     $this->assertEquals($expectedAcl, $groupFolder->user_prop_acl_internal());
     $this->assertSame('/system/sponsors/sponsor_a', $groupFolder->user_prop(\BeeHub::PROP_SPONSOR));
 }
Exemplo n.º 8
0
 public function testProperty_priv_write()
 {
     if (!setUpStorageBackend()) {
         $this->markTestSkipped('No storage backend specified; all tests depending on the storage backend are skipped');
         return;
     }
     $this->setCurrentUser('/system/users/jane');
     $john = new \BeeHub_User('/system/users/john');
     $propsJohn = $john->property_priv_read(array(\BeeHub::PROP_EMAIL, \BeeHub::PROP_SURFCONEXT, \BeeHub::PROP_SURFCONEXT_DESCRIPTION, \BeeHub::PROP_X509, \BeeHub::PROP_SPONSOR, \DAV::PROP_GROUP_MEMBERSHIP));
     $this->assertFalse($propsJohn[\BeeHub::PROP_EMAIL]);
     $this->assertFalse($propsJohn[\BeeHub::PROP_SURFCONEXT]);
     $this->assertFalse($propsJohn[\BeeHub::PROP_SURFCONEXT_DESCRIPTION]);
     $this->assertFalse($propsJohn[\BeeHub::PROP_X509]);
     $this->assertFalse($propsJohn[\BeeHub::PROP_SPONSOR]);
     $this->assertFalse($propsJohn[\DAV::PROP_GROUP_MEMBERSHIP]);
     $jane = new \BeeHub_User('/system/users/jane');
     $propsJane = $jane->property_priv_read(array(\BeeHub::PROP_EMAIL, \BeeHub::PROP_SURFCONEXT, \BeeHub::PROP_SURFCONEXT_DESCRIPTION, \BeeHub::PROP_X509, \BeeHub::PROP_SPONSOR, \DAV::PROP_GROUP_MEMBERSHIP));
     $this->assertTrue($propsJane[\BeeHub::PROP_EMAIL]);
     $this->assertTrue($propsJane[\BeeHub::PROP_SURFCONEXT]);
     $this->assertTrue($propsJane[\BeeHub::PROP_SURFCONEXT_DESCRIPTION]);
     $this->assertTrue($propsJane[\BeeHub::PROP_X509]);
     $this->assertTrue($propsJane[\BeeHub::PROP_SPONSOR]);
     $this->assertTrue($propsJane[\DAV::PROP_GROUP_MEMBERSHIP]);
 }