Merge ~nick-moffitt/content-cache-charm:fix-timezones-in-tests into content-cache-charm:master

Proposed by Nick Moffitt
Status: Merged
Approved by: Nick Moffitt
Approved revision: d4989902edd9b3f85ffd806cddf3622530f562ff
Merged at revision: c91ae0524d0393ebe148c77fb43a55416667c85a
Proposed branch: ~nick-moffitt/content-cache-charm:fix-timezones-in-tests
Merge into: content-cache-charm:master
Diff against target: 132 lines (+22/-14)
6 files modified
tests/unit/files/content_cache_rendered_haproxy_test_output.txt (+1/-1)
tests/unit/files/haproxy_config_rendered_backends_stanzas_test_output.txt (+1/-1)
tests/unit/files/haproxy_config_rendered_test_output.txt (+1/-1)
tests/unit/test_content_cache.py (+14/-6)
tests/unit/test_haproxy.py (+2/-2)
tests/unit/test_utils.py (+3/-3)
Reviewer Review Type Date Requested Status
Joel Sing (community) +1 Approve
Review via email: mp+365516@code.launchpad.net

Commit message

Fix test timezones and include obsolete TLS

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Joel Sing (jsing) wrote :

LGTM

review: Approve (+1)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision c91ae0524d0393ebe148c77fb43a55416667c85a

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
2index e2ebce0..e17e3bf 100644
3--- a/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
4+++ b/tests/unit/files/content_cache_rendered_haproxy_test_output.txt
5@@ -61,7 +61,7 @@ listen site3-local
6
7 backend backend-cached-site1-local
8 option forwardfor
9- option httpchk HEAD /?token=1868533200_bd98d0a61eb5006de53d00549ba0f78b365b72ad HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk
10+ option httpchk HEAD /?token=1868572800_4eb30fc94f247635f7ed445083a4783862ad58de HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk
11 http-request set-header Host site1.local
12 balance leastconn
13 server server_1 127.0.0.1:6080 check inter 5000 rise 2 fall 5 maxconn 16
14diff --git a/tests/unit/files/haproxy_config_rendered_backends_stanzas_test_output.txt b/tests/unit/files/haproxy_config_rendered_backends_stanzas_test_output.txt
15index 5a06898..87ac817 100644
16--- a/tests/unit/files/haproxy_config_rendered_backends_stanzas_test_output.txt
17+++ b/tests/unit/files/haproxy_config_rendered_backends_stanzas_test_output.txt
18@@ -1,6 +1,6 @@
19
20 backend backend-site1-local
21- option httpchk HEAD /?token=1868533200_bd98d0a61eb5006de53d00549ba0f78b365b72ad HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk
22+ option httpchk HEAD /?token=1868572800_4eb30fc94f247635f7ed445083a4783862ad58de HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk
23 http-request set-header Host site1.local
24 balance leastconn
25 server server_1 127.0.1.10:80 check inter 5000 rise 2 fall 5 maxconn 16
26diff --git a/tests/unit/files/haproxy_config_rendered_test_output.txt b/tests/unit/files/haproxy_config_rendered_test_output.txt
27index 147b6ae..86ad110 100644
28--- a/tests/unit/files/haproxy_config_rendered_test_output.txt
29+++ b/tests/unit/files/haproxy_config_rendered_test_output.txt
30@@ -48,7 +48,7 @@ listen site2-local
31 default_backend backend-site2-local
32
33 backend backend-site1-local
34- option httpchk HEAD /?token=1868533200_bd98d0a61eb5006de53d00549ba0f78b365b72ad HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk
35+ option httpchk HEAD /?token=1868572800_4eb30fc94f247635f7ed445083a4783862ad58de HTTP/1.0\r\nHost:\ site1.local\r\nUser-Agent:\ haproxy/httpchk
36 http-request set-header Host site1.local
37 balance leastconn
38 server server_1 127.0.1.10:80 check inter 5000 rise 2 fall 5 maxconn 16
39diff --git a/tests/unit/test_content_cache.py b/tests/unit/test_content_cache.py
40index b37fed1..576928c 100644
41--- a/tests/unit/test_content_cache.py
42+++ b/tests/unit/test_content_cache.py
43@@ -218,7 +218,7 @@ site1.local:
44 self.assertFalse(status.blocked.assert_called())
45 self.assertFalse(clear_flag.assert_called_once_with('content_cache.active'))
46
47- @freezegun.freeze_time("2019-03-22")
48+ @freezegun.freeze_time("2019-03-22", tz_offset=0)
49 @mock.patch('reactive.content_cache.service_start_or_restart')
50 def test_configure_haproxy_sites(self, service_start_or_restart):
51 with open('tests/unit/files/config_test_config.txt', 'r', encoding='utf-8') as f:
52@@ -250,7 +250,7 @@ site1.local:
53 self.assertFalse(clear_flag.assert_called_with('content_cache.active'))
54 self.assertFalse(set_flag.assert_not_called())
55
56- @freezegun.freeze_time("2019-03-22")
57+ @freezegun.freeze_time("2019-03-22", tz_offset=0)
58 @mock.patch('charms.reactive.set_flag')
59 @mock.patch('charmhelpers.contrib.charmsupport.nrpe.get_nagios_hostname')
60 @mock.patch('charmhelpers.contrib.charmsupport.nrpe.NRPE')
61@@ -266,16 +266,24 @@ site1.local:
62
63 want = [mock.call('site_site1_local_listen', 'site1.local site listen check',
64 '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site1.local -p 80 -j HEAD'
65- ' -u http://site1.local/?token=1868533200_bd98d0a61eb5006de53d00549ba0f78b365b72ad'),
66+ ' -u http://site1.local/?token=1868572800_4eb30fc94f247635f7ed445083a4783862ad58de'),
67 mock.call('site_site1_local_cache', 'site1.local cache check',
68 '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site1.local -p 6080 -j HEAD'
69- ' -u http://site1.local/?token=1868533200_bd98d0a61eb5006de53d00549ba0f78b365b72ad'),
70+ ' -u http://site1.local/?token=1868572800_4eb30fc94f247635f7ed445083a4783862ad58de'),
71 mock.call('site_site1_local_backend_proxy', 'site1.local backend proxy check',
72 '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site1.local -p 8080 -j HEAD'
73 ' -u http://site1.local/')]
74 self.assertFalse(nrpe_instance_mock.add_check.assert_has_calls(want, any_order=True))
75- want = [mock.call('site_site2_local_listen', 'site2.local site listen check',
76- '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site2.local -p 443 -S --sni'
77+ want = [mock.call('site_site2_local_no_tls_1', 'site2.local confirm obsolete TLS v1 denied',
78+ '/usr/lib/nagios/plugins/negate'
79+ ' /usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site2.local -p 443 --ssl=1 --sni'
80+ ' -j GET -u https://site2.local/check/'),
81+ mock.call('site_site2_local_no_tls_1_1', 'site2.local confirm obsolete TLS v1.1 denied',
82+ '/usr/lib/nagios/plugins/negate'
83+ ' /usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site2.local -p 443 --ssl=1.1 --sni'
84+ ' -j GET -u https://site2.local/check/'),
85+ mock.call('site_site2_local_listen', 'site2.local site listen check',
86+ '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site2.local -p 443 --ssl=1.2 --sni'
87 ' -j GET -u https://site2.local/check/'),
88 mock.call('site_site2_local_cache', 'site2.local cache check',
89 '/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -H site2.local -p 6081'
90diff --git a/tests/unit/test_haproxy.py b/tests/unit/test_haproxy.py
91index a84befc..3417c1d 100644
92--- a/tests/unit/test_haproxy.py
93+++ b/tests/unit/test_haproxy.py
94@@ -50,7 +50,7 @@ class TestLibHAProxy(unittest.TestCase):
95 config[site]['backend-name'] = site
96 self.assertEqual(''.join(haproxy.render_stanza_listen(config)), want)
97
98- @freezegun.freeze_time("2019-03-22")
99+ @freezegun.freeze_time("2019-03-22", tz_offset=0)
100 def test_haproxy_config_rendered_backend_stanzas(self):
101 haproxy = HAProxy.HAProxyConf(self.tmpdir)
102 config = self.site_config
103@@ -59,7 +59,7 @@ class TestLibHAProxy(unittest.TestCase):
104 want = f.read()
105 self.assertEqual(''.join(haproxy.render_stanza_backend(config)), want)
106
107- @freezegun.freeze_time("2019-03-22")
108+ @freezegun.freeze_time("2019-03-22", tz_offset=0)
109 def test_haproxy_config_rendered_full_config(self):
110 haproxy = HAProxy.HAProxyConf(self.tmpdir)
111 config = self.site_config
112diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
113index 55736dd..5cb39e4 100644
114--- a/tests/unit/test_utils.py
115+++ b/tests/unit/test_utils.py
116@@ -53,13 +53,13 @@ class TestLibUtils(unittest.TestCase):
117 def test_generate_nagios_check_name(self):
118 self.assertEqual(utils.generate_nagios_check_name('site-1.local'), 'site_1_local')
119
120- @freezegun.freeze_time("2019-03-22")
121+ @freezegun.freeze_time("2019-03-22", tz_offset=0)
122 def test_generate_token(self):
123 signing_key = '2KmMh3/rx1LQRdjZIzto07Qaz/+LghG1c2G7od7FC/I='
124 expiry_time = datetime.datetime.now() + datetime.timedelta(hours=1)
125- want = '1553176800_f8a6667ad994a013645eab53e9a757e65c206ee2'
126+ want = '1553216400_cd3920a15f1d58b9953ef7a8e7e9c46d4522a5e9'
127 self.assertEqual(utils.generate_token(signing_key, '/', expiry_time), want)
128
129 expiry_time = datetime.datetime.now() + datetime.timedelta(days=1)
130- want = '1553259600_4cbf405bf08cee57eadcceb2ea98fc6767c6007b'
131+ want = '1553299200_d5257bb9f1e5e27065f2e7c986ca8c95f4cc3680'
132 self.assertEqual(utils.generate_token(signing_key, '/', expiry_time), want)

Subscribers

People subscribed via source and target branches