File: 12_badconfig.t

package info (click to toggle)
libcgi-application-plugin-session-perl 1.06-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 244 kB
  • sloc: perl: 533; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use lib './t';
use Test::More;
BEGIN {
    eval { require Test::Exception; Test::Exception->import; };
    if ( $@ ) {
        plan skip_all => 'These tests require Test::Exception';
    }
    else {
         plan tests => 3;
    }
};

{
    package TestAppBadConfig;
    @TestAppBadConfig::ISA = qw(CGI::Application);
    use CGI::Application::Plugin::Session;
};

my $app = TestAppBadConfig->new();
$app->session_config( CGI_SESSION_OPTIONS => [ "driver:invalid_driver", $app->query ] );

dies_ok(sub { $app->session }, 'creation of CGI::Session object fails with a bad config');

## sub our own testing warn handler
my $warning;
$SIG{'__WARN__'} = sub { $warning = join ' ', @_ };

## mismatch cookie name and session name
my $app2 = TestAppBadConfig->new();
$app2->session_config(
    CGI_SESSION_OPTIONS => [
        "driver:File", '1111', {}, { name => 'foobar' }
    ],
    COOKIE_PARAMS => { -name => 'monkeybeard' }
);

## should generate warning
$app2->session;

ok $warning, "cookie and session name don't match";
like $warning, qr/Cookie.*?Session/;

1;