diff --git a/tests/test_ssl.py b/tests/test_ssl.py new file mode 100755 index 0000000000000000000000000000000000000000..790dd7fddf0f115c411b605f647b520c8970f2f4 --- /dev/null +++ b/tests/test_ssl.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright 2017, Florent Thiery +''' +Criticality: Normal +Checks that SSL certificates are valid; if invalid, the user will have to add an exception in his browser +''' +import os +import sys +import requests +import imp + +os.chdir(os.path.dirname(__file__)) +if not os.path.isfile('../utils.py'): + print('conf.sh not found') + sys.exit(1) + +es_utils = imp.load_source('es_utils', '../utils.py') +conf = es_utils.load_conf() + +all_ok = True + +conf_servers = ( + 'MS_SERVER_NAME', + 'MONITOR_SERVER_NAME', + 'CM_SERVER_NAME', +) + +for s in conf_servers: + v = conf.get(s) + try: + url = "https://%s" % s + requests.get(url) + sys.exit(0) + except requests.exceptions.SSLError as e: + print('Error: SSL certificate for %s is not valid' % (url, e)) + sys.exit(1)