summaryrefslogtreecommitdiff
path: root/test/nagios/webapp_login.py
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-04-15 09:47:07 +0200
committerAzul <azul@leap.se>2014-04-17 10:39:59 +0200
commita14f66c2642ff43c2cc497b0597bfb17d19a7139 (patch)
tree05c3d2f6a2fec60e5709f4d110894722a446b0b2 /test/nagios/webapp_login.py
parent3513ad74f950b113af1ba1e3d06bc6a55c48fde5 (diff)
refactor nagios tests, remove parse
Diffstat (limited to 'test/nagios/webapp_login.py')
-rwxr-xr-xtest/nagios/webapp_login.py19
1 files changed, 5 insertions, 14 deletions
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):