From cf198e9279137812800e2722e5e0c56ceaf60881 Mon Sep 17 00:00:00 2001
From: Bill Erickson <berick@esilibrary.com>
Date: Mon, 16 Jan 2012 16:24:01 -0500
Subject: [PATCH] User activity tracking : auth verify test for srfsh.py

Added a handler for auth_verify, which calls
open-ils.auth.authenticate.verify.

Added here (srfsh.py) instead of srfsh(.c) because a) it's quick and b)
srfsh(.c) already has too much open-ils in it.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
---
 Open-ILS/src/python/oils/srfsh.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/Open-ILS/src/python/oils/srfsh.py b/Open-ILS/src/python/oils/srfsh.py
index e5baa26f4d..df8072c57f 100644
--- a/Open-ILS/src/python/oils/srfsh.py
+++ b/Open-ILS/src/python/oils/srfsh.py
@@ -44,6 +44,34 @@ def handle_login(srfsh, args):
         )
     ])
 
+def handle_auth_verify(srfsh, args):
+    ''' Verify auth w/ args '''
+
+    username = args[0]
+    password = args[1]
+
+    seed = srfsh.handle_request([
+        'open-ils.auth', 
+        'open-ils.auth.authenticate.init', 
+        '"%s"' % username
+    ])
+
+    password = md5sum(seed + md5sum(password))
+
+    response = srfsh.handle_request([
+        'open-ils.auth', 
+        'open-ils.auth.authenticate.verify', 
+
+        osrf.json.to_json( 
+            {   # handle_request accepts json-encoded params
+                'username'    : username,
+                'password'    : password,
+                'type'        : args[2] if len(args) > 2 else None,
+            }
+        )
+    ])
+
+
 def handle_org_setting(srfsh, args):
     ''' Retrieves the requested org setting.
 
@@ -91,6 +119,7 @@ def load(srfsh, config):
 
     # register custom commands
     srfsh.add_command(command = 'login', handler = handle_login)
+    srfsh.add_command(command = 'auth_verify', handler = handle_auth_verify)
     srfsh.add_command(command = 'idl', handler = handle_idl)
     srfsh.add_command(command = 'org_setting', handler = handle_org_setting)
 
-- 
2.11.0