Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

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 

import tools.acme_account_rollover 

 

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

 

class TestACMEAccountRollover(unittest.TestCase): 

"Tests for acme_account_rollover" 

 

@classmethod 

def setUpClass(self): 

self.configs = generate_acme_account_rollover_config() 

acme_dns_tiny.main([self.configs['config']]) 

super(TestACMEAccountRollover, self).setUpClass() 

 

# To clean ACME staging server and close correctly temporary files 

@classmethod 

def tearDownClass(self): 

# deactivate account key registration at end of tests 

# (we assume the key has been roll oved) 

account_deactivate(self.configs["newaccountkey"], ACMEDirectory) 

# 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): 

""" Test success account key rollover """ 

with self.assertLogs(level='INFO') as accountrolloverlog: 

tools.acme_account_rollover.main(["--current", self.configs['oldaccountkey'], 

"--new", self.configs['newaccountkey'], 

"--acme-directory", ACMEDirectory]) 

self.assertIn("INFO:acme_account_rollover:Account keys rolled over !", 

accountrolloverlog.output) 

 

if __name__ == "__main__": 

unittest.main()