Commit 9bb17d13 authored by Adrien Dorsaz's avatar Adrien Dorsaz

tests: adapt tearDown() method for classes so they correctly cleanup temporary files

parent da5845ac
Pipeline #219 passed with stage
in 9 minutes and 37 seconds
import unittest, os, time
import unittest, os, time, configparser
import acme_dns_tiny
from tests.config_factory import generate_acme_account_deactivate_config
import tools.acme_account_deactivate
......@@ -23,8 +23,14 @@ class TestACMEAccountDeactivate(unittest.TestCase):
@classmethod
def tearDownClass(self):
# Remove temporary files
os.remove(self.configs['config'])
os.remove(self.configs['key'])
parser = configparser.ConfigParser()
parser.read(self.configs['config'])
try:
os.remove(parser["acmednstiny"]["AccountKeyFile"])
os.remove(parser["acmednstiny"]["CSRFile"])
os.remove(self.configs['config'])
except:
pass
super(TestACMEAccountDeactivate, self).tearDownClass()
def test_success_account_deactivate(self):
......
import unittest, os, time
import unittest, os, time, configparser
import acme_dns_tiny
from tests.config_factory import generate_acme_account_rollover_config
from tools.acme_account_deactivate import account_deactivate
......@@ -21,9 +21,16 @@ class TestACMEAccountRollover(unittest.TestCase):
# deactivate account key registration at end of tests
# (we assume the key has been roll oved)
account_deactivate(self.configs["newaccountkey"], ACMEDirectory)
# close temp files correctly
for tmpfile in self.configs:
os.remove(self.configs[tmpfile])
# Remove temporary files
parser = configparser.ConfigParser()
parser.read(self.configs['config'])
try:
os.remove(parser["acmednstiny"]["AccountKeyFile"])
os.remove(parser["acmednstiny"]["CSRFile"])
os.remove(self.configs["newaccountkey"])
os.remove(self.configs['config'])
except:
pass
super(TestACMEAccountRollover, self).tearDownClass()
def test_success_account_rollover(self):
......
import unittest, sys, os, subprocess, time
import unittest, sys, os, subprocess, time, configparser
from io import StringIO
import dns.version
import acme_dns_tiny
......@@ -22,11 +22,19 @@ class TestACMEDNSTiny(unittest.TestCase):
# To clean ACME staging server and close correctly temporary files
@classmethod
def tearDownClass(self):
# deactivate account key registration at end of tests
account_deactivate(self.configs["accountkey"], ACMEDirectory)
# close temp files correctly
for tmpfile in self.configs:
os.remove(self.configs[tmpfile])
for conffile in self.configs:
parser = configparser.ConfigParser()
parser.read(conffile)
try:
os.remove(parser["acmednstiny"]["AccountKeyFile"])
os.remove(parser["acmednstiny"]["CSRFile"])
# for each configuraiton, deactivate the account key
if conffile != "cnameCSR":
account_deactivate(parser["acmednstiny"]["AccountKeyFile"], ACMEDirectory)
os.remove(conffile)
except:
pass
super(TestACMEDNSTiny, self).tearDownClass()
# helper function to run openssl command
......
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