Add test for $hostname parsing

This commit is contained in:
OsirisInferi
2020-02-06 21:10:41 +01:00
parent 9b35dbf2be
commit 5035a510a2
2 changed files with 9 additions and 2 deletions
+4 -2
View File
@@ -76,15 +76,17 @@ class NginxConfiguratorTest(util.NginxTest):
else: # pragma: no cover
self.fail("Exception wasn't raised!")
@mock.patch("certbot_nginx._internal.configurator.socket.gethostname")
@mock.patch("certbot_nginx._internal.configurator.socket.gethostbyaddr")
def test_get_all_names(self, mock_gethostbyaddr):
def test_get_all_names(self, mock_gethostbyaddr, mock_gethostname):
mock_gethostbyaddr.return_value = ('155.225.50.69.nephoscale.net', [], [])
mock_gethostname.return_value = ('example.net')
names = self.config.get_all_names()
self.assertEqual(names, {
"155.225.50.69.nephoscale.net", "www.example.org", "another.alias",
"migration.com", "summer.com", "geese.com", "sslon.com",
"globalssl.com", "globalsslsetssl.com", "ipv6.com", "ipv6ssl.com",
"headers.com"})
"headers.com", "example.net"})
def test_supported_enhancements(self):
self.assertEqual(['redirect', 'ensure-http-header', 'staple-ocsp'],
@@ -0,0 +1,5 @@
server {
listen 80;
listen [::]:80;
server_name $hostname;
}