예제 #1
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'
예제 #2
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)
예제 #3
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)