Skip to content

Commit 3f9adac

Browse files
committed
Use Option.map instead of Optional.get
1 parent 1124ea5 commit 3f9adac

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CertificateUtilSpec extends AnyFunSpec with Matchers {
1919
describe("parseFidoSerNumExtension") {
2020
val idFidoGenCeSernum = "1.3.6.1.4.1.45724.1.1.2"
2121
it("should correctly parse the serial number from a valid certificate with the id-fido-gen-ce-sernum extension.") {
22-
val goodCert: X509Certificate = TestAuthenticator
22+
val (cert, _): (X509Certificate, _) = TestAuthenticator
2323
.generateAttestationCertificate(
2424
name = new X500Name(
2525
"O=Yubico, C=SE, OU=Authenticator Attestation"
@@ -32,14 +32,13 @@ class CertificateUtilSpec extends AnyFunSpec with Matchers {
3232
)
3333
),
3434
)
35-
._1
3635

37-
val result = new ByteArray(
36+
val result =
3837
CertificateUtil
39-
.parseFidoSerNumExtension(goodCert)
40-
.get
41-
)
42-
result should equal(ByteArray.fromHex("00010203"))
38+
.parseFidoSerNumExtension(cert)
39+
.toScala
40+
.map(new ByteArray(_))
41+
result should equal(Some(ByteArray.fromHex("00010203")))
4342
}
4443

4544
it("correctly parses the serial number from a real YubiKey enterprise attestation certificate.") {

0 commit comments

Comments
 (0)