mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-08-19 21:35:00 -04:00
Create and delete .htaccess files based on the view permissions for
the group::everybody() user.
This commit is contained in:
@@ -44,13 +44,6 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
user::set_active(user::guest());
|
||||
}
|
||||
|
||||
private function _add_album($parent) {
|
||||
$album = ORM::factory("item");
|
||||
$album->type = "album";
|
||||
$album->add_to_parent($parent);
|
||||
return $album;
|
||||
}
|
||||
|
||||
public function groups_and_permissions_are_bound_to_columns_test() {
|
||||
access::register_permission("access_test");
|
||||
$group = group::create("access_test");
|
||||
@@ -91,8 +84,7 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
public function new_photos_inherit_parent_permissions_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
|
||||
$album = $this->_add_album($root);
|
||||
access::add_item($album);
|
||||
$album = album::create($root->id, rand(), "test album");
|
||||
access::allow(group::everybody(), "view", $album);
|
||||
|
||||
$photo = ORM::factory("item");
|
||||
@@ -105,8 +97,7 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
|
||||
public function can_allow_deny_and_reset_intent_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$album = $this->_add_album($root);
|
||||
access::add_item($album);
|
||||
$album = album::create($root->id, rand(), "test album");
|
||||
$intent = ORM::factory("access_intent")->where("item_id", $album)->find();
|
||||
|
||||
// Allow
|
||||
@@ -158,9 +149,9 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
|
||||
public function cant_view_child_of_hidden_parent_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$album = $this->_add_album($root);
|
||||
access::add_item($album);
|
||||
$album = album::create($root->id, rand(), "test album");
|
||||
|
||||
$root->reload();
|
||||
access::deny(group::everybody(), "view", $root);
|
||||
access::reset(group::everybody(), "view", $album);
|
||||
|
||||
@@ -170,8 +161,7 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
|
||||
public function view_permissions_propagate_down_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$album = $this->_add_album($root);
|
||||
access::add_item($album);
|
||||
$album = album::create($root->id, rand(), "test album");
|
||||
|
||||
access::allow(group::everybody(), "view", $root);
|
||||
access::reset(group::everybody(), "view", $album);
|
||||
@@ -181,17 +171,10 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
|
||||
public function can_toggle_view_permissions_propagate_down_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$album1 = $this->_add_album($root);
|
||||
access::add_item($album1);
|
||||
|
||||
$album2 = $this->_add_album($album1);
|
||||
access::add_item($album2);
|
||||
|
||||
$album3 = $this->_add_album($album2);
|
||||
access::add_item($album3);
|
||||
|
||||
$album4 = $this->_add_album($album3);
|
||||
access::add_item($album4);
|
||||
$album1 = album::create($root->id, rand(), "test album");
|
||||
$album2 = album::create($album1->id, rand(), "test album");
|
||||
$album3 = album::create($album2->id, rand(), "test album");
|
||||
$album4 = album::create($album3->id, rand(), "test album");
|
||||
|
||||
$album1->reload();
|
||||
$album2->reload();
|
||||
@@ -214,9 +197,9 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
|
||||
public function revoked_view_permissions_cant_be_allowed_lower_down_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$album = $this->_add_album($root);
|
||||
access::add_item($album);
|
||||
$album = album::create($root->id, rand(), "test album");
|
||||
|
||||
$root->reload();
|
||||
access::deny(group::everybody(), "view", $root);
|
||||
access::allow(group::everybody(), "view", $album);
|
||||
|
||||
@@ -232,8 +215,7 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
|
||||
public function non_view_permissions_propagate_down_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$album = $this->_add_album($root);
|
||||
access::add_item($album);
|
||||
$album = album::create($root->id, rand(), "test album");
|
||||
|
||||
access::allow(group::everybody(), "edit", $root);
|
||||
access::reset(group::everybody(), "edit", $album);
|
||||
@@ -242,15 +224,11 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
|
||||
public function non_view_permissions_can_be_revoked_lower_down_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$outer = $this->_add_album($root);
|
||||
access::add_item($outer);
|
||||
|
||||
$outer = album::create($root->id, rand(), "test album");
|
||||
$outer_photo = ORM::factory("item")->add_to_parent($outer);
|
||||
access::add_item($outer_photo);
|
||||
|
||||
$inner = $this->_add_album($outer);
|
||||
access::add_item($inner);
|
||||
|
||||
$inner = album::create($outer->id, rand(), "test album");
|
||||
$inner_photo = ORM::factory("item")->add_to_parent($inner);
|
||||
access::add_item($inner_photo);
|
||||
|
||||
@@ -291,4 +269,15 @@ class Access_Helper_Test extends Unit_Test_Case {
|
||||
// And verify that the user can edit.
|
||||
$this->assert_true(access::can("edit", $root));
|
||||
}
|
||||
|
||||
public function everybody_view_permission_maintains_htaccess_files_test() {
|
||||
$root = ORM::factory("item", 1);
|
||||
$album = album::create($root->id, rand(), "test album");
|
||||
|
||||
$this->assert_false(file_exists($album->file_path() . "/.htaccess"));
|
||||
access::deny(group::everybody(), "view", $album);
|
||||
$this->assert_true(file_exists($album->file_path() . "/.htaccess"));
|
||||
access::allow(group::everybody(), "view", $album);
|
||||
$this->assert_false(file_exists($album->file_path() . "/.htaccess"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user