LP#1710949 auth.login Perl live test script
authorBill Erickson <berickxx@gmail.com>
Tue, 15 Aug 2017 19:21:01 +0000 (15:21 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 1 Sep 2017 17:05:32 +0000 (13:05 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/live_t/24-lp1710949-login-api.t [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/live_t/24-lp1710949-login-api.t b/Open-ILS/src/perlmods/live_t/24-lp1710949-login-api.t
new file mode 100644 (file)
index 0000000..ba4e4df
--- /dev/null
@@ -0,0 +1,69 @@
+#!perl
+
+use Test::More tests => 6;
+
+diag("Tests open-ils.auth.login");
+
+use strict; use warnings;
+use OpenILS::Utils::TestUtils;
+use OpenILS::Application::AppUtils;
+our $U = "OpenILS::Application::AppUtils";
+
+OpenILS::Utils::TestUtils->new->bootstrap;
+
+my $resp = $U->simplereq(
+    'open-ils.auth',
+    'open-ils.auth.login', {
+        username => 'admin',
+        password => 'demo123',
+        type => 'staff'
+    }
+);
+
+is($resp->{textcode}, 'SUCCESS', 'Admin username login OK');
+
+my $authtoken = $resp->{payload}->{authtoken};
+ok($authtoken, 'Have an authtoken');
+
+$resp = $U->simplereq(
+    'open-ils.auth',
+    'open-ils.auth.session.retrieve', $authtoken);
+
+ok( 
+    (ref($resp) && !$U->event_code($resp) && $resp->usrname eq 'admin'), 
+    'Able to retrieve session'
+);
+
+$resp = $U->simplereq(
+    'open-ils.auth',
+    'open-ils.auth.login', {
+        username => 'admin',
+        password => 'demo123x', # bad password
+        type => 'staff'
+    }
+);
+
+isnt($resp->{textcode}, 'SUCCESS', 'Admin bad password rejected');
+
+$resp = $U->simplereq(
+    'open-ils.auth',
+    'open-ils.auth.login', {
+        barcode => '99999381970',
+        password => 'montyc1234',
+        type => 'staff'
+    }
+);
+
+is($resp->{textcode}, 'SUCCESS', '99999381970 login OK');
+
+$resp = $U->simplereq(
+    'open-ils.auth',
+    'open-ils.auth.login', {
+        identifier => 'br1mclark',
+        password => 'montyc1234',
+        type => 'staff'
+    }
+);
+
+is($resp->{textcode}, 'SUCCESS', 'Identifier check for br1mclark OK');
+