Skip to content

Commit

Permalink
test: tun tests without having ykman installed
Browse files Browse the repository at this point in the history
renatav committed Dec 4, 2024
1 parent 2f16959 commit f22da80
Showing 5 changed files with 18 additions and 319 deletions.
13 changes: 5 additions & 8 deletions taf/keys.py
Original file line number Diff line number Diff line change
@@ -31,11 +31,7 @@
load_signer_from_private_keystore,
)
from taf import YubikeyMissingLibrary


from securesystemslib.signer._crypto_signer import CryptoSigner
from taf.yubikey import get_serial_num, yk_secrets_handler


try:
import taf.yubikey as yk
@@ -240,7 +236,7 @@ def _load_and_append_yubikeys(
)
if public_key is not None and public_key not in yubikeys:
signer = YkSigner(
public_key, partial(yk_secrets_handler, serial_num=serial_num)
public_key, partial(yk.yk_secrets_handler, serial_num=serial_num)
)
yubikeys.append(signer)
taf_logger.info(f"Successfully loaded {key_name} from inserted YubiKey")
@@ -388,7 +384,7 @@ def _setup_yubikey_roles_keys(
)
loaded_keys_num += 1
signer = YkSigner(
public_key, partial(yk_secrets_handler, serial_num=serial_num)
public_key, partial(yk.yk_secrets_handler, serial_num=serial_num)
)
signers.append(signer)

@@ -409,7 +405,8 @@ def _setup_yubikey_roles_keys(
loaded_keys_num += 1
loaded_keys.append(key_id)
signer = YkSigner(
public_key, partial(yk_secrets_handler, serial_num=serial_num)
public_key,
partial(yk.yk_secrets_handler, serial_num=serial_num),
)
signers.append(signer)
if loaded_keys_num == role.threshold:
@@ -559,4 +556,4 @@ def _load_and_verify_yubikey(
print("Public key of the inserted key is not equal to the specified one.")
if not click.confirm("Try again?"):
return None
return get_serial_num()
return yk.get_serial_num()
Empty file.
107 changes: 0 additions & 107 deletions taf/tests/test_repository_tool/conftest.py

This file was deleted.

204 changes: 0 additions & 204 deletions taf/tests/test_repository_tool/test_repository_tool.py

This file was deleted.

13 changes: 13 additions & 0 deletions taf/tests/tuf/test_keys/test_yk.py
Original file line number Diff line number Diff line change
@@ -23,6 +23,19 @@
_SIG = b"\xc1}\xaa\xec\xf6#;\xe6\x89\xc26\x81\x1a;\xd3\xb2\x7f\xce\xe3}\x9a6w}P\xe0d\x8d\xeb\xbcb\xba8\x8c\x96tS\xf2_\xf37\xe8Z\xc4\xf4\x1a\xaa\xdd\xdd%AB#w\x93\xc9\x0f\x8d\xe4\x93)\x9f\xa4)\x0b\xbb\xce\xf4\x9e\x8b\xaa\x1c\xda\xb8\x9ex\xe2\xc8\x9c\x02\\\xb7\x89\x88g\xd3\xb2\x0be\xf4S\x0c*\x0c\xce\xfe\x8aL=\x07\xfa\xe9\xa2\xe1\xed\x1cA\xf9\xbeZR\x91\xae@\x12\xfe<n\xe9;\xa3\xcdr\xabB\x87\x02N\xe5\x8a\x0b3>\xbey`\x07 /)Z_\xd0\xca\x7f\xcey\xe6\x1ee~\x01\x0c\xcfQZ=a\xf6\xe9\xabm_\x12\x8e\xda\xb0\xd4\xaeb1W\x0e\xf0\x909\xae\x05}\x8f\xba\xf7\xa0\\Rx\xe9\x98\x0f4j86\x87\x17\xf5\xff\xc2U\x80oh\xad\xb2\xaf\xa5\x91\x9a\xafI,\xadj\xd5\x02$\xc6\xf8\xf2`y\xd2\xa6\xf3\xce[;\r\xb6y\xd4\xa5\x96y$}{!r\xc1\xfb@\x1e<\xd9\xa0\xe6\x7f\xf1\x17\xe5\x0c\x8e\xbd\xf3\xba"


def is_yubikey_manager_installed():
try:
import taf.yubikey
except ImportError:
return False
else:
return True


@pytest.mark.skipif(
not is_yubikey_manager_installed(),
reason="Yubikey Manager not installed)",
)
def test_fake_yk(mocker):
"""Test public key export and signing with fake Yubikey."""
mocker.patch("taf.yubikey.export_piv_pub_key", return_value=_PUB)

0 comments on commit f22da80

Please sign in to comment.