Skip to content

Commit

Permalink
Add tests for FASC-N
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherL91 committed Mar 12, 2024
1 parent 26e990b commit f0a8087
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/test_piv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from _pytest.config import _assertion_supported
from ykman.piv import generate_random_management_key, parse_rfc4514_string

from yubikit.core import NotSupportedError, Version
from yubikit.nist_piv.fascn import FASCNBuilder
from yubikit.piv import (
KEY_TYPE,
MANAGEMENT_KEY_TYPE,
Expand Down Expand Up @@ -77,3 +79,39 @@ def test_supported_algorithms(self):
check_key_support(
Version(5, 7, 0), key_type, PIN_POLICY.DEFAULT, TOUCH_POLICY.DEFAULT
)

def test_fascn_create(self):
fascn = (
FASCNBuilder()
.agency_code("9999")
.system_code("9999")
.credential_number("999999")
.credential_series("0")
.individual_credential_issue("0")
.person_identifier("0000000000")
.organizational_category("0")
.organization_association_category("0")
.build()
)

expected = bytearray(
b"\xd4\xe79\xdas\x9c\xed9\xces\x9d\x83`\xd8!\x08B\x10\x84!\x08B\x10\x87\xf3"
)
assert fascn.encode() == expected

def test_fascn_encode_decode(self):
fascn = (
FASCNBuilder()
.agency_code("9999")
.system_code("9999")
.credential_number("999999")
.credential_series("0")
.individual_credential_issue("0")
.person_identifier("0000000000")
.organizational_category("0")
.organization_association_category("0")
.build()
)

copy = fascn.decode(fascn.encode())
assert fascn == copy

0 comments on commit f0a8087

Please sign in to comment.