3 use Test::More tests => 22;
5 diag("Tests open-ils.auth.login");
7 use strict; use warnings;
8 use OpenILS::Utils::TestUtils;
9 use OpenILS::Application::AppUtils;
10 use OpenSRF::Utils::Cache;
11 our $U = "OpenILS::Application::AppUtils";
13 OpenILS::Utils::TestUtils->new->bootstrap;
15 my $resp = $U->simplereq(
17 'open-ils.auth.login', {
19 password => 'demo123',
24 is($resp->{textcode}, 'SUCCESS', 'Admin username login OK');
26 my $authtoken = $resp->{payload}->{authtoken};
27 ok($authtoken, 'Have an authtoken');
29 $resp = $U->simplereq(
31 'open-ils.auth.session.retrieve', $authtoken);
34 (ref($resp) && !$U->event_code($resp) && $resp->usrname eq 'admin'),
35 'Able to retrieve session'
38 $resp = $U->simplereq(
40 'open-ils.auth.login', {
42 password => 'demo123x', # bad password
47 isnt($resp->{textcode}, 'SUCCESS', 'Admin bad password rejected');
49 $resp = $U->simplereq(
51 'open-ils.auth.login', {
52 barcode => '99999381970',
53 password => 'montyc1234',
58 is($resp->{textcode}, 'SUCCESS', '99999381970 login OK');
60 $resp = $U->simplereq(
62 'open-ils.auth.login', {
63 identifier => 'br1mclark',
64 password => 'montyc1234',
69 is($resp->{textcode}, 'SUCCESS', 'Identifier check for br1mclark OK');
71 foreach my $i (1..15) {
72 $resp = $U->simplereq(
74 'open-ils.auth.login', {
75 identifier => 'br1mclark',
76 password => 'justplainwrong',
80 isnt($resp->{textcode}, 'SUCCESS', "Attempt $i: wrong password br1mclark does not work");
83 $resp = $U->simplereq(
85 'open-ils.auth.login', {
86 identifier => 'br1mclark',
87 password => 'montyc1234',
91 isnt($resp->{textcode}, 'SUCCESS', '... and consequently multiple failed attempts block');
94 my $cache = OpenSRF::Utils::Cache->new("global", 0);
95 $cache->delete_cache('oils_auth_br1mclark_count');