From 3c40476b34ce9e65ada58bc063a30e5389219811 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 4 Oct 2010 23:42:07 -0700 Subject: Not sure why digibug::close_window() changed in the listing, but it looks fine here. --- modules/gallery/tests/controller_auth_data.txt | 1 - modules/gallery/tests/xss_data.txt | 52 +++++++++++++------------- 2 files changed, 26 insertions(+), 27 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/controller_auth_data.txt b/modules/gallery/tests/controller_auth_data.txt index 9ea6043a..24170092 100644 --- a/modules/gallery/tests/controller_auth_data.txt +++ b/modules/gallery/tests/controller_auth_data.txt @@ -1,7 +1,6 @@ modules/comment/controllers/admin_manage_comments.php queue DIRTY_CSRF modules/comment/helpers/comment_rss.php feed DIRTY_AUTH modules/digibug/controllers/digibug.php print_proxy DIRTY_CSRF|DIRTY_AUTH -modules/digibug/controllers/digibug.php close_window DIRTY_AUTH modules/g2_import/controllers/g2.php map DIRTY_CSRF modules/gallery/controllers/admin.php __call DIRTY_AUTH modules/gallery/controllers/albums.php index DIRTY_AUTH diff --git a/modules/gallery/tests/xss_data.txt b/modules/gallery/tests/xss_data.txt index a714b3e5..0345df96 100644 --- a/modules/gallery/tests/xss_data.txt +++ b/modules/gallery/tests/xss_data.txt @@ -43,8 +43,8 @@ modules/digibug/views/digibug_form.html.php 6 DIRTY form:: 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 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_advanced_settings.html.php 20 DIRTY_ATTR text::alternate("g-odd","g-even") +modules/gallery/views/admin_advanced_settings.html.php 21 DIRTY $var->module_name modules/gallery/views/admin_block_log_entries.html.php 4 DIRTY_ATTR log::severity_class($entry->severity) modules/gallery/views/admin_block_log_entries.html.php 8 DIRTY_JS user_profile::url($entry->user->id) modules/gallery/views/admin_block_log_entries.html.php 10 DIRTY gallery::date_time($entry->timestamp) @@ -355,19 +355,19 @@ modules/user/views/admin_users_group.html.php 24 DIRTY_JS $group modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $width modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $height modules/watermark/views/admin_watermarks.html.php 20 DIRTY_ATTR $url -themes/admin_wind/views/admin.html.php 22 DIRTY_JS $theme->url() -themes/admin_wind/views/admin.html.php 39 DIRTY $theme->admin_head() -themes/admin_wind/views/admin.html.php 43 DIRTY $theme->admin_page_top() -themes/admin_wind/views/admin.html.php 51 DIRTY $theme->admin_header_top() -themes/admin_wind/views/admin.html.php 52 DIRTY_JS item::root()->url() -themes/admin_wind/views/admin.html.php 55 DIRTY $theme->user_menu() -themes/admin_wind/views/admin.html.php 58 DIRTY $theme->admin_menu() -themes/admin_wind/views/admin.html.php 61 DIRTY $theme->admin_header_bottom() -themes/admin_wind/views/admin.html.php 68 DIRTY $content -themes/admin_wind/views/admin.html.php 74 DIRTY $sidebar -themes/admin_wind/views/admin.html.php 79 DIRTY $theme->admin_footer() -themes/admin_wind/views/admin.html.php 82 DIRTY $theme->admin_credits() -themes/admin_wind/views/admin.html.php 87 DIRTY $theme->admin_page_bottom() +themes/admin_wind/views/admin.html.php 21 DIRTY_JS $theme->url() +themes/admin_wind/views/admin.html.php 38 DIRTY $theme->admin_head() +themes/admin_wind/views/admin.html.php 42 DIRTY $theme->admin_page_top() +themes/admin_wind/views/admin.html.php 50 DIRTY $theme->admin_header_top() +themes/admin_wind/views/admin.html.php 51 DIRTY_JS item::root()->url() +themes/admin_wind/views/admin.html.php 54 DIRTY $theme->user_menu() +themes/admin_wind/views/admin.html.php 57 DIRTY $theme->admin_menu() +themes/admin_wind/views/admin.html.php 60 DIRTY $theme->admin_header_bottom() +themes/admin_wind/views/admin.html.php 67 DIRTY $content +themes/admin_wind/views/admin.html.php 73 DIRTY $sidebar +themes/admin_wind/views/admin.html.php 78 DIRTY $theme->admin_footer() +themes/admin_wind/views/admin.html.php 81 DIRTY $theme->admin_credits() +themes/admin_wind/views/admin.html.php 86 DIRTY $theme->admin_page_bottom() themes/admin_wind/views/block.html.php 3 DIRTY_ATTR $anchor themes/admin_wind/views/block.html.php 5 DIRTY $id themes/admin_wind/views/block.html.php 5 DIRTY_ATTR $css_id @@ -399,17 +399,17 @@ themes/wind/views/dynamic.html.php 29 DIRTY $theme themes/wind/views/movie.html.php 5 DIRTY $theme->paginator() themes/wind/views/movie.html.php 9 DIRTY $item->movie_img(array("class"=>"g-movie","id"=>"g-item-id-{$item->id}")) themes/wind/views/page.html.php 9 DIRTY $page_title -themes/wind/views/page.html.php 33 DIRTY_JS $theme->url() -themes/wind/views/page.html.php 42 DIRTY $new_width -themes/wind/views/page.html.php 43 DIRTY $new_height -themes/wind/views/page.html.php 44 DIRTY $thumb_proportion -themes/wind/views/page.html.php 81 DIRTY $header_text -themes/wind/views/page.html.php 83 DIRTY_JS item::root()->url() -themes/wind/views/page.html.php 87 DIRTY $theme->user_menu() -themes/wind/views/page.html.php 108 DIRTY_JS $parent->url($parent->id==$theme->item()->parent_id?"show={$theme->item()->id}":null) -themes/wind/views/page.html.php 129 DIRTY $content -themes/wind/views/page.html.php 135 DIRTY newView("sidebar.html") -themes/wind/views/page.html.php 142 DIRTY $footer_text +themes/wind/views/page.html.php 32 DIRTY_JS $theme->url() +themes/wind/views/page.html.php 41 DIRTY $new_width +themes/wind/views/page.html.php 42 DIRTY $new_height +themes/wind/views/page.html.php 43 DIRTY $thumb_proportion +themes/wind/views/page.html.php 80 DIRTY $header_text +themes/wind/views/page.html.php 82 DIRTY_JS item::root()->url() +themes/wind/views/page.html.php 86 DIRTY $theme->user_menu() +themes/wind/views/page.html.php 107 DIRTY_JS $parent->url($parent->id==$theme->item()->parent_id?"show={$theme->item()->id}":null) +themes/wind/views/page.html.php 128 DIRTY $content +themes/wind/views/page.html.php 134 DIRTY newView("sidebar.html") +themes/wind/views/page.html.php 141 DIRTY $footer_text themes/wind/views/paginator.html.php 33 DIRTY_JS $first_page_url themes/wind/views/paginator.html.php 42 DIRTY_JS $previous_page_url themes/wind/views/paginator.html.php 70 DIRTY_JS $next_page_url -- cgit v1.2.3 From 853a3acc9b5b017b479fa93e29e1d80c0acc1a50 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 8 Nov 2010 11:45:14 -0800 Subject: Implement module::clear_all_vars($module_name) Also switch from using ORM to Database_Builder for the SQL because it's cleaner, and clean up the test. Fixes #1479. --- modules/gallery/helpers/module.php | 22 +++++++++++++++++----- modules/gallery/tests/Var_Test.php | 38 ++++++++++++++++++++++---------------- 2 files changed, 39 insertions(+), 21 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index 64d0d1d6..16c7bb72 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -503,13 +503,25 @@ class module_Core { * @param string $name */ static function clear_var($module_name, $name) { - $var = ORM::factory("var") + db::build() + ->delete("vars") ->where("module_name", "=", $module_name) ->where("name", "=", $name) - ->find(); - if ($var->loaded()) { - $var->delete(); - } + ->execute(); + + Cache::instance()->delete("var_cache"); + self::$var_cache = null; + } + + /** + * Remove all variables for this module. + * @param string $module_name + */ + static function clear_all_vars($module_name) { + db::build() + ->delete("vars") + ->where("module_name", "=", $module_name) + ->execute(); Cache::instance()->delete("var_cache"); self::$var_cache = null; diff --git a/modules/gallery/tests/Var_Test.php b/modules/gallery/tests/Var_Test.php index b3492c71..292fe2f1 100644 --- a/modules/gallery/tests/Var_Test.php +++ b/modules/gallery/tests/Var_Test.php @@ -19,31 +19,37 @@ */ class Var_Test extends Gallery_Unit_Test_Case { public function add_parameter_test() { - module::set_var("gallery", "Parameter", "original value"); - $this->assert_equal("original value", module::get_var("gallery", "Parameter")); + module::set_var("Var_Test", "Parameter", "original value"); + $this->assert_equal("original value", module::get_var("Var_Test", "Parameter")); - module::set_var("gallery", "Parameter", "updated value"); - $this->assert_equal("updated value", module::get_var("gallery", "Parameter")); + module::set_var("Var_Test", "Parameter", "updated value"); + $this->assert_equal("updated value", module::get_var("Var_Test", "Parameter")); } public function clear_parameter_test() { - module::set_var("gallery", "Parameter", "original value"); - $this->assert_equal("original value", module::get_var("gallery", "Parameter")); + module::set_var("Var_Test", "Parameter", "original value"); + module::clear_var("Var_Test", "Parameter"); + $this->assert_equal(null, module::get_var("Var_Test", "Parameter")); + } - module::clear_var("gallery", "Parameter"); - $this->assert_equal(null, module::get_var("gallery", "Parameter")); + public function clear_all_module_parameters_test() { + module::set_var("Var_Test", "Parameter1", "original value"); + module::set_var("Var_Test", "Parameter2", "original value"); + module::clear_all_vars("Var_Test"); + $this->assert_equal(null, module::get_var("Var_Test", "Parameter1")); + $this->assert_equal(null, module::get_var("Var_Test", "Parameter2")); } public function incr_parameter_test() { - module::set_var("gallery", "Parameter", "original value"); - module::incr_var("gallery", "Parameter"); - $this->assert_equal("1", module::get_var("gallery", "Parameter")); + module::set_var("Var_Test", "Parameter", "original value"); + module::incr_var("Var_Test", "Parameter"); + $this->assert_equal("1", module::get_var("Var_Test", "Parameter")); - module::set_var("gallery", "Parameter", "2"); - module::incr_var("gallery", "Parameter", "9"); - $this->assert_equal("11", module::get_var("gallery", "Parameter")); + module::set_var("Var_Test", "Parameter", "2"); + module::incr_var("Var_Test", "Parameter", "9"); + $this->assert_equal("11", module::get_var("Var_Test", "Parameter")); - module::incr_var("gallery", "NonExistent", "9"); - $this->assert_equal(null, module::get_var("gallery", "NonExistent")); + module::incr_var("Var_Test", "NonExistent", "9"); + $this->assert_equal(null, module::get_var("Var_Test", "NonExistent")); } } \ No newline at end of file -- cgit v1.2.3 From e87c502eded374e927c531ad10a78dac8ee70e64 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 9 Nov 2010 12:48:07 -0800 Subject: Tie the image cachebuster to the file mtime instead of Item_Model::$updated since we want the url to be stable whenever possible. Fixes #1482. --- modules/gallery/models/item.php | 13 +++++++++---- modules/gallery/tests/Item_Model_Test.php | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) (limited to 'modules/gallery/tests') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index eaf09c9c..891153d1 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -166,8 +166,9 @@ class Item_Model_Core extends ORM_MPTT { */ public function file_url($full_uri=false) { $relative_path = "var/albums/" . $this->relative_path(); + $cache_buster = $this->_cache_buster($this->file_path()); return ($full_uri ? url::abs_file($relative_path) : url::file($relative_path)) - . "?m={$this->updated}"; + . $cache_buster; } /** @@ -198,7 +199,7 @@ class Item_Model_Core extends ORM_MPTT { * photo: http://example.com/gallery3/var/albums/album1/photo.thumb.jpg */ public function thumb_url($full_uri=false) { - $cache_buster = "?m={$this->updated}"; + $cache_buster = $this->_cache_buster($this->thumb_path()); $relative_path = "var/thumbs/" . $this->relative_path(); $base = ($full_uri ? url::abs_file($relative_path) : url::file($relative_path)); if ($this->is_photo()) { @@ -227,9 +228,9 @@ class Item_Model_Core extends ORM_MPTT { */ public function resize_url($full_uri=false) { $relative_path = "var/resizes/" . $this->relative_path(); + $cache_buster = $this->_cache_buster($this->resize_path()); return ($full_uri ? url::abs_file($relative_path) : url::file($relative_path)) . - ($this->is_album() ? "/.album.jpg" : "") - . "?m={$this->updated}"; + ($this->is_album() ? "/.album.jpg" : "") . $cache_buster; } /** @@ -1024,4 +1025,8 @@ class Item_Model_Core extends ORM_MPTT { } return $data; } + + private function _cache_buster($path) { + return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0); + } } diff --git a/modules/gallery/tests/Item_Model_Test.php b/modules/gallery/tests/Item_Model_Test.php index 90c54e3c..264a2128 100644 --- a/modules/gallery/tests/Item_Model_Test.php +++ b/modules/gallery/tests/Item_Model_Test.php @@ -406,6 +406,29 @@ class Item_Model_Test extends Gallery_Unit_Test_Case { return; // pass } $this->assert_true(false, "Shouldn't get here"); + } + + public function urls_test() { + $photo = test::random_photo(); + $this->assert_true( + preg_match("|http://./var/resizes/name_\d+\.jpg\?m=\d+|", $photo->resize_url()), + $photo->resize_url() . " is malformed"); + $this->assert_true( + preg_match("|http://./var/thumbs/name_\d+\.jpg\?m=\d+|", $photo->thumb_url()), + $photo->thumb_url() . " is malformed"); + $this->assert_true( + preg_match("|http://./var/albums/name_\d+\.jpg\?m=\d+|", $photo->file_url()), + $photo->file_url() . " is malformed"); + // Albums have special thumbnails. Empty album has cachebuster of 0 since it has no thumbnail + $album = test::random_album(); + $this->assert_true( + preg_match("|http://./var/thumbs/name_\d+/\.album\.jpg\?m=0|", $album->thumb_url()), + $album->thumb_url() . " is malformed"); + + $photo = test::random_photo($album); + $this->assert_true( + preg_match("|http://./var/thumbs/name_\d+/\.album\.jpg\?m=\d+|", $album->thumb_url()), + $album->thumb_url() . " is malformed"); } } -- cgit v1.2.3 From 13cc0087ec135caf67e7c3c2becd9a12b72298b4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 20 Nov 2010 20:43:18 -0800 Subject: I don't run these, I doubt anybody does. Deleting --- modules/gallery/tests/selenium/Add_Album.html | 52 --------------------- modules/gallery/tests/selenium/Add_Comment.html | 52 --------------------- modules/gallery/tests/selenium/Add_Item.html | 62 ------------------------- modules/gallery/tests/selenium/Login.html | 47 ------------------- 4 files changed, 213 deletions(-) delete mode 100644 modules/gallery/tests/selenium/Add_Album.html delete mode 100644 modules/gallery/tests/selenium/Add_Comment.html delete mode 100644 modules/gallery/tests/selenium/Add_Item.html delete mode 100644 modules/gallery/tests/selenium/Login.html (limited to 'modules/gallery/tests') diff --git a/modules/gallery/tests/selenium/Add_Album.html b/modules/gallery/tests/selenium/Add_Album.html deleted file mode 100644 index ccd4d0b7..00000000 --- a/modules/gallery/tests/selenium/Add_Album.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -AddAlbum - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AddAlbum
open/index.php/albums/1
clicklink=Add album
typenameseleniumtest
typetitleSelenium Test Album
typedescriptionTest
click//button[@type='button']
assertTextPresentSelenium Test Album
- - diff --git a/modules/gallery/tests/selenium/Add_Comment.html b/modules/gallery/tests/selenium/Add_Comment.html deleted file mode 100644 index 054e7597..00000000 --- a/modules/gallery/tests/selenium/Add_Comment.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -Add comment - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Add comment
open/index.php/albums/1
clickAndWaitg-photo-id-2
typeg-authorTest
typeg-emailtest@gmail.com
typeg-textThis is a selenium test comment.
click//button[@type='submit']
assertTextPresentThis is a selenium test comment.
- - diff --git a/modules/gallery/tests/selenium/Add_Item.html b/modules/gallery/tests/selenium/Add_Item.html deleted file mode 100644 index 741dff65..00000000 --- a/modules/gallery/tests/selenium/Add_Item.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - -AddItem - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AddItem
open/index.php/albums/1
clicklink=Add an item
typenameseleniumitem.jpg
typetitleSelenium Item
typedescriptionTest item
typefile/Users/ckieffer/Sites/gallery3.0/core/tests/images/DSC_0003.jpg
click//button[@type='button']
clicklink=X
assertTextPresentSelenium Item
- - diff --git a/modules/gallery/tests/selenium/Login.html b/modules/gallery/tests/selenium/Login.html deleted file mode 100644 index d2e45c63..00000000 --- a/modules/gallery/tests/selenium/Login.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - -Login - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Login
open/index.php/albums/1
clickg-login-link
typeg-nameadmin
typeg-passwordadmin
clickAndWait//button[@type='button']
clickAndWaitg-user-profile-link
- - -- cgit v1.2.3