Commit 3330fc7e authored by Adrien Dorsaz's avatar Adrien Dorsaz

test-acme-dns-tiny: add a test to check the --csr argument is well used

parent c53c6a33
Pipeline #184 failed with stage
in 17 minutes and 7 seconds
......@@ -90,8 +90,12 @@ def generate_acme_dns_tiny_config():
config = configparser.ConfigParser()
config.read(goodCName)
goodCNameWithoutCSR = NamedTemporaryFile(delete=False)
del config["acmednstiny"]["CSRFile"]
with open(goodCNameWithoutCSR.name, 'w') as configfile:
config.write(configfile)
wildCName = NamedTemporaryFile(delete=False)
config["acmednstiny"]["AccountKeyFile"] = account_key
config["acmednstiny"]["CSRFile"] = wilddomain_csr.name
with open(wildCName.name, 'w') as configfile:
config.write(configfile)
......@@ -103,13 +107,11 @@ def generate_acme_dns_tiny_config():
config["DNS"]["Host"] = DNSHOST
goodSAN = NamedTemporaryFile(delete=False)
config["acmednstiny"]["AccountKeyFile"] = account_key
config["acmednstiny"]["CSRFile"] = san_csr.name
with open(goodSAN.name, 'w') as configfile:
config.write(configfile)
wildSAN = NamedTemporaryFile(delete=False)
config["acmednstiny"]["AccountKeyFile"] = account_key
config["acmednstiny"]["CSRFile"] = wildsan_csr.name
with open(wildSAN.name, 'w') as configfile:
config.write(configfile)
......@@ -139,6 +141,7 @@ def generate_acme_dns_tiny_config():
return {
# configs
"goodCName": goodCName,
"goodCNameWithoutCSR": goodCNameWithoutCSR,
"wildCName": wildCName.name,
"dnsHostIP": dnsHostIP.name,
"goodSAN": goodSAN.name,
......@@ -149,6 +152,8 @@ def generate_acme_dns_tiny_config():
"missingDNS": missingDNS.name,
# key (just to simply remove the account from staging server)
"accountkey": account_key,
# CName CSR file to use with goodCNameWithoutCSR
"cnameCSR": domain_csr,
}
# generate two account keys to roll over them
......
......@@ -128,6 +128,16 @@ class TestACMEDNSTiny(unittest.TestCase):
self.assertCertificateChain(certchain)
def test_success_cli_with_csr_option(self):
""" Successfully issue a certificate via command line interface using CSR option"""
certout, err = subprocess.Popen([
"python3", "acme_dns_tiny.py", ['--csr', sefl.configs['cnameCSR'], self.configs['goodCNameWithoutCSR']]
], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
certchain = certout.decode("utf8")
self.assertCertificateChain(certchain)
def test_weak_key(self):
""" Let's Encrypt rejects weak keys """
self.assertRaisesRegex(ValueError,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment