Commit 47ba7fec authored by Łukasz Nowak's avatar Łukasz Nowak

check_surykatka_json: Improve tests and adapt code

Improvements:
 * use real dict in the test
 * merge test cases
 * increase test coverage
 * minimize and improve messages
 * use error state instead of error list
 * always shall full diff during test failure to ease debugging
 * fix ssl_certificate missing information
 * avoid cluttering code with test time
parent efcc40ee
......@@ -27,34 +27,31 @@ class RunPromise(GenericPromise):
self.failure_amount = int(
self.getConfig('failure-amount', self.getConfig('failure_amount', 1)))
self.result_count = self.failure_amount
self.error_list = []
self.info_list = []
self.error = False
self.message_list = []
# Make promise test-less, as it's result is not important for instantiation
self.setTestLess()
def appendErrorMessage(self, message):
self.error_list.append(message)
def appendInfoMessage(self, message):
self.info_list.append(message)
def appendMessage(self, message):
self.message_list.append(message)
def emitLog(self):
if len(self.error_list) > 0:
if self.error:
emit = self.logger.error
else:
emit = self.logger.info
message_list = self.error_list + self.info_list
url = self.getConfig('url')
if url:
message_list.insert(0, '%s :' % (url,))
emit(' '.join(message_list))
self.message_list.insert(0, '%s :' % (url,))
emit(' '.join(self.message_list))
def senseBotStatus(self):
key = 'bot_status'
def appendError(msg, *args):
self.appendErrorMessage(key + ': ERROR ' + msg % args)
self.error = True
self.appendMessage(key + ': ERROR ' + msg % args)
if key not in self.surykatka_json:
appendError("%r not in %r", key, self.json_file)
......@@ -80,13 +77,14 @@ class RunPromise(GenericPromise):
appendError('Last bot datetime is more than 15 minutes old')
return
self.appendInfoMessage('%s: OK Last bot status' % (key,))
self.appendMessage('%s: OK Last bot status' % (key,))
def senseSslCertificate(self):
key = 'ssl_certificate'
def appendError(msg, *args):
self.appendErrorMessage(key + ': ERROR ' + msg % args)
self.error = True
self.appendMessage(key + ': ERROR ' + msg % args)
url = self.getConfig('url')
parsed_url = urlparse(url)
......@@ -121,33 +119,35 @@ class RunPromise(GenericPromise):
if len(entry_list) == 0:
appendError('No data')
return
if len(entry_list) > 0:
self.appendMessage('%s:' % (key,))
def addError(msg, *args):
self.error = True
self.appendMessage('ERROR ' + msg % args)
for entry in entry_list:
timetuple = email.utils.parsedate(entry['not_after'])
if timetuple is None:
appendError('No certificate information for %s' % (entry['ip']))
addError('IP %s no information' % (entry['ip'],))
else:
certificate_expiration_time = datetime.datetime.fromtimestamp(
time.mktime(timetuple))
if certificate_expiration_time - datetime.timedelta(
days=certificate_expiration_days) < self.utcnow:
appendError(
'Certificate on %s will expire on %s, which is less than %s days',
entry['ip'], entry['not_after'], certificate_expiration_days)
return
addError(
'IP %s will expire in < %s days',
entry['ip'], certificate_expiration_days)
else:
self.appendInfoMessage(
'%s: OK Certificate on %s will expire on %s, which is more than '
'%s days' % (
key, entry['ip'], entry['not_after'],
certificate_expiration_days))
return
self.appendMessage(
'OK IP %s will expire in > %s days' % (
entry['ip'], certificate_expiration_days))
def senseHttpQuery(self):
key = 'http_query'
error = False
def appendError(msg, *args):
self.appendErrorMessage(key + ': ERROR ' + msg % args)
self.error = True
self.appendMessage(key + ': ERROR ' + msg % args)
if key not in self.surykatka_json:
appendError("%r not in %r", key, self.json_file)
......@@ -162,6 +162,11 @@ class RunPromise(GenericPromise):
if len(entry_list) == 0:
appendError('No data')
return
def addError(msg, *args):
self.error = True
self.appendMessage('ERROR ' + msg % args)
self.appendMessage('%s:' % (key,))
for entry in entry_list:
entry_status_code = str(entry['status_code'])
if entry_status_code != status_code:
......@@ -172,45 +177,44 @@ class RunPromise(GenericPromise):
entry_status_code, status_code_explanation)
else:
status_code_explanation = entry_status_code
appendError(
'IP %s got status code %s instead of %s' % (
addError(
'IP %s expected status_code %s != %s' % (
entry['ip'], status_code_explanation, status_code))
error = True
if http_header_dict and http_header_dict != entry['http_header_dict']:
appendError(
'HTTP Header dict was %s instead of %s' % (
json.dumps(entry['http_header_dict'], sort_keys=True),
json.dumps(http_header_dict, sort_keys=True),))
error = True
else:
self.appendMessage(
'OK IP %s status_code %s' % (entry['ip'], status_code))
if http_header_dict:
if http_header_dict != entry['http_header_dict']:
addError(
'IP %s expected HTTP Header %s != of %s' % (
entry['ip'],
json.dumps(http_header_dict, sort_keys=True),
json.dumps(entry['http_header_dict'], sort_keys=True)))
else:
self.appendMessage(
'OK IP %s HTTP Header %s' % (
entry['ip'], json.dumps(http_header_dict, sort_keys=True)))
db_ip_list = [q['ip'] for q in entry_list]
if len(ip_list):
if set(ip_list) != set(db_ip_list):
appendError(
'expected IPs %s differes from got %s' % (
addError(
'expected IPs %s != %s' % (
' '.join(ip_list), ' '.join(db_ip_list)))
error = True
if error:
return
info_message = '%s: OK with status code %s' % (key, status_code)
if http_header_dict:
info_message += ' and HTTP Header dict %s' % (
json.dumps(http_header_dict, sort_keys=True),
)
if len(ip_list) > 0:
info_message += ' on IPs %s' % (' '.join(ip_list))
self.appendInfoMessage(info_message)
def senseElapsedTime(self):
key = 'elapsed_time'
surykatka_key = 'http_query'
def appendError(msg, *args):
self.appendErrorMessage(key + ': ERROR ' + msg % args)
self.error = True
self.appendMessage('ERROR ' + msg % args)
if surykatka_key not in self.surykatka_json:
appendError(
'No key %r. If the error persist, please update surykatka.' % (
surykatka_key,))
self.error = True
self.appendMessage(
'%s: ERROR No key %r. If the error persist, please update '
'surykatka.' % (
key, surykatka_key,))
return
url = self.getConfig('url')
......@@ -219,43 +223,51 @@ class RunPromise(GenericPromise):
entry_list = [
q for q in self.surykatka_json[surykatka_key] if q['url'] == url]
if len(entry_list) == 0:
appendError('No data')
self.error = True
self.appendMessage('%s: ERROR No data' % (key,))
return
prefix_added = False
for entry in entry_list:
if maximum_elapsed_time:
if 'total_seconds' in entry:
maximum_elapsed_time = float(maximum_elapsed_time)
if entry['total_seconds'] == 0.:
if not prefix_added:
self.appendMessage('%s:' % (key,))
prefix_added = True
appendError('IP %s failed to reply' % (entry['ip']))
elif entry['total_seconds'] > maximum_elapsed_time:
if not prefix_added:
self.appendMessage('%s:' % (key,))
prefix_added = True
appendError(
'IP %s replied in more time than maximum %.2fs' %
'IP %s replied > %.2fs' %
(entry['ip'], maximum_elapsed_time))
else:
self.appendInfoMessage(
'%s: OK IP %s replied in less time than maximum %.2fs' % (
key, entry['ip'], maximum_elapsed_time))
if not prefix_added:
self.appendMessage('%s:' % (key,))
prefix_added = True
self.appendMessage(
'OK IP %s replied < %.2fs' % (
entry['ip'], maximum_elapsed_time))
def sense(self):
"""
Check if frontend URL is available
"""
test_utcnow = self.getConfig('test-utcnow')
if test_utcnow:
self.utcnow = datetime.datetime.fromtimestamp(
time.mktime(email.utils.parsedate(test_utcnow)))
else:
self.utcnow = datetime.datetime.utcnow()
self.json_file = self.getConfig('json-file', '')
if not os.path.exists(self.json_file):
self.appendErrorMessage('ERROR File %r does not exists' % self.json_file)
self.error = True
self.appendMessage('ERROR File %r does not exists' % self.json_file)
else:
with open(self.json_file) as fh:
try:
self.surykatka_json = json.load(fh)
except Exception:
self.appendErrorMessage(
self.error = True
self.appendMessage(
"ERROR loading JSON from %r" % self.json_file)
else:
report = self.getConfig('report')
......@@ -266,7 +278,8 @@ class RunPromise(GenericPromise):
self.senseSslCertificate()
self.senseElapsedTime()
else:
self.appendErrorMessage(
self.error = True
self.appendMessage(
"ERROR Report %r is not supported" % report)
self.emitLog()
......
from slapos.grid.promise import PromiseError
from slapos.test.promise.plugin import TestPromisePluginMixin
import email
import json
import os
import shutil
import tempfile
import time
class CheckSurykatkaJSONMixin(TestPromisePluginMixin):
maxDiff = None # show full diffs for test readability
promise_name = 'check-surykatka-json.py'
def setUp(self):
......@@ -15,6 +19,18 @@ class CheckSurykatkaJSONMixin(TestPromisePluginMixin):
self.addCleanup(shutil.rmtree, self.working_directory)
TestPromisePluginMixin.setUp(self)
now = time.time()
minute = 60
day = 24 * 3600
create_date = email.utils.formatdate
self.time_past14d = create_date(now - 14 * day)
self.time_past20m = create_date(now - 20 * minute)
self.time_past2m = create_date(now - 2 * minute)
self.time_future20m = create_date(now + 20 * minute)
self.time_future3d = create_date(now + 3 * day)
self.time_future14d = create_date(now + 14 * day)
self.time_future60d = create_date(now + 60 * day)
def writeSurykatkaPromise(self, d=None):
if d is None:
d = {}
......@@ -26,10 +42,14 @@ class CheckSurykatkaJSONMixin(TestPromisePluginMixin):
content_list.append('}')
self.writePromise(self.promise_name, '\n'.join(content_list))
def writeSurykatkaJson(self, content):
def writeSurykatkaJsonDirect(self, content):
with open(self.json_file, 'w') as fh:
fh.write(content)
def writeSurykatkaJson(self, content):
with open(self.json_file, 'w') as fh:
json.dump(content, fh, indent=2)
def assertFailedMessage(self, result, message):
self.assertEqual(result['result']['failed'], True)
self.assertEqual(
......@@ -43,7 +63,7 @@ class CheckSurykatkaJSONMixin(TestPromisePluginMixin):
message)
class TestCheckSurykatkaJSON(CheckSurykatkaJSONMixin):
class TestCheckSurykatkaJSONBase(CheckSurykatkaJSONMixin):
def test_no_config(self):
self.writeSurykatkaPromise()
self.configureLauncher(enable_anomaly=True)
......@@ -64,7 +84,7 @@ class TestCheckSurykatkaJSON(CheckSurykatkaJSONMixin):
def test_empty_file(self):
self.writeSurykatkaPromise({'json-file': self.json_file})
self.writeSurykatkaJson('')
self.writeSurykatkaJsonDirect('')
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
......@@ -72,8 +92,6 @@ class TestCheckSurykatkaJSON(CheckSurykatkaJSONMixin):
self.getPromiseResult(self.promise_name),
"ERROR loading JSON from '%s'" % (self.json_file,))
class TestCheckSurykatkaJSONUnknownReport(CheckSurykatkaJSONMixin):
def test(self):
self.writeSurykatkaPromise(
{
......@@ -81,9 +99,7 @@ class TestCheckSurykatkaJSONUnknownReport(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
}
)
self.writeSurykatkaJson("""{
}
""")
self.writeSurykatkaJson({})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
......@@ -98,18 +114,13 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
{
'report': 'bot_status',
'json-file': self.json_file,
'test-utcnow': 'Wed, 13 Dec 2222 09:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"bot_status": [
{
"date": "Wed, 13 Dec 2222 09:10:11 -0000",
"text": "loop"
}
]
}
""")
"date": self.time_past2m,
"text": "loop"}]})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
......@@ -122,18 +133,13 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
{
'report': 'bot_status',
'json-file': self.json_file,
'test-utcnow': 'Wed, 13 Dec 2222 09:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"bot_status": [
{
"date": "Wed, 13 Dec 2222 09:10:11 -0000",
"text": "error"
}
]
}
""")
"text": "error"}]})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
......@@ -148,18 +154,13 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
{
'report': 'bot_status',
'json-file': self.json_file,
'test-utcnow': 'Wed, 13 Dec 2222 09:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"bot_status": [
{
"date": "Wed, 13 Dec 2223 09:10:11 -0000",
"text": "loop"
}
]
}
""")
"date": self.time_future20m,
"text": "loop"}]})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
......@@ -173,18 +174,13 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
{
'report': 'bot_status',
'json-file': self.json_file,
'test-utcnow': 'Wed, 13 Dec 2223 09:26:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"bot_status": [
{
"date": "Wed, 13 Dec 2223 09:10:11 -0000",
"text": "loop"
}
]
}
""")
"date": self.time_past20m,
"text": "loop"}]})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
......@@ -200,9 +196,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
}
)
self.writeSurykatkaJson("""{
}
""")
self.writeSurykatkaJson({})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
......@@ -217,10 +211,7 @@ class TestCheckSurykatkaJSONBotStatus(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
}
)
self.writeSurykatkaJson("""{
"bot_status": []
}
""")
self.writeSurykatkaJson({"bot_status": []})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
......@@ -238,10 +229,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'https://www.erp5.com/',
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -267,24 +257,25 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: OK with status code 302 on IPs "
"127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days"
)
def test_maximum_elapsed_time(self):
......@@ -296,10 +287,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'maximum-elapsed-time': '5',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -328,26 +318,27 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: OK with status code 302 on IPs "
"127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days "
"elapsed_time: OK IP 127.0.0.1 replied in less time than maximum 5.00s "
"elapsed_time: OK IP 127.0.0.2 replied in less time than maximum 5.00s"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days "
"elapsed_time: OK IP 127.0.0.1 replied < 5.00s OK IP 127.0.0.2 replied "
"< 5.00s"
)
def test_maximum_elapsed_time_too_long(self):
......@@ -359,10 +350,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'maximum-elapsed-time': '5',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -391,27 +381,28 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : elapsed_time: ERROR IP 127.0.0.1 replied in "
"more time than maximum 5.00s elapsed_time: ERROR IP 127.0.0.2 failed "
"to reply http_query: OK with status code 302 on IPs 127.0.0.1 "
"127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will expire on "
"Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days "
"elapsed_time: ERROR IP 127.0.0.1 replied > 5.00s ERROR IP "
"127.0.0.2 failed to reply"
)
def test_maximum_elapsed_time_no_total_seconds(self):
......@@ -423,10 +414,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'maximum-elapsed-time': '5',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -452,24 +442,25 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: OK with status code 302 on IPs "
"127.0.0.1 127.0.0.2 ssl_certificate: OK Certificate on 127.0.0.1 will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days"
)
def test_http(self):
......@@ -480,10 +471,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'http://www.erp5.com/',
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -506,14 +496,14 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
],
"ssl_certificate": [
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"http://www.erp5.com/ : http_query: OK with status code 302 on IPs "
"127.0.0.1 127.0.0.2"
"http://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302"
)
def test_http_with_header_dict(self):
......@@ -525,32 +515,30 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'status-code': '200',
'http-header-dict': '{"Vary": "Accept-Encoding", "Cache-Control": '
'"max-age=300, public"}',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson(
"""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
"ip": "176.31.129.213",
"http_header_dict": {"Vary": "Accept-Encoding", """
""""Cache-Control": "max-age=300, public"},
"http_header_dict": {
"Vary": "Accept-Encoding", "Cache-Control": "max-age=300, public"},
"status_code": 200,
"url": "http://www.erp5.com/"
}
],
"ssl_certificate": [
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"http://www.erp5.com/ : http_query: OK with status code 200 "
"and HTTP Header dict {\"Cache-Control\": \"max-age=300, public\", "
"\"Vary\": \"Accept-Encoding\"}"
'http://www.erp5.com/ : '
'http_query: OK IP 176.31.129.213 status_code 200 OK IP '
'176.31.129.213 HTTP Header {"Cache-Control": "max-age=300, public", '
'"Vary": "Accept-Encoding"}'
)
def test_http_with_bad_header_dict(self):
......@@ -562,35 +550,33 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'status-code': '200',
'http-header-dict': '{"Vary": "Accept-Encoding", "Cache-Control": '
'"max-age=300, public"}',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson(
"""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
"ip": "176.31.129.213",
"http_header_dict": {"Vary": "Accept-Encoding,Cookie", """
""""Cache-Control": "max-age=300, public"},
"http_header_dict": {
"Vary": "Accept-Encoding,Cookie",
"Cache-Control": "max-age=300, public"},
"status_code": 200,
"url": "http://www.erp5.com/"
}
],
"ssl_certificate": [
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"http://www.erp5.com/ : http_query: ERROR HTTP Header dict was "
"{\"Cache-Control\": \"max-age=300, public\", \"Vary\": "
"\"Accept-Encoding,Cookie\"} "
"instead of {\"Cache-Control\": \"max-age=300, public\", \"Vary\": "
"\"Accept-Encoding\"}"
'http://www.erp5.com/ : '
'http_query: OK IP 176.31.129.213 status_code 200 ERROR IP '
'176.31.129.213 expected HTTP Header {"Cache-Control": "max-age=300, '
'public", "Vary": "Accept-Encoding"} != of {"Cache-Control": '
'"max-age=300, public", "Vary": "Accept-Encoding,Cookie"}'
)
def test_no_ip_list(self):
......@@ -600,10 +586,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '302',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -629,24 +614,25 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: OK with status code 302 "
"ssl_certificate: OK Certificate on 127.0.0.1 will expire on Mon, 13 "
"Jul 2020 12:00:00 -0000, which is more than 15 days"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days"
)
def test_good_certificate_2_day(self):
......@@ -656,11 +642,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '302',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000',
'certificate-expiration-days': '2'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -674,18 +659,17 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Sun, 30 Dec 2019 12:00:00 -0000"
"not_after": self.time_future3d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
self.launcher.run()
self.assertPassedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: OK with status code 302 "
"ssl_certificate: OK Certificate on 127.0.0.1 will expire on Sun, 30 "
"Dec 2019 12:00:00 -0000, which is more than 2 days"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 2 days"
)
def test_expired_certificate_2_day(self):
......@@ -695,11 +679,10 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '302',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000',
'certificate-expiration-days': '2'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -713,19 +696,18 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Sat, 28 Dec 2019 12:00:00 -0000"
"not_after": self.time_future1d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : ssl_certificate: ERROR Certificate on "
"127.0.0.1 will expire on Sat, 28 Dec 2019 12:00:00 -0000, which is "
"less than 2 days http_query: OK with status code 302"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: ERROR IP 127.0.0.1 will expire in < 2 days"
)
def test_expired_certificate(self):
......@@ -735,10 +717,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '302',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -752,19 +733,18 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Sat, 28 Dec 2019 12:00:00 -0000"
"not_after": self.time_future14d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : ssl_certificate: ERROR Certificate on "
"127.0.0.1 will expire on Sat, 28 Dec 2019 12:00:00 -0000, which is "
"less than 15 days http_query: OK with status code 302"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: ERROR IP 127.0.0.1 will expire in < 15 days"
)
def test_expired_certificate_before_today(self):
......@@ -774,10 +754,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '302',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -791,20 +770,18 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Thu, 26 Dec 2019 12:00:00 -0000"
"not_after": self.time_past14d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : ssl_certificate: ERROR Certificate on "
"127.0.0.1 will expire on Thu, 26 Dec 2019 12:00:00 -0000, which is "
"less than 15 days http_query: OK with status code 302"
)
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 "
"ssl_certificate: ERROR IP 127.0.0.1 will expire in < 15 days")
def test_no_http_query_data(self):
self.writeSurykatkaPromise(
......@@ -814,10 +791,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'https://www.erp5.com/',
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
],
"ssl_certificate": [
......@@ -825,25 +801,65 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": self.time_future60d
}
]
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : "
"http_query: ERROR No data "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days "
"elapsed_time: ERROR No data"
)
def test_no_http_query_present(self):
self.writeSurykatkaPromise(
{
'report': 'http_query',
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
}
)
self.writeSurykatkaJson({
"ssl_certificate": [
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: ERROR No data elapsed_time: ERROR "
"No data ssl_certificate: OK Certificate on 127.0.0.1 will expire on "
"Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
"https://www.erp5.com/ : "
"http_query: ERROR 'http_query' not in %(json_file)r "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days "
"elapsed_time: ERROR No key 'http_query'. If the error persist, please "
"update surykatka." % {'json_file': self.json_file}
)
def test_no_ssl_certificate_data(self):
......@@ -854,10 +870,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'https://www.erp5.com/',
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -880,15 +895,16 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
],
"ssl_certificate": [
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : ssl_certificate: ERROR No data http_query: "
"OK with status code 302 on IPs 127.0.0.1 127.0.0.2"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: ERROR No data"
)
def test_no_ssl_certificate(self):
......@@ -899,10 +915,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'https://www.erp5.com/',
'status-code': '302',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -923,16 +938,17 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"url": "https://www.erp5.org/"
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : ssl_certificate: ERROR No key "
"'ssl_certificate'. If the error persist, please update surykatka. "
"http_query: OK with status code 302 on IPs 127.0.0.1 127.0.0.2"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 302 OK IP 127.0.0.2 "
"status_code 302 "
"ssl_certificate: ERROR No key 'ssl_certificate'. If the error "
"persist, please update surykatka."
)
def test_bad_code(self):
......@@ -942,10 +958,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '301',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -971,25 +986,26 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: ERROR IP 127.0.0.1 got status code "
"302 instead of 301 ssl_certificate: OK Certificate on 127.0.0.1 will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
"https://www.erp5.com/ : "
"http_query: ERROR IP 127.0.0.1 expected status_code 302 != 301 OK IP "
"127.0.0.2 status_code 301 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days"
)
def _test_bad_code_explanation(self, status_code, explanation):
......@@ -999,15 +1015,14 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'json-file': self.json_file,
'url': 'https://www.erp5.com/',
'status-code': '301',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
"ip": "127.0.0.1",
"status_code": %s,
"status_code": status_code,
"url": "https://www.erp5.com/"
}
],
......@@ -1016,26 +1031,25 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""" % status_code)
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: ERROR IP 127.0.0.1 got status code "
"%s instead of 301 ssl_certificate: OK Certificate on 127.0.0.1 will "
"expire on Mon, 13 Jul 2020 12:00:00 -0000, which is more than 15 days"
"" % (explanation,)
"https://www.erp5.com/ : "
"http_query: ERROR IP 127.0.0.1 expected status_code %s != 301 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days" % (explanation,)
)
def test_bad_code_explanation_520(self):
......@@ -1058,10 +1072,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'https://www.erp5.com/',
'status-code': '301',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -1087,26 +1100,27 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: ERROR expected IPs 127.0.0.1 "
"127.0.0.2 differes from got 127.0.0.1 127.0.0.4 ssl_certificate: "
"OK Certificate on 127.0.0.1 will expire on Mon, 13 Jul 2020 12:00:00 "
"-0000, which is more than 15 days"
"https://www.erp5.com/ : "
"http_query: OK IP 127.0.0.1 status_code 301 OK IP 127.0.0.4 "
"status_code 301 ERROR expected IPs 127.0.0.1 127.0.0.2 != 127.0.0.1 "
"127.0.0.4 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days"
)
def test_bad_ip_status_code(self):
......@@ -1117,10 +1131,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'https://www.erp5.com/',
'status-code': '301',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -1146,27 +1159,27 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": "Mon, 13 Jul 2020 12:00:00 -0000"
"not_after": self.time_future60d
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: ERROR IP 127.0.0.1 got status code "
"302 instead of 301 http_query: ERROR expected IPs 127.0.0.1 127.0.0.2 "
"differes from got 127.0.0.1 127.0.0.4 ssl_certificate: OK Certificate "
"on 127.0.0.1 will expire on Mon, 13 Jul 2020 12:00:00 -0000, which is "
"more than 15 days"
"https://www.erp5.com/ : "
"http_query: ERROR IP 127.0.0.1 expected status_code 302 != 301 OK IP "
"127.0.0.4 status_code 301 ERROR expected IPs 127.0.0.1 127.0.0.2 != "
"127.0.0.1 127.0.0.4 "
"ssl_certificate: OK IP 127.0.0.1 will expire in > 15 days OK IP "
"127.0.0.2 will expire in > 15 days"
)
def test_https_no_cert(self):
......@@ -1177,10 +1190,9 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
'url': 'https://www.erp5.com/',
'status-code': '301',
'ip-list': '127.0.0.1 127.0.0.2',
'test-utcnow': 'Fri, 27 Dec 2019 15:11:12 -0000'
}
)
self.writeSurykatkaJson("""{
self.writeSurykatkaJson({
"http_query": [
{
"date": "Wed, 11 Dec 2019 09:35:28 -0000",
......@@ -1200,25 +1212,25 @@ class TestCheckSurykatkaJSONHttpQuery(CheckSurykatkaJSONMixin):
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.1",
"not_after": null
"not_after": None
},
{
"date": "Fri, 27 Dec 2019 14:43:26 -0000",
"hostname": "www.erp5.com",
"ip": "127.0.0.2",
"not_after": null
"not_after": None
}
]
}
""")
})
self.configureLauncher(enable_anomaly=True)
with self.assertRaises(PromiseError):
self.launcher.run()
self.assertFailedMessage(
self.getPromiseResult(self.promise_name),
"https://www.erp5.com/ : http_query: ERROR IP 127.0.0.1 got status code "
"302 instead of 301 http_query: ERROR expected IPs 127.0.0.1 127.0.0.2 "
"differes from got 127.0.0.1 127.0.0.4 ssl_certificate: ERROR No "
"certificate information for 127.0.0.1 ssl_certificate: ERROR No "
"certificate information for 127.0.0.2"
"https://www.erp5.com/ : "
"http_query: ERROR IP 127.0.0.1 expected status_code 302 != 301 OK IP "
"127.0.0.4 status_code 301 ERROR expected IPs 127.0.0.1 127.0.0.2 != "
"127.0.0.1 127.0.0.4 "
"ssl_certificate: ERROR IP 127.0.0.1 no information ERROR IP 127.0.0.2 "
"no information"
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment