Skip to content

Commit

Permalink
Merge branch 'min-devel' of https://github.com/grindsa/acme2certifier
Browse files Browse the repository at this point in the history
…into min-devel
  • Loading branch information
grindsa committed Oct 10, 2024
2 parents 7d56597 + e7aae93 commit 2bdf5e6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
4 changes: 2 additions & 2 deletions acme_srv/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ def eab_profile_header_info_check(logger: logging.Logger, cahandler, csr: str, h
# profiling enabled - check profile
error = eab_profile_check(logger, cahandler, csr, handler_hifield)
else:
logger.error('eab_profile_header_info_check(): eab_profiling enabled but no handler defined')
logger.error('Helper.eab_profile_header_info_check(): eab_profiling enabled but no handler defined')
error = 'Eab_profiling enabled but no handler defined'

elif cahandler.header_info_field:
Expand All @@ -1698,7 +1698,7 @@ def eab_profile_header_info_check(logger: logging.Logger, cahandler, csr: str, h
setattr(cahandler, handler_hifield, hil_value)
error = None
else:
logger.debug('eab_profile_header_info_check(): no header_info field found')
logger.debug('Helper.eab_profile_header_info_check(): no header_info field found')
error = None
else:
# no profiling - no header_info_field
Expand Down
2 changes: 1 addition & 1 deletion examples/ca_handler/asa_ca_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import requests
from requests.auth import HTTPBasicAuth
# pylint: disable=e0401
from acme_srv.helper import load_config, encode_url, csr_pubkey_get, csr_cn_get, csr_san_get, uts_now, uts_to_date_utc, b64_decode, cert_der2pem, convert_byte_to_string, cert_ski_get, config_eab_profile_load, config_headerinfo_load, eab_profile_header_info_check
from acme_srv.helper import load_config, encode_url, csr_pubkey_get, csr_cn_get, csr_san_get, uts_now, uts_to_date_utc, b64_decode, cert_der2pem, convert_byte_to_string, cert_ski_get, csr_san_byte_get, header_info_field_validate, header_info_lookup, config_eab_profile_load, config_headerinfo_load, eab_profile_header_info_check


class CAhandler(object):
Expand Down
20 changes: 2 additions & 18 deletions test/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2819,7 +2819,8 @@ def test_356_eab_profile_header_info_check(self, mock_lookup, mock_eab):
cahandler.hi_field = 'pre_hi_field'
with self.assertLogs('test_a2c', level='INFO') as lcm:
self.assertEqual('Eab_profiling enabled but no handler defined', self.eab_profile_header_info_check(self.logger, cahandler, 'csr', 'hi_field'))
self.assertIn('ERROR:test_a2c:eab_profile_header_info_check(): eab_profiling enabled but no handler defined', lcm.output)
self.assertIn('ERROR:test_a2c:Helper.eab_profile_header_info_check(): eab_profiling enabled but no handler defined', lcm.output)

self.assertEqual('pre_hi_field', cahandler.hi_field)
self.assertFalse(mock_eab.called)
self.assertFalse(mock_lookup.called)
Expand Down Expand Up @@ -2905,22 +2906,5 @@ def test_362_eab_profile_check(self, mock_string, mock_list):
self.assertFalse(mock_string.called)
self.assertFalse(mock_list.called)

@patch('cryptography.__version__', '3.4.7')
def test_363_cryptography_version_get_success(self):
self.assertEqual(3, self.cryptography_version_get(self.logger))

@patch('cryptography.__version__', None)
def test_364_cryptography_version_get_success(self):
with self.assertLogs('test_a2c', level='INFO') as lcm:
self.assertEqual(36, self.cryptography_version_get(self.logger))
self.assertIn("ERROR:test_a2c:cryptography_version_get(): Error: 'NoneType' object has no attribute 'split'", lcm.output)


#@patch('cryptography.__version__', new_callable=lambda: None)
#def test_364_cryptography_version_get_missing_version(self):
# with self.assertRaises(AttributeError):
# cryptography_version_get()


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

0 comments on commit 2bdf5e6

Please sign in to comment.