test_acme_account_rollover.py 1.57 KB
Newer Older
1 2 3 4
import unittest, sys, os
from subprocess import Popen, PIPE
from io import StringIO
import acme_dns_tiny
5
from tests.config_factory import generate_acme_account_rollover_config
6
from tools.acme_account_delete import account_delete
7 8 9 10 11 12
import tools.acme_account_rollover
import logassert

ACMEDirectory = os.getenv("GITLABCI_ACMEDIRECTORY", "https://acme-staging.api.letsencrypt.org/directory")

class TestACMEAccountRollover(unittest.TestCase):
13
    "Tests for acme_account_rollover"
14 15 16

    @classmethod
    def setUpClass(self):
17
        self.configs = generate_acme_account_rollover_config()
18 19 20 21 22 23
        super(TestACMEAccountRollover, self).setUpClass()

    # To clean ACME staging server and close correctly temporary files
    @classmethod
    def tearDownClass(self):
        # delete account key registration at end of tests
24
        account_delete(self.configs["newaccountkey"].name, ACMEDirectory)
25 26 27 28 29 30 31 32 33 34
        # close temp files correctly
        for tmpfile in self.configs:
            self.configs[tmpfile].close()
        super(TestACMEAccountRollover, self).tearDownClass()

    def setUp(self):
        logassert.setup(self, 'acme_account_rollover')

    def test_success_account_rollover(self):
        """ Test success account key rollover """
35 36
        tools.acme_account_rollover.main(["--current", self.configs['oldaccountkey'].name,
                                          "--new", self.configs['newaccountkey'].name,
37 38 39 40 41
                                          "--acme-directory", ACMEDirectory])
        self.assertLoggedInfo("Account keys rolled over !")

if __name__ == "__main__":
    unittest.main()