Skip to content

Commit afd3463

Browse files
committed
Add test of parseFidoSerNumExtension on cert without sernum extension
1 parent ee6b44d commit afd3463

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

webauthn-server-attestation/src/test/scala/com/yubico/webauthn/attestation/CertificateUtilSpec.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import scala.jdk.OptionConverters.RichOptional
1717
class CertificateUtilSpec extends AnyFunSpec with Matchers {
1818
describe("parseFidoSerNumExtension") {
1919
val idFidoGenCeSernum = "1.3.6.1.4.1.45724.1.1.2"
20+
2021
it("correctly parses the id-fido-gen-ce-sernum extension.") {
2122
val (cert, _): (X509Certificate, _) = TestAuthenticator
2223
.generateAttestationCertificate(
@@ -37,6 +38,16 @@ class CertificateUtilSpec extends AnyFunSpec with Matchers {
3738
result should equal(Some(ByteArray.fromHex("00010203")))
3839
}
3940

41+
it("returns empty when cert has no id-fido-gen-ce-sernum extension.") {
42+
val (cert, _): (X509Certificate, _) =
43+
TestAuthenticator.generateAttestationCertificate(extensions = Nil)
44+
val result =
45+
CertificateUtil
46+
.parseFidoSerNumExtension(cert)
47+
.toScala
48+
result should be(None)
49+
}
50+
4051
it("correctly parses the serial number from a real YubiKey enterprise attestation certificate.") {
4152
val cert = CertificateParser.parsePem("""-----BEGIN CERTIFICATE-----
4253
|MIIC8zCCAdugAwIBAgIJAKr/KiUzkKrgMA0GCSqGSIb3DQEBCwUAMC8xLTArBgNV

0 commit comments

Comments
 (0)