Commit 114fe459 authored by Adrien Dorsaz's avatar Adrien Dorsaz

tests: add ACME account key rollover test

parent 2d22e977
......@@ -118,3 +118,16 @@ def generate_acme_dns_tiny_config():
"accountcsr": account_csr
# generate account and domain keys
def generate_account_rollover_config():
# Old account key
old_account_key = NamedTemporaryFile()
Popen(["openssl", "genrsa", "-out",, "2048"]).wait()
# New account key
new_account_key = NamedTemporaryFile()
Popen(["openssl", "genrsa", "-out",, "2048"]).wait()
return {
# keys (returned to keep files on system)
"oldaccountkey": old_account_key,
"newaccountkey": new_account_key
import unittest, sys, os
from subprocess import Popen, PIPE
from io import StringIO
import acme_dns_tiny
from tests.config_factory import generate_account_rollover_config
from tools.acme_account_delete import delete_account
import tools.acme_account_rollover
import logassert
ACMEDirectory = os.getenv("GITLABCI_ACMEDIRECTORY", "")
class TestACMEAccountRollover(unittest.TestCase):
"Tests for acme_account_key_rollover"
def setUpClass(self):
self.configs = generate_account_rollover_config()
super(TestACMEAccountRollover, self).setUpClass()
# To clean ACME staging server and close correctly temporary files
def tearDownClass(self):
# delete account key registration at end of tests
delete_account(self.configs["newaccountkey"].name, ACMEDirectory)
# close temp files correctly
for tmpfile in self.configs:
super(TestACMEAccountRollover, self).tearDownClass()
def setUp(self):
logassert.setup(self, 'acme_account_rollover')
def test_success_account_rollover(self):
""" Test success account key rollover """
tools.acme_account_rollover.main(["--current-account-key", self.configs['oldaccountkey'].name,
"--new-account-key", self.configs['newaccountkey'].name,
"--acme-directory", ACMEDirectory])
self.assertLoggedInfo("Account keys rolled over !")
if __name__ == "__main__":
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