@@ -85,7 +85,7 @@ def test_get_all_names(self, mock_getutility):
8585 mock_getutility .notification = mock .MagicMock (return_value = True )
8686 names = self .config .get_all_names ()
8787 self .assertEqual (names , set (
88- ["letsencrypt.demo" , "encryption-example.demo" , "ip-172-30-0-17" ]))
88+ ["letsencrypt.demo" , "encryption-example.demo" , "ip-172-30-0-17" , "*.blue.purple.com" ]))
8989
9090 @mock .patch ("zope.component.getUtility" )
9191 @mock .patch ("letsencrypt_apache.configurator.socket.gethostbyaddr" )
@@ -103,7 +103,7 @@ def test_get_all_names_addrs(self, mock_gethost, mock_getutility):
103103 self .config .vhosts .append (vhost )
104104
105105 names = self .config .get_all_names ()
106- self .assertEqual (len (names ), 5 )
106+ self .assertEqual (len (names ), 6 )
107107 self .assertTrue ("zombo.com" in names )
108108 self .assertTrue ("google.com" in names )
109109 self .assertTrue ("letsencrypt.demo" in names )
@@ -124,7 +124,7 @@ def test_get_virtual_hosts(self):
124124
125125 """
126126 vhs = self .config .get_virtual_hosts ()
127- self .assertEqual (len (vhs ), 6 )
127+ self .assertEqual (len (vhs ), 7 )
128128 found = 0
129129
130130 for vhost in vhs :
@@ -135,15 +135,15 @@ def test_get_virtual_hosts(self):
135135 else :
136136 raise Exception ("Missed: %s" % vhost ) # pragma: no cover
137137
138- self .assertEqual (found , 6 )
138+ self .assertEqual (found , 7 )
139139
140140 # Handle case of non-debian layout get_virtual_hosts
141141 with mock .patch (
142142 "letsencrypt_apache.configurator.ApacheConfigurator.conf"
143143 ) as mock_conf :
144144 mock_conf .return_value = False
145145 vhs = self .config .get_virtual_hosts ()
146- self .assertEqual (len (vhs ), 6 )
146+ self .assertEqual (len (vhs ), 7 )
147147
148148 @mock .patch ("letsencrypt_apache.display_ops.select_vhost" )
149149 def test_choose_vhost_none_avail (self , mock_select ):
@@ -186,6 +186,20 @@ def test_choose_vhost_select_vhost_conflicting_non_ssl(self, mock_select):
186186 self .assertRaises (
187187 errors .PluginError , self .config .choose_vhost , "none.com" )
188188
189+ def test_choosevhost_select_vhost_with_wildcard (self ):
190+ chosen_vhost = self .config .choose_vhost ("blue.purple.com" , temp = True )
191+ self .assertEqual (self .vh_truth [6 ], chosen_vhost )
192+
193+ def test_findbest_continues_on_short_domain (self ):
194+ # pylint: disable=protected-access
195+ chosen_vhost = self .config ._find_best_vhost ("purple.com" )
196+ self .assertEqual (None , chosen_vhost )
197+
198+ def test_findbest_continues_on_long_domain (self ):
199+ # pylint: disable=protected-access
200+ chosen_vhost = self .config ._find_best_vhost ("green.red.purple.com" )
201+ self .assertEqual (None , chosen_vhost )
202+
189203 def test_find_best_vhost (self ):
190204 # pylint: disable=protected-access
191205 self .assertEqual (
@@ -211,14 +225,15 @@ def test_find_best_vhost_default(self):
211225 self .config .vhosts = [
212226 vh for vh in self .config .vhosts
213227 if vh .name not in ["letsencrypt.demo" , "encryption-example.demo" ]
228+ and "*.blue.purple.com" not in vh .aliases
214229 ]
215230
216231 self .assertEqual (
217232 self .config ._find_best_vhost ("example.demo" ), self .vh_truth [2 ])
218233
219234 def test_non_default_vhosts (self ):
220235 # pylint: disable=protected-access
221- self .assertEqual (len (self .config ._non_default_vhosts ()), 4 )
236+ self .assertEqual (len (self .config ._non_default_vhosts ()), 5 )
222237
223238 def test_is_site_enabled (self ):
224239 """Test if site is enabled.
@@ -524,7 +539,7 @@ def test_make_vhost_ssl(self):
524539 self .assertEqual (self .config .is_name_vhost (self .vh_truth [0 ]),
525540 self .config .is_name_vhost (ssl_vhost ))
526541
527- self .assertEqual (len (self .config .vhosts ), 7 )
542+ self .assertEqual (len (self .config .vhosts ), 8 )
528543
529544 def test_clean_vhost_ssl (self ):
530545 # pylint: disable=protected-access
@@ -942,7 +957,7 @@ def test_create_own_redirect(self):
942957
943958 # pylint: disable=protected-access
944959 self .config ._enable_redirect (self .vh_truth [1 ], "" )
945- self .assertEqual (len (self .config .vhosts ), 7 )
960+ self .assertEqual (len (self .config .vhosts ), 8 )
946961
947962 def test_create_own_redirect_for_old_apache_version (self ):
948963 self .config .parser .modules .add ("rewrite_module" )
@@ -953,7 +968,7 @@ def test_create_own_redirect_for_old_apache_version(self):
953968
954969 # pylint: disable=protected-access
955970 self .config ._enable_redirect (self .vh_truth [1 ], "" )
956- self .assertEqual (len (self .config .vhosts ), 7 )
971+ self .assertEqual (len (self .config .vhosts ), 8 )
957972
958973 def test_sift_line (self ):
959974 # pylint: disable=protected-access
0 commit comments