From: Bill Erickson Date: Mon, 16 Jan 2012 21:24:01 +0000 (-0500) Subject: User activity tracking : auth verify test for srfsh.py X-Git-Tag: sprint4-merge-nov22~4534 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=cf198e9279137812800e2722e5e0c56ceaf60881;p=working%2FEvergreen.git 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 Signed-off-by: Thomas Berezansky --- 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)