Remove getStatus and setStatus in Session::Http, and replace them with status, from $session->status.
This commit is contained in:
parent
b830bd8e71
commit
e5adc07a05
27 changed files with 88 additions and 129 deletions
|
|
@ -860,19 +860,19 @@ is $clippedAsset->get('state'), 'clipboard', '... clipped an asset';
|
|||
|
||||
$session->switchAdminOff;
|
||||
$session->http->setRedirectLocation('');
|
||||
$session->http->setStatus(200, 'OK');
|
||||
$session->response->status(200, 'OK');
|
||||
|
||||
$trashedAsset->checkView();
|
||||
is $session->http->getStatus, 410, '... status set to 410 for trashed asset';
|
||||
is $session->response->status, 410, '... status set to 410 for trashed asset';
|
||||
is $session->http->getRedirectLocation, '', '... no redirect set';
|
||||
|
||||
$session->http->setStatus(200, 'OK');
|
||||
$session->response->status(200, 'OK');
|
||||
$clippedAsset->checkView();
|
||||
is $session->http->getStatus, 410, '... status set to 410 for cut asset';
|
||||
is $session->response->status, 410, '... status set to 410 for cut asset';
|
||||
is $session->http->getRedirectLocation, '', '... no redirect set';
|
||||
|
||||
$session->switchAdminOn;
|
||||
$session->http->setStatus(200, 'OK');
|
||||
$session->response->status(200, 'OK');
|
||||
is $trashedAsset->checkView(), 'chunked', '... returns "chunked" when admin is on for trashed asset';
|
||||
is $session->http->getRedirectLocation, $trashedAsset->getUrl('func=manageTrash'), '... trashed asset sets redirect to manageTrash';
|
||||
|
||||
|
|
|
|||
|
|
@ -353,26 +353,26 @@ is($printRemainingTicketsTemplateId, "hreA_bgxiTX-EzWCSZCZJw", 'Default print re
|
|||
#Make sure permissions work on pages
|
||||
my $data;
|
||||
$session->user({userId => $crasher->getId});
|
||||
$session->http->setStatus(201);
|
||||
$session->response->status(201);
|
||||
$data = $ems->www_viewSchedule();
|
||||
is($session->http->getStatus, 401, 'www_viewSchedule: visitor may not see the schedule');
|
||||
is($session->response->status, 401, 'www_viewSchedule: visitor may not see the schedule');
|
||||
$data = $ems->www_printRemainingTickets();
|
||||
is($session->http->getStatus, 401, 'www_printRemainingTickets: visitor may not print the remaining tickets');
|
||||
is($session->response->status, 401, 'www_printRemainingTickets: visitor may not print the remaining tickets');
|
||||
|
||||
$session->http->setStatus(201);
|
||||
$session->response->status(201);
|
||||
$session->user({userId => $attender->getId});
|
||||
$data = $ems->www_viewSchedule();
|
||||
is($session->http->getStatus, 201, '... attender user can see the schedule');
|
||||
is($session->response->status, 201, '... attender user can see the schedule');
|
||||
$data = $ems->www_printRemainingTickets();
|
||||
is($session->http->getStatus, 401, 'www_printRemainingTickets: attender may not print the remaining tickets');
|
||||
is($session->response->status, 401, 'www_printRemainingTickets: attender may not print the remaining tickets');
|
||||
|
||||
$session->http->setStatus(201);
|
||||
$session->response->status(201);
|
||||
$session->user({userId => $registrar->getId});
|
||||
$data = $ems->www_printRemainingTickets();
|
||||
is($session->http->getStatus, 201, 'www_printRemainingTickets: registration staff may print the remaining tickets');
|
||||
is($session->response->status, 201, 'www_printRemainingTickets: registration staff may print the remaining tickets');
|
||||
|
||||
|
||||
$session->http->setStatus(201);
|
||||
$session->response->status(201);
|
||||
$session->user({userId => $crasher->getId});
|
||||
my ($json, $records);
|
||||
$json = $ems->www_getScheduleDataJSON();
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ cmp_deeply(from_json($surveyEnd), { type => 'forward', url => '/getting_started'
|
|||
# Check a simple www_jumpTo request
|
||||
$session->user( { userId => 3 } );
|
||||
WebGUI::Test->getPage( $survey, 'www_jumpTo', { formParams => {id => '0'} } );
|
||||
is( $session->http->getStatus, '201', 'Page request ok' ); # why is "201 - created" status used??
|
||||
is( $session->response->status, '201', 'Page request ok' ); # why is "201 - created" status used??
|
||||
is($survey->responseJSON->nextResponse, 0, 'S0 is the first response');
|
||||
|
||||
tie my %expectedSurveyOrder, 'Tie::IxHash';
|
||||
|
|
|
|||
|
|
@ -430,10 +430,10 @@ $session->request->setup_body({
|
|||
});
|
||||
|
||||
$session->user({userId => '3'});
|
||||
$session->http->setStatus(200);
|
||||
$session->response->status(200);
|
||||
my $json = $thingy->www_editThingDataSaveViaAjax();
|
||||
diag "json: ".$json;
|
||||
is $json, '{}', 'www_editThingDataSaveViaAjax: Empty JSON hash';
|
||||
is $session->http->getStatus, 200, '... http status=200';
|
||||
is $session->response->status, 200, '... http status=200';
|
||||
|
||||
$session->request->setup_body({ });
|
||||
|
|
|
|||
|
|
@ -224,14 +224,14 @@ WebGUI::Test->addToCleanup( $notModifiedSession );
|
|||
|
||||
my $output = WebGUI::Content::Asset::handler( $notModifiedSession );
|
||||
is( $output, "chunked", "304 returns chunked" );
|
||||
is( $notModifiedSession->http->getStatus, "304", "http status code set" );
|
||||
is( $notModifiedSession->response->status, "304", "http status code set" );
|
||||
ok( !$notModifiedSession->closed, "session is not closed" );
|
||||
|
||||
$notModifiedSession = WebGUI::Test->newSession( undef, $http_request);
|
||||
WebGUI::Test->addToCleanup( $notModifiedSession );
|
||||
$notModifiedSession->user({ userId => 3});
|
||||
my $output = WebGUI::Content::Asset::handler( $notModifiedSession );
|
||||
isnt( $notModifiedSession->http->getStatus, "304", "logged in user doesn't get 304" );
|
||||
isnt( $notModifiedSession->response->status, "304", "logged in user doesn't get 304" );
|
||||
ok( !$notModifiedSession->closed, "session is not closed" );
|
||||
|
||||
# Test that requesting a URL that doesn't exist, but one of the permutations does exist, returns undef
|
||||
|
|
|
|||
|
|
@ -20,11 +20,12 @@ use Data::Dumper;
|
|||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
plan tests => 48;
|
||||
plan tests => 46;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $http = $session->http;
|
||||
my $http = $session->http;
|
||||
my $response = $session->response;
|
||||
|
||||
use Test::MockObject::Extends;
|
||||
|
||||
|
|
@ -38,37 +39,21 @@ $http->mock( getCookies => sub { return {$cookieName => $varId} } );
|
|||
|
||||
isa_ok($http, 'WebGUI::Session::Http', 'session has correct object type');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# setStatus, getStatus
|
||||
#
|
||||
####################################################
|
||||
|
||||
$http->setStatus('123');
|
||||
|
||||
is($http->getStatus, '123', 'getStatus: returns correct code');
|
||||
|
||||
$http->setStatus('');
|
||||
|
||||
is($http->getStatus, '200', 'getStatus: returns default code');
|
||||
|
||||
$http->setStatus('', 'packets are great');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# isRedirect
|
||||
#
|
||||
####################################################
|
||||
|
||||
$http->setStatus('200');
|
||||
$response->status('200');
|
||||
ok(!$http->isRedirect, 'isRedirect: 200 is not');
|
||||
|
||||
$http->setStatus('301');
|
||||
$response->status('301');
|
||||
ok($http->isRedirect, '... 301 is');
|
||||
|
||||
$http->setStatus('302');
|
||||
$response->status('302');
|
||||
ok($http->isRedirect, '... 302 is too');
|
||||
$http->setStatus('200');
|
||||
$response->status('200');
|
||||
|
||||
####################################################
|
||||
#
|
||||
|
|
@ -151,7 +136,7 @@ $http->setCacheControl(undef);
|
|||
$session->request->uri('/here/later');
|
||||
|
||||
$http->setRedirect('/here/now');
|
||||
is($http->getStatus, 302, 'setRedirect: sets HTTP status');
|
||||
is($response->status, 302, 'setRedirect: sets HTTP status');
|
||||
is($http->getRedirectLocation, '/here/now', 'setRedirect: redirect location');
|
||||
|
||||
$session->style->useEmptyStyle(1);
|
||||
|
|
@ -234,7 +219,7 @@ is($http->sendHeader, undef, 'sendHeader returns undef when no request object is
|
|||
my $guard = WebGUI::Test->cleanupGuard($session);
|
||||
my $http = $session->http;
|
||||
my $response = $session->response;
|
||||
$http->setStatus(200, 'Just spiffy');
|
||||
$response->status(200);
|
||||
$http->setMimeType('');
|
||||
$session->request->protocol('');
|
||||
$http->setLastModified(1200);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ my $i18n = WebGUI::International->new($session);
|
|||
foreach my $test (@simpleTests) {
|
||||
my $method = $test->{method};
|
||||
my $output = $privilege->$method;
|
||||
is($session->http->getStatus(), $test->{status}, "$method: status code");
|
||||
is($session->response->status(), $test->{status}, "$method: status code");
|
||||
my $title = $i18n->get($test->{titleCode});
|
||||
like($output, qr{<h1>$title</h1>}, "$method: correct title");
|
||||
like($output, qr{^USERSTYLE}, "$method: renders in WebGUI User Style");
|
||||
|
|
@ -97,7 +97,7 @@ foreach my $test (@simpleTests) {
|
|||
####################################################
|
||||
|
||||
my $output = $privilege->insufficient(1);
|
||||
is($session->http->getStatus(), '401', 'insufficient: status code with Visitor');
|
||||
is($session->response->status(), '401', 'insufficient: status code with Visitor');
|
||||
my $title = $i18n->get(37);
|
||||
unlike($output, qr{^USERSTYLE}, "insufficient: when noStyle is true the user style is not used");
|
||||
like($output, qr{<h1>$title</h1>}, "insufficient: when noStyle is true the title is still okay");
|
||||
|
|
@ -111,7 +111,7 @@ like($output, qr{<h1>$title</h1>}, "insufficient: when noStyle is true the title
|
|||
$session->user({userId=>1});
|
||||
|
||||
my $output = $privilege->noAccess;
|
||||
is($session->http->getStatus(), '401', 'noAccess: status code with Visitor');
|
||||
is($session->response->status(), '401', 'noAccess: status code with Visitor');
|
||||
##Is the auth screen returned, not validating the auth screen
|
||||
is($output, WebGUI::Operation::Auth::www_auth($session, "init"), 'noAccess: visitor sees auth screen');
|
||||
|
||||
|
|
|
|||
|
|
@ -445,8 +445,8 @@ ok( ! $session->url->forceSecureConnection(), 'HTTPS must not be "on" to force S
|
|||
ok( ! $session->url->forceSecureConnection('/test/url'), 'all conditions must be met, even if a URL is directly passed in');
|
||||
|
||||
##Validate the HTTP object state before we start
|
||||
$session->http->setStatus('200', 'OK');
|
||||
is($session->http->getStatus, 200, 'http status is okay, 200');
|
||||
$session->response->status('200');
|
||||
is($session->response->status, 200, 'http status is okay, 200');
|
||||
is($session->http->getRedirectLocation, undef, 'redirect location is empty');
|
||||
|
||||
$env->{'psgi.url_scheme'} = "http";
|
||||
|
|
@ -455,10 +455,10 @@ my $secureUrl = $session->url->getSiteURL . '/foo/bar/baz/buz';
|
|||
$secureUrl =~ s/http:/https:/;
|
||||
|
||||
ok($session->url->forceSecureConnection('/foo/bar/baz/buz'), 'forced secure connection');
|
||||
is($session->http->getStatus, 302, 'http status set to redirect, 302');
|
||||
is($session->response->status, 302, 'http status set to redirect, 302');
|
||||
is($session->http->getRedirectLocation, $secureUrl, 'redirect location set to proper passed in URL with SSL and sitename added');
|
||||
|
||||
$session->http->setStatus('200', 'OK');
|
||||
$session->response->status('200', 'OK');
|
||||
$session->http->setRedirectLocation(undef);
|
||||
|
||||
$secureUrl = $session->url->getSiteURL . $session->url->page();
|
||||
|
|
|
|||
|
|
@ -482,10 +482,10 @@ cmp_bag(
|
|||
#
|
||||
####################################################
|
||||
|
||||
$session->http->setStatus(413);
|
||||
$session->response->status(413);
|
||||
is($fileStore->addFileFromFormPost(), '', 'addFileFromFormPost returns empty string when HTTP status is 413');
|
||||
|
||||
$session->http->setStatus(200);
|
||||
$session->response->status(200);
|
||||
$session->request->upload('files', []);
|
||||
my $formStore = WebGUI::Storage->create($session);
|
||||
addToCleanup($formStore);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue