Exemplo n.º 1
0
 def test_702_001(self):
     domain = self.test_domain
     # generate config with one MD
     domains = [domain, "www." + domain]
     conf = HttpdConf()
     conf.add_admin("admin@" + domain)
     conf.add_drive_mode("auto")
     conf.add_md(domains)
     conf.install()
     #
     # restart, check that MD is synched to store
     assert TestEnv.apache_restart() == 0
     TestEnv.check_md(domains)
     stat = TestEnv.get_md_status(domain)
     assert stat["watched"] == 0
     #
     # add vhost for MD, restart should drive it
     conf.add_vhost(domains)
     conf.install()
     assert TestEnv.apache_restart() == 0
     assert TestEnv.await_completion([domain])
     TestEnv.check_md_complete(domain)
     stat = TestEnv.get_md_status(domain)
     assert stat["watched"] == 1
     cert = TestEnv.get_cert(domain)
     assert domain in cert.get_san_list()
     #
     # challenges should have been removed
     # file system needs to have correct permissions
     TestEnv.check_dir_empty(TestEnv.store_challenges())
     TestEnv.check_file_permissions(domain)
Exemplo n.º 2
0
    def test_702_001(self):
        domain = self.test_domain
        # generate config with one MD
        dns_list = [domain, "www." + domain]
        conf = HttpdConf()
        conf.add_admin("admin@" + domain)
        conf.add_drive_mode("auto")
        conf.add_md(dns_list)
        conf.install()

        # restart, check that MD is synched to store
        assert TestEnv.apache_restart() == 0
        TestEnv.check_md(domain, dns_list)
        time.sleep(2)
        # assert drive did not start
        TestEnv.check_md(domain, dns_list, TestEnv.MD_S_INCOMPLETE)
        assert TestEnv.apache_err_scan(
            re.compile('.*\[md:debug\].*no mds to drive'))

        # add vhost for MD, restart should drive it
        conf.add_vhost(TestEnv.HTTPS_PORT, domain, aliasList=[dns_list[1]])
        conf.install()
        assert TestEnv.apache_restart() == 0
        assert TestEnv.await_completion([domain])
        TestEnv.check_md_complete(domain)
        cert = CertUtil.load_server_cert(TestEnv.HTTPD_HOST,
                                         TestEnv.HTTPS_PORT, domain)
        assert domain in cert.get_san_list()

        # challenges should have been removed
        TestEnv.check_dir_empty(TestEnv.store_challenges())

        # file system needs to have correct permissions
        TestEnv.check_file_permissions(domain)
Exemplo n.º 3
0
    def test_500_100(self):
        # test case: md with one domain
        domain = self.test_domain
        name = "www." + domain
        self._prepare_md([name])
        assert TestEnv.apache_start() == 0
        # drive
        prevMd = TestEnv.a2md(["list", name])['jout']['output'][0]
        assert TestEnv.a2md(["drive", "-c", "http-01", name])['rv'] == 0
        TestEnv.check_md_credentials([name])
        self._check_account_key(name)

        # check archive content
        storeMd = json.loads(
            open(TestEnv.store_archived_file(name, 1, 'md.json')).read())
        for f in [
                'name', 'ca', 'domains', 'contacts', 'renew-mode',
                'renew-window', 'must-staple'
        ]:
            assert storeMd[f] == prevMd[f]

        # check file system permissions:
        TestEnv.check_file_permissions(name)
        # check: challenges removed
        TestEnv.check_dir_empty(TestEnv.store_challenges())
        # check how the challenge resources are answered in sevceral combinations
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge", False)
        assert result['rv'] == 0
        assert result['http_status'] == 404
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge/",
                                  False)
        assert result['rv'] == 0
        assert result['http_status'] == 404
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge/123",
                                  False)
        assert result['rv'] == 0
        assert result['http_status'] == 404
        assert result['rv'] == 0
        cdir = os.path.join(TestEnv.store_challenges(), domain)
        os.makedirs(cdir)
        open(os.path.join(cdir, 'acme-http-01.txt'),
             "w").write("content-of-123")
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge/123",
                                  False)
        assert result['rv'] == 0
        assert result['http_status'] == 200
        assert result['http_headers']['Content-Length'] == '14'
