Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 5, 2024
1 parent 7ee15f1 commit a506434
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions tests/softhsm_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def run_cmd(args, softhsm_conf=None) -> Tuple[bytes, bytes]:
if softhsm_conf is not None:
env['SOFTHSM_CONF'] = softhsm_conf
env['SOFTHSM2_CONF'] = softhsm_conf
proc = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env
)
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
out, err = proc.communicate()
if err is not None and len(err) > 0:
logging.error(err)
Expand Down Expand Up @@ -88,19 +86,15 @@ def run_cmd(args, softhsm_conf=None) -> Tuple[bytes, bytes]:
}

component_path: Dict[str, str] = {
component_name: find_alts(
component_name, paths_for_component(component_name, default_paths)
)
component_name: find_alts(component_name, paths_for_component(component_name, default_paths))
for component_name, default_paths in component_default_paths.items()
}

softhsm_version = 1
if component_path['SOFTHSM'].endswith('softhsm2-util'):
softhsm_version = 2

openssl_version = subprocess.check_output([component_path['OPENSSL'], 'version'])[
8:11
].decode()
openssl_version = subprocess.check_output([component_path['OPENSSL'], 'version'])[8:11].decode()

p11_test_files: List[str] = []
softhsm_conf: Optional[str] = None
Expand All @@ -119,9 +113,7 @@ def _temp_dir() -> str:
return d


@unittest.skipIf(
component_path['P11_MODULE'] is None, 'SoftHSM PKCS11 module not installed'
)
@unittest.skipIf(component_path['P11_MODULE'] is None, 'SoftHSM PKCS11 module not installed')
def setup() -> None:
logging.debug('Creating test pkcs11 token using softhsm')
try:
Expand Down Expand Up @@ -228,9 +220,7 @@ def setup() -> None:
)
signer_cert_pem = _temp_file()
openssl_conf = _temp_file()
logging.debug(
'Generating OpenSSL config for version {}'.format(openssl_version)
)
logging.debug('Generating OpenSSL config for version {}'.format(openssl_version))
with open(openssl_conf, 'w') as f:
# Might be needed with some versions of openssl, but in more recent versions dynamic_path breaks it.
# dynamic_path = (
Expand Down

0 comments on commit a506434

Please sign in to comment.