def test_deploy_cert(plugin, temp_dir, domains): """Tests deploy_cert returning True if the tests are successful""" cert = crypto_util.gen_ss_cert(util.KEY, domains) cert_path = os.path.join(temp_dir, "cert.pem") with open(cert_path, "w") as f: f.write(OpenSSL.crypto.dump_certificate( OpenSSL.crypto.FILETYPE_PEM, cert)) for domain in domains: try: plugin.deploy_cert(domain, cert_path, util.KEY_PATH) except le_errors.Error as error: logger.error("Plugin failed to deploy ceritificate for %s:", domain) logger.exception(error) return False if not _save_and_restart(plugin, "deployed"): return False success = True for domain in domains: verify = functools.partial(validator.Validator().certificate, cert, domain, "127.0.0.1", plugin.https_port) if not _try_until_true(verify): logger.error("Could not verify certificate for domain %s", domain) success = False if success: logger.info("HTTPS validation succeeded") return success
def test_enhancements(plugin, domains): """Tests supported enhancements returning True if successful""" supported = plugin.supported_enhancements() if "redirect" not in supported: logger.error("The plugin and this program support no common " "enhancements") return False for domain in domains: try: plugin.enhance(domain, "redirect") except le_errors.PluginError as error: # Don't immediately fail because a redirect may already be enabled logger.warning("Plugin failed to enable redirect for %s:", domain) logger.warning("%s", error) except le_errors.Error as error: logger.error("An error occurred while enabling redirect for %s:", domain) logger.exception(error) if not _save_and_restart(plugin, "enhanced"): return False success = True for domain in domains: verify = functools.partial(validator.Validator().redirect, "localhost", plugin.http_port, headers={"Host": domain}) if not _try_until_true(verify): logger.error("Improper redirect for domain %s", domain) success = False if success: logger.info("Enhancments test succeeded") return success
def setUp(self): self.validator = validator.Validator()