コード例 #1
0
def test_domain_definitions_from_cli_parse_error(capsys):
    from check_tls_certs import domain_definitions_from_cli
    with pytest.raises(SystemExit) as e:
        domain_definitions_from_cli(["foo:bar"])
    (out, err) = capsys.readouterr()
    assert "Error in definition 'foo:bar': Couldn't parse 'foo:bar', port 'bar' is not an integer" in err
    assert e.value.args == (5, )
コード例 #2
0
    def poll_hosts(self):
        if (self.hosts is not None):
            logger.info("Polling hosts")
            self.domains = list(
                check_tls_certs.itertools.chain(
                    check_tls_certs.domain_definitions_from_cli(self.hosts)))
        else:
            self.domains = list(
                check_tls_certs.itertools.chain(
                    check_tls_certs.domain_definitions_from_filename(
                        self.path + "/hosts.txt")))

        logger.info("Iterations:%s", self.absolute_iterations)

        self.domain_certs = check_tls_certs.get_domain_certs(self.domains)
        self.exceptions = list(x for x in self.domain_certs.values()
                               if isinstance(x, Exception))
        self.total_warnings = 0
        self.total_errors = 0
        self.earliest_expiration = None
        self.utcnow = datetime.datetime.utcnow()
        self.checked_domains = check_tls_certs.check_domains(
            self.domains,
            self.domain_certs,
            self.utcnow,
            expiry_warn=self.default_expiry_warn)

        print("Checked Domains:", self.checked_domains)