summaryrefslogtreecommitdiff
path: root/test/nagios
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-03-02 08:38:10 +0100
committerAzul <azul@leap.se>2014-03-02 12:34:58 +0100
commit35b3387b99024a69402cc0d7b5d0dc7fed37a0fa (patch)
tree12c6b38cb642256f908e6f9b2fc2079f8c9a778c /test/nagios
parente4b42733d61887e2e7f01e9f159e963d50044465 (diff)
including chiiphs comments
Diffstat (limited to 'test/nagios')
-rwxr-xr-x[-rw-r--r--]test/nagios/webapp_login.py18
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'