]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/live_t/24-lp1710949-login-api.t
LP#1710949 auth.login Perl live test script
[working/Evergreen.git] / Open-ILS / src / perlmods / live_t / 24-lp1710949-login-api.t
1 #!perl
2
3 use Test::More tests => 6;
4
5 diag("Tests open-ils.auth.login");
6
7 use strict; use warnings;
8 use OpenILS::Utils::TestUtils;
9 use OpenILS::Application::AppUtils;
10 our $U = "OpenILS::Application::AppUtils";
11
12 OpenILS::Utils::TestUtils->new->bootstrap;
13
14 my $resp = $U->simplereq(
15     'open-ils.auth',
16     'open-ils.auth.login', {
17         username => 'admin',
18         password => 'demo123',
19         type => 'staff'
20     }
21 );
22
23 is($resp->{textcode}, 'SUCCESS', 'Admin username login OK');
24
25 my $authtoken = $resp->{payload}->{authtoken};
26 ok($authtoken, 'Have an authtoken');
27
28 $resp = $U->simplereq(
29     'open-ils.auth',
30     'open-ils.auth.session.retrieve', $authtoken);
31
32 ok( 
33     (ref($resp) && !$U->event_code($resp) && $resp->usrname eq 'admin'), 
34     'Able to retrieve session'
35 );
36
37 $resp = $U->simplereq(
38     'open-ils.auth',
39     'open-ils.auth.login', {
40         username => 'admin',
41         password => 'demo123x', # bad password
42         type => 'staff'
43     }
44 );
45
46 isnt($resp->{textcode}, 'SUCCESS', 'Admin bad password rejected');
47
48 $resp = $U->simplereq(
49     'open-ils.auth',
50     'open-ils.auth.login', {
51         barcode => '99999381970',
52         password => 'montyc1234',
53         type => 'staff'
54     }
55 );
56
57 is($resp->{textcode}, 'SUCCESS', '99999381970 login OK');
58
59 $resp = $U->simplereq(
60     'open-ils.auth',
61     'open-ils.auth.login', {
62         identifier => 'br1mclark',
63         password => 'montyc1234',
64         type => 'staff'
65     }
66 );
67
68 is($resp->{textcode}, 'SUCCESS', 'Identifier check for br1mclark OK');
69