diff --git a/acme_srv/challenge.py b/acme_srv/challenge.py index 29327c13..b606f7b2 100644 --- a/acme_srv/challenge.py +++ b/acme_srv/challenge.py @@ -193,8 +193,7 @@ def _config_dns_load(self, config_dic: Dict[str, str]): self.dns_server_list = json.loads(config_dic['Challenge']['dns_server_list']) except Exception as err_: self.logger.warning('Challenge._config_load() dns_server_list failed with error: %s', err_) - - if 'dns_validation_pause_timer' in config_dic['Challenge']: + if 'Challenge' in config_dic and 'dns_validation_pause_timer' in config_dic['Challenge']: try: self.dns_validation_pause_timer = int(config_dic['Challenge']['dns_validation_pause_timer']) except Exception as err_: diff --git a/examples/ca_handler/acme_ca_handler.py b/examples/ca_handler/acme_ca_handler.py index ece16194..433ec56f 100644 --- a/examples/ca_handler/acme_ca_handler.py +++ b/examples/ca_handler/acme_ca_handler.py @@ -80,8 +80,10 @@ def _config_account_load(self, config_dic: Dict[str, str]): self.email = config_dic['CAhandler'].get('acme_account_email', None) if 'ssl_verify' in config_dic['CAhandler']: - self.ssl_verify = config_dic.getboolean('CAhandler', 'ssl_verify', fallback=False) - + try: + self.ssl_verify = config_dic.getboolean('CAhandler', 'ssl_verify', fallback=False) + except Exception as err: + self.logger.error('CAhandler._config_load(): failed to parse ssl_verify: %s', err) self.logger.debug('CAhandler._config_account_load() ended') def _config_parameters_load(self, config_dic: Dict[str, str]): diff --git a/examples/db_handler/wsgi_handler.py b/examples/db_handler/wsgi_handler.py index 1ef703f8..f5b816fe 100644 --- a/examples/db_handler/wsgi_handler.py +++ b/examples/db_handler/wsgi_handler.py @@ -437,14 +437,14 @@ def _db_update_housekeeping(self): else: self.cursor.execute('''PRAGMA table_info(housekeeping)''') for column in self.cursor.fetchall(): - if column[1] == 'name' and column[2].lower() == 'varchar(15)': - self.logger.info('alter housekeeping table - change size of the name field to 30') - self.cursor.execute('''ALTER TABLE housekeeping RENAME TO tmp_hk''') + if column[1] == 'name' and column[2].lower() == 'varchar(15)': # pragma: no cover + self.logger.info('alter housekeeping table - change size of the name field to 30') # pragma: no cover + self.cursor.execute('''ALTER TABLE housekeeping RENAME TO tmp_hk''') # pragma: no cover self.cursor.execute(''' CREATE TABLE "housekeeping" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(30) NOT NULL UNIQUE, "value" text, "modified_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL) - ''') - self.cursor.execute('''INSERT INTO housekeeping(id, name, value, modified_at) SELECT id, name, value, modified_at FROM tmp_hk''') - self.cursor.execute('''DROP TABLE tmp_hk''') + ''') # pragma: no cover + self.cursor.execute('''INSERT INTO housekeeping(id, name, value, modified_at) SELECT id, name, value, modified_at FROM tmp_hk''') # pragma: no cover + self.cursor.execute('''DROP TABLE tmp_hk''') # pragma: no cover def _db_update_orders(self): """ alter orders table """ diff --git a/test/test_acme_ca_handler.py b/test/test_acme_ca_handler.py index 0edae417..b0ae7a3e 100644 --- a/test/test_acme_ca_handler.py +++ b/test/test_acme_ca_handler.py @@ -6,6 +6,7 @@ import os import unittest from unittest.mock import patch, mock_open, Mock, MagicMock +import configparser # from OpenSSL import crypto sys.path.insert(0, '.') @@ -72,6 +73,7 @@ def test_004__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_005__config_load(self, mock_load_cfg): @@ -88,6 +90,7 @@ def test_005__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_006__config_load(self, mock_load_cfg): @@ -103,6 +106,7 @@ def test_006__config_load(self, mock_load_cfg): self.assertFalse(self.cahandler.email) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_007__config_load(self, mock_load_cfg): @@ -118,6 +122,7 @@ def test_007__config_load(self, mock_load_cfg): self.assertFalse(self.cahandler.email) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertEqual('acme_keypath', self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_008__config_load(self, mock_load_cfg): @@ -133,6 +138,7 @@ def test_008__config_load(self, mock_load_cfg): self.assertFalse(self.cahandler.email) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_009__config_load(self, mock_load_cfg): @@ -149,6 +155,7 @@ def test_009__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_010__config_load(self, mock_load_cfg): @@ -165,6 +172,7 @@ def test_010__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_011__config_load(self, mock_load_cfg): @@ -181,6 +189,7 @@ def test_011__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_012__config_load(self, mock_load_cfg): @@ -197,6 +206,7 @@ def test_012__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_013__config_load(self, mock_load_cfg): @@ -213,6 +223,7 @@ def test_013__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_014__config_load(self, mock_load_cfg): @@ -230,6 +241,7 @@ def test_014__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_015__config_load(self, mock_load_cfg): @@ -248,9 +260,74 @@ def test_015__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load(): failed to parse allowed_domainlist: Expecting value: line 1 column 1 (char 0)', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') def test_016__config_load(self, mock_load_cfg): + """ test _config_load allowlist - failed json parse """ + parser = configparser.ConfigParser() + parser['CAhandler'] = {'ssl_verify': False} + + mock_load_cfg.return_value = parser + with self.assertLogs('test_a2c', level='INFO') as lcm: + self.cahandler._config_load() + self.assertFalse(self.cahandler.acme_keyfile) + self.assertFalse(self.cahandler.acme_url) + self.assertFalse(self.cahandler.account) + self.assertEqual({'acct_path': '/acme/acct/', 'directory_path': '/directory'}, self.cahandler.path_dic) + self.assertEqual(2048, self.cahandler.key_size) + self.assertFalse(self.cahandler.email) + self.assertFalse(self.cahandler.allowed_domainlist) + self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) + self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) + self.assertFalse(self.cahandler.acme_keypath) + self.assertFalse(self.cahandler.ssl_verify) + + @patch('examples.ca_handler.acme_ca_handler.load_config') + def test_017__config_load(self, mock_load_cfg): + """ test _config_load allowlist - failed json parse """ + parser = configparser.ConfigParser() + parser['CAhandler'] = {'ssl_verify': True} + + mock_load_cfg.return_value = parser + with self.assertLogs('test_a2c', level='INFO') as lcm: + self.cahandler._config_load() + self.assertFalse(self.cahandler.acme_keyfile) + self.assertFalse(self.cahandler.acme_url) + self.assertFalse(self.cahandler.account) + self.assertEqual({'acct_path': '/acme/acct/', 'directory_path': '/directory'}, self.cahandler.path_dic) + self.assertEqual(2048, self.cahandler.key_size) + self.assertFalse(self.cahandler.email) + self.assertFalse(self.cahandler.allowed_domainlist) + self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) + self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) + self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) + + @patch('examples.ca_handler.acme_ca_handler.load_config') + def test_018__config_load(self, mock_load_cfg): + """ test _config_load allowlist - failed json parse """ + parser = configparser.ConfigParser() + parser['CAhandler'] = {'ssl_verify': 'aaa'} + + mock_load_cfg.return_value = parser + with self.assertLogs('test_a2c', level='INFO') as lcm: + self.cahandler._config_load() + self.assertFalse(self.cahandler.acme_keyfile) + self.assertFalse(self.cahandler.acme_url) + self.assertFalse(self.cahandler.account) + self.assertEqual({'acct_path': '/acme/acct/', 'directory_path': '/directory'}, self.cahandler.path_dic) + self.assertEqual(2048, self.cahandler.key_size) + self.assertFalse(self.cahandler.email) + self.assertFalse(self.cahandler.allowed_domainlist) + self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) + self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) + self.assertIn('ERROR:test_a2c:CAhandler._config_load(): failed to parse ssl_verify: Not a boolean: aaa', lcm.output) + self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) + + @patch('examples.ca_handler.acme_ca_handler.load_config') + def test_019__config_load(self, mock_load_cfg): """ test _config_load allowlist - failed json parse """ mock_load_cfg.return_value = {'CAhandler': {'eab_kid': 'eab_kid'}} with self.assertLogs('test_a2c', level='INFO') as lcm: @@ -267,9 +344,10 @@ def test_016__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) @patch('examples.ca_handler.acme_ca_handler.load_config') - def test_017__config_load(self, mock_load_cfg): + def test_020__config_load(self, mock_load_cfg): """ test _config_load allowlist - failed json parse """ mock_load_cfg.return_value = {'CAhandler': {'eab_hmac_key': 'eab_hmac_key'}} with self.assertLogs('test_a2c', level='INFO') as lcm: @@ -286,8 +364,9 @@ def test_017__config_load(self, mock_load_cfg): self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_keyfile" parameter is missing in config file', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._config_load() configuration incomplete: "acme_url" parameter is missing in config file', lcm.output) self.assertFalse(self.cahandler.acme_keypath) + self.assertTrue(self.cahandler.ssl_verify) - def test_018__challenge_filter(self): + def test_021__challenge_filter(self): """ test _challenge_filter single http """ challenge1 = Mock(return_value='foo') challenge1.chall.to_partial_json.return_value = {'type': 'http-01'} @@ -298,7 +377,7 @@ def test_018__challenge_filter(self): self.assertEqual('http-01', self.cahandler._challenge_filter(authz).chall.typ) self.assertEqual('value-01', self.cahandler._challenge_filter(authz).chall.value) - def test_019__challenge_filter(self): + def test_022__challenge_filter(self): """ test _challenge_filter dns and http """ challenge1 = Mock(return_value='foo') challenge1.chall.to_partial_json.return_value = {'type': 'dns-01'} @@ -313,7 +392,7 @@ def test_019__challenge_filter(self): self.assertEqual('http-01', self.cahandler._challenge_filter(authz).chall.typ) self.assertEqual('value-02', self.cahandler._challenge_filter(authz).chall.value) - def test_020__challenge_filter(self): + def test_023__challenge_filter(self): """ test _challenge_filter double http to test break """ challenge1 = Mock(return_value='foo') challenge1.chall.to_partial_json.return_value = {'type': 'http-01'} @@ -328,7 +407,7 @@ def test_020__challenge_filter(self): self.assertEqual('http-01', self.cahandler._challenge_filter(authz).chall.typ) self.assertEqual('value-01', self.cahandler._challenge_filter(authz).chall.value) - def test_021__challenge_filter(self): + def test_024__challenge_filter(self): """ test _challenge_filter no http challenge """ challenge1 = Mock(return_value='foo') challenge1.chall.to_partial_json.return_value = {'type': 'type-01'} @@ -344,25 +423,25 @@ def test_021__challenge_filter(self): self.assertFalse(self.cahandler._challenge_filter(authz)) self.assertIn('ERROR:test_a2c:CAhandler._challenge_filter() ended. Could not find challenge of type http-01', lcm.output) - def test_022__challenge_store(self): + def test_025__challenge_store(self): """ test _challenge_store() no challenge_content """ # mock_add.return_value = 'ff' self.cahandler._challenge_store('challenge_name', None) self.assertFalse(self.cahandler.dbstore.cahandler_add.called) - def test_023__challenge_store(self): + def test_026__challenge_store(self): """ test _challenge_store() no challenge_content """ # mock_add.return_value = 'ff' self.cahandler._challenge_store(None, 'challenge_content') self.assertFalse(self.cahandler.dbstore.cahandler_add.called) - def test_024__challenge_store(self): + def test_027__challenge_store(self): """ test _challenge_store() """ self.cahandler._challenge_store('challenge_name', 'challenge_content') self.assertTrue(self.cahandler.dbstore.cahandler_add.called) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_filter') - def test_025__challenge_info(self, mock_filter): + def test_028__challenge_info(self, mock_filter): """ test _challenge_info - all ok """ response = Mock() response.chall.validation = Mock(return_value='foo.bar') @@ -371,7 +450,7 @@ def test_025__challenge_info(self, mock_filter): self.assertIn('foo.bar', self.cahandler._challenge_info('authzr', 'user_key')[1]) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_filter') - def test_026__challenge_info(self, mock_filter): + def test_029__challenge_info(self, mock_filter): """ test _challenge_info - wrong split """ response = Mock() response.chall.validation = Mock(return_value='foobar') @@ -383,7 +462,7 @@ def test_026__challenge_info(self, mock_filter): self.assertIn('ERROR:test_a2c:CAhandler._challenge_info() challenge split failed: foobar', lcm.output) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_filter') - def test_027__challenge_info(self, mock_filter): + def test_030__challenge_info(self, mock_filter): """ test _challenge_info - wrong split """ response = Mock() response.chall.validation = Mock(return_value='foobar') @@ -393,7 +472,7 @@ def test_027__challenge_info(self, mock_filter): self.assertIn('ERROR:test_a2c:CAhandler._challenge_info() authzr is missing', lcm.output) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_filter') - def test_028__challenge_info(self, mock_filter): + def test_031__challenge_info(self, mock_filter): """ test _challenge_info - wrong split """ response = Mock() response.chall.validation = Mock(return_value='foobar') @@ -403,7 +482,7 @@ def test_028__challenge_info(self, mock_filter): self.assertIn('ERROR:test_a2c:CAhandler._challenge_info() userkey is missing', lcm.output) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_filter') - def test_029__challenge_info(self, mock_filter): + def test_032__challenge_info(self, mock_filter): """ test _challenge_info - all ok """ challenge1 = Mock(return_value='foo') challenge1.to_partial_json.return_value = {'foo': 'bar'} @@ -413,7 +492,7 @@ def test_029__challenge_info(self, mock_filter): self.assertEqual({'foo': 'bar'}, self.cahandler._challenge_info('authzr', 'user_key')[1]) @patch('josepy.JWKRSA') - def test_030__key_generate(self, mock_key): + def test_033__key_generate(self, mock_key): """ test _key_generate() """ mock_key.return_value = 'key' self.assertEqual('key', self.cahandler._key_generate()) @@ -422,7 +501,7 @@ def test_030__key_generate(self, mock_key): @patch('josepy.JWKRSA.fields_from_json') @patch("builtins.open", mock_open(read_data='csv_dump'), create=True) @patch('os.path.exists') - def test_031__user_key_load(self, mock_file, mock_key, mock_json): + def test_034__user_key_load(self, mock_file, mock_key, mock_json): """ test user_key_load for an existing file """ mock_file.return_value = True mock_key.return_value = 'loaded_key' @@ -436,7 +515,7 @@ def test_031__user_key_load(self, mock_file, mock_key, mock_json): @patch('josepy.JWKRSA.fields_from_json') @patch("builtins.open", mock_open(read_data='csv_dump'), create=True) @patch('os.path.exists') - def test_032__user_key_load(self, mock_file, mock_key, mock_json): + def test_035__user_key_load(self, mock_file, mock_key, mock_json): """ test user_key_load for an existing file """ mock_file.return_value = True mock_key.return_value = 'loaded_key' @@ -450,7 +529,7 @@ def test_032__user_key_load(self, mock_file, mock_key, mock_json): @patch('examples.ca_handler.acme_ca_handler.CAhandler._key_generate') @patch("builtins.open", mock_open(read_data='csv_dump'), create=True) @patch('os.path.exists') - def test_033__user_key_load(self, mock_file, mock_key, mock_json): + def test_036__user_key_load(self, mock_file, mock_key, mock_json): """ test user_key_load for an existing file """ mock_file.return_value = False mock_key.to_json.return_value = {'foo': 'generate_key'} @@ -463,7 +542,7 @@ def test_033__user_key_load(self, mock_file, mock_key, mock_json): @patch('examples.ca_handler.acme_ca_handler.CAhandler._key_generate') @patch("builtins.open", mock_open(read_data='csv_dump'), create=True) @patch('os.path.exists') - def test_034__user_key_load(self, mock_file, mock_key, mock_json): + def test_037__user_key_load(self, mock_file, mock_key, mock_json): """ test user_key_load for an existing file """ mock_file.return_value = False mock_key.to_json.return_value = {'foo': 'generate_key'} @@ -475,7 +554,7 @@ def test_034__user_key_load(self, mock_file, mock_key, mock_json): self.assertTrue(mock_json.called) @patch('acme.messages') - def test_035__account_register(self, mock_messages): + def test_038__account_register(self, mock_messages): """ test account register existing account - no replacement """ response = Mock() response.uri = 'uri' @@ -491,7 +570,7 @@ def test_035__account_register(self, mock_messages): self.assertEqual('uri', self.cahandler.account) @patch('acme.messages') - def test_036__account_register(self, mock_messages): + def test_039__account_register(self, mock_messages): """ test account register existing account - url replacement """ response = Mock() response.uri = 'urluri' @@ -507,7 +586,7 @@ def test_036__account_register(self, mock_messages): self.assertEqual('uri', self.cahandler.account) @patch('acme.messages') - def test_037__account_register(self, mock_messages): + def test_040__account_register(self, mock_messages): """ test account register existing account - acct_path replacement """ response = Mock() response.uri = 'acct_pathuri' @@ -523,7 +602,7 @@ def test_037__account_register(self, mock_messages): self.assertEqual('uri', self.cahandler.account) @patch('acme.messages') - def test_038__account_register(self, mock_messages): + def test_041__account_register(self, mock_messages): """ test account register existing account - with email """ response = Mock() response.uri = 'newuri' @@ -539,7 +618,7 @@ def test_038__account_register(self, mock_messages): self.assertEqual('newuri', self.cahandler.account) @patch('acme.messages') - def test_039__account_register(self, mock_messages): + def test_042__account_register(self, mock_messages): """ test account register existing account - no email """ response = Mock() response.uri = 'newuri' @@ -554,7 +633,7 @@ def test_039__account_register(self, mock_messages): @patch('acme.messages') - def test_040__account_register(self, mock_messages): + def test_043__account_register(self, mock_messages): """ test account register existing account - no url """ response = Mock() response.uri = 'newuri' @@ -567,7 +646,7 @@ def test_040__account_register(self, mock_messages): self.assertFalse(self.cahandler.account) @patch('acme.messages') - def test_041__account_register(self, mock_messages): + def test_044__account_register(self, mock_messages): """ test account register existing account - wrong pathdic """ response = Mock() response.uri = 'newuri' @@ -582,7 +661,7 @@ def test_041__account_register(self, mock_messages): @patch('examples.ca_handler.acme_ca_handler.CAhandler._zerossl_eab_get') @patch('acme.messages') - def test_042__account_register(self, mock_messages, mock_eab): + def test_045__account_register(self, mock_messages, mock_eab): """ test account register existing account - normal url """ response = Mock() response.uri = 'urluri' @@ -598,7 +677,7 @@ def test_042__account_register(self, mock_messages, mock_eab): @patch('examples.ca_handler.acme_ca_handler.CAhandler._zerossl_eab_get') @patch('acme.messages') - def test_043__account_register(self, mock_messages, mock_eab): + def test_046__account_register(self, mock_messages, mock_eab): """ test account register existing account - zerossl.com url """ response = Mock() response.uri = 'zerossl.comuri' @@ -615,7 +694,7 @@ def test_043__account_register(self, mock_messages, mock_eab): @patch('examples.ca_handler.acme_ca_handler.messages.ExternalAccountBinding.from_data') @patch('acme.messages') - def test_044__account_register(self, mock_messages, mock_eab): + def test_047__account_register(self, mock_messages, mock_eab): """ test account register existing account - zerossl.com url """ response = Mock() response.uri = 'urluri' @@ -631,7 +710,7 @@ def test_044__account_register(self, mock_messages, mock_eab): @patch('examples.ca_handler.acme_ca_handler.messages.ExternalAccountBinding.from_data') @patch('acme.messages') - def test_045__account_register(self, mock_messages, mock_eab): + def test_048__account_register(self, mock_messages, mock_eab): """ test account register existing account - zerossl.com url """ response = Mock() response.uri = 'urluri' @@ -648,7 +727,7 @@ def test_045__account_register(self, mock_messages, mock_eab): self.assertTrue(mock_eab.called) @patch('acme.messages.NewRegistration.from_data') - def test_046_acount_create(self, mock_newreg): + def test_049_acount_create(self, mock_newreg): """ test account_create """ response = 'response' acmeclient = Mock() @@ -658,7 +737,7 @@ def test_046_acount_create(self, mock_newreg): self.assertTrue(mock_newreg.called) @patch('acme.messages.NewRegistration.from_data') - def test_047_acount_create(self, mock_newreg): + def test_050_acount_create(self, mock_newreg): """ test account_create """ response = 'response' acmeclient = Mock() @@ -670,7 +749,7 @@ def test_047_acount_create(self, mock_newreg): self.assertIn('ERROR:test_a2c:CAhandler._account_create(): registration failed: mock_exception', lcm.output) @patch('acme.messages.NewRegistration.from_data') - def test_048_acount_create(self, mock_newreg): + def test_051_acount_create(self, mock_newreg): """ test account_create """ response = 'response' acmeclient = Mock() @@ -681,11 +760,11 @@ def test_048_acount_create(self, mock_newreg): self.assertTrue(mock_newreg.called) self.assertIn('ERROR:test_a2c:CAhandler._account_create(): registration failed: ConflictError', lcm.output) - def test_049_trigger(self): + def test_052_trigger(self): """ test trigger """ self.assertEqual(('Not implemented', None, None), self.cahandler.trigger('payload')) - def test_050_poll(self): + def test_053_poll(self): """ test poll """ self.assertEqual(('Not implemented', None, None, 'poll_identifier', False), self.cahandler.poll('cert_name', 'poll_identifier','csr')) @@ -695,7 +774,7 @@ def test_050_poll(self): @patch('examples.ca_handler.acme_ca_handler.CAhandler._user_key_load') @patch('acme.client.ClientNetwork') @patch('acme.messages') - def test_051_enroll(self, mock_messages, mock_clientnw, mock_key, mock_reg, mock_enroll): + def test_054_enroll(self, mock_messages, mock_clientnw, mock_key, mock_reg, mock_enroll): """ test enroll registration error """ mock_key.return_value = 'key' mock_reg.return_value = 'mock_reg' @@ -707,7 +786,7 @@ def test_051_enroll(self, mock_messages, mock_clientnw, mock_key, mock_reg, mock @patch('examples.ca_handler.acme_ca_handler.CAhandler._user_key_load') @patch('acme.client.ClientNetwork') @patch('acme.messages') - def test_052_enroll(self, mock_messages, mock_clientnw, mock_key, mock_reg, mock_enroll): + def test_055_enroll(self, mock_messages, mock_clientnw, mock_key, mock_reg, mock_enroll): """ test enroll registration error """ mock_key.return_value = 'key' mock_reg.return_value = None @@ -727,7 +806,7 @@ def test_052_enroll(self, mock_messages, mock_clientnw, mock_key, mock_reg, mock @patch('acme.client.ClientV2.new_order') @patch('acme.client.ClientNetwork') @patch('acme.messages') - def test_053_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert): + def test_056_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert): """ test enroll with no account configured """ mock_key.return_value = 'key' mock_messages = Mock() @@ -762,7 +841,7 @@ def test_053_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock @patch('acme.client.ClientV2.new_order') @patch('acme.client.ClientNetwork') @patch('acme.messages') - def test_054_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk): + def test_057_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk): """ test enroll with existing account """ self.cahandler.account = 'account' mock_key.return_value = 'key' @@ -799,7 +878,7 @@ def test_054_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock @patch('acme.client.ClientV2.new_order') @patch('acme.client.ClientNetwork') @patch('acme.messages') - def test_055_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk): + def test_058_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk): """ test enroll with bodystatus invalid """ mock_key.return_value = 'key' mock_messages = Mock() @@ -838,7 +917,7 @@ def test_055_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock @patch('acme.client.ClientV2.new_order') @patch('acme.client.ClientNetwork') @patch('acme.messages') - def test_056_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk): + def test_059_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk): """ test enroll with no fullchain """ mock_key.return_value = 'key' mock_messages = Mock() @@ -871,7 +950,7 @@ def test_056_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock @patch('examples.ca_handler.acme_ca_handler.CAhandler._account_register') @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_store') @patch('examples.ca_handler.acme_ca_handler.CAhandler._user_key_load') - def test_057_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, mock_csrchk): + def test_060_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, mock_csrchk): """ test enroll exception during enrollment """ mock_csrchk.return_value = True mock_key.side_effect = Exception('ex_user_key_load') @@ -890,7 +969,7 @@ def test_057_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, @patch('examples.ca_handler.acme_ca_handler.CAhandler._account_register') @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_store') @patch('examples.ca_handler.acme_ca_handler.CAhandler._user_key_load') - def test_058_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, mock_csrchk, mock_profilechk): + def test_061_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, mock_csrchk, mock_profilechk): """ test enroll exception during enrollment """ mock_profilechk.return_value = False mock_csrchk.return_value = False @@ -911,7 +990,7 @@ def test_058_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, @patch('examples.ca_handler.acme_ca_handler.CAhandler._account_register') @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_store') @patch('examples.ca_handler.acme_ca_handler.CAhandler._user_key_load') - def test_059_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, mock_csrchk, mock_profilechk): + def test_062_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, mock_csrchk, mock_profilechk): """ test enroll exception during enrollment """ mock_profilechk.return_value = False mock_csrchk.return_value = False @@ -938,7 +1017,7 @@ def test_059_enroll(self, mock_key, mock_store, mock_reg, mock_nw, mock_newreg, @patch('acme.client.ClientV2.new_order') @patch('acme.client.ClientNetwork') @patch('acme.messages') - def test_060_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk, mock_issue): + def test_063_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock_pof, mock_key, mock_reg, mock_cinfo, mock_store, mock_dumpcert, mock_loadcert, mock_csrchk, mock_issue): """ test enroll with bodystatus None (existing account) """ mock_key.return_value = 'key' mock_messages = Mock() @@ -968,7 +1047,7 @@ def test_060_enroll(self, mock_messages, mock_clientnw, mock_c2o, mock_ach, mock self.assertIn('INFO:test_a2c:Existing but not configured ACME account: uri', lcm.output) @patch('acme.messages') - def test_061__account_lookup(self, mock_messages): + def test_064__account_lookup(self, mock_messages): """ test account register existing account - no replacement """ response = Mock() response.uri = 'urluriacc_info' @@ -982,7 +1061,7 @@ def test_061__account_lookup(self, mock_messages): self.assertEqual('urluriacc_info', self.cahandler.account) @patch('acme.messages') - def test_062__account_lookup(self, mock_messages): + def test_065__account_lookup(self, mock_messages): """ test account register existing account - url replacement """ response = Mock() response.uri = 'urluriacc_info' @@ -997,7 +1076,7 @@ def test_062__account_lookup(self, mock_messages): self.assertEqual('uriacc_info', self.cahandler.account) @patch('acme.messages') - def test_063__account_lookup(self, mock_messages): + def test_066__account_lookup(self, mock_messages): """ test account register existing account - acct_path replacement """ response = Mock() response.uri = 'urluriacc_info' @@ -1012,7 +1091,7 @@ def test_063__account_lookup(self, mock_messages): self.assertEqual('urluri', self.cahandler.account) @patch('acme.messages') - def test_064__account_lookup(self, mock_messages): + def test_067__account_lookup(self, mock_messages): """ test account register existing account - acct_path replacement """ response = Mock() response.uri = 'urluriacc_info' @@ -1036,7 +1115,7 @@ def test_064__account_lookup(self, mock_messages): @patch('josepy.ComparableX509') @patch('OpenSSL.crypto.load_certificate') @patch('os.path.exists') - def test_065_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, mock_reg, mock_revoke, mock_key): + def test_068_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, mock_reg, mock_revoke, mock_key): """ test revoke successful """ self.cahandler.acme_keyfile = 'keyfile' self.cahandler.account = 'account' @@ -1060,7 +1139,7 @@ def test_065_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, @patch('josepy.ComparableX509') @patch('OpenSSL.crypto.load_certificate') @patch('os.path.exists') - def test_066_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, mock_reg, mock_revoke, mock_key): + def test_069_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, mock_reg, mock_revoke, mock_key): """ test revoke invalid status after reglookup """ self.cahandler.acme_keyfile = 'keyfile' self.cahandler.account = 'account' @@ -1084,7 +1163,7 @@ def test_066_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, @patch('josepy.ComparableX509') @patch('OpenSSL.crypto.load_certificate') @patch('os.path.exists') - def test_067_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, mock_lookup, mock_key): + def test_070_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, mock_lookup, mock_key): """ test revoke account lookup failed """ self.cahandler.acme_keyfile = 'keyfile' mock_exists.return_value = True @@ -1103,7 +1182,7 @@ def test_067_revoke(self, mock_exists, mock_load, mock_comp, mock_nw, mock_mess, @patch('josepy.ComparableX509') @patch('OpenSSL.crypto.load_certificate') @patch('os.path.exists') - def test_068_revoke(self, mock_exists, mock_load, mock_comp, mock_kload, mock_nw, mock_mess, mock_lookup): + def test_071_revoke(self, mock_exists, mock_load, mock_comp, mock_kload, mock_nw, mock_mess, mock_lookup): """ test revoke user key load failed """ self.cahandler.acme_keyfile = 'keyfile' mock_exists.return_value = False @@ -1115,7 +1194,7 @@ def test_068_revoke(self, mock_exists, mock_load, mock_comp, mock_kload, mock_nw @patch("builtins.open", mock_open(read_data='mock_open'), create=True) @patch('josepy.ComparableX509') @patch('OpenSSL.crypto.load_certificate') - def test_069_revoke(self, mock_load, mock_comp): + def test_072_revoke(self, mock_load, mock_comp): """ test revoke exception during processing """ self.cahandler.acme_keyfile = 'keyfile' mock_load.side_effect = Exception('ex_user_key_load') @@ -1124,7 +1203,7 @@ def test_069_revoke(self, mock_load, mock_comp): self.assertIn('ERROR:test_a2c:CAhandler.enroll: error: ex_user_key_load', lcm.output) @patch('requests.post') - def test_070__zerossl_eab_get(self, mock_post): + def test_073__zerossl_eab_get(self, mock_post): """ CAhandler._zerossl_eab_get() - all ok """ mock_post.return_value.json.return_value = {'success': True, 'eab_kid': 'eab_kid', 'eab_hmac_key': 'eab_hmac_key'} self.cahandler._zerossl_eab_get() @@ -1133,7 +1212,7 @@ def test_070__zerossl_eab_get(self, mock_post): self.assertEqual('eab_hmac_key', self.cahandler.eab_hmac_key) @patch('requests.post') - def test_071__zerossl_eab_get(self, mock_post): + def test_074__zerossl_eab_get(self, mock_post): """ CAhandler._zerossl_eab_get() - success false """ mock_post.return_value.json.return_value = {'success': False, 'eab_kid': 'eab_kid', 'eab_hmac_key': 'eab_hmac_key'} mock_post.return_value.text = 'text' @@ -1145,7 +1224,7 @@ def test_071__zerossl_eab_get(self, mock_post): self.assertIn('ERROR:test_a2c:CAhandler._zerossl_eab_get() failed: text', lcm.output) @patch('requests.post') - def test_072__zerossl_eab_get(self, mock_post): + def test_075__zerossl_eab_get(self, mock_post): """ CAhandler._zerossl_eab_get() - no success key """ mock_post.return_value.json.return_value = {'eab_kid': 'eab_kid', 'eab_hmac_key': 'eab_hmac_key'} mock_post.return_value.text = 'text' @@ -1157,7 +1236,7 @@ def test_072__zerossl_eab_get(self, mock_post): self.assertIn('ERROR:test_a2c:CAhandler._zerossl_eab_get() failed: text', lcm.output) @patch('requests.post') - def test_073__zerossl_eab_get(self, mock_post): + def test_076__zerossl_eab_get(self, mock_post): """ CAhandler._zerossl_eab_get() - no eab_kid key """ mock_post.return_value.json.return_value = {'success': True, 'eab_hmac_key': 'eab_hmac_key'} mock_post.return_value.text = 'text' @@ -1169,7 +1248,7 @@ def test_073__zerossl_eab_get(self, mock_post): self.assertIn('ERROR:test_a2c:CAhandler._zerossl_eab_get() failed: text', lcm.output) @patch('requests.post') - def test_074__zerossl_eab_get(self, mock_post): + def test_077__zerossl_eab_get(self, mock_post): """ CAhandler._zerossl_eab_get() - no eab_mac key """ mock_post.return_value.json.return_value = {'success': True, 'eab_kid': 'eab_kid'} mock_post.return_value.text = 'text' @@ -1181,7 +1260,7 @@ def test_074__zerossl_eab_get(self, mock_post): self.assertIn('ERROR:test_a2c:CAhandler._zerossl_eab_get() failed: text', lcm.output) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_info') - def test_075__order_authorization(self, mock_info): + def test_078__order_authorization(self, mock_info): """ CAhandler._order_authorization - sectigo challenge """ order = Mock() order.authorizations = ['foo'] @@ -1189,7 +1268,7 @@ def test_075__order_authorization(self, mock_info): self.assertTrue(self.cahandler._order_authorization('acmeclient', order, 'user_key')) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_info') - def test_076__order_authorization(self, mock_info): + def test_079__order_authorization(self, mock_info): """ CAhandler._order_authorization - sectigo challenge """ order = Mock() order.authorizations = ['foo'] @@ -1197,7 +1276,7 @@ def test_076__order_authorization(self, mock_info): self.assertFalse(self.cahandler._order_authorization('acmeclient', order, 'user_key')) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_info') - def test_077__order_authorization(self, mock_info): + def test_080__order_authorization(self, mock_info): """ CAhandler._order_authorization - sectigo challenge """ order = Mock() order.authorizations = ['foo'] @@ -1205,27 +1284,27 @@ def test_077__order_authorization(self, mock_info): self.assertFalse(self.cahandler._order_authorization('acmeclient', order, 'user_key')) @patch('examples.ca_handler.acme_ca_handler.CAhandler._challenge_info') - def test_078__order_authorization(self, mock_info): + def test_081__order_authorization(self, mock_info): """ CAhandler._order_authorization - sectigo challenge """ order = Mock() order.authorizations = ['foo'] mock_info.return_value = [None, 'string', 'challenge'] self.assertFalse(self.cahandler._order_authorization('acmeclient', order, 'user_key')) - def test_079_eab_profile_list_check(self): + def test_082_eab_profile_list_check(self): """ test eab_profile_list_check """ with self.assertLogs('test_a2c', level='INFO') as lcm: self.assertFalse(self.cahandler.eab_profile_list_check('eab_handler', 'csr', 'acme_keyfile', 'key_file')) self.assertIn('ERROR:test_a2c:CAhandler._eab_profile_list_check(): acme_keyfile is not allowed in profile', lcm.output) - def test_080_eab_profile_list_check(self): + def test_083_eab_profile_list_check(self): """ test eab_profile_list_check """ with self.assertLogs('test_a2c', level='INFO') as lcm: self.assertEqual('acme_keypath is missing in config', self.cahandler.eab_profile_list_check('eab_handler', 'csr', 'acme_url', 'acme_url')) self.assertIn('ERROR:test_a2c:CAhandler._eab_profile_list_check(): acme_keypath is missing in config', lcm.output) @patch('examples.ca_handler.acme_ca_handler.header_info_field_validate') - def test_081_eab_profile_list_check(self, mock_hiv ): + def test_084_eab_profile_list_check(self, mock_hiv ): """ test eab_profile_list_check """ mock_hiv.return_value = ('http://acme_url', None) self.cahandler.acme_keypath = 'acme_keypath' @@ -1234,7 +1313,7 @@ def test_081_eab_profile_list_check(self, mock_hiv ): self.assertEqual('acme_keypath/acme_url.json', self.cahandler.acme_keyfile) @patch('examples.ca_handler.acme_ca_handler.header_info_field_validate') - def test_082_eab_profile_list_check(self, mock_hiv ): + def test_085_eab_profile_list_check(self, mock_hiv ): """ test eab_profile_list_check """ mock_hiv.return_value = (None, 'error') self.cahandler.acme_keypath = 'acme_keypath' @@ -1243,7 +1322,7 @@ def test_082_eab_profile_list_check(self, mock_hiv ): self.assertEqual('acme_keyfile', self.cahandler.acme_keyfile) @patch('examples.ca_handler.acme_ca_handler.header_info_field_validate') - def test_083_eab_profile_list_check(self, mock_hiv ): + def test_086_eab_profile_list_check(self, mock_hiv ): """ test eab_profile_list_check """ mock_hiv.return_value = ('http://acme_url', None) self.cahandler.acme_keypath = 'acme_keypath' @@ -1252,7 +1331,7 @@ def test_083_eab_profile_list_check(self, mock_hiv ): self.assertEqual('acme_keyfile', self.cahandler.acme_keyfile) @patch('examples.ca_handler.acme_ca_handler.header_info_field_validate') - def test_084_eab_profile_list_check(self, mock_hiv ): + def test_087_eab_profile_list_check(self, mock_hiv ): """ test eab_profile_list_check """ mock_hiv.return_value = ('http://acme_url', None) self.cahandler.acme_keypath = 'acme_keypath' @@ -1263,7 +1342,7 @@ def test_084_eab_profile_list_check(self, mock_hiv ): self.assertEqual('acme_keyfile', self.cahandler.acme_keyfile) @patch('examples.ca_handler.acme_ca_handler.header_info_field_validate') - def test_085_eab_profile_list_check(self, mock_hiv ): + def test_088_eab_profile_list_check(self, mock_hiv ): """ test eab_profile_list_check """ mock_hiv.return_value = ('http://acme_url', None) self.cahandler.acme_keypath = 'acme_keypath' @@ -1274,7 +1353,7 @@ def test_085_eab_profile_list_check(self, mock_hiv ): self.assertEqual('acme_keyfile', self.cahandler.acme_keyfile) @patch("builtins.open", new_callable=mock_open, read_data='{}') - def test_086_account_to_keyfile(self, mock_file): + def test_089_account_to_keyfile(self, mock_file): """ test account_to_keyfile """ self.cahandler.acme_keyfile = 'dummy_keyfile_path' self.cahandler.account = 'dummy_account' @@ -1282,7 +1361,7 @@ def test_086_account_to_keyfile(self, mock_file): self.assertTrue(mock_file.called) @patch("builtins.open", new_callable=mock_open, read_data='{}') - def test_087_account_to_keyfile(self, mock_file): + def test_090_account_to_keyfile(self, mock_file): """ test account_to_keyfile """ self.cahandler.acme_keyfile = 'dummy_keyfile_path' self.cahandler.account = None @@ -1290,7 +1369,7 @@ def test_087_account_to_keyfile(self, mock_file): self.assertFalse(mock_file.called) @patch("builtins.open", new_callable=mock_open, read_data='{}') - def test_088_account_to_keyfile(self, mock_file): + def test_091_account_to_keyfile(self, mock_file): """ test account_to_keyfile """ self.cahandler.acme_keyfile = None self.cahandler.account = 'dummy_account' @@ -1298,7 +1377,7 @@ def test_088_account_to_keyfile(self, mock_file): self.assertFalse(mock_file.called) @patch("builtins.open", new_callable=mock_open, read_data='{}') - def test_089_account_to_keyfile(self, mock_file): + def test_092_account_to_keyfile(self, mock_file): """ test account_to_keyfile """ self.cahandler.acme_keyfile = 'dummy_keyfile_path' self.cahandler.account = 'dummy_account' @@ -1308,35 +1387,35 @@ def test_089_account_to_keyfile(self, mock_file): self.assertTrue(mock_file.called) self.assertIn('ERROR:test_a2c:CAhandler._account_to_keyfile() failed: ex_json_dump', lcm.output) - def test_090_accountname_get(self): + def test_093_accountname_get(self): """ test accountname_get """ url = 'url' acme_url = 'acme_url' path_dic = {'acct_path': 'acct_path'} self.assertEqual('url', self.cahandler._accountname_get(url, acme_url, path_dic)) - def test_091_accountname_get(self): + def test_094_accountname_get(self): """ test accountname_get """ url = 'acme_url/foo' acme_url = 'acme_url' path_dic = {'acct_path': 'acct_path'} self.assertEqual('/foo', self.cahandler._accountname_get(url, acme_url, path_dic)) - def test_092_accountname_get(self): + def test_095_accountname_get(self): """ test accountname_get """ url = 'acme_url/foo/acct_path' acme_url = 'acme_url' path_dic = {'acct_path': 'acct_path'} self.assertEqual('/foo/', self.cahandler._accountname_get(url, acme_url, path_dic)) - def test_093_accountname_get(self): + def test_096_accountname_get(self): """ test accountname_get """ url = 'acme_url/acct_path/foo' acme_url = 'acme_url' path_dic = {'acct_path': '/'} self.assertEqual('acct_path/foo', self.cahandler._accountname_get(url, acme_url, path_dic)) - def test_094_accountname_get(self): + def test_097_accountname_get(self): """ test accountname_get """ url = 'acme_url/foo/foo' acme_url = 'acme_url' diff --git a/test/test_challenge.py b/test/test_challenge.py index 2e6ac685..a39f0136 100644 --- a/test/test_challenge.py +++ b/test/test_challenge.py @@ -895,9 +895,10 @@ def test_091_config_load(self, mock_load_cfg): self.challenge._config_load() self.assertFalse(self.challenge.challenge_validation_disable) self.assertFalse(self.challenge.tnauthlist_support) - self.assertFalse(self.challenge.dns_server_list ) - self.assertFalse(self.challenge.sectigo_sim ) - self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertFalse(self.challenge.dns_server_list) + self.assertFalse(self.challenge.sectigo_sim) + self.assertEqual(10, self.challenge.challenge_validation_timeout) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_092_config_load(self, mock_load_cfg): @@ -911,6 +912,7 @@ def test_092_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.dns_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_093_config_load(self, mock_load_cfg): @@ -924,6 +926,7 @@ def test_093_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.dns_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_094_config_load(self, mock_load_cfg): @@ -937,6 +940,7 @@ def test_094_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.dns_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_095_config_load(self, mock_load_cfg): @@ -950,6 +954,7 @@ def test_095_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.dns_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_096_config_load(self, mock_load_cfg): @@ -963,6 +968,7 @@ def test_096_config_load(self, mock_load_cfg): self.assertEqual(['10.10.10.10'], self.challenge.dns_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_097_config_load(self, mock_load_cfg): @@ -976,6 +982,7 @@ def test_097_config_load(self, mock_load_cfg): self.assertEqual(['10.10.10.10', '10.0.0.1'], self.challenge.dns_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('json.loads') @patch('acme_srv.challenge.load_config') @@ -993,6 +1000,7 @@ def test_098_config_load(self, mock_load_cfg, mock_json): self.assertFalse(self.challenge.dns_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_099_config_load(self, mock_load_cfg): @@ -1007,6 +1015,7 @@ def test_099_config_load(self, mock_load_cfg): self.assertEqual({'authz_path': 'url_prefix//acme/authz/','chall_path': 'url_prefix//acme/chall/'}, self.challenge.path_dic) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_100_config_load(self, mock_load_cfg): @@ -1020,6 +1029,7 @@ def test_100_config_load(self, mock_load_cfg): self.assertEqual({'key1.bar.local': 'val1.bar.local'}, self.challenge.proxy_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_101_config_load(self, mock_load_cfg): @@ -1033,6 +1043,7 @@ def test_101_config_load(self, mock_load_cfg): self.assertEqual({'key1.bar.local': 'val1.bar.local', 'key2.bar.local': 'val2.bar.local'}, self.challenge.proxy_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('json.loads') @patch('acme_srv.challenge.load_config') @@ -1050,6 +1061,7 @@ def test_102_config_load(self, mock_load_cfg, mock_json): self.assertFalse(self.challenge.proxy_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_103_config_load(self, mock_load_cfg): @@ -1063,6 +1075,7 @@ def test_103_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.proxy_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(5, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_104_config_load(self, mock_load_cfg): @@ -1078,6 +1091,7 @@ def test_104_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.proxy_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_105_config_load(self, mock_load_cfg): @@ -1091,6 +1105,7 @@ def test_105_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.proxy_server_list) self.assertTrue(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) @patch('acme_srv.challenge.load_config') def test_106_config_load(self, mock_load_cfg): @@ -1104,21 +1119,52 @@ def test_106_config_load(self, mock_load_cfg): self.assertFalse(self.challenge.proxy_server_list) self.assertFalse(self.challenge.sectigo_sim ) self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) + + @patch('acme_srv.challenge.load_config') + def test_107_config_load(self, mock_load_cfg): + """ test _config_load sectigo_sim """ + parser = configparser.ConfigParser() + parser['Challenge'] = {'dns_validation_pause_timer': 20} + mock_load_cfg.return_value = parser + self.challenge._config_load() + self.assertFalse(self.challenge.challenge_validation_disable) + self.assertFalse(self.challenge.tnauthlist_support) + self.assertFalse(self.challenge.proxy_server_list) + self.assertFalse(self.challenge.sectigo_sim ) + self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(20, self.challenge.dns_validation_pause_timer) + + @patch('acme_srv.challenge.load_config') + def test_108_config_load(self, mock_load_cfg): + """ test _config_load sectigo_sim """ + parser = configparser.ConfigParser() + parser['Challenge'] = {'dns_validation_pause_timer': 'aa'} + mock_load_cfg.return_value = parser + with self.assertLogs('test_a2c', level='INFO') as lcm: + self.challenge._config_load() + self.assertIn("WARNING:test_a2c:Challenge._config_load() failed to load dns_validation_pause_timer: invalid literal for int() with base 10: 'aa'", lcm.output) + self.assertFalse(self.challenge.challenge_validation_disable) + self.assertFalse(self.challenge.tnauthlist_support) + self.assertFalse(self.challenge.proxy_server_list) + self.assertFalse(self.challenge.sectigo_sim ) + self.assertEqual(10, self.challenge.challenge_validation_timeout ) + self.assertEqual(0.5, self.challenge.dns_validation_pause_timer) - def test_107__name_get(self): + def test_109__name_get(self): """ test name get no touch""" url = 'foo' self.assertEqual('foo', self.challenge._name_get(url)) @patch('acme_srv.challenge.parse_url') - def test_108__name_get(self, mock_parse): + def test_110__name_get(self, mock_parse): """ test name get urlparse""" mock_parse.return_value = {'path': 'path'} url = 'foo' self.assertEqual('path', self.challenge._name_get(url)) @patch('acme_srv.challenge.parse_url') - def test_109__name_get(self, mock_parse): + def test_111__name_get(self, mock_parse): """ test name get challenge_path replace """ mock_parse.return_value = {'path': 'foo/my_path'} self.challenge.path_dic = {'chall_path': 'foo/'} @@ -1126,7 +1172,7 @@ def test_109__name_get(self, mock_parse): self.assertEqual('my_path', self.challenge._name_get(url)) @patch('acme_srv.challenge.parse_url') - def test_110__name_get(self, mock_parse): + def test_112__name_get(self, mock_parse): """ test name get challenge_path replace """ mock_parse.return_value = {'path': 'foo/my/path'} self.challenge.path_dic = {'chall_path': 'foo/'} @@ -1135,7 +1181,7 @@ def test_110__name_get(self, mock_parse): @patch('acme_srv.challenge.Challenge._update_authz') @patch('acme_srv.challenge.Challenge._update') - def test_111__validate(self, mock_update, mock_aupdate): + def test_113__validate(self, mock_update, mock_aupdate): """ test validate """ challenge_name = 'challenge_name' payload = 'payload' @@ -1149,7 +1195,7 @@ def test_111__validate(self, mock_update, mock_aupdate): @patch('acme_srv.challenge.Challenge._check') @patch('acme_srv.challenge.Challenge._update_authz') @patch('acme_srv.challenge.Challenge._update') - def test_112__validate(self, mock_update, mock_aupdate, mock_check): + def test_114__validate(self, mock_update, mock_aupdate, mock_check): """ test validate check returned ch:False/inv:False """ challenge_name = 'challenge_name' payload = 'payload' @@ -1163,7 +1209,7 @@ def test_112__validate(self, mock_update, mock_aupdate, mock_check): @patch('acme_srv.challenge.Challenge._check') @patch('acme_srv.challenge.Challenge._update_authz') @patch('acme_srv.challenge.Challenge._update') - def test_113__validate(self, mock_update, mock_aupdate, mock_check): + def test_115__validate(self, mock_update, mock_aupdate, mock_check): """ test validate check returned ch:False/inv:True """ challenge_name = 'challenge_name' payload = 'payload' @@ -1177,7 +1223,7 @@ def test_113__validate(self, mock_update, mock_aupdate, mock_check): @patch('acme_srv.challenge.Challenge._check') @patch('acme_srv.challenge.Challenge._update_authz') @patch('acme_srv.challenge.Challenge._update') - def test_114__validate(self, mock_update, mock_aupdate, mock_check): + def test_116__validate(self, mock_update, mock_aupdate, mock_check): """ test validate check returned ch:True/inv:False """ challenge_name = 'challenge_name' payload = 'payload' @@ -1191,7 +1237,7 @@ def test_114__validate(self, mock_update, mock_aupdate, mock_check): @patch('acme_srv.challenge.Challenge._check') @patch('acme_srv.challenge.Challenge._update_authz') @patch('acme_srv.challenge.Challenge._update') - def test_115__validate(self, mock_update, mock_aupdate, mock_check): + def test_117__validate(self, mock_update, mock_aupdate, mock_check): """ test validate check returned ch:True/inv:True """ challenge_name = 'challenge_name' payload = 'payload' @@ -1205,7 +1251,7 @@ def test_115__validate(self, mock_update, mock_aupdate, mock_check): @patch('acme_srv.challenge.Challenge._check') @patch('acme_srv.challenge.Challenge._update_authz') @patch('acme_srv.challenge.Challenge._update') - def test_116__validate(self, mock_update, mock_aupdate, mock_check): + def test_118__validate(self, mock_update, mock_aupdate, mock_check): """ test validate check returned ch:True/inv:False """ challenge_name = 'challenge_name' payload = {'keyAuthorization': 'keyAuthorization'} @@ -1218,7 +1264,7 @@ def test_116__validate(self, mock_update, mock_aupdate, mock_check): @patch('acme_srv.challenge.Challenge._name_get') @patch('acme_srv.challenge.Challenge._info') - def test_117_get(self, mock_info, mock_name): + def test_119_get(self, mock_info, mock_name): """ test get """ mock_info.return_value = 'chall_info' mock_name.return_value = 'foo' @@ -1228,7 +1274,7 @@ def test_117_get(self, mock_info, mock_name): @patch('acme_srv.challenge.Challenge.new_set') @patch('acme_srv.challenge.Challenge._existing_challenge_validate') @patch('acme_srv.challenge.Challenge._challengelist_search') - def test_118_challengeset_get(self, mock_chsearch, mock_val, mock_set): + def test_120_challengeset_get(self, mock_chsearch, mock_val, mock_set): """ test challengeset_get - no challenge_list returned """ mock_chsearch.return_value = [] mock_val.return_value = True @@ -1240,7 +1286,7 @@ def test_118_challengeset_get(self, mock_chsearch, mock_val, mock_set): @patch('acme_srv.challenge.Challenge.new_set') @patch('acme_srv.challenge.Challenge._existing_challenge_validate') @patch('acme_srv.challenge.Challenge._challengelist_search') - def test_119_challengeset_get(self, mock_chsearch, mock_val, mock_set): + def test_121_challengeset_get(self, mock_chsearch, mock_val, mock_set): """ test challengeset_get - challenge_list returned """ mock_chsearch.return_value = [{'name': 'name1', 'foo': 'bar'}] mock_val.return_value = True diff --git a/test/test_pkcs7_soap_ca_handler.py b/test/test_pkcs7_soap_ca_handler.py index 70de1398..86510a63 100644 --- a/test/test_pkcs7_soap_ca_handler.py +++ b/test/test_pkcs7_soap_ca_handler.py @@ -220,6 +220,23 @@ def test_009_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') def test_010_config_load(self, mock_load_cfg, mock_file): + """ test _config_load signing cert configured but does not exist """ + mock_file.return_value = False + mock_load_cfg.return_value = {'CAhandler': {'password': 'password'}} + with self.assertLogs('test_a2c', level='INFO') as lcm: + self.cahandler._config_load() + self.assertFalse(self.cahandler.soap_srv) + self.assertFalse(self.cahandler.profilename) + self.assertFalse(self.cahandler.email) + self.assertFalse(self.cahandler.signing_cert) + self.assertFalse(self.cahandler.signing_key) + self.assertEqual('password'.encode('utf8'), self.cahandler.password) + self.assertFalse(self.cahandler.signing_script_dic) + + + @patch('os.path.exists') + @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') + def test_011_config_load(self, mock_load_cfg, mock_file): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = False mock_load_cfg.return_value = {'CAhandler': {'signing_key': 'signing_key'}} @@ -246,7 +263,7 @@ def test_010_config_load(self, mock_load_cfg, mock_file): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_011_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_012_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -273,7 +290,7 @@ def test_011_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_012_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_013_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -303,7 +320,7 @@ def test_012_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_013_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_014_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -332,7 +349,7 @@ def test_013_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_014_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_015_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -362,7 +379,7 @@ def test_014_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_015_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_016_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -391,7 +408,7 @@ def test_015_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_016_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_017_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -421,7 +438,7 @@ def test_016_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_017_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_018_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -451,7 +468,7 @@ def test_017_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('cryptography.hazmat.primitives.serialization.load_pem_private_key') @patch('os.path.exists') @patch('examples.ca_handler.pkcs7_soap_ca_handler.load_config') - def test_018_config_load(self, mock_load_cfg, mock_file, mock_load): + def test_019_config_load(self, mock_load_cfg, mock_file, mock_load): """ test _config_load signing cert configured but does not exist """ mock_file.return_value = True mock_load.return_value = 'signing_key' @@ -479,43 +496,43 @@ def test_018_config_load(self, mock_load_cfg, mock_file, mock_load): @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._config_load') - def test_019_enter(self, mock_cfgload): + def test_020_enter(self, mock_cfgload): """ enter - no soap server configured """ self.cahandler.__enter__() self.assertTrue(mock_cfgload.called) @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._config_load') - def test_020_enter(self, mock_cfgload): + def test_021_enter(self, mock_cfgload): """ enter soap server configured """ self.cahandler.soap_srv = 'mock_srv' self.cahandler.__enter__() self.assertFalse(mock_cfgload.called) - def test_021_exit(self): + def test_022_exit(self): """ enter - no soap server configured """ self.cahandler.__exit__() @patch('pyasn1.codec.der.decoder.decode') - def test_022_cert_decode(self, mock_der): + def test_023_cert_decode(self, mock_der): """ test _cert_decode()""" mock_der.return_value = 'decode' cert = Mock() cert.public_bytes = Mock() self.assertEqual('decode', self.cahandler._cert_decode(cert)) - def test_023_poll(self): + def test_024_poll(self): """ test poll """ self.assertEqual((None, None, None, 'poll_identifier', False), self.cahandler.poll('cert_name', 'poll_identifier', 'csr')) - def test_024_revoke(self): + def test_025_revoke(self): """ test revoke """ self.assertEqual((500, 'urn:ietf:params:acme:error:serverInternal', 'Revocation is not supported.'), self.cahandler.revoke('cert_name', 'reason', 'date')) - def test_025_trigger(self): + def test_026_trigger(self): """ test revoke """ self.assertEqual((None, None, None), self.cahandler.trigger('identifier')) - def test_026_soaprequest_build(self): + def test_027_soaprequest_build(self): """ test soap request build """ self.cahandler.profilename = 'profilename' self.cahandler.email = 'email' @@ -537,23 +554,23 @@ def test_026_soaprequest_build(self): self.assertEqual(result, self.cahandler._soaprequest_build(pkcs7)) @patch("builtins.open", mock_open(read_data='foo'), create=True) - def test_027_binary_read(self): + def test_028_binary_read(self): """ test read binary file """ self.assertEqual('foo', self.binary_read(self.logger, 'filename')) @patch("builtins.open", mock_open(read_data='foo'), create=True) - def test_028_binary_write(self): + def test_029_binary_write(self): """ test wrote binary file """ self.assertFalse(self.binary_write(self.logger, 'filename', 'content')) - def test_029_sign(self): + def test_030_sign(self): """ test _sign unkown key format """ key = 'key' payload = 'foo' self.assertEqual((None, None), self.cahandler._sign(key, payload)) @patch('cryptography.hazmat.primitives.asymmetric.rsa') - def test_030_sign(self, mock_rsa): + def test_031_sign(self, mock_rsa): """ test _sign rsa key """ keyph = b'Test1234' with open(self.dir_path + '/ca/sub-ca-key.pem', 'rb') as open_file: @@ -566,7 +583,7 @@ def test_030_sign(self, mock_rsa): self.assertEqual(alg, str(result[1])) @patch('cryptography.hazmat.primitives.asymmetric.rsa') - def test_031_sign(self, mock_rsa): + def test_032_sign(self, mock_rsa): """ test _sign ecc key """ ecc_key = b'-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIGCu1fYGkqMdPtsNH7xVc8QBjCWCkcUTVKX6f8vLhtkvoAoGCCqGSM49\nAwEHoUQDQgAEan72++swi7J5B1HVYp1CjXPqckkQquiMIQhz5xYesv9f4KK/ouKS\n1uJ3ZYwPbWUsDd8/03vf9VdlfZzL3W3ZQw==\n-----END EC PRIVATE KEY-----' key = serialization.load_pem_private_key(ecc_key, password=None, backend=default_backend()) @@ -575,14 +592,14 @@ def test_031_sign(self, mock_rsa): alg = """AlgorithmIdentifier:\n algorithm=1.2.840.10045.4.3.2\n""" self.assertEqual(alg, str(result[1])) - def test_032_certraw_get(self): + def test_033_certraw_get(self): """ test _certraw_get """"" with open(self.dir_path + '/ca/sub-ca-client.pem', 'r') as fso: pem_data = fso.read() result = 'MIIEGDCCAgCgAwIBAgIJALL8aztMPfV2MA0GCSqGSIb3DQEBCwUAMEgxCzAJBgNVBAYTAkRFMQ8wDQYDVQQIDAZCZXJsaW4xFzAVBgNVBAoMDkFjbWUyQ2VydGlmaWVyMQ8wDQYDVQQDDAZzdWItY2EwHhcNMTkwNjI1MDEyNTAwWhcNMjAwNjI1MDEyNTAwWjBPMQswCQYDVQQGEwJERTEPMA0GA1UEBxMGQmVybGluMRcwFQYDVQQKEw5BY21lMkNlcnRpZmllcjEWMBQGA1UEAwwNY2xpZW50X3N1Yi1jYTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALvoKKg3ciBVWZtquiWyMogWU6ydEfmLbXktK6T+owxzxHVaoePVGH9DZvTZD2pHS8xJ6fpFr3pZYiuqiUHuxdMpj9gVxik5ivBrSJIkZXLxwvNJWpMa1o1Hxz1By3Hrlm3ebKIzfQPqRRcdjWtJgCFbcTpalwhE1RQFMp4Icb08aAE9uEaZQ4uZ8Ls30J6IHC4PG63lGI1tkAtLIoUWupRAmnWDx0ysXzXeN7m+Lff9ols9MZNgzRMgY/zGUq0LzZfi+L+Iev3sztCdoIOBA/K63jv0hOPyYg331L05XIwbLeUoUG41J4pZzafx6MAFp4Zam1w+aafCzEw7ZPHQvn0CAwEAATANBgkqhkiG9w0BAQsFAAOCAgEABPgWo4KAXJNXNfEBbixDuCxtwO1JuphSOTcpIlEp+uNOSDzgNEbrhUXTNM8SPshzFjBpudc29okiyC62CfLD/X+EvIeKo/oa477kN6MuNfqLGZ42a935ES3S00Wy8rbwyIoPCsKWT/6VsHRHUn8XhFNFUBKZ8FGxwXcAVpPanyikURqVH1MgAk62hJQdYjSxdga/GKS1dS39fyxQz7uBPt5WIQZPzL6dr2Yn/4lQUvTUVus2e1cTh3z02yB5EDlEAcMMvMNpfYvNdU5H6QEPwysbkW9E/Ep84aq21zwuPxICh0KdjHWKkHtCqDoEYIADDl1AD5UdJTMQ9LIzUjsBvtB5I6yT7jgsx/iqTDrkJVK/zRf4NeKRa3AW57jsPUIcUstUFnVJbg+MM4fYmapx8Hqm/Aq+II9ip80AM6hXvierTQn4MNQivL0ZJfj0Ro9KEIDAHN3IAfIlFovbkBPLMi9PtfyhuVmXpthE9OaDlgUguWb45LAKwgfu1TFGPPpf5jTw2qVx0F+iCiUwK8ZgnakkXOKE5+KIb8ejL+3pPd5Wt+45w/7gEFOjT6XAzZGnUtcMH/lpxmgbl3/SKkyrW4h7PnF2FEEVC4XnZuQm+ZwD/PpXfmAA52ygKHBzUr9V33CkW0FhvjqkAUya5x9CqWlHoal0RVvFavnw+4ImqbE=' self.assertEqual(result, self.cahandler._certraw_get(pem_data)) - def test_033_pkcs7_create(self): + def test_034_pkcs7_create(self): """ test pkcs7_create """ keyph = b'Test1234' with open(self.dir_path + '/ca/csr.der', 'rb') as open_file: @@ -598,7 +615,7 @@ def test_033_pkcs7_create(self): self.assertEqual(expected_result, base64.b64encode(result)) @patch('requests.post') - def test_034_soaprequest_send(self, mock_post): + def test_035_soaprequest_send(self, mock_post): """ soaprequest_send() - request exception """ mock_post.side_effect = Exception('exc_api_post') with self.assertLogs('test_a2c', level='INFO') as lcm: @@ -607,7 +624,7 @@ def test_034_soaprequest_send(self, mock_post): @patch('xmltodict.parse') @patch('requests.post') - def test_035_soaprequest_send(self, mock_post, mock_xml_parse): + def test_036_soaprequest_send(self, mock_post, mock_xml_parse): """ soaprequest_send() - 200 xml-parsing error """ mock_post.return_value = Mock(status_code=200) mock_xml_parse.return_value = {'foo': 'bar'} @@ -617,7 +634,7 @@ def test_035_soaprequest_send(self, mock_post, mock_xml_parse): @patch('xmltodict.parse') @patch('requests.post') - def test_036_soaprequest_send(self, mock_post, mock_xml_parse): + def test_037_soaprequest_send(self, mock_post, mock_xml_parse): """ soaprequest_send() - 200 xml-parsing successful """ mock_post.return_value = Mock(status_code=200) mock_xml_parse.return_value = {'s:Envelope': {'s:Body': {'RequestCertificateResponse': {'RequestCertificateResult': {'IssuedCertificate': 'foo'}}}}} @@ -625,7 +642,7 @@ def test_036_soaprequest_send(self, mock_post, mock_xml_parse): @patch('xmltodict.parse') @patch('requests.post') - def test_037_soaprequest_send(self, mock_post, mock_xml_parse): + def test_038_soaprequest_send(self, mock_post, mock_xml_parse): """ soaprequest_send() - 400 xml-parsing error """ mock_post.return_value = Mock(status_code=400) mock_xml_parse.return_value = {'foo': 'bar'} @@ -636,7 +653,7 @@ def test_037_soaprequest_send(self, mock_post, mock_xml_parse): @patch('xmltodict.parse') @patch('requests.post') - def test_038_soaprequest_send(self, mock_post, mock_xml_parse): + def test_039_soaprequest_send(self, mock_post, mock_xml_parse): """ soaprequest_send() - 400 xml-parsing successful """ mock_post.return_value = Mock(status_code=400) mock_xml_parse.return_value = {'s:Envelope': {'s:Body': {'s:Fault': {'faultcode': 'faultcode', 'faultstring': 'faultstring'}}}} @@ -646,85 +663,85 @@ def test_038_soaprequest_send(self, mock_post, mock_xml_parse): self.assertIn('ERROR:test_a2c:CAhandler._soaprequest_send() - faultcode: faultcode', lcm.output) self.assertIn('ERROR:test_a2c:CAhandler._soaprequest_send() - faultstring: faultstring', lcm.output) - def test_039_get_certificates(self): + def test_040_get_certificates(self): """ test pkcs7_create """ with open(self.dir_path + '/ca/certs_der.p7b', 'rb') as open_file: pkcs7_bundle = open_file.read() result = ['-----BEGIN CERTIFICATE-----\nMIIFTzCCAzegAwIBAgIIAzHyhSyrXfMwDQYJKoZIhvcNAQELBQAwKzEXMBUGA1UE\nCxMOYWNtZTJjZXJ0aWZpZXIxEDAOBgNVBAMTB3Jvb3QtY2EwHhcNMjAwNTI3MTM1\nNDAwWhcNMzAwNTI2MjM1OTAwWjAqMRcwFQYDVQQLEw5hY21lMmNlcnRpZmllcjEP\nMA0GA1UEAxMGc3ViLWNhMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA\nxXHaGZsolXe+PBdUryngHP9VbBC1mehqeTtYI+hqsqGNH7q9a7bSrxMwFuF1kYL8\njqqxkJdtl0L94xcxJg/ZdMx7Nt0vGI+BaAuTpEpUEHeN4tqS6NhB/m/0LGkAELc/\nqkzmoO4B1FDwEEj/3IXtZcupqG80oDt7jWSGXdtF7NTjzcumznMeRXidCdhxRxT/\n/WrsChaytXo0xWZ56oeNwd6x6Dr8/39PBOWtj4fldyDcg+Q+alci2tx9pxmu2bCV\nXcB9ftCLKhDk2WEHE88bgKSp7fV2RCmq9po+Tx8JJ7qecLunUsK/F0XN4kpoQLm9\nhcymqchnMSncSiyin1dQHGHWgXDtBDdq6A2Z6rx26Qk5H9HTYvcNSe1YwFEDoGLB\nZQjbCPWiaqoaH4agBQTclPvrrSCRaVmhUSO+pBtSXDkmN4t3MDZxfgRkp8ixwkB1\n5Y5f0LTpCyAJsdQDw8+Ea0aDqO30eskh4CErnm9+Fejd9Ew2cwpdwfBXzVSbYilM\nGueQihZHvJmVRxAwU69aO2Qs8B0tQ60CfWKVlmWPiakrvYYlPp0FBsM61G6LZEN8\nhH2CKnS8hHv5IWEXZvp0Pk8V3P5h6bWN0Tl+x/V1Prt7Wp8NoiPETE8XyDDxe6dm\nKxztWBH/mTsJyMGb6ZiUoXdPU9TFUKqHxTRLHaxfsPsCAwEAAaN4MHYwEgYDVR0T\nAQH/BAgwBgEB/wIBATAdBgNVHQ4EFgQUv96OjgYiIqutQ8jd1E+oq0hBPtUwDgYD\nVR0PAQH/BAQDAgGGMBEGCWCGSAGG+EIBAQQEAwIABzAeBglghkgBhvhCAQ0EERYP\neGNhIGNlcnRpZmljYXRlMA0GCSqGSIb3DQEBCwUAA4ICAQBbHLEVyg4f9uEujroc\n31UVyDRLMdPgEPLjOenSBCBmH0N81whDmxNI/7JAAB6J14WMX8OLF0HkZnb7G77W\nvDhy1aFvQFbXHBz3/zUO9Mw9J4L2XEW6ond3Nsh1m2oXeBde3R3ANxuIzHqZDlP9\n6YrRcHjnf4+1/5AKDJAvJD+gFb5YnYUKH2iSvHUvG17xcZx98Rf2eo8LealG4JqH\nJh4sKRy0VjDQD7jXSCbweTHEb8wz+6OfNGrIo+BhTFP5vPcwE4nlJwYBoaOJ5cVa\n7gdQJ7WkLSxvwHxuxzvSVK73u3jl3I9SqTrbMLG/jeJyV0P8EvdljOaGnCtQVRwC\nzM4ptXUvKhKOHy7/nyTF/Bc35ZwwL/2xWvNK1+NibgE/6CFxupwWpdmxQbVVuoQ3\n2tUil9ty0yC6m5GKE8+t1lrZuxyA+b/TBnYNO5xo8UEMbkpxaNYSwmw+f/loxXP/\nM7sIBcLvy2ugHEBxwd9o/kLXeXT2DaRvxPjp4yk8MpJRpNmz3aB5HJwaUnaRLVo5\nZ3XWWXmjMGZ6/m0AAoDbDz/pXtOoJZT8BJdD1DuDdszVsQnLVn4B/LtIXL6FbXsF\nzfv6ERP9a5gpKUZ+4NjgrnlGtdccNZpwyWF0IXcvaq3b8hXIRO4hMjzHeHfzJN4t\njX1vlY35Ofonc4+6dRVamBiF9A==\n-----END CERTIFICATE-----\n', '-----BEGIN CERTIFICATE-----\nMIIFcDCCA1igAwIBAgIIevLTTxOMoZgwDQYJKoZIhvcNAQELBQAwKzEXMBUGA1UE\nCxMOYWNtZTJjZXJ0aWZpZXIxEDAOBgNVBAMTB3Jvb3QtY2EwHhcNMjAwNTI3MDAw\nMDAwWhcNMzAwNTI2MjM1OTU5WjArMRcwFQYDVQQLEw5hY21lMmNlcnRpZmllcjEQ\nMA4GA1UEAxMHcm9vdC1jYTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIB\nAJy4UZHdZgYt64k/rFamoC676tYvtabeuiqVw1c6oVZI897cFLG6BYwyr2Eaj7tF\nrqTJDeMN4vZSudLsmLDq6m8KwX/riPzUTIlcjM5aIMANZr9rLEs3NWtcivolB5aQ\n1slhdVitUPLuxsFnYeQTyxFyP7lng9M/Z403KLG8phdmKjM0vJkaj4OuKOXf3UsW\nqWQYyRl/ms07xVj02uq08LkoeO+jtQisvyVXURdaCceZtyK/ZBQ7NFCsbK112cVR\n1e2aJol7NJAA6Wm6iBzAdkAA2l3kh40SLoEbaiaVMixLN2vilIZOOAoDXX4+T6ir\n+KnDVSJ2yu5c/OJMwuXwHrh7Lgg1vsFR5TNehknhjUuWOUO+0TkKPg2A7KTg72OZ\n2mOcLZIbxzr1P5RRvdmLQLPrTF2EJvpQPNmbXqN3ZVWEvfHTjkkTFY/dsOTvFTgS\nri15zYKch8votcU7z+BQhgmMtwO2JhPMmZ6ABd9skI7ijWpwOltAhxtdoBO6T6CB\nCrE2yXc6V/PyyAKcFglNmIght5oXsnE+ub/dtx8f9Iea/xNPdo5aGy8fdaitolDK\n16kd3Kb7OE4HMHIwOxxF1BEAqerxxhbLMRBr8hRSZI5cvLzWLvpAQ5zuhjD6V3b9\nBYFd4ujAu3zl3mbzdbYjFoGOX6aBZaGDxlc4O2W7HxntAgMBAAGjgZcwgZQwDwYD\nVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUDGVvuTFYZtEAkz3af9wRKDDvAswwHwYD\nVR0jBBgwFoAUDGVvuTFYZtEAkz3af9wRKDDvAswwDgYDVR0PAQH/BAQDAgGGMBEG\nCWCGSAGG+EIBAQQEAwIABzAeBglghkgBhvhCAQ0EERYPeGNhIGNlcnRpZmljYXRl\nMA0GCSqGSIb3DQEBCwUAA4ICAQAjko7dX+iCgT+m3Iy1Vg6j7MRevPAzq1lqHRRN\nNdt2ct530pIut7Fv5V2xYk35ka+i/G+XyOvTXa9vAUKiBtiRnUPsXu4UcS7CcrCX\nEzHx4eOtHnp5wDhO0Fx5/OUZTaP+L7Pd1GD/j953ibx5bMa/M9Rj+S486nst57tu\nDRmEAavFDiMd6L3jH4YSckjmIH2uSeDIaRa9k6ag077XmWhvVYQ9tuR7RGbSuuV3\nFc6pqcFbbWpoLhNRcFc+hbUKOsKl2cP+QEKP/H2s3WMllqgAKKZeO+1KOsGo1CDs\n475bIXyCBpFbH2HOPatmu3yZRQ9fj9ta9EW46n33DFRNLinFWa4WJs4yLVP1juge\n2TCOyA1t61iy++RRXSG3e7NFYrEZuCht1EdDAdzIUY89m9NCPwoDYS4CahgnfkkO\n7YQe6f6yqK6isyf8ZFcp1uF58eERDiF/FDqS8nLmCdURuI56DDoNvDpig5J/9RNW\nG8vEvt2p7QrjeZ3EAatx5JuYty/NKTHZwJWk51CgzEgzDwzE2JIiqeldtL5d0Sl6\neVuv0G04BEyuXxEWpgVVzBS4qEFIBSnTJzgu1PXmId3yLvg2Nr8NKvwyZmN5xKFp\n0A9BWo15zW1PXDaD+l39oTYD7agjXkzTAjYIcfNJ7ATIYFD0xAvNAOf70s7aNupF\nfvkG2Q==\n-----END CERTIFICATE-----\n'] self.assertEqual(result, self.cahandler._get_certificate(pkcs7_bundle)) - def test_040_pkcs7_signing_config_verify(self): + def test_041_pkcs7_signing_config_verify(self): """ test _pkcs7_signing_config_verify() """ self.cahandler.signing_script_dic = {} self.assertEqual('signing config incomplete: option signing_script is missing', self.cahandler._pkcs7_signing_config_verify()) - def test_041_pkcs7_signing_config_verify(self): + def test_042_pkcs7_signing_config_verify(self): """ test _pkcs7_signing_config_verify() """ self.cahandler.signing_script_dic = {'signing_script': 'signing_script'} self.assertEqual('signing config incomplete: option signing_alias is missing', self.cahandler._pkcs7_signing_config_verify()) - def test_042_pkcs7_signing_config_verify(self): + def test_043_pkcs7_signing_config_verify(self): """ test _pkcs7_signing_config_verify() """ self.cahandler.signing_script_dic = {'signing_script': 'signing_script', 'signing_alias': 'signing_alias'} self.assertEqual('signing config incomplete: option signing_csr_path is missing', self.cahandler._pkcs7_signing_config_verify()) @patch('os.path.isdir') - def test_043_pkcs7_signing_config_verify(self, mock_path): + def test_044_pkcs7_signing_config_verify(self, mock_path): """ test _pkcs7_signing_config_verify() """ mock_path.return_value = False self.cahandler.signing_script_dic = {'signing_script': 'signing_script', 'signing_alias': 'signing_alias', 'signing_csr_path': 'signing_csr_path'} self.assertEqual('signing_csr_path signing_csr_path does not exist or is not a directory', self.cahandler._pkcs7_signing_config_verify()) @patch('os.path.isdir') - def test_044_pkcs7_signing_config_verify(self, mock_path): + def test_045_pkcs7_signing_config_verify(self, mock_path): """ test _pkcs7_signing_config_verify() """ mock_path.return_value = True self.cahandler.signing_script_dic = {'signing_script': 'signing_script', 'signing_alias': 'signing_alias', 'signing_csr_path': 'signing_csr_path'} self.assertEqual('signing config incomplete: option signing_config_variant is missing', self.cahandler._pkcs7_signing_config_verify()) @patch('os.path.isdir') - def test_045_pkcs7_signing_config_verify(self, mock_path): + def test_046_pkcs7_signing_config_verify(self, mock_path): """ test _pkcs7_signing_config_verify() """ mock_path.return_value = True self.cahandler.signing_script_dic = {'signing_script': 'signing_script', 'signing_alias': 'signing_alias', 'signing_csr_path': 'signing_csr_path', 'signing_config_variant': 'signing_config_variant'} self.assertEqual(None, self.cahandler._pkcs7_signing_config_verify()) - def test_046_signing_command_build(self): + def test_047_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {} self.assertEqual([], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) - def test_047_signing_command_build(self): + def test_048_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {} self.assertEqual([], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) - def test_048_signing_command_build(self): + def test_049_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {'signing_user': 'signing_user'} self.assertEqual([], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) - def test_049_signing_command_build(self): + def test_050_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {'signing_user': 'signing_user', 'signing_script': 'signing_script'} self.assertEqual(['sudo', 'signing_user', 'signing_script', 'csr_unsigned', 'csr_signed'], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) - def test_050_signing_command_build(self): + def test_051_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {'signing_user': 'signing_user', 'signing_script': 'signing_script', 'signing_interpreter': 'signing_interpreter'} self.assertEqual(['sudo', 'signing_user', 'signing_interpreter', 'signing_script', 'csr_unsigned', 'csr_signed'], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) - def test_051_signing_command_build(self): + def test_052_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {'signing_script': 'signing_script', 'signing_interpreter': 'signing_interpreter'} self.assertEqual(['signing_interpreter', 'signing_script', 'csr_unsigned', 'csr_signed'], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) - def test_052_signing_command_build(self): + def test_053_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {'signing_script': 'signing_script', 'signing_interpreter': 'signing_interpreter', 'signing_alias': 'signing_alias'} self.assertEqual(['signing_interpreter', 'signing_script', 'csr_unsigned', 'csr_signed'], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) - def test_053_signing_command_build(self): + def test_054_signing_command_build(self): """ test _signing_command_build() """ self.cahandler.signing_script_dic = {'signing_script': 'signing_script', 'signing_interpreter': 'signing_interpreter', 'signing_alias': 'signing_alias', 'signing_config_variant': 'signing_config_variant'} self.assertEqual(['signing_interpreter', 'signing_script', 'csr_unsigned', 'csr_signed', 'signing_alias', 'signing_config_variant'], self.cahandler._signing_command_build('csr_unsigned', 'csr_signed')) @@ -737,7 +754,7 @@ def test_053_signing_command_build(self): @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._signing_command_build') @patch('examples.ca_handler.pkcs7_soap_ca_handler.generate_random_string') @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_signing_config_verify') - def test_054_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): + def test_055_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): """ test _pkcs7_sign_external() """ mock_vrf.return_value = True with self.assertLogs('test_a2c', level='INFO') as lcm: @@ -759,7 +776,7 @@ def test_054_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_wri @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._signing_command_build') @patch('examples.ca_handler.pkcs7_soap_ca_handler.generate_random_string') @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_signing_config_verify') - def test_055_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): + def test_056_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): """ test _pkcs7_sign_external() all good """ mock_vrf.return_value = False mock_read.return_value = 'foo' @@ -785,7 +802,7 @@ def test_055_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_wri @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._signing_command_build') @patch('examples.ca_handler.pkcs7_soap_ca_handler.generate_random_string') @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_signing_config_verify') - def test_056_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): + def test_057_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): """ test _pkcs7_sign_external() no delete """ mock_vrf.return_value = False mock_read.return_value = 'foo' @@ -809,7 +826,7 @@ def test_056_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_wri @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._signing_command_build') @patch('examples.ca_handler.pkcs7_soap_ca_handler.generate_random_string') @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_signing_config_verify') - def test_057_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): + def test_058_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_write, mock_call, mock_read, mock_file, mock_rm): """ test _pkcs7_sign_external() subprocess call returns something """ mock_vrf.return_value = False mock_read.return_value = 'foo' @@ -837,7 +854,7 @@ def test_057_pkcs7_sign_external(self, mock_vrf, mock_rand, mock_build, mock_wri @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_sign_external') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_decode') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_url_recode') - def test_058_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): + def test_059_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): """ test enroll() external signature script returning an error """ self.cahandler.signing_script_dic = {'foo': 'bar'} mock_sigext.return_value = ('error', None) @@ -865,7 +882,7 @@ def test_058_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decod @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_sign_external') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_decode') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_url_recode') - def test_059_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): + def test_060_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): """ test enroll() internal signer returns error """ self.cahandler.signing_script_dic = {} mock_pkcs7_cr.return_value = ('error', None) @@ -895,7 +912,7 @@ def test_059_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decod @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_sign_external') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_decode') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_url_recode') - def test_060_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): + def test_061_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): """ test enroll() - soap_request_send returns error """ self.cahandler.signing_script_dic = {} mock_cert_decode.return_value = 'decoded_cert' @@ -925,7 +942,7 @@ def test_060_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decod @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_sign_external') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_decode') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_url_recode') - def test_061_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): + def test_062_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): """ test enroll() - soap_request_send returns no error but no bundle """ self.cahandler.signing_script_dic = {} mock_cert_decode.return_value = 'decoded_cert' @@ -955,7 +972,7 @@ def test_061_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decod @patch('examples.ca_handler.pkcs7_soap_ca_handler.CAhandler._pkcs7_sign_external') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_decode') @patch('examples.ca_handler.pkcs7_soap_ca_handler.b64_url_recode') - def test_062_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): + def test_063_enroll(self, mock_recode, mock_decode, mock_sigext, mock_cert_decode, mock_pkcs7_cr, mock_encode, mock_sbuild, mock_ssend, mock_cert_get, mock_cert_raw): """ test enroll() - soap_request_send returns no error but no bundle """ self.cahandler.signing_script_dic = {} mock_cert_decode.return_value = 'decoded_cert'