File: Root.pm

package info (click to toggle)
libcatalyst-authentication-credential-authen-simple-perl 0.09-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 228 kB
  • ctags: 26
  • sloc: perl: 305; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,185 bytes parent folder | download | duplicates (4)
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
44
45
46
47
48
49
50
51
package AuthTestApp2::Controller::Root;

use strict;
use warnings;

use Test::More;
use Test::Exception;

use parent 'Catalyst::Controller';

__PACKAGE__->config(namespace => '');

sub authed_ok : Local {
	my ( $self, $c ) = @_;

	ok(!$c->user, "no user");
        my $authd = $c->authenticate( { "username" => $c->request->param('username'),
	                               "password" => $c->request->param('password') });
	ok($authd, "logged in");
	ok(defined($c->user->get('name')), "user object is ok");

	if ($authd){
	    $c->response->body( "authed " . $c->user->get('name') );
	} else {
            $c->response->body( "not authed" );
	}

        $c->logout;
	ok(!$c->user, "no user");
}

sub authed_ko : Local {
	my ( $self, $c ) = @_;

	ok(!$c->user, "no user");
        my $authd = $c->authenticate( { "username" => $c->request->param('username'),
	                               "password" => $c->request->param('password') });
	ok(not($authd), "not logged in");
	ok(!$c->user, "user object not present");

	if ($authd){
	    $c->response->body( "authed" );
	} else {
            $c->response->body( "not authed" );
	}

        $c->logout;
	ok(!$c->user, "no user");
}

1;