Skip to content

Commit

Permalink
Merge branch 'master' into talmdal_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Almdal committed Mar 8, 2010
2 parents 1c022a5 + be580c9 commit 8715f60
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion modules/gallery/helpers/gallery_event.php
Expand Up @@ -383,7 +383,7 @@ static function context_menu($menu, $theme, $item, $thumb_css_selector) {
->id("delete") ->id("delete")
->label($delete_title) ->label($delete_title)
->css_class("ui-icon-trash") ->css_class("ui-icon-trash")
->css_id("g-quick-delete") ->css_class("g-quick-delete")
->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type"))); ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type")));
} }


Expand Down
5 changes: 2 additions & 3 deletions modules/organize/helpers/organize_event.php
Expand Up @@ -26,7 +26,7 @@ static function site_menu($menu, $theme) {
->append(Menu::factory("dialog") ->append(Menu::factory("dialog")
->id("organize") ->id("organize")
->label(t("Organize album")) ->label(t("Organize album"))
->css_id("g-organize-link") ->css_id("g-menu-organize-link")
->url(url::site("organize/dialog/{$item->id}"))); ->url(url::site("organize/dialog/{$item->id}")));
} }
} }
Expand All @@ -37,8 +37,7 @@ static function context_menu($menu, $theme, $item) {
->append(Menu::factory("dialog") ->append(Menu::factory("dialog")
->id("organize") ->id("organize")
->label(t("Organize album")) ->label(t("Organize album"))
->css_id("g-organize-link") ->css_class("ui-icon-folder-open g-organize-link")
->css_class("ui-icon-folder-open")
->url(url::site("organize/dialog/{$item->id}"))); ->url(url::site("organize/dialog/{$item->id}")));
} }
} }
Expand Down
3 changes: 1 addition & 2 deletions modules/rest/helpers/rest.php
Expand Up @@ -39,8 +39,7 @@ static function reply($data=array()) {


static function set_active_user($access_token) { static function set_active_user($access_token) {
if (empty($access_token)) { if (empty($access_token)) {
identity::set_active_user(identity::guest()); throw new Rest_Exception("Forbidden", 403);
return;
} }


$key = ORM::factory("user_access_token") $key = ORM::factory("user_access_token")
Expand Down
32 changes: 20 additions & 12 deletions modules/rest/tests/Rest_Controller_Test.php
Expand Up @@ -20,6 +20,9 @@
class Rest_Controller_Test extends Gallery_Unit_Test_Case { class Rest_Controller_Test extends Gallery_Unit_Test_Case {
public function setup() { public function setup() {
$this->_save = array($_GET, $_POST, $_SERVER); $this->_save = array($_GET, $_POST, $_SERVER);

$key = rest::get_access_token(1); // admin user
$_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $key->access_key;
} }


public function teardown() { public function teardown() {
Expand Down Expand Up @@ -60,24 +63,26 @@ public function login_failed_test() {
} }


public function get_test() { public function get_test() {
unset($_SERVER["HTTP_X_GALLERY_REQUEST_KEY"]);

$_SERVER["REQUEST_METHOD"] = "GET"; $_SERVER["REQUEST_METHOD"] = "GET";
$_GET["key"] = "value"; $_GET["key"] = "value";


$this->assert_array_equal_to_json( try {
array("params" => array("key" => "value"), test::call_and_capture(array(new Rest_Controller(), "mock"));
"method" => "get", } catch (Rest_Exception $e) {
"access_token" => null, $this->assert_same(403, $e->getCode());
"url" => "http://./index.php/gallery_unit_test"), return;
test::call_and_capture(array(new Rest_Controller(), "mock"))); }

$this->assert_true(false, "Should be forbidden");
} }


public function get_with_access_key_test() { public function get_with_access_key_test() {
$key = rest::get_access_token(1); // admin user

$_SERVER["REQUEST_METHOD"] = "GET"; $_SERVER["REQUEST_METHOD"] = "GET";
$_SERVER["HTTP_X_GALLERY_REQUEST_KEY"] = $key->access_key;
$_GET["key"] = "value"; $_GET["key"] = "value";


$key = rest::get_access_token(1); // admin user
$this->assert_array_equal_to_json( $this->assert_array_equal_to_json(
array("params" => array("key" => "value"), array("params" => array("key" => "value"),
"method" => "get", "method" => "get",
Expand All @@ -90,10 +95,11 @@ public function post_test() {
$_SERVER["REQUEST_METHOD"] = "POST"; $_SERVER["REQUEST_METHOD"] = "POST";
$_POST["key"] = "value"; $_POST["key"] = "value";


$key = rest::get_access_token(1); // admin user
$this->assert_array_equal_to_json( $this->assert_array_equal_to_json(
array("params" => array("key" => "value"), array("params" => array("key" => "value"),
"method" => "post", "method" => "post",
"access_token" => null, "access_token" => $key->access_key,
"url" => "http://./index.php/gallery_unit_test"), "url" => "http://./index.php/gallery_unit_test"),
test::call_and_capture(array(new Rest_Controller(), "mock"))); test::call_and_capture(array(new Rest_Controller(), "mock")));
} }
Expand All @@ -103,10 +109,11 @@ public function put_test() {
$_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "put"; $_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "put";
$_POST["key"] = "value"; $_POST["key"] = "value";


$key = rest::get_access_token(1); // admin user
$this->assert_array_equal_to_json( $this->assert_array_equal_to_json(
array("params" => array("key" => "value"), array("params" => array("key" => "value"),
"method" => "put", "method" => "put",
"access_token" => null, "access_token" => $key->access_key,
"url" => "http://./index.php/gallery_unit_test"), "url" => "http://./index.php/gallery_unit_test"),
test::call_and_capture(array(new Rest_Controller(), "mock"))); test::call_and_capture(array(new Rest_Controller(), "mock")));
} }
Expand All @@ -116,10 +123,11 @@ public function delete_test() {
$_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "delete"; $_SERVER["HTTP_X_GALLERY_REQUEST_METHOD"] = "delete";
$_POST["key"] = "value"; $_POST["key"] = "value";


$key = rest::get_access_token(1); // admin user
$this->assert_array_equal_to_json( $this->assert_array_equal_to_json(
array("params" => array("key" => "value"), array("params" => array("key" => "value"),
"method" => "delete", "method" => "delete",
"access_token" => null, "access_token" => $key->access_key,
"url" => "http://./index.php/gallery_unit_test"), "url" => "http://./index.php/gallery_unit_test"),
test::call_and_capture(array(new Rest_Controller(), "mock"))); test::call_and_capture(array(new Rest_Controller(), "mock")));
} }
Expand Down

0 comments on commit 8715f60

Please sign in to comment.