Skip to content

Commit 07c9b32

Browse files
committed
Add tests for parseFidoSerNumExtenstion
1 parent 81ac116 commit 07c9b32

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.yubico.webauthn.attestation
2+
3+
import com.yubico.webauthn.TestAuthenticator
4+
import com.yubico.webauthn.data.ByteArray
5+
import org.bouncycastle.asn1.DEROctetString
6+
import org.bouncycastle.asn1.x500.X500Name
7+
import org.junit.runner.RunWith
8+
import org.scalatest.funspec.AnyFunSpec
9+
import org.scalatest.matchers.should.Matchers.convertToAnyShouldWrapper
10+
import org.scalatestplus.junit.JUnitRunner
11+
12+
import java.security.cert.X509Certificate
13+
14+
@RunWith(classOf[JUnitRunner])
15+
class CertificateUtilSpec extends AnyFunSpec {
16+
describe("parseFidoSerNumExtension") {
17+
val idFidoGenCeSernum = "1.3.6.1.4.1.45724.1.1.2"
18+
it("should correctly parse the serial number from a valid certificate with the id-fido-gen-ce-sernum extension.") {
19+
val goodCert: X509Certificate = TestAuthenticator
20+
.generateAttestationCertificate(
21+
name = new X500Name(
22+
"O=Yubico, C=SE, OU=Authenticator Attestation"
23+
),
24+
extensions = List(
25+
(
26+
idFidoGenCeSernum,
27+
false,
28+
new DEROctetString(Array[Byte](0, 1, 2, 3)),
29+
)
30+
),
31+
)
32+
._1
33+
34+
val result = new ByteArray(
35+
CertificateUtil
36+
.parseFidoSerNumExtension(goodCert)
37+
.get
38+
)
39+
result.shouldEqual(ByteArray.fromHex("00010203"));
40+
}
41+
42+
}
43+
44+
}

0 commit comments

Comments
 (0)