From 7d59a4d7c73ab69e333f01252cfc356425c2e062 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sun, 14 Sep 2008 02:39:32 +0000 Subject: [PATCH] Fix a bug where GUID style userIds were rejected by AssetExportHtml. --- lib/WebGUI/AssetExportHtml.pm | 4 ++-- t/Asset/AssetExportHtml.t | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/AssetExportHtml.pm b/lib/WebGUI/AssetExportHtml.pm index 0c66c1de5..66c976941 100644 --- a/lib/WebGUI/AssetExportHtml.pm +++ b/lib/WebGUI/AssetExportHtml.pm @@ -224,7 +224,7 @@ sub exportAsHtml { } # we take either a numeric userId or a WebGUI::User object - if( ref $userId ne 'WebGUI::User' && !looks_like_number($userId) ) { + if( ref $userId ne 'WebGUI::User' && ! (looks_like_number($userId) || $session->id->valid($userId))) { $returnCode = 0; $message = "'$userId' is not a valid userId"; return ($returnCode, $message); @@ -826,7 +826,7 @@ sub www_export { -value => "index.html" ); $f->text( - -label => 'Export site root URL', + -label => $i18n->get("Export site root URL"), -name => 'exportUrl', -value => '', ); diff --git a/t/Asset/AssetExportHtml.t b/t/Asset/AssetExportHtml.t index 408ef227a..b9a46e498 100644 --- a/t/Asset/AssetExportHtml.t +++ b/t/Asset/AssetExportHtml.t @@ -42,7 +42,7 @@ my $originalExportPath = $session->config->get('exportPath'); my $testRan = 1; if ($originalExportPath) { - plan tests => 145; # Increment this number for each test you create + plan tests => 146; # Increment this number for each test you create } else { $testRan = 0; @@ -714,6 +714,13 @@ is($message, "need a userId parameter", "exportAsHtml returns correct message wh is($success, 0, "exportAsHtml returns 0 when given a bogus (but nonetheless funny) userId"); is($message, "' perlDreamer is a 500 lb test mandating gorilla' is not a valid userId", "exportAsHtml returns correct message when given a bogus (but nonetheless funny) userId"); +# checking an autogenerated userId +my $randomUser = WebGUI::User->new($session, 'new'); +($success, $message) = $home->exportAsHtml( { userId => $randomUser->userId, depth => 99} ); +is($success, 1, "exportAsHtml returns 1 when given a valid userId"); +$randomUser->delete; +undef $randomUser; + # checking userId works, so check extrasUploadAction next. ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99, extrasUploadAction => 'o hai' } ); is($success, 0, "exportAsHtml returns 0 when given bogus, memetic extrasUploadAction parameter"); @@ -1010,5 +1017,12 @@ END { # make sure people can view /home $home->update( { groupIdView => 7 } ); # everyone + + # delete test user + if ($randomUser and ref $randomUser eq 'WebGUI::User') { + $randomUser->delete; + } + + } }