Code quality
This commit is contained in:
parent
83f310e28a
commit
81264a3b6c
|
@ -206,11 +206,14 @@ class SecretLoader:
|
|||
)
|
||||
|
||||
return self._convert_pass_process_result_to_password(
|
||||
process.returncode, process.stdout
|
||||
process.returncode,
|
||||
process.stdout,
|
||||
)
|
||||
|
||||
def _convert_pass_process_result_to_password(
|
||||
self, returncode: int, stdout: bytes
|
||||
self,
|
||||
returncode: int,
|
||||
stdout: bytes,
|
||||
) -> str | None:
|
||||
if returncode != 0:
|
||||
return None
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import secret_loader
|
||||
import pytest
|
||||
|
||||
import secret_loader
|
||||
|
||||
|
||||
def test_hardcoded():
|
||||
loader = secret_loader.SecretLoader(ENV_KEY_PREFIX='TEST', KEY='VALUE')
|
||||
|
@ -37,10 +38,12 @@ def test_fail_hardcoded_prefix_with_trailing_underscore():
|
|||
|
||||
def test_lookup_unknown_or_fail():
|
||||
loader = secret_loader.SecretLoader(
|
||||
ENV_KEY_PREFIX='TEST', PASS_STORE_SUBFOLDER='test'
|
||||
ENV_KEY_PREFIX='TEST',
|
||||
PASS_STORE_SUBFOLDER='test', # noqa: S106
|
||||
)
|
||||
with pytest.raises(
|
||||
ValueError, match='Failed to load secret with key:.*UNKNOWN.*'
|
||||
ValueError,
|
||||
match='Failed to load secret with key:.*UNKNOWN.*',
|
||||
) as e:
|
||||
assert loader.load_or_fail('UNKNOWN')
|
||||
|
||||
|
@ -51,8 +54,8 @@ def test_lookup_unknown_or_fail():
|
|||
|
||||
def test_convert_process():
|
||||
loader = secret_loader.SecretLoader()
|
||||
assert loader._convert_pass_process_result_to_password(1, b'') is None
|
||||
assert loader._convert_pass_process_result_to_password(1, b'') is None # noqa: SLF001
|
||||
assert (
|
||||
loader._convert_pass_process_result_to_password(0, b'Hello\nWorld') == 'Hello'
|
||||
loader._convert_pass_process_result_to_password(0, b'Hello\nWorld') == 'Hello' # noqa: SLF001
|
||||
)
|
||||
assert loader._convert_pass_process_result_to_password(0, b'') == ''
|
||||
assert loader._convert_pass_process_result_to_password(0, b'') == '' # noqa: SLF001
|
||||
|
|
Loading…
Reference in New Issue
Block a user