public function testWheel() { $obj = new \BeeHub_ACL_Provider(); $this->setCurrentUser('/system/users/john'); $this->assertTrue($obj->wheel(), 'BeeHub_ACL_Provider::wheel() should return true, because John is a member of the admin group'); $config = \BeeHub::config(); $adminGroup = new \BeeHub_Group($config['namespace']['admin_group']); $adminGroup->change_memberships(array('jane'), \BeeHub_Group::USER_ACCEPT); $adminGroup->change_memberships(array('jane'), \BeeHub_Group::ADMIN_ACCEPT); $this->setCurrentUser('/system/users/jane'); $this->assertTrue($obj->wheel(), 'BeeHub_ACL_Provider::wheel() should return true, because Jane is also a member of the admin group'); $this->setCurrentUser('/system/users/johny'); $this->assertFalse($obj->wheel(), 'BeeHub_ACL_Provider::wheel() should return true, because Johny is not a member of the admin group'); }
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'; }
// The configuration checks out, let's install stuff // Import the database structure print "Creating database structure..."; // Create users collection // TODO: Check input! $username = $_SERVER['PHP_AUTH_USER']; $userEmail = $_POST['email']; $usersCollection = $db->createCollection('users'); $usersCollection->ensureIndex(array('name' => 1), array('unique' => 1)); $usersCollection->insert(array('name' => $username, 'displayname' => 'Administrator', 'email' => $userEmail, 'password' => \crypt($_SERVER['PHP_AUTH_PW'], '$6$rounds=5000$' . md5(time() . rand(0, 99999)) . '$'), 'default_sponsor' => DEFAULT_SPONSOR_NAME)); // Create groups collection $groupsCollection = $db->createCollection('groups'); $groupsCollection->ensureIndex(array('name' => 1), array('unique' => 1)); $groupsCollection->insert(array('name' => \basename($config['namespace']['admin_group']), 'displayname' => ADMIN_GROUP_DISPLAYNAME, 'description' => ADMIN_GROUP_DESCRIPTION)); $group = new \BeeHub_Group($config['namespace']['admin_group']); $group->change_memberships(array($username), \BeeHub_Group::USER_ACCEPT); $group->change_memberships(array($username), \BeeHub_Group::ADMIN_ACCEPT); $group->change_memberships(array($username), \BeeHub_Group::SET_ADMIN); // Create sponsors collection $sponsorsCollection = $db->createCollection('sponsors'); $sponsorsCollection->ensureIndex(array('name' => 1), array('unique' => 1)); $sponsorsCollection->insert(array('name' => DEFAULT_SPONSOR_NAME, 'displayname' => DEFAULT_SPONSOR_DISPLAYNAME, 'description' => DEFAULT_SPONSOR_DESCRIPTION)); $sponsor = new \BeeHub_Sponsor(\BeeHub::SPONSORS_PATH . DEFAULT_SPONSOR_NAME); $sponsor->change_memberships(array($username), \BeeHub_Sponsor::ADMIN_ACCEPT); $sponsor->change_memberships(array($username), \BeeHub_Sponsor::SET_ADMIN); // Create the beehub_system collection $systemCollection = $db->createCollection('beehub_system'); $systemCollection->insert(array('name' => 'etag', 'counter' => 0)); // Create the files collection $filesCollection = $db->createCollection('files'); $filesCollection->ensureIndex(array('props.http://beehub%2Enl/ sponsor' => 1));
public function testMethod_POST_DeleteMember() { $_POST['delete_members'] = array('/system/users/jane'); $headers = array(); $emailer = $this->getMock('\\BeeHub_Emailer', array('email')); $emailer->expects($this->once())->method('email'); \BeeHub::setEmailer($emailer); $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); $expectedMemberships = array('/system/users/jane', '/system/users/john'); sort($expectedMemberships); $returnedMemberships = $foo->user_prop_group_member_set(); sort($returnedMemberships); $this->assertSame($expectedMemberships, $returnedMemberships); $this->setCurrentUser('/system/users/john'); $foo->method_POST($headers); $this->assertSame(array('/system/users/john'), $foo->user_prop_group_member_set()); $this->setCurrentUser('/system/users/jane'); $this->assertFalse($foo->is_invited()); $this->assertFalse($foo->is_requested()); $this->assertFalse($foo->is_member()); $this->assertFalse($foo->is_admin()); \BeeHub::setEmailer(new \BeeHub_Emailer()); }