summaryrefslogtreecommitdiff
path: root/modules/gallery/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/tests')
-rw-r--r--modules/gallery/tests/Access_Helper_Test.php4
-rw-r--r--modules/gallery/tests/Cache_Test.php20
-rw-r--r--modules/gallery/tests/Item_Model_Test.php57
-rw-r--r--modules/gallery/tests/controller_auth_data.txt4
-rw-r--r--modules/gallery/tests/xss_data.txt73
5 files changed, 69 insertions, 89 deletions
diff --git a/modules/gallery/tests/Access_Helper_Test.php b/modules/gallery/tests/Access_Helper_Test.php
index c092e3fd..32b3020f 100644
--- a/modules/gallery/tests/Access_Helper_Test.php
+++ b/modules/gallery/tests/Access_Helper_Test.php
@@ -359,11 +359,13 @@ class Access_Helper_Test extends Gallery_Unit_Test_Case {
$public_album = test::random_album();
$public_photo = test::random_photo($public_album);
access::allow(identity::everybody(), "view", $public_album);
+ access::allow(identity::everybody(), "edit", $public_album);
item::root()->reload(); // Account for MPTT changes
$private_album = test::random_album();
access::deny(identity::everybody(), "view", $private_album);
+ access::deny(identity::everybody(), "edit", $private_album);
$private_photo = test::random_photo($private_album);
// Make sure that we now have a public photo and private photo.
@@ -385,6 +387,8 @@ class Access_Helper_Test extends Gallery_Unit_Test_Case {
// Make sure that the public_photo is now private, and the private_photo is now public.
$this->assert_false(access::group_can(identity::everybody(), "view", $public_photo));
+ $this->assert_false(access::group_can(identity::everybody(), "edit", $public_photo));
$this->assert_true(access::group_can(identity::everybody(), "view", $private_photo));
+ $this->assert_true(access::group_can(identity::everybody(), "edit", $private_photo));
}
}
diff --git a/modules/gallery/tests/Cache_Test.php b/modules/gallery/tests/Cache_Test.php
index 4c65698a..e8d8b6f4 100644
--- a/modules/gallery/tests/Cache_Test.php
+++ b/modules/gallery/tests/Cache_Test.php
@@ -85,26 +85,6 @@ class Cache_Test extends Gallery_Unit_Test_Case {
$this->assert_equal(array($id3 => $value3), $data, "Expected id3");
}
- public function cache_delete_expired_test() {
- $id1 = md5(rand());
- $value1 = array("field1" => "value1", "field2" => "value2");
- $this->_driver->set(array($id1 => $value1), array("tag1", "tag2"), -84600);
-
- $id2 = md5(rand());
- $value2 = array("field3" => "value3", "field4" => "value4");
- $this->_driver->set(array($id2 => $value2), array("tag2", "tag3"), -846000);
-
- $id3 = md5(rand());
- $value3 = array("field5" => "value5", "field6" => "value6");
- $this->_driver->set(array($id3 => $value3), array("tag3", "tag4"), -84600);
-
- $data = $this->_driver->delete_expired();
-
- $this->assert_false($this->_driver->exists($id1), "$id1 should have been deleted");
- $this->assert_false($this->_driver->exists($id2), "$id2 should have been deleted");
- $this->assert_false($this->_driver->exists($id3), "$id3 should have been deleted");
- }
-
public function cache_delete_id_test() {
$id1 = md5(rand());
$value1 = array("field1" => "value1", "field2" => "value2");
diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php
index bd123098..90c54e3c 100644
--- a/modules/gallery/tests/Item_Model_Test.php
+++ b/modules/gallery/tests/Item_Model_Test.php
@@ -136,20 +136,17 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(false, "Shouldn't get here");
}
- public function item_rename_fails_with_existing_name_test() {
+ public function item_rename_over_existing_name_gets_uniqified_test() {
// Create a test photo
$item = test::random_photo();
$item2 = test::random_photo();
- try {
- $item->name = $item2->name;
- $item->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_true(in_array("conflict", $e->validation->errors()));
- return;
- }
+ $item->name = $item2->name;
+ $item->save();
- $this->assert_false(true, "rename should conflict");
+ // foo.jpg should become foo-####.jpg
+ $this->assert_true(
+ preg_match("/" . str_replace(".jpg", "", $item2->name) . "-\d+\.jpg/", $item->name));
}
public function move_album_test() {
@@ -208,24 +205,21 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_equal("file", file_get_contents($photo->file_path()));
}
- public function move_album_fails_conflicting_target_test() {
+ public function move_album_with_conflicting_target_gets_uniqified_test() {
$album = test::random_album();
$source = test::random_album_unsaved($album);
$source->name = $album->name;
$source->save();
// $source and $album have the same name, so if we move $source into the root they should
- // conflict.
+ // conflict and get randomized
- try {
- $source->parent_id = item::root()->id;
- $source->save();
- } catch (ORM_Validation_Exception $e) {
- $this->assert_equal(
- array("name" => "conflict", "slug" => "conflict"), $e->validation->errors());
- return;
- }
- $this->assert_true(false, "Shouldn't get here");
+ $source->parent_id = item::root()->id;
+ $source->save();
+
+ // foo should become foo-####
+ $this->assert_true(preg_match("/{$album->name}-\d+/", $source->name));
+ $this->assert_true(preg_match("/{$album->slug}-\d+/", $source->slug));
}
public function move_album_fails_wrong_target_type_test() {
@@ -245,7 +239,7 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$this->assert_true(false, "Shouldn't get here");
}
- public function move_photo_fails_conflicting_target_test() {
+ public function move_photo_with_conflicting_target_gets_uniqified_test() {
$photo1 = test::random_photo();
$album = test::random_album();
$photo2 = test::random_photo_unsaved($album);
@@ -253,18 +247,17 @@ class Item_Model_Test extends Gallery_Unit_Test_Case {
$photo2->save();
// $photo1 and $photo2 have the same name, so if we move $photo1 into the root they should
- // conflict.
+ // conflict and get uniqified.
- try {
- $photo2->parent_id = item::root()->id;
- $photo2->save();
- } catch (Exception $e) {
- // pass
- $this->assert_equal(
- array("name" => "conflict", "slug" => "conflict"), $e->validation->errors());
- return;
- }
- $this->assert_true(false, "Shouldn't get here");
+ $photo2->parent_id = item::root()->id;
+ $photo2->save();
+
+ // foo.jpg should become foo-####.jpg
+ $this->assert_true(
+ preg_match("/" . str_replace(".jpg", "", $photo1->name) . "-\d+\.jpg/", $photo2->name));
+
+ // foo should become foo
+ $this->assert_true(preg_match("/{$photo1->slug}/", $photo2->name));
}
public function move_album_inside_descendent_fails_test() {
diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt
index 212577c7..9ea6043a 100644
--- a/modules/gallery/tests/controller_auth_data.txt
+++ b/modules/gallery/tests/controller_auth_data.txt
@@ -15,7 +15,7 @@ modules/gallery/controllers/login.php html
modules/gallery/controllers/login.php auth_html DIRTY_AUTH
modules/gallery/controllers/logout.php index DIRTY_AUTH
modules/gallery/controllers/quick.php form_edit DIRTY_CSRF
-modules/gallery/controllers/upgrader.php index DIRTY_AUTH
+modules/gallery/controllers/upgrader.php index DIRTY_CSRF|DIRTY_AUTH
modules/gallery/controllers/uploader.php start DIRTY_AUTH
modules/gallery/controllers/uploader.php status DIRTY_AUTH
modules/gallery/controllers/uploader.php finish DIRTY_AUTH
@@ -34,7 +34,7 @@ modules/search/controllers/search.php index
modules/server_add/controllers/admin_server_add.php autocomplete DIRTY_CSRF
modules/server_add/controllers/server_add.php children DIRTY_CSRF
modules/tag/controllers/admin_tags.php index DIRTY_CSRF
-modules/tag/controllers/tags.php show DIRTY_CSRF|DIRTY_AUTH
+modules/tag/controllers/tag.php __call DIRTY_CSRF|DIRTY_AUTH
modules/tag/controllers/tags.php autocomplete DIRTY_CSRF|DIRTY_AUTH
modules/user/controllers/password.php reset DIRTY_AUTH
modules/user/controllers/password.php do_reset DIRTY_CSRF|DIRTY_AUTH
diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt
index 4405dad3..a714b3e5 100644
--- a/modules/gallery/tests/xss_data.txt
+++ b/modules/gallery/tests/xss_data.txt
@@ -42,7 +42,7 @@ modules/digibug/views/digibug_form.html.php 4 DIRTY form::
modules/digibug/views/digibug_form.html.php 6 DIRTY form::hidden($key,$value)
modules/exif/views/exif_dialog.html.php 14 DIRTY $details[$i]["caption"]
modules/exif/views/exif_dialog.html.php 21 DIRTY $details[$i]["caption"]
-modules/g2_import/views/admin_g2_import.html.php 30 DIRTY $form
+modules/g2_import/views/admin_g2_import.html.php 9 DIRTY $form
modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY_ATTR text::alternate("g-odd","g-even")
modules/gallery/views/admin_advanced_settings.html.php 22 DIRTY $var->module_name
modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity)
@@ -58,9 +58,9 @@ modules/gallery/views/admin_block_photo_stream.html.php 6 DIRTY photo:
modules/gallery/views/admin_block_photo_stream.html.php 7 DIRTY_ATTR $photo->thumb_url()
modules/gallery/views/admin_dashboard.html.php 5 DIRTY_JS $csrf
modules/gallery/views/admin_dashboard.html.php 35 DIRTY $blocks
-modules/gallery/views/admin_graphics.html.php 24 DIRTY newView("admin_graphics_none.html")
-modules/gallery/views/admin_graphics.html.php 26 DIRTY newView("admin_graphics_$active.html",array("tk"=>$tk->$active,"is_active"=>true))
-modules/gallery/views/admin_graphics.html.php 33 DIRTY newView("admin_graphics_$id.html",array("tk"=>$tk->$id,"is_active"=>false))
+modules/gallery/views/admin_graphics.html.php 25 DIRTY newView("admin_graphics_none.html")
+modules/gallery/views/admin_graphics.html.php 27 DIRTY newView("admin_graphics_$active.html",array("tk"=>$tk->$active,"is_active"=>true))
+modules/gallery/views/admin_graphics.html.php 34 DIRTY newView("admin_graphics_$id.html",array("tk"=>$tk->$id,"is_active"=>false))
modules/gallery/views/admin_graphics_gd.html.php 2 DIRTY_ATTR $is_active?" g-selected":""
modules/gallery/views/admin_graphics_gd.html.php 2 DIRTY_ATTR $tk->installed?" g-installed-toolkit":" g-unavailable"
modules/gallery/views/admin_graphics_gd.html.php 19 DIRTY $tk->error
@@ -248,14 +248,15 @@ modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $permi
modules/gallery/views/permissions_form.html.php 80 DIRTY_JS $item->id
modules/gallery/views/quick_delete_confirm.html.php 11 DIRTY $form
modules/gallery/views/reauthenticate.html.php 9 DIRTY $form
-modules/gallery/views/upgrader.html.php 59 DIRTY_ATTR $done?"muted":""
-modules/gallery/views/upgrader.html.php 63 DIRTY_ATTR $done?"muted":""
-modules/gallery/views/upgrader.html.php 71 DIRTY_ATTR $module->version==$module->code_version?"current":"upgradeable"
-modules/gallery/views/upgrader.html.php 72 DIRTY_ATTR $id
-modules/gallery/views/upgrader.html.php 76 DIRTY $module->version
-modules/gallery/views/upgrader.html.php 79 DIRTY $module->code_version
-modules/gallery/views/upgrader.html.php 101 DIRTY_ATTR $done?"muted":""
-modules/gallery/views/upgrader.html.php 104 DIRTY_ATTR $done?"muted":""
+modules/gallery/views/upgrader.html.php 76 DIRTY_ATTR $done?"muted":""
+modules/gallery/views/upgrader.html.php 94 DIRTY_ATTR $done?"muted":""
+modules/gallery/views/upgrader.html.php 102 DIRTY_ATTR $module->version==$module->code_version?"current":"upgradeable"
+modules/gallery/views/upgrader.html.php 102 DIRTY_ATTR in_array($id,$failed)?"failed":""
+modules/gallery/views/upgrader.html.php 103 DIRTY_ATTR $id
+modules/gallery/views/upgrader.html.php 107 DIRTY $module->version
+modules/gallery/views/upgrader.html.php 110 DIRTY $module->code_version
+modules/gallery/views/upgrader.html.php 120 DIRTY_ATTR $done?"muted":""
+modules/gallery/views/upgrader.html.php 123 DIRTY_ATTR $done?"muted":""
modules/gallery/views/user_languages_block.html.php 2 DIRTY form::dropdown("g-select-session-locale",$installed_locales,$selected)
modules/gallery/views/user_profile.html.php 34 DIRTY_ATTR $user->avatar_url(40,$theme->url(,true))
modules/gallery/views/user_profile.html.php 43 DIRTY $info->view
@@ -273,19 +274,19 @@ modules/notification/views/item_updated.html.php 20 DIRTY_JS $item-
modules/notification/views/item_updated.html.php 20 DIRTY $item->abs_url()
modules/notification/views/user_profile_notification.html.php 5 DIRTY_ATTR $subscription->id
modules/notification/views/user_profile_notification.html.php 6 DIRTY_JS $subscription->url
-modules/organize/views/organize_dialog.html.php 86 DIRTY_JS $domain
-modules/organize/views/organize_dialog.html.php 87 DIRTY_JS $access_key
-modules/organize/views/organize_dialog.html.php 88 DIRTY_JS request::protocol()
-modules/organize/views/organize_dialog.html.php 89 DIRTY_JS $file_filter
-modules/organize/views/organize_dialog.html.php 90 DIRTY_JS $sort_order
-modules/organize/views/organize_dialog.html.php 91 DIRTY_JS $sort_fields
-modules/organize/views/organize_dialog.html.php 92 DIRTY_JS $album->id
-modules/organize/views/organize_dialog.html.php 93 DIRTY_JS $selected_id
-modules/organize/views/organize_dialog.html.php 94 DIRTY_JS $rest_uri
-modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $controller_uri
-modules/organize/views/organize_dialog.html.php 101 DIRTY_JS $flash_minimum_version="10.0.0"
-modules/organize/views/organize_dialog.html.php 119 DIRTY_JS $swf_uri
-modules/organize/views/organize_dialog.html.php 132 DIRTY_ATTR request::protocol()
+modules/organize/views/organize_dialog.html.php 94 DIRTY_JS $domain
+modules/organize/views/organize_dialog.html.php 95 DIRTY_JS $access_key
+modules/organize/views/organize_dialog.html.php 96 DIRTY_JS request::protocol()
+modules/organize/views/organize_dialog.html.php 97 DIRTY_JS $file_filter
+modules/organize/views/organize_dialog.html.php 98 DIRTY_JS $sort_order
+modules/organize/views/organize_dialog.html.php 99 DIRTY_JS $sort_fields
+modules/organize/views/organize_dialog.html.php 100 DIRTY_JS $album->id
+modules/organize/views/organize_dialog.html.php 101 DIRTY_JS $selected_id
+modules/organize/views/organize_dialog.html.php 102 DIRTY_JS $rest_uri
+modules/organize/views/organize_dialog.html.php 103 DIRTY_JS $controller_uri
+modules/organize/views/organize_dialog.html.php 109 DIRTY_JS $flash_minimum_version="10.0.0"
+modules/organize/views/organize_dialog.html.php 127 DIRTY_JS $swf_uri
+modules/organize/views/organize_dialog.html.php 140 DIRTY_ATTR request::protocol()
modules/recaptcha/views/admin_recaptcha.html.php 11 DIRTY $form
modules/recaptcha/views/admin_recaptcha.html.php 23 DIRTY_JS $public_key
modules/recaptcha/views/form_recaptcha.html.php 7 DIRTY_JS $public_key
@@ -330,23 +331,25 @@ modules/server_add/views/server_add_tree_dialog.html.php 4 DIRTY_JS url::s
modules/server_add/views/server_add_tree_dialog.html.php 21 DIRTY $tree
modules/tag/views/admin_tags.html.php 45 DIRTY_ATTR $tag->id
modules/tag/views/admin_tags.html.php 46 DIRTY $tag->count
-modules/tag/views/tag_block.html.php 25 DIRTY $cloud
-modules/tag/views/tag_block.html.php 27 DIRTY $form
+modules/tag/views/tag_block.html.php 26 DIRTY $cloud
+modules/tag/views/tag_block.html.php 28 DIRTY $form
modules/tag/views/tag_cloud.html.php 4 DIRTY_ATTR (int)(($tag->count/$max_count)*7)
modules/tag/views/tag_cloud.html.php 5 DIRTY $tag->count
modules/tag/views/tag_cloud.html.php 6 DIRTY_JS $tag->url()
modules/user/views/admin_users.html.php 3 DIRTY_JS url::site("admin/users/add_user_to_group/__USERID__/__GROUPID__?csrf=$csrf")
modules/user/views/admin_users.html.php 26 DIRTY_JS url::site("admin/users/group/__GROUPID__")
modules/user/views/admin_users.html.php 36 DIRTY_JS url::site("admin/users/remove_user_from_group/__USERID__/__GROUPID__?csrf=$csrf")
-modules/user/views/admin_users.html.php 71 DIRTY_ATTR $user->id
-modules/user/views/admin_users.html.php 71 DIRTY_ATTR text::alternate("g-odd","g-even")
-modules/user/views/admin_users.html.php 71 DIRTY_ATTR $user->admin?"g-admin":""
modules/user/views/admin_users.html.php 72 DIRTY_ATTR $user->id
-modules/user/views/admin_users.html.php 73 DIRTY_ATTR $user->avatar_url(20,$theme->url(,true))
-modules/user/views/admin_users.html.php 87 DIRTY ($user->last_login==0)?"":gallery::date($user->last_login)
-modules/user/views/admin_users.html.php 123 DIRTY_ATTR $group->id
-modules/user/views/admin_users.html.php 123 DIRTY_ATTR ($group->special?"g-default-group":"")
-modules/user/views/admin_users.html.php 125 DIRTY $v
+modules/user/views/admin_users.html.php 72 DIRTY_ATTR text::alternate("g-odd","g-even")
+modules/user/views/admin_users.html.php 72 DIRTY_ATTR $user->admin?"g-admin":""
+modules/user/views/admin_users.html.php 73 DIRTY_ATTR $user->id
+modules/user/views/admin_users.html.php 74 DIRTY_ATTR $user->avatar_url(20,$theme->url(,true))
+modules/user/views/admin_users.html.php 88 DIRTY ($user->last_login==0)?"":gallery::date($user->last_login)
+modules/user/views/admin_users.html.php 91 DIRTY db::build()->from("items")->where("owner_id","=",$user->id)->count_records()
+modules/user/views/admin_users.html.php 127 DIRTY_ATTR $group->id
+modules/user/views/admin_users.html.php 127 DIRTY_ATTR ($group->special?"g-default-group":"")
+modules/user/views/admin_users.html.php 129 DIRTY $v
+modules/user/views/admin_users_delete_user.html.php 6 DIRTY $form
modules/user/views/admin_users_group.html.php 24 DIRTY_JS $user->id
modules/user/views/admin_users_group.html.php 24 DIRTY_JS $group->id
modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width