Apache-AuthCookie

 view release on metacpan or  search on metacpan

t/real.t  view on Meta::CPAN


    $r = POST('/LOGIN-ENFORCELOCAL-NODEFAULT', [
        credential_0 => 'programmer',
        credential_1 => 'Hero'
    ]);

    like($r->content, qr/Failure reason: 'no_cookie'/,
        'login form was returned for no destination in params');

    $r = POST('/LOGIN-ENFORCELOCAL-NODEFAULT', [
        destination  => '/docs/protected/get_me.html',
        credential_0 => 'programmer',
        credential_1 => 'Hero'
    ]);

    is($r->header('Location'), '/docs/protected/get_me.html',
       'Got redirected to protected document for local destination');

    $r = POST('/LOGIN-ENFORCELOCAL-NODEFAULT', [
        destination  => '//metacpan.org/index.html',
        credential_0 => 'programmer',
        credential_1 => 'Hero'
    ]);

    like($r->content, qr/Failure reason: 'no_cookie'/,
        'login form was returned - protocol relative destination in params');
};

subtest 'EnforceLocalDestination with non local default destination' => sub {
    plan tests => 3;

    my $r = POST('/LOGIN-ENFORCELOCAL-REMOTEDEFAULT', [
        destination  => "http://metacpan.org/",
        credential_0 => 'programmer',
        credential_1 => 'Hero'
    ]);

    like($r->content, qr/Failure reason: 'no_cookie'/,
        'login form was returned for non local destination');

    $r = POST('/LOGIN-ENFORCELOCAL-REMOTEDEFAULT', [
        credential_0 => 'programmer',
        credential_1 => 'Hero'
    ]);

    like($r->content, qr/Failure reason: 'no_cookie'/,
        'login form was returned for no destination in params');

    $r = POST('/LOGIN-ENFORCELOCAL-REMOTEDEFAULT', [
        destination  => '/docs/protected/get_me.html',
        credential_0 => 'programmer',
        credential_1 => 'Hero'
    ]);

    is($r->header('Location'), '/docs/protected/get_me.html',
       'Got redirected to protected document for local destination');
};

# remove CR's from a string.  Win32 apache apparently does line ending
# conversion, and that can cause test cases to fail because output does not
# match expected because expected has UNIX line endings, and OUTPUT has dos
# style line endings.
sub strip_cr {
    my $data = shift;
    $data =~ s/\r//gs;
    return $data;
}

# vim: ft=perl ts=4 ai et sw=4



( run in 1.539 second using v1.01-cache-2.11-cpan-f56aa216473 )