File: 05cookie.t

package info (click to toggle)
libmojomojo-perl 1.01%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,272 kB
  • ctags: 879
  • sloc: perl: 14,055; sh: 145; xml: 120; ruby: 6; makefile: 2
file content (20 lines) | stat: -rw-r--r-- 676 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env perl
use strict;
use warnings;
use HTTP::Request::Common;
use Test::More tests => 3;

BEGIN {
    $ENV{CATALYST_CONFIG} = 't/var/mojomojo.yml';
    use_ok( 'Catalyst::Test', 'MojoMojo' );
}

# Test that a cookie is not set when an anonymous user (non-authenticated) requests the root node.
my $response = request('/');
ok( !$response->headers->header('set-cookie'), 'No cookie set for anonymous request of "/"' );

# Test that a cookie is set when logging in.
my $login = 'admin';
my $pass  = 'admin';
$response = request( POST '/.login', [ login => $login, pass => $pass ] );
ok( $response->headers->header('set-cookie'), 'Yes, cookie set when logging in.' );