CGI-Application-Framework

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

0.24
   - Rebuild with better Module::Build YAML support

0.23
   - Added version number requirements on Module::Build (0.2602) and
     DBD::SQLite (1.09) so that 'make test' doesn't fail for people
     with older versions; thanks to Dan Horne for finding this stuff

0.20_8 Sep 7, 2005
   - version number update, attributions, license & copyright info, etc.
     in prep of an upload to PAUSE

0.20_7 Jul 11, 2005
   - login validation errors weren't being passed to login template
   - checksum_okay wasn't picking up the checksum from URL for POSTed forms

0.20 Jun 12, 2005
   - first release with Module::Build installer
   - docs converted to POD
   - basic tests are now done (still need to write more detailed ones, though)
   - now requires CGI::Application 4.0 (for callback support)

t/05-relogin.t  view on Meta::CPAN

$Consistency_Match = qr/hobgoblin/;

# Create a CGI query in a data file

# my $input = CGI::Test::Input::Multipart->new();
#
# $input->add_field("come_from_rm", "page_the_second");
# $input->add_field("rm",           "page_the_second");
# # $input->add_field("bork",         "bork\n\rfoo".chr(27)."beeble\n");
# $input->add_field("_session_id",  $session_id);
# $input->add_file("upfile",        "t/data/test_upload.txt");

# Ideas and code borrowed from Gabor Szabo's CGI::Upload test script
# and from CGI::Test::Input::Multipart by Raphael Manfredi and Steven Hilton

my $unusual_value = "bork\n\rfoo".chr(27)."beeble\r\n\r\nkowabunga";
my %form_params = (
    come_from_rm => 'page_the_second',
    rm           => 'page_the_second',
    _session_id  => $session_id,
    'unusual'    => $unusual_value,

t/05-relogin.t  view on Meta::CPAN

open STDIN, '>&', $old_stdin, or die "Can't restore STDIN: $!\n";

$app   = MyTestApp->new(QUERY => $query);
$app->stash->{'Suppress_Output'} = 1;
$app->run;
undef $app->stash->{'Suppress_Output'};

ok($app->stash->{'Seen_Run_Mode'}{'relogin'},  '[page_the_second, query test, fail _relogin_test] redirected to relogin');
is($app->stash->{'Final_Run_Mode'}, 'relogin', '[page_the_second, query test, fail _relogin_test] final page was relogin');

my %upload_contents;
{
    local $/;

    for my $field (qw(first_files second_files)) {
        my (@fh)        = $query->upload($field);
        my (@filenames) = $query->param($field);

        for (my $i = 0; $i < @fh; $i++) {
            my $handle = $fh[$i];
            $upload_contents{$filenames[$i]} = <$handle>;
        }
    }
}

for my $file (keys %file_contents) {
    is($upload_contents{$file}, $file_contents{$file}, "[initial query] upload file contents okay: $file");
}
is($query->param('unusual'), $unusual_value,           '[initial query] unusual value survived');


$Consistency_Match = qr/goblin/;

#######################################################################
# relogin submitted, successfully reauthenticated

$query = new CGI;

t/05-relogin.t  view on Meta::CPAN

$query->param('rm',           'relogin');
$query->param('password',     'seekrit');

$app   = MyTestApp->new(QUERY => $query);
$app->run;

ok($app->stash->{'Seen_Run_Mode'}{'page_the_second'},  '[relogin sub to page_the_second, pass] fall through to page_the_second');
is($app->stash->{'Final_Run_Mode'}, 'page_the_second', '[relogin sub to page_the_second, pass] final page was page_the_second');
is($query->param('unusual'), $unusual_value, '[relogin sub to page_the_second, pass] unusual value survived');

undef %upload_contents;
{
    local $/;

    for my $field (qw(first_files second_files)) {
        my (@fh)        = $query->upload($field);
        my (@filenames) = $query->param($field);

        for (my $i = 0; $i < @fh; $i++) {
            my $handle = $fh[$i];
            $upload_contents{$filenames[$i]} = <$handle>;
        }
    }
}

SKIP: {
    my $num_files = keys %file_contents;
    skip "CGI uploads don't currently survive the relogin process", $num_files;
    for my $file (keys %file_contents) {
        is($upload_contents{$file}, $file_contents{$file}, "[initial query] upload file contents okay: $file");
    }
}




t/data/formdata.foo  view on Meta::CPAN

page_the_second
---------------cgi-test--------------102102619-2089727187
Content-Disposition: form-data; name="rm"

page_the_second
---------------cgi-test--------------102102619-2089727187
Content-Disposition: form-data; name="_session_id"

29e6894863b482484b34a0ff1cc180fd
---------------cgi-test--------------102102619-2089727187
Content-Disposition: form-data; name="upfile"; filename="t/data/test_upload.txt"
Content-Type: application/octet-stream

'Twas brillig and the slithy toves
Did gyre and gimble on the wabe
All mimsy were the borogoves
And the mome raths outgrabe
---------------cgi-test--------------102102619-2089727187



( run in 2.198 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )