Skip to content

Commit a76ce91

Browse files
committed
Delete/fix unused code
1 parent ac9f519 commit a76ce91

File tree

6 files changed

+20
-60
lines changed

6 files changed

+20
-60
lines changed

webauthn-server-attestation/src/integrationTest/scala/com/yubico/fido/metadata/FidoMetadataServiceIntegrationTest.scala

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.yubico.fido.metadata
22

3-
import com.fasterxml.jackson.databind.JsonNode
43
import com.yubico.fido.metadata.AttachmentHint.ATTACHMENT_HINT_EXTERNAL
54
import com.yubico.fido.metadata.AttachmentHint.ATTACHMENT_HINT_INTERNAL
65
import com.yubico.fido.metadata.AttachmentHint.ATTACHMENT_HINT_NFC
@@ -10,7 +9,6 @@ import com.yubico.internal.util.CertificateParser
109
import com.yubico.webauthn.FinishRegistrationOptions
1110
import com.yubico.webauthn.RelyingParty
1211
import com.yubico.webauthn.TestWithEachProvider
13-
import com.yubico.webauthn.data.AttestationObject
1412
import com.yubico.webauthn.test.Helpers
1513
import com.yubico.webauthn.test.RealExamples
1614
import org.bouncycastle.jce.provider.BouncyCastleProvider
@@ -22,13 +20,9 @@ import org.scalatest.tags.Network
2220
import org.scalatest.tags.Slow
2321
import org.scalatestplus.junit.JUnitRunner
2422

25-
import java.io.IOException
26-
import java.security.cert.X509Certificate
2723
import java.time.Clock
2824
import java.time.ZoneOffset
29-
import java.util
3025
import java.util.Optional
31-
import scala.jdk.CollectionConverters.IteratorHasAsScala
3226
import scala.jdk.CollectionConverters.SetHasAsJava
3327
import scala.jdk.CollectionConverters.SetHasAsScala
3428
import scala.jdk.OptionConverters.RichOptional
@@ -76,40 +70,6 @@ class FidoMetadataServiceIntegrationTest
7670
attachmentHints: Set[AttachmentHint],
7771
): Unit = {
7872

79-
def getAttestationTrustPath(
80-
attestationObject: AttestationObject
81-
): Option[util.List[X509Certificate]] = {
82-
val x5cNode: JsonNode = getX5cArray(attestationObject)
83-
if (x5cNode != null && x5cNode.isArray) {
84-
val certs: util.List[X509Certificate] =
85-
new util.ArrayList[X509Certificate](x5cNode.size)
86-
for (binary <- x5cNode.elements().asScala) {
87-
if (binary.isBinary)
88-
try certs.add(
89-
CertificateParser.parseDer(binary.binaryValue)
90-
)
91-
catch {
92-
case e: IOException =>
93-
throw new RuntimeException(
94-
"binary.isBinary() was true but binary.binaryValue() failed",
95-
e,
96-
)
97-
}
98-
else
99-
throw new IllegalArgumentException(
100-
String.format(
101-
"Each element of \"x5c\" property of attestation statement must be a binary value, was: %s",
102-
binary.getNodeType,
103-
)
104-
)
105-
}
106-
Some(certs)
107-
} else None
108-
}
109-
110-
def getX5cArray(attestationObject: AttestationObject): JsonNode =
111-
attestationObject.getAttestationStatement.get("x5c")
112-
11373
val rp = RelyingParty
11474
.builder()
11575
.identity(testData.rp)

webauthn-server-attestation/src/test/scala/com/yubico/fido/metadata/FidoMds3Spec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ class FidoMds3Spec extends AnyFunSpec with Matchers {
622622
def makeStatusReportsBlob(
623623
statusReports: String,
624624
timeOfLastStatusChange: String,
625-
authenticatorVersion: Int = 1,
625+
authenticatorVersion: Int,
626626
): (String, X509Certificate, java.util.Set[CRL]) =
627627
makeBlob(s"""{
628628
"legalHeader" : "Kom ihåg att du aldrig får snyta dig i mattan!",

webauthn-server-core/src/test/scala/com/yubico/webauthn/RelyingPartyRegistrationSpec.scala

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,13 @@ class RelyingPartyRegistrationSpec
235235

236236
describe("3. Let response be credential.response.") {
237237
it("If response is not an instance of AuthenticatorAttestationResponse, abort the ceremony with a user-visible error.") {
238+
val testData = RegistrationTestData.Packed.BasicAttestationEdDsa
238239
val frob = FinishRegistrationOptions
239240
.builder()
240-
.request(
241-
RegistrationTestData.Packed.BasicAttestationEdDsa.request
242-
)
243-
val testData =
244-
RegistrationTestData.Packed.BasicAttestationEdDsa.assertion.get
245-
"frob.response(testData.response)" shouldNot compile
246-
frob
247-
.response(
248-
RegistrationTestData.Packed.BasicAttestationEdDsa.response
249-
)
250-
.build() should not be null
241+
.request(testData.request)
242+
"frob.response(testData.response)" should compile
243+
"frob.response(testData.assertion.get.response)" shouldNot compile
244+
frob.response(testData.response).build() should not be null
251245
}
252246
}
253247

webauthn-server-core/src/test/scala/com/yubico/webauthn/WebAuthnCodecsSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class WebAuthnCodecsSpec
4848
Arbitrary(
4949
for {
5050
ySign: Byte <- Gen.oneOf(0x02: Byte, 0x03: Byte)
51-
rawBytes: Seq[Byte] <- Gen.listOfN[Byte](32, Arbitrary.arbitrary[Byte])
51+
rawBytes <- Gen.listOfN[Byte](32, Arbitrary.arbitrary[Byte])
5252
key = Try(
5353
Util
5454
.decodePublicKey(new ByteArray((ySign +: rawBytes).toArray))

webauthn-server-core/src/test/scala/com/yubico/webauthn/data/Generators.scala

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ object Generators {
360360
Set("appidExclude", "credProps", "largeBlob", "uvm")
361361
private val AuthenticationExtensionIds: Set[String] =
362362
Set("appid", "largeBlob", "uvm")
363-
private val ExtensionIds: Set[String] =
364-
RegistrationExtensionIds ++ AuthenticationExtensionIds
365363

366364
private val ClientRegistrationExtensionOutputIds: Set[String] =
367365
RegistrationExtensionIds - "uvm"
@@ -445,12 +443,16 @@ object Generators {
445443
)
446444

447445
def authenticatorRegistrationExtensionOutputs(
448-
uvmGen: Gen[Option[CBORObject]] = Gen.option(Uvm.authenticatorOutput)
446+
uvmGen: Gen[Option[CBORObject]] = Gen.option(Uvm.authenticatorOutput),
447+
includeUnknown: Boolean = true,
449448
): Gen[CBORObject] =
450449
for {
450+
base <-
451+
if (includeUnknown) unknownAuthenticatorRegistrationExtensionOutput
452+
else Gen.const(CBORObject.NewMap())
451453
uvm: Option[CBORObject] <- uvmGen
452454
} yield {
453-
val result = CBORObject.NewMap()
455+
val result = base
454456
uvm.foreach(result.set("uvm", _))
455457
result
456458
}
@@ -511,12 +513,16 @@ object Generators {
511513
}
512514

513515
def authenticatorAssertionExtensionOutputs(
514-
uvmGen: Gen[Option[CBORObject]] = Gen.option(Uvm.authenticatorOutput)
516+
uvmGen: Gen[Option[CBORObject]] = Gen.option(Uvm.authenticatorOutput),
517+
includeUnknown: Boolean = true,
515518
): Gen[CBORObject] =
516519
for {
520+
base <-
521+
if (includeUnknown) unknownAuthenticatorAssertionExtensionOutput
522+
else Gen.const(CBORObject.NewMap())
517523
uvm: Option[CBORObject] <- uvmGen
518524
} yield {
519-
val result = CBORObject.NewMap()
525+
val result = base
520526
uvm.foreach(result.set("uvm", _))
521527
result
522528
}

webauthn-server-demo/src/test/scala/demo/webauthn/WebAuthnServerSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class WebAuthnServerSpec
251251

252252
def newServerWithAuthenticationRequest(
253253
testData: RegistrationTestData,
254-
signatureCount: Option[Long] = None,
254+
signatureCount: Option[Long],
255255
) = {
256256
val assertionRequests: Cache[ByteArray, AssertionRequestWrapper] =
257257
newCache()

0 commit comments

Comments
 (0)