diff options
author | Azul <azul@leap.se> | 2014-04-15 09:47:07 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-04-17 10:39:59 +0200 |
commit | a14f66c2642ff43c2cc497b0597bfb17d19a7139 (patch) | |
tree | 05c3d2f6a2fec60e5709f4d110894722a446b0b2 | |
parent | 3513ad74f950b113af1ba1e3d06bc6a55c48fde5 (diff) |
refactor nagios tests, remove parse
-rwxr-xr-x | test/nagios/soledad_sync.py | 2 | ||||
-rwxr-xr-x | test/nagios/webapp_login.py | 19 |
2 files changed, 6 insertions, 15 deletions
diff --git a/test/nagios/soledad_sync.py b/test/nagios/soledad_sync.py index 94679b1..faf552a 100755 --- a/test/nagios/soledad_sync.py +++ b/test/nagios/soledad_sync.py @@ -52,7 +52,7 @@ def get_soledad_info(config, tempdir): api = config['api'] usr = srp.User( user['username'], user['password'], srp.SHA256, srp.NG_1024 ) try: - auth = webapp_login.parse(webapp_login.authenticate(api, usr)) + auth = webapp_login.authenticate(api, usr) except requests.exceptions.ConnectionError: fail('no connection to server') # get soledad server url diff --git a/test/nagios/webapp_login.py b/test/nagios/webapp_login.py index 1711238..86a4045 100755 --- a/test/nagios/webapp_login.py +++ b/test/nagios/webapp_login.py @@ -33,21 +33,11 @@ def run_tests(config): api = config['api'] usr = srp.User(user['username'], user['password'], srp.SHA256, srp.NG_1024) try: - auth = parse(authenticate(api, usr)) + auth = authenticate(api, usr) except requests.exceptions.ConnectionError: fail('no connection to server') exit(report(auth, usr)) -# parse the server responses - - -def parse(response): - request = response.request - try: - return json.loads(response.text) - except ValueError: - return None - def authenticate(api, usr): api_url = "https://{domain}:{port}/{version}".format(**api) @@ -57,14 +47,15 @@ def authenticate(api, usr): 'login': uname, 'A': binascii.hexlify(A) } - init = parse( - session.post(api_url + '/sessions', data=params, verify=False)) + response = session.post(api_url + '/sessions', data=params, verify=False) + init = response.json() if ('errors' in init): fail('test user not found') M = usr.process_challenge( safe_unhexlify(init['salt']), safe_unhexlify(init['B'])) - return session.put(api_url + '/sessions/' + uname, verify=False, + response = session.put(api_url + '/sessions/' + uname, verify=False, data={'client_auth': binascii.hexlify(M)}) + return response.json() def report(auth, usr): |