From 35b3387b99024a69402cc0d7b5d0dc7fed37a0fa Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 2 Mar 2014 08:38:10 +0100 Subject: including chiiphs comments --- test/nagios/webapp_login.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) mode change 100644 => 100755 test/nagios/webapp_login.py (limited to 'test/nagios') diff --git a/test/nagios/webapp_login.py b/test/nagios/webapp_login.py old mode 100644 new mode 100755 index 1239769..afa3edf --- 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' -- cgit v1.2.3