Debian Codegraph @

lemonldap-ng-common/t/40-Common-Session.t

raw
1 use warnings;
2
3 # Before `make install' is performed this script should be runnable with
4 # `make test'. After `make install' it should work as `perl Lemonldap-NG-Manager.t'
5
6 #########################
7
8 # change 'tests => 1' to 'tests => last_test_to_print';
9
10 use Test::More tests => 7;
11 use File::Path;
12 BEGIN { use_ok('Lemonldap::NG::Common::Session') }
13
14 #########################
15
16 # Insert your test code below, the Test::More module is used here so read
17 # its man page ( perldoc Test::More ) for help writing this test script.
18
19 use File::Temp;
20 my $dir = File::Temp::tempdir();
21
22 my $sessionModule = "Apache::Session::File";
23 my $sessionOptions = {
24 Directory => $dir,
25 LockDirectory => $dir,
26 };
27
28 my $session = Lemonldap::NG::Common::Session->new( {
29 storageModule => $sessionModule,
30 storageModuleOptions => $sessionOptions,
31 kind => "TEST",
32 }
33
34 );
35
36 ok( defined $session->id, "Creation of session" );
37
38 ok( $session->kind eq "TEST", "Store session kind" );
39
40 ok( $session->remove, 'Remove session' );
41
42 use_ok('Lemonldap::NG::Common::Apache::Session::Generate::SHA256');
43
44 $sessionOptions->{generateModule} =
45 "Lemonldap::NG::Common::Apache::Session::Generate::SHA256";
46
47 my $session2 = Lemonldap::NG::Common::Session->new( {
48 storageModule => $sessionModule,
49 storageModuleOptions => $sessionOptions,
50 kind => "TEST",
51 }
52 );
53
54 ok( length $session2->id == 64, "Use SHA256 generate module" );
55
56 ok( $session2->remove, 'Remove session' );
57
58 rmtree $dir;