Skip to content

remove magic date strings #1019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions tests/unittests/comparators/test_certificate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@

import datetime

from unittest import TestCase

from hubblestack.comparators import certificate as certificate_comparator

def datestring(days=0, fmt='%Y-%m-%d %H:%M:%S'):
ret = datetime.datetime.now() + datetime.timedelta(days=days)
return ret.strftime(fmt)

class TestCertificate(TestCase):
"""
Expand All @@ -14,8 +20,8 @@ def test_match_1(self):
"""
audit_id = 'test-1'
result_to_match = {
'ssl_start_time': '2019-02-06 00:00:00',
'ssl_end_time': '2022-02-02 00:00:00'
'ssl_start_time': datestring(-300),
'ssl_end_time': datestring(300)
}
args = {
'match': {
Expand All @@ -32,8 +38,8 @@ def test_match_2(self):
"""
audit_id = 'test-2'
result_to_match = {
'ssl_start_time': '2022-02-06 00:00:00',
'ssl_end_time': '2022-02-02 00:00:00'
'ssl_start_time': datestring(300),
'ssl_end_time': datestring(300),
}
args = {
'match': {
Expand All @@ -51,8 +57,8 @@ def test_match_3(self):
"""
audit_id = 'test-3'
result_to_match = {
'ssl_start_time': '2019-02-06 00:00:00',
'ssl_end_time': '2020-02-02 00:00:00'
'ssl_start_time': datestring(-300),
'ssl_end_time': datestring(-15),
}
args = {
'match': {
Expand All @@ -70,8 +76,8 @@ def test_match_4(self):
"""
audit_id = 'test-4'
result_to_match = {
'ssl_start_time': '2025-02-06 00:00:00',
'ssl_end_time': '2026-02-02 00:00:00'
'ssl_start_time': datestring(300),
'ssl_end_time': datestring(600)
}
args = {
'match': {
Expand All @@ -90,8 +96,8 @@ def test_match_5(self):
"""
audit_id = 'test-5'
result_to_match = {
'ssl_start_time': '2019-02-06 00:00:00',
'ssl_end_time': '2022-02-02 00:00:00',
'ssl_start_time': datestring(-300),
'ssl_end_time': datestring(300),
'ssl_issuer_common_name' : 'DigiCert SHA2 Secure Server CA'
}
args = {
Expand All @@ -110,8 +116,8 @@ def test_match_6(self):
"""
audit_id = 'test-5'
result_to_match = {
'ssl_start_time': '2019-02-06 00:00:00',
'ssl_end_time': '2022-02-02 00:00:00',
'ssl_start_time': datestring(-300),
'ssl_end_time': datestring(300),
'ssl_issuer_common_name' : 'DigiCert SHA2 Secure Server CA'
}
args = {
Expand Down