diff options
author | Azul <azul@leap.se> | 2014-03-02 08:38:10 +0100 |
---|---|---|
committer | varac <varacanero@zeromail.org> | 2014-04-02 14:54:16 +0200 |
commit | 588ae06b051ca35abebdd925d99980cb541d6f95 (patch) | |
tree | dbb107a6421454057e565b9f0d5adf70106af1ec | |
parent | 91b6d9ec2952930cb894785f01169cbc91d679c9 (diff) |
including chiiphs comments
-rwxr-xr-x[-rw-r--r--] | test/nagios/webapp_login.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/nagios/webapp_login.py b/test/nagios/webapp_login.py index 1239769..afa3edf 100644..100755 --- a/test/nagios/webapp_login.py +++ b/test/nagios/webapp_login.py @@ -16,12 +16,12 @@ safe_unhexlify = lambda x: binascii.unhexlify(x) if ( def read_config(): - open("/etc/leap/hiera.yaml", 'r') as stream - config = yaml.load(stream) + with open("/etc/leap/hiera.yaml", 'r') as stream: + config = yaml.load(stream) user = config['webapp']['nagios_test_user'] - if ('username' not in user): + if 'username' not in user: fail('nagios test user lacks username') - if ('password' not in user): + if 'password' not in user: fail('nagios test user lacks password') api = config['api'] api['version'] = config['webapp']['api_version'] @@ -50,8 +50,7 @@ def parse(response): def authenticate(api, usr): - api_url = 'https://' + api['domain'] + ':' + \ - str(api['port']) + '/' + str(api['version']) + api_url = "https://{domain}:{port}/{version}".format(**api) session = requests.session() uname, A = usr.start_authentication() params = { @@ -67,9 +66,10 @@ def authenticate(api, usr): return session.put(api_url + '/sessions/' + uname, verify=False, data={'client_auth': binascii.hexlify(M)}) - def report(auth, usr): - if ('errors' in auth): - fail('srp password auth failed') + +def report(auth, usr): + if ('errors' in auth): + fail('srp password auth failed') usr.verify_session(safe_unhexlify(auth["M2"])) if usr.authenticated(): print '0 webapp_login - OK - can login to webapp fine' |