Exemplo n.º 4
0
    def test_500_100(self):
        # test case: md with one domain
        domain = "test500-100-" + TestDrive.dns_uniq
        name = "www." + domain
        self._prepare_md([name])
        assert TestEnv.apache_start() == 0
        # drive
        prevMd = TestEnv.a2md(["list", name])['jout']['output'][0]
        assert TestEnv.a2md(["drive", "-c", "http-01", name])['rv'] == 0
        self._check_md_cert([name])
        self._check_account_key(name)

        # check: challenges removed
        TestEnv.check_dir_empty(TestEnv.path_challenges())
        # check archive content
        assert json.loads(
            open(TestEnv.path_domain(name, archiveVersion=1)).read()) == prevMd

        # check file system permissions:
        TestEnv.check_file_permissions(name)
Exemplo n.º 5
0
    def test_700_001(self):
        domain = "test700-001-" + TestAuto.dns_uniq

        # generate config with one MD
        dns_list = [domain, "www." + domain]
        conf = HttpdConf(TestAuto.TMP_CONF)
        conf.add_admin("admin@" + domain)
        conf.add_drive_mode("auto")
        conf.add_md(dns_list)
        conf.install()

        # restart, check that MD is synched to store
        assert TestEnv.apache_restart() == 0
        self._check_md_names(domain, dns_list)
        time.sleep(2)
        # assert drive did not start
        md = TestEnv.a2md(["-j", "list", domain])['jout']['output'][0]
        assert md['state'] == TestEnv.MD_S_INCOMPLETE
        assert 'account' not in md['ca']
        assert TestEnv.apache_err_scan(
            re.compile('.*\[md:debug\].*no mds to auto drive'))

        # add vhost for MD, restart should drive it
        conf.add_vhost(TestEnv.HTTPS_PORT,
                       domain,
                       aliasList=[dns_list[1]],
                       withSSL=True)
        conf.install()
        assert TestEnv.apache_restart() == 0

        assert TestEnv.await_completion([domain])
        self._check_md_cert(dns_list)
        cert = CertUtil.load_server_cert(TestEnv.HTTPD_HOST,
                                         TestEnv.HTTPS_PORT, domain)
        assert domain in cert.get_san_list()

        # challenges should have been removed
        TestEnv.check_dir_empty(TestEnv.path_challenges())

        # file system needs to have correct permissions
        TestEnv.check_file_permissions(domain)
Exemplo n.º 6
0
    def test_502_100(self):
        # test case: md with one domain
        domain = "test502-100-" + TestDrive.dns_uniq
        name = "www." + domain
        self._prepare_md([name])
        assert TestEnv.apache_start() == 0
        # drive
        prevMd = TestEnv.a2md(["list", name])['jout']['output'][0]
        assert TestEnv.a2md(["-v", "drive", "-c", "http-01", name])['rv'] == 0
        self._check_md_cert([name])
        self._check_account_key(name)

        # check archive content
        assert json.loads(
            open(TestEnv.path_domain(name, archiveVersion=1)).read()) == prevMd
        # check file system permissions:
        TestEnv.check_file_permissions(name)
        # check: challenges removed
        TestEnv.check_dir_empty(TestEnv.path_challenges())
        # check how the challenge resources are answered in sevceral combinations
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge", False)
        assert result['rv'] == 0
        assert result['http_status'] == 404
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge/",
                                  False)
        assert result['rv'] == 0
        assert result['http_status'] == 404
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge/123",
                                  False)
        assert result['rv'] == 0
        assert result['http_status'] == 404
        assert result['rv'] == 0
        cdir = os.path.join(TestEnv.path_challenges(), domain)
        os.makedirs(cdir)
        open(os.path.join(cdir, 'acme-http-01.txt'),
             "w").write("content-of-123")
        result = TestEnv.get_meta(domain, "/.well-known/acme-challenge/123",
                                  False)
        assert result['rv'] == 0
        assert result['http_status'] == 200
        assert result['http_headers']['Content-Length'] == '14'