configurator_test.py
1 # pylint: disable=too-many-public-methods 2 """Test for letsencrypt_apache.configurator.""" 3 import os 4 import shutil 5 import socket 6 import unittest 7 8 import mock 9 10 from acme import challenges 11 12 from letsencrypt import achallenges 13 from letsencrypt import errors 14 15 from letsencrypt.tests import acme_util 16 17 from letsencrypt_apache import configurator 18 from letsencrypt_apache import obj 19 20 from letsencrypt_apache.tests import util 21 22 23 class TwoVhost80Test(util.ApacheTest): 24 """Test two standard well-configured HTTP vhosts.""" 25 26 def setUp(self): # pylint: disable=arguments-differ 27 super(TwoVhost80Test, self).setUp() 28 29 self.config = util.get_apache_configurator( 30 self.config_path, self.config_dir, self.work_dir) 31 32 self.vh_truth = util.get_vh_truth( 33 self.temp_dir, "debian_apache_2_4/two_vhost_80") 34 35 def tearDown(self): 36 shutil.rmtree(self.temp_dir) 37 shutil.rmtree(self.config_dir) 38 shutil.rmtree(self.work_dir) 39 40 @mock.patch("letsencrypt_apache.configurator.le_util.exe_exists") 41 def test_prepare_no_install(self, mock_exe_exists): 42 mock_exe_exists.return_value = False 43 self.assertRaises( 44 errors.NoInstallationError, self.config.prepare) 45 46 @mock.patch("letsencrypt_apache.parser.ApacheParser") 47 @mock.patch("letsencrypt_apache.configurator.le_util.exe_exists") 48 def test_prepare_version(self, mock_exe_exists, _): 49 mock_exe_exists.return_value = True 50 self.config.version = None 51 self.config.config_test = mock.Mock() 52 self.config.get_version = mock.Mock(return_value=(1, 1)) 53 54 self.assertRaises( 55 errors.NotSupportedError, self.config.prepare) 56 57 def test_add_parser_arguments(self): # pylint: disable=no-self-use 58 from letsencrypt_apache.configurator import ApacheConfigurator 59 # Weak test.. 60 ApacheConfigurator.add_parser_arguments(mock.MagicMock()) 61 62 def test_get_all_names(self): 63 names = self.config.get_all_names() 64 self.assertEqual(names, set( 65 ["letsencrypt.demo", "encryption-example.demo", "ip-172-30-0-17"])) 66 67 @mock.patch("letsencrypt_apache.configurator.socket.gethostbyaddr") 68 def test_get_all_names_addrs(self, mock_gethost): 69 mock_gethost.side_effect = [("google.com", "", ""), socket.error] 70 vhost = obj.VirtualHost( 71 "fp", "ap", 72 set([obj.Addr(("8.8.8.8", "443")), 73 obj.Addr(("zombo.com",)), 74 obj.Addr(("192.168.1.2"))]), 75 True, False) 76 self.config.vhosts.append(vhost) 77 78 names = self.config.get_all_names() 79 self.assertEqual(len(names), 5) 80 self.assertTrue("zombo.com" in names) 81 self.assertTrue("google.com" in names) 82 self.assertTrue("letsencrypt.demo" in names) 83 84 def test_add_servernames_alias(self): 85 self.config.parser.add_dir( 86 self.vh_truth[2].path, "ServerAlias", ["*.le.co"]) 87 self.config._add_servernames(self.vh_truth[2]) # pylint: disable=protected-access 88 89 self.assertEqual( 90 self.vh_truth[2].get_names(), set(["*.le.co", "ip-172-30-0-17"])) 91 92 def test_get_virtual_hosts(self): 93 """Make sure all vhosts are being properly found. 94 95 .. note:: If test fails, only finding 1 Vhost... it is likely that 96 it is a problem with is_enabled. If finding only 3, likely is_ssl 97 98 """ 99 vhs = self.config.get_virtual_hosts() 100 self.assertEqual(len(vhs), 4) 101 found = 0 102 103 for vhost in vhs: 104 for truth in self.vh_truth: 105 if vhost == truth: 106 found += 1 107 break 108 else: 109 raise Exception("Missed: %s" % vhost) # pragma: no cover 110 111 self.assertEqual(found, 4) 112 113 @mock.patch("letsencrypt_apache.display_ops.select_vhost") 114 def test_choose_vhost_none_avail(self, mock_select): 115 mock_select.return_value = None 116 self.assertRaises( 117 errors.PluginError, self.config.choose_vhost, "none.com") 118 119 @mock.patch("letsencrypt_apache.display_ops.select_vhost") 120 def test_choose_vhost_select_vhost_ssl(self, mock_select): 121 mock_select.return_value = self.vh_truth[1] 122 self.assertEqual( 123 self.vh_truth[1], self.config.choose_vhost("none.com")) 124 125 @mock.patch("letsencrypt_apache.display_ops.select_vhost") 126 def test_choose_vhost_select_vhost_non_ssl(self, mock_select): 127 mock_select.return_value = self.vh_truth[0] 128 chosen_vhost = self.config.choose_vhost("none.com") 129 self.assertEqual( 130 self.vh_truth[0].get_names(), chosen_vhost.get_names()) 131 132 # Make sure we go from HTTP -> HTTPS 133 self.assertFalse(self.vh_truth[0].ssl) 134 self.assertTrue(chosen_vhost.ssl) 135 136 @mock.patch("letsencrypt_apache.display_ops.select_vhost") 137 def test_choose_vhost_select_vhost_conflicting_non_ssl(self, mock_select): 138 mock_select.return_value = self.vh_truth[3] 139 conflicting_vhost = obj.VirtualHost( 140 "path", "aug_path", set([obj.Addr.fromstring("*:443")]), True, True) 141 self.config.vhosts.append(conflicting_vhost) 142 143 self.assertRaises( 144 errors.PluginError, self.config.choose_vhost, "none.com") 145 146 def test_find_best_vhost(self): 147 # pylint: disable=protected-access 148 self.assertEqual( 149 self.vh_truth[3], self.config._find_best_vhost("letsencrypt.demo")) 150 self.assertEqual( 151 self.vh_truth[0], 152 self.config._find_best_vhost("encryption-example.demo")) 153 self.assertTrue( 154 self.config._find_best_vhost("does-not-exist.com") is None) 155 156 def test_find_best_vhost_variety(self): 157 # pylint: disable=protected-access 158 ssl_vh = obj.VirtualHost( 159 "fp", "ap", set([obj.Addr(("*", "443")), obj.Addr(("zombo.com",))]), 160 True, False) 161 self.config.vhosts.append(ssl_vh) 162 self.assertEqual(self.config._find_best_vhost("zombo.com"), ssl_vh) 163 164 def test_find_best_vhost_default(self): 165 # pylint: disable=protected-access 166 # Assume only the two default vhosts. 167 self.config.vhosts = [ 168 vh for vh in self.config.vhosts 169 if vh.name not in ["letsencrypt.demo", "encryption-example.demo"] 170 ] 171 172 self.assertEqual( 173 self.config._find_best_vhost("example.demo"), self.vh_truth[2]) 174 175 def test_non_default_vhosts(self): 176 # pylint: disable=protected-access 177 self.assertEqual(len(self.config._non_default_vhosts()), 3) 178 179 def test_is_site_enabled(self): 180 """Test if site is enabled. 181 182 .. note:: This test currently fails for hard links 183 (which may happen if you move dirs incorrectly) 184 .. warning:: This test does not work when running using the 185 unittest.main() function. It incorrectly copies symlinks. 186 187 """ 188 self.assertTrue(self.config.is_site_enabled(self.vh_truth[0].filep)) 189 self.assertFalse(self.config.is_site_enabled(self.vh_truth[1].filep)) 190 self.assertTrue(self.config.is_site_enabled(self.vh_truth[2].filep)) 191 self.assertTrue(self.config.is_site_enabled(self.vh_truth[3].filep)) 192 193 @mock.patch("letsencrypt.le_util.run_script") 194 @mock.patch("letsencrypt.le_util.exe_exists") 195 @mock.patch("letsencrypt_apache.parser.subprocess.Popen") 196 def test_enable_mod(self, mock_popen, mock_exe_exists, mock_run_script): 197 mock_popen().communicate.return_value = ("Define: DUMP_RUN_CFG", "") 198 mock_popen().returncode = 0 199 mock_exe_exists.return_value = True 200 201 self.config.enable_mod("ssl") 202 self.assertTrue("ssl_module" in self.config.parser.modules) 203 self.assertTrue("mod_ssl.c" in self.config.parser.modules) 204 205 self.assertTrue(mock_run_script.called) 206 207 def test_enable_mod_unsupported_dirs(self): 208 shutil.rmtree(os.path.join(self.config.parser.root, "mods-enabled")) 209 self.assertRaises( 210 errors.NotSupportedError, self.config.enable_mod, "ssl") 211 212 @mock.patch("letsencrypt.le_util.exe_exists") 213 def test_enable_mod_no_disable(self, mock_exe_exists): 214 mock_exe_exists.return_value = False 215 self.assertRaises( 216 errors.MisconfigurationError, self.config.enable_mod, "ssl") 217 218 def test_enable_site(self): 219 # Default 443 vhost 220 self.assertFalse(self.vh_truth[1].enabled) 221 self.config.enable_site(self.vh_truth[1]) 222 self.assertTrue(self.vh_truth[1].enabled) 223 224 # Go again to make sure nothing fails 225 self.config.enable_site(self.vh_truth[1]) 226 227 def test_enable_site_failure(self): 228 self.assertRaises( 229 errors.NotSupportedError, 230 self.config.enable_site, 231 obj.VirtualHost("asdf", "afsaf", set(), False, False)) 232 233 def test_deploy_cert(self): 234 self.config.parser.modules.add("ssl_module") 235 self.config.parser.modules.add("mod_ssl.c") 236 237 # Get the default 443 vhost 238 self.config.assoc["random.demo"] = self.vh_truth[1] 239 self.config.deploy_cert( 240 "random.demo", 241 "example/cert.pem", "example/key.pem", "example/cert_chain.pem") 242 self.config.save() 243 244 # Verify ssl_module was enabled. 245 self.assertTrue(self.vh_truth[1].enabled) 246 self.assertTrue("ssl_module" in self.config.parser.modules) 247 248 loc_cert = self.config.parser.find_dir( 249 "sslcertificatefile", "example/cert.pem", self.vh_truth[1].path) 250 loc_key = self.config.parser.find_dir( 251 "sslcertificateKeyfile", "example/key.pem", self.vh_truth[1].path) 252 loc_chain = self.config.parser.find_dir( 253 "SSLCertificateChainFile", "example/cert_chain.pem", 254 self.vh_truth[1].path) 255 256 # Verify one directive was found in the correct file 257 self.assertEqual(len(loc_cert), 1) 258 self.assertEqual(configurator.get_file_path(loc_cert[0]), 259 self.vh_truth[1].filep) 260 261 self.assertEqual(len(loc_key), 1) 262 self.assertEqual(configurator.get_file_path(loc_key[0]), 263 self.vh_truth[1].filep) 264 265 self.assertEqual(len(loc_chain), 1) 266 self.assertEqual(configurator.get_file_path(loc_chain[0]), 267 self.vh_truth[1].filep) 268 269 # One more time for chain directive setting 270 self.config.deploy_cert( 271 "random.demo", 272 "two/cert.pem", "two/key.pem", "two/cert_chain.pem") 273 self.assertTrue(self.config.parser.find_dir( 274 "SSLCertificateChainFile", "two/cert_chain.pem", 275 self.vh_truth[1].path)) 276 277 def test_deploy_cert_invalid_vhost(self): 278 self.config.parser.modules.add("ssl_module") 279 mock_find = mock.MagicMock() 280 mock_find.return_value = [] 281 self.config.parser.find_dir = mock_find 282 283 # Get the default 443 vhost 284 self.config.assoc["random.demo"] = self.vh_truth[1] 285 self.assertRaises( 286 errors.PluginError, self.config.deploy_cert, "random.demo", 287 "example/cert.pem", "example/key.pem", "example/cert_chain.pem") 288 289 def test_is_name_vhost(self): 290 addr = obj.Addr.fromstring("*:80") 291 self.assertTrue(self.config.is_name_vhost(addr)) 292 self.config.version = (2, 2) 293 self.assertFalse(self.config.is_name_vhost(addr)) 294 295 def test_add_name_vhost(self): 296 self.config.add_name_vhost(obj.Addr.fromstring("*:443")) 297 self.config.add_name_vhost(obj.Addr.fromstring("*:80")) 298 self.assertTrue(self.config.parser.find_dir( 299 "NameVirtualHost", "*:443", exclude=False)) 300 self.assertTrue(self.config.parser.find_dir( 301 "NameVirtualHost", "*:80")) 302 303 def test_prepare_server_https(self): 304 mock_enable = mock.Mock() 305 self.config.enable_mod = mock_enable 306 307 mock_find = mock.Mock() 308 mock_add_dir = mock.Mock() 309 mock_find.return_value = [] 310 311 # This will test the Add listen 312 self.config.parser.find_dir = mock_find 313 self.config.parser.add_dir_to_ifmodssl = mock_add_dir 314 315 self.config.prepare_server_https("443") 316 self.assertEqual(mock_enable.call_args[1], {"temp": False}) 317 318 self.config.prepare_server_https("8080", temp=True) 319 # Enable mod is temporary 320 self.assertEqual(mock_enable.call_args[1], {"temp": True}) 321 322 self.assertEqual(mock_add_dir.call_count, 2) 323 324 def test_make_vhost_ssl(self): 325 ssl_vhost = self.config.make_vhost_ssl(self.vh_truth[0]) 326 327 self.assertEqual( 328 ssl_vhost.filep, 329 os.path.join(self.config_path, "sites-available", 330 "encryption-example-le-ssl.conf")) 331 332 self.assertEqual(ssl_vhost.path, 333 "/files" + ssl_vhost.filep + "/IfModule/VirtualHost") 334 self.assertEqual(len(ssl_vhost.addrs), 1) 335 self.assertEqual(set([obj.Addr.fromstring("*:443")]), ssl_vhost.addrs) 336 self.assertEqual(ssl_vhost.name, "encryption-example.demo") 337 self.assertTrue(ssl_vhost.ssl) 338 self.assertFalse(ssl_vhost.enabled) 339 340 self.assertTrue(self.config.parser.find_dir( 341 "SSLCertificateFile", None, ssl_vhost.path, False)) 342 self.assertTrue(self.config.parser.find_dir( 343 "SSLCertificateKeyFile", None, ssl_vhost.path, False)) 344 345 self.assertEqual(self.config.is_name_vhost(self.vh_truth[0]), 346 self.config.is_name_vhost(ssl_vhost)) 347 348 self.assertEqual(len(self.config.vhosts), 5) 349 350 def test_make_vhost_ssl_extra_vhs(self): 351 self.config.aug.match = mock.Mock(return_value=["p1", "p2"]) 352 self.assertRaises( 353 errors.PluginError, self.config.make_vhost_ssl, self.vh_truth[0]) 354 355 def test_make_vhost_ssl_bad_write(self): 356 mock_open = mock.mock_open() 357 # This calls open 358 self.config.reverter.register_file_creation = mock.Mock() 359 mock_open.side_effect = IOError 360 with mock.patch("__builtin__.open", mock_open): 361 self.assertRaises( 362 errors.PluginError, 363 self.config.make_vhost_ssl, self.vh_truth[0]) 364 365 def test_get_ssl_vhost_path(self): 366 # pylint: disable=protected-access 367 self.assertTrue( 368 self.config._get_ssl_vhost_path("example_path").endswith(".conf")) 369 370 def test_add_name_vhost_if_necessary(self): 371 # pylint: disable=protected-access 372 self.config.save = mock.Mock() 373 self.config.version = (2, 2) 374 self.config._add_name_vhost_if_necessary(self.vh_truth[0]) 375 self.assertTrue(self.config.save.called) 376 377 @mock.patch("letsencrypt_apache.configurator.dvsni.ApacheDvsni.perform") 378 @mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart") 379 def test_perform(self, mock_restart, mock_dvsni_perform): 380 # Only tests functionality specific to configurator.perform 381 # Note: As more challenges are offered this will have to be expanded 382 account_key, achall1, achall2 = self.get_achalls() 383 384 dvsni_ret_val = [ 385 achall1.gen_response(account_key), 386 achall2.gen_response(account_key), 387 ] 388 389 mock_dvsni_perform.return_value = dvsni_ret_val 390 responses = self.config.perform([achall1, achall2]) 391 392 self.assertEqual(mock_dvsni_perform.call_count, 1) 393 self.assertEqual(responses, dvsni_ret_val) 394 395 self.assertEqual(mock_restart.call_count, 1) 396 397 @mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart") 398 def test_cleanup(self, mock_restart): 399 _, achall1, achall2 = self.get_achalls() 400 401 self.config._chall_out.add(achall1) # pylint: disable=protected-access 402 self.config._chall_out.add(achall2) # pylint: disable=protected-access 403 404 self.config.cleanup([achall1]) 405 self.assertFalse(mock_restart.called) 406 407 self.config.cleanup([achall2]) 408 self.assertTrue(mock_restart.called) 409 410 @mock.patch("letsencrypt_apache.configurator.ApacheConfigurator.restart") 411 def test_cleanup_no_errors(self, mock_restart): 412 _, achall1, achall2 = self.get_achalls() 413 414 self.config._chall_out.add(achall1) # pylint: disable=protected-access 415 416 self.config.cleanup([achall2]) 417 self.assertFalse(mock_restart.called) 418 419 self.config.cleanup([achall1, achall2]) 420 self.assertTrue(mock_restart.called) 421 422 @mock.patch("letsencrypt.le_util.run_script") 423 def test_get_version(self, mock_script): 424 mock_script.return_value = ( 425 "Server Version: Apache/2.4.2 (Debian)", "") 426 self.assertEqual(self.config.get_version(), (2, 4, 2)) 427 428 mock_script.return_value = ( 429 "Server Version: Apache/2 (Linux)", "") 430 self.assertEqual(self.config.get_version(), (2,)) 431 432 mock_script.return_value = ( 433 "Server Version: Apache (Debian)", "") 434 self.assertRaises(errors.PluginError, self.config.get_version) 435 436 mock_script.return_value = ( 437 "Server Version: Apache/2.3{0} Apache/2.4.7".format(os.linesep), "") 438 self.assertRaises(errors.PluginError, self.config.get_version) 439 440 mock_script.side_effect = errors.SubprocessError("Can't find program") 441 self.assertRaises(errors.PluginError, self.config.get_version) 442 443 @mock.patch("letsencrypt_apache.configurator.subprocess.Popen") 444 def test_restart(self, mock_popen): 445 """These will be changed soon enough with reload.""" 446 mock_popen().returncode = 0 447 mock_popen().communicate.return_value = ("", "") 448 449 self.config.restart() 450 451 @mock.patch("letsencrypt_apache.configurator.subprocess.Popen") 452 def test_restart_bad_process(self, mock_popen): 453 mock_popen.side_effect = OSError 454 455 self.assertRaises(errors.MisconfigurationError, self.config.restart) 456 457 @mock.patch("letsencrypt_apache.configurator.subprocess.Popen") 458 def test_restart_failure(self, mock_popen): 459 mock_popen().communicate.return_value = ("", "") 460 mock_popen().returncode = 1 461 462 self.assertRaises(errors.MisconfigurationError, self.config.restart) 463 464 @mock.patch("letsencrypt.le_util.run_script") 465 def test_config_test(self, _): 466 self.config.config_test() 467 468 @mock.patch("letsencrypt.le_util.run_script") 469 def test_config_test_bad_process(self, mock_run_script): 470 mock_run_script.side_effect = errors.SubprocessError 471 472 self.assertRaises(errors.MisconfigurationError, self.config.config_test) 473 474 def test_get_all_certs_keys(self): 475 c_k = self.config.get_all_certs_keys() 476 477 self.assertEqual(len(c_k), 1) 478 cert, key, path = next(iter(c_k)) 479 self.assertTrue("cert" in cert) 480 self.assertTrue("key" in key) 481 self.assertTrue("default-ssl.conf" in path) 482 483 def test_get_all_certs_keys_malformed_conf(self): 484 self.config.parser.find_dir = mock.Mock(side_effect=[["path"], []]) 485 c_k = self.config.get_all_certs_keys() 486 487 self.assertFalse(c_k) 488 489 def test_more_info(self): 490 self.assertTrue(self.config.more_info()) 491 492 def test_get_chall_pref(self): 493 self.assertTrue(isinstance(self.config.get_chall_pref(""), list)) 494 495 def test_temp_install(self): 496 from letsencrypt_apache.configurator import temp_install 497 path = os.path.join(self.work_dir, "test_it") 498 temp_install(path) 499 self.assertTrue(os.path.isfile(path)) 500 501 # TEST ENHANCEMENTS 502 def test_supported_enhancements(self): 503 self.assertTrue(isinstance(self.config.supported_enhancements(), list)) 504 505 def test_enhance_unknown_enhancement(self): 506 self.assertRaises( 507 errors.PluginError, 508 self.config.enhance, "letsencrypt.demo", "unknown_enhancement") 509 510 @mock.patch("letsencrypt.le_util.run_script") 511 @mock.patch("letsencrypt.le_util.exe_exists") 512 def test_redirect_well_formed_http(self, mock_exe, _): 513 self.config.parser.update_runtime_variables = mock.Mock() 514 mock_exe.return_value = True 515 # This will create an ssl vhost for letsencrypt.demo 516 self.config.enhance("letsencrypt.demo", "redirect") 517 518 # These are not immediately available in find_dir even with save() and 519 # load(). They must be found in sites-available 520 rw_engine = self.config.parser.find_dir( 521 "RewriteEngine", "on", self.vh_truth[3].path) 522 rw_rule = self.config.parser.find_dir( 523 "RewriteRule", None, self.vh_truth[3].path) 524 525 self.assertEqual(len(rw_engine), 1) 526 # three args to rw_rule 527 self.assertEqual(len(rw_rule), 3) 528 529 self.assertTrue(rw_engine[0].startswith(self.vh_truth[3].path)) 530 self.assertTrue(rw_rule[0].startswith(self.vh_truth[3].path)) 531 532 self.assertTrue("rewrite_module" in self.config.parser.modules) 533 534 def test_redirect_with_conflict(self): 535 self.config.parser.modules.add("rewrite_module") 536 ssl_vh = obj.VirtualHost( 537 "fp", "ap", set([obj.Addr(("*", "443")), obj.Addr(("zombo.com",))]), 538 True, False) 539 # No names ^ this guy should conflict. 540 541 # pylint: disable=protected-access 542 self.assertRaises( 543 errors.PluginError, self.config._enable_redirect, ssl_vh, "") 544 545 def test_redirect_twice(self): 546 # Skip the enable mod 547 self.config.parser.modules.add("rewrite_module") 548 self.config.enhance("encryption-example.demo", "redirect") 549 self.assertRaises( 550 errors.PluginError, 551 self.config.enhance, "encryption-example.demo", "redirect") 552 553 def test_unknown_rewrite(self): 554 # Skip the enable mod 555 self.config.parser.modules.add("rewrite_module") 556 self.config.parser.add_dir( 557 self.vh_truth[3].path, "RewriteRule", ["Unknown"]) 558 self.config.save() 559 self.assertRaises( 560 errors.PluginError, 561 self.config.enhance, "letsencrypt.demo", "redirect") 562 563 def test_unknown_rewrite2(self): 564 # Skip the enable mod 565 self.config.parser.modules.add("rewrite_module") 566 self.config.parser.add_dir( 567 self.vh_truth[3].path, "RewriteRule", ["Unknown", "2", "3"]) 568 self.config.save() 569 self.assertRaises( 570 errors.PluginError, 571 self.config.enhance, "letsencrypt.demo", "redirect") 572 573 def test_unknown_redirect(self): 574 # Skip the enable mod 575 self.config.parser.modules.add("rewrite_module") 576 self.config.parser.add_dir( 577 self.vh_truth[3].path, "Redirect", ["Unknown"]) 578 self.config.save() 579 self.assertRaises( 580 errors.PluginError, 581 self.config.enhance, "letsencrypt.demo", "redirect") 582 583 def test_create_own_redirect(self): 584 self.config.parser.modules.add("rewrite_module") 585 # For full testing... give names... 586 self.vh_truth[1].name = "default.com" 587 self.vh_truth[1].aliases = set(["yes.default.com"]) 588 589 self.config._enable_redirect(self.vh_truth[1], "") # pylint: disable=protected-access 590 self.assertEqual(len(self.config.vhosts), 5) 591 592 def get_achalls(self): 593 """Return testing achallenges.""" 594 account_key = self.rsa512jwk 595 achall1 = achallenges.DVSNI( 596 challb=acme_util.chall_to_challb( 597 challenges.DVSNI( 598 token="jIq_Xy1mXGN37tb4L6Xj_es58fW571ZNyXekdZzhh7Q"), 599 "pending"), 600 domain="encryption-example.demo", account_key=account_key) 601 achall2 = achallenges.DVSNI( 602 challb=acme_util.chall_to_challb( 603 challenges.DVSNI( 604 token="uqnaPzxtrndteOqtrXb0Asl5gOJfWAnnx6QJyvcmlDU"), 605 "pending"), 606 domain="letsencrypt.demo", account_key=account_key) 607 608 return account_key, achall1, achall2 609 610 def test_make_addrs_sni_ready(self): 611 self.config.version = (2, 2) 612 self.config.make_addrs_sni_ready( 613 set([obj.Addr.fromstring("*:443"), obj.Addr.fromstring("*:80")])) 614 self.assertTrue(self.config.parser.find_dir( 615 "NameVirtualHost", "*:80", exclude=False)) 616 self.assertTrue(self.config.parser.find_dir( 617 "NameVirtualHost", "*:443", exclude=False)) 618 619 620 if __name__ == "__main__": 621 unittest.main() # pragma: no cover