-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bae1083
commit e834296
Showing
29 changed files
with
1,322 additions
and
740 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,53 @@ | ||
from yubikit.management import CAPABILITY | ||
from ... import condition | ||
from .util import DEFAULT_PIN, DEFAULT_PUK, DEFAULT_MANAGEMENT_KEY | ||
from typing import NamedTuple | ||
import pytest | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
@condition.capability(CAPABILITY.PIV) | ||
def ensure_piv(ykman_cli): | ||
ykman_cli("piv", "reset", "-f") | ||
|
||
|
||
class Keys(NamedTuple): | ||
pin: str | ||
puk: str | ||
mgmt: str | ||
|
||
|
||
@pytest.fixture | ||
def default_keys(): | ||
yield Keys(DEFAULT_PIN, DEFAULT_PUK, DEFAULT_MANAGEMENT_KEY) | ||
|
||
|
||
@pytest.fixture | ||
def keys(ykman_cli, info, default_keys): | ||
if CAPABILITY.PIV in info.fips_capable: | ||
new_keys = Keys( | ||
"12345679", | ||
"12345670", | ||
"010203040506070801020304050607080102030405060709", | ||
) | ||
|
||
ykman_cli( | ||
"piv", "access", "change-pin", "-P", default_keys.pin, "-n", new_keys.pin | ||
) | ||
ykman_cli( | ||
"piv", "access", "change-puk", "-p", default_keys.puk, "-n", new_keys.puk | ||
) | ||
ykman_cli( | ||
"piv", | ||
"access", | ||
"change-management-key", | ||
"-m", | ||
default_keys.mgmt, | ||
"-n", | ||
new_keys.mgmt, | ||
"-f", | ||
) | ||
|
||
yield new_keys | ||
else: | ||
yield default_keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.