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

import unittest, os, time, configparser 

import acme_dns_tiny 

from tests.config_factory import generate_acme_account_deactivate_config 

import tools.acme_account_deactivate 

 

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

 

class TestACMEAccountDeactivate(unittest.TestCase): 

"Tests for acme_account_deactivate" 

 

@classmethod 

def setUpClass(self): 

self.configs = generate_acme_account_deactivate_config() 

try: 

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

except ValueError as err: 

if str(err).startswith("Error register"): 

raise ValueError("Fail test as account has not been registered correctly: {0}".format(err)) 

 

super(TestACMEAccountDeactivate, self).setUpClass() 

 

# To clean ACME staging server and close correctly temporary files 

@classmethod 

def tearDownClass(self): 

# 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['config']) 

except: 

pass 

super(TestACMEAccountDeactivate, self).tearDownClass() 

 

def test_success_account_deactivate(self): 

""" Test success account key deactivate """ 

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

tools.acme_account_deactivate.main(["--account-key", self.configs['key'], 

"--acme-directory", ACMEDirectory]) 

self.assertIn("INFO:acme_account_deactivate:Account key deactivated !", 

accountdeactivatelog.output) 

 

if __name__ == "__main__": 

unittest.main()