Skip to content

Commit b92e447

Browse files
committed
Clean up lint
1 parent 72b66ea commit b92e447

File tree

7 files changed

+18
-64
lines changed

7 files changed

+18
-64
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package com.yubico.webauthn.attestation
2626

27-
import com.fasterxml.jackson.databind.node.JsonNodeFactory
2827
import com.yubico.internal.util.JacksonCodecs
2928
import com.yubico.internal.util.scala.JavaConverters._
3029
import com.yubico.webauthn.TestAuthenticator
@@ -46,8 +45,6 @@ import scala.jdk.CollectionConverters._
4645
@RunWith(classOf[JUnitRunner])
4746
class StandardMetadataServiceSpec extends FunSpec with Matchers {
4847

49-
private def jsonFactory: JsonNodeFactory = JsonNodeFactory.instance
50-
5148
private val TRANSPORTS_EXT_OID = "1.3.6.1.4.1.45724.2.1.1"
5249

5350
private val ooidA = "1.3.6.1.4.1.41482.1.1"
@@ -109,10 +106,6 @@ class StandardMetadataServiceSpec extends FunSpec with Matchers {
109106
caCertAndKey = Some((caCert, caKey)),
110107
extensions = List((ooidB, false, new DEROctetString(Array[Byte]()))),
111108
)
112-
val (unknownCert, _) = TestAuthenticator.generateAttestationCertificate(
113-
name = new X500Name("CN=Unknown Cert"),
114-
extensions = List((ooidA, false, new DEROctetString(Array[Byte]()))),
115-
)
116109

117110
val metadataJson =
118111
s"""{

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ class RelyingPartyAssertionSpec
121121

122122
}
123123

124-
private def getUserHandleIfDefault(
124+
private def getUserHandleIfDefaultUsername(
125125
username: String,
126-
userHandle: ByteArray = Defaults.userHandle,
126+
userHandle: ByteArray,
127127
): Optional[ByteArray] =
128128
if (username == Defaults.username)
129129
Some(userHandle).asJava
130130
else
131131
???
132132

133-
private def getUsernameIfDefault(
133+
private def getUsernameIfDefaultUserHandle(
134134
userHandle: ByteArray,
135-
username: String = Defaults.username,
135+
username: String,
136136
): Optional[String] =
137137
if (userHandle == Defaults.userHandle)
138138
Some(username).asJava
@@ -242,10 +242,16 @@ class RelyingPartyAssertionSpec
242242
override def getCredentialIdsForUsername(username: String) = ???
243243
override def getUserHandleForUsername(username: String)
244244
: Optional[ByteArray] =
245-
getUserHandleIfDefault(username, userHandle = userHandleForUser)
245+
getUserHandleIfDefaultUsername(
246+
username,
247+
userHandle = userHandleForUser,
248+
)
246249
override def getUsernameForUserHandle(userHandle: ByteArray)
247250
: Optional[String] =
248-
getUsernameIfDefault(userHandle, username = usernameForUser)
251+
getUsernameIfDefaultUserHandle(
252+
userHandle,
253+
username = usernameForUser,
254+
)
249255
}
250256
)
251257
.preferredPubkeyParams(Nil.asJava)

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

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class RelyingPartyRegistrationSpec
102102
allowUnrequestedExtensions: Boolean = false,
103103
allowUntrustedAttestation: Boolean = false,
104104
callerTokenBindingId: Option[ByteArray] = None,
105-
credentialId: Option[ByteArray] = None,
106105
credentialRepository: CredentialRepository =
107106
Helpers.CredentialRepository.unimplemented,
108107
metadataService: Option[MetadataService] = None,
@@ -1165,10 +1164,7 @@ class RelyingPartyRegistrationSpec
11651164
val testData = RegistrationTestData.FidoU2f.BasicAttestation
11661165
.editAuthenticatorData { flipByte(index, _) }
11671166

1168-
val steps = finishRegistration(
1169-
testData = testData,
1170-
credentialId = Some(new ByteArray(Array.fill(16)(0))),
1171-
)
1167+
val steps = finishRegistration(testData = testData)
11721168
val step: FinishRegistrationSteps#Step14 = new steps.Step14(
11731169
Crypto.sha256(testData.clientDataJsonBytes),
11741170
new AttestationObject(testData.attestationObject),
@@ -1214,10 +1210,7 @@ class RelyingPartyRegistrationSpec
12141210
) ++ evilPublicKey.getBytes
12151211
)
12161212
}
1217-
val steps = finishRegistration(
1218-
testData = testData,
1219-
credentialId = Some(new ByteArray(Array.fill(16)(0))),
1220-
)
1213+
val steps = finishRegistration(testData = testData)
12211214
val step: FinishRegistrationSteps#Step14 = new steps.Step14(
12221215
Crypto.sha256(testData.clientDataJsonBytes),
12231216
new AttestationObject(testData.attestationObject),
@@ -1259,8 +1252,7 @@ class RelyingPartyRegistrationSpec
12591252
credential.getResponse.getClientDataJSON.getBytes,
12601253
"UTF-8",
12611254
),
1262-
),
1263-
credentialId = Some(credential.getId),
1255+
)
12641256
)
12651257
val step: FinishRegistrationSteps#Step14 =
12661258
steps.begin.next.next.next.next.next.next.next.next.next.next.next.next.next
@@ -1311,8 +1303,7 @@ class RelyingPartyRegistrationSpec
13111303
credential.getResponse.getClientDataJSON.getBytes,
13121304
"UTF-8",
13131305
),
1314-
),
1315-
credentialId = Some(credential.getId),
1306+
)
13161307
)
13171308
val step: FinishRegistrationSteps#Step14 =
13181309
steps.begin.next.next.next.next.next.next.next.next.next.next.next.next.next
@@ -1998,14 +1989,6 @@ class RelyingPartyRegistrationSpec
19981989
IllegalArgumentException
19991990
]
20001991

2001-
val goodCert: X509Certificate = TestAuthenticator
2002-
.generateAttestationCertificate(
2003-
name = new X500Name(
2004-
"O=Yubico, C=SE, OU=Authenticator Attestation"
2005-
),
2006-
extensions = Nil,
2007-
)
2008-
._1
20091992
val goodResult = Try(
20101993
verifier.verifyX5cRequirements(badCert, testDataBase.aaguid)
20111994
)

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package com.yubico.webauthn
2626

27-
import com.fasterxml.jackson.databind.node.JsonNodeFactory
2827
import com.fasterxml.jackson.databind.node.ObjectNode
2928
import com.yubico.internal.util.scala.JavaConverters._
3029
import com.yubico.webauthn.data.AuthenticatorAssertionResponse
@@ -50,8 +49,6 @@ import scala.util.Try
5049
@RunWith(classOf[JUnitRunner])
5150
class RelyingPartyUserIdentificationSpec extends FunSpec with Matchers {
5251

53-
private def jsonFactory: JsonNodeFactory = JsonNodeFactory.instance
54-
5552
private object Defaults {
5653

5754
val rpId =

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

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package com.yubico.webauthn
2626

2727
import com.fasterxml.jackson.databind.JsonNode
28-
import com.fasterxml.jackson.databind.ObjectMapper
2928
import com.fasterxml.jackson.databind.node.JsonNodeFactory
3029
import com.fasterxml.jackson.databind.node.ObjectNode
3130
import com.yubico.internal.util.BinaryUtil
@@ -41,7 +40,6 @@ import com.yubico.webauthn.data.ClientAssertionExtensionOutputs
4140
import com.yubico.webauthn.data.ClientRegistrationExtensionOutputs
4241
import com.yubico.webauthn.data.PublicKeyCredential
4342
import com.yubico.webauthn.data.PublicKeyCredentialRequestOptions
44-
import com.yubico.webauthn.data.UserIdentity
4543
import com.yubico.webauthn.test.Util
4644
import org.bouncycastle.asn1.ASN1ObjectIdentifier
4745
import org.bouncycastle.asn1.ASN1Primitive
@@ -171,8 +169,6 @@ object TestAuthenticator {
171169

172170
private def jsonFactory: JsonNodeFactory = JsonNodeFactory.instance
173171
private def toBytes(s: String): ByteArray = new ByteArray(s.getBytes("UTF-8"))
174-
private def toJson(node: JsonNode): String =
175-
new ObjectMapper().writeValueAsString(node)
176172
private def sha256(s: String): ByteArray = sha256(toBytes(s))
177173
private def sha256(b: ByteArray): ByteArray =
178174
new ByteArray(MessageDigest.getInstance("SHA-256").digest(b.getBytes))
@@ -348,7 +344,7 @@ object TestAuthenticator {
348344
""".stripMargin
349345

350346
def makeAssertionExample(alg: COSEAlgorithmIdentifier): String = {
351-
val (credential, keypair) =
347+
val (_, keypair) =
352348
createCredential(attestationMaker = AttestationMaker.default())
353349
val assertion = createAssertion(alg, credentialKey = keypair)
354350

@@ -383,15 +379,8 @@ object TestAuthenticator {
383379
credentialKeypair: Option[KeyPair] = None,
384380
keyAlgorithm: COSEAlgorithmIdentifier = Defaults.keyAlgorithm,
385381
origin: String = Defaults.origin,
386-
rpId: String = Defaults.rpId,
387382
tokenBindingStatus: String = Defaults.TokenBinding.status,
388383
tokenBindingId: Option[String] = Defaults.TokenBinding.id,
389-
userId: UserIdentity = UserIdentity
390-
.builder()
391-
.name("Test")
392-
.displayName("Test")
393-
.id(new ByteArray(Array(42, 13, 37)))
394-
.build(),
395384
): (
396385
data.PublicKeyCredential[
397386
data.AuthenticatorAttestationResponse,
@@ -452,7 +441,6 @@ object TestAuthenticator {
452441
makeAttestedCredentialDataBytes(
453442
aaguid = aaguid,
454443
publicKeyCose = publicKeyCose,
455-
rpId = Defaults.rpId,
456444
)
457445
),
458446
)
@@ -544,7 +532,6 @@ object TestAuthenticator {
544532
credentialId = testData.response.getId,
545533
credentialKey = testData.keypair.get,
546534
origin = origin,
547-
rpId = testData.rpId.getId,
548535
tokenBindingStatus = tokenBindingStatus,
549536
tokenBindingId = tokenBindingId,
550537
userHandle = if (withUserHandle) Some(testData.userId.getId) else None,
@@ -561,7 +548,6 @@ object TestAuthenticator {
561548
credentialId: ByteArray = Defaults.credentialId,
562549
credentialKey: KeyPair = Defaults.credentialKey,
563550
origin: String = Defaults.origin,
564-
rpId: String = Defaults.rpId,
565551
tokenBindingStatus: String = Defaults.TokenBinding.status,
566552
tokenBindingId: Option[String] = Defaults.TokenBinding.id,
567553
userHandle: Option[ByteArray] = None,
@@ -882,8 +868,6 @@ object TestAuthenticator {
882868

883869
def makeAttestedCredentialDataBytes(
884870
publicKeyCose: ByteArray,
885-
rpId: String = Defaults.rpId,
886-
counterBytes: ByteArray = ByteArray.fromHex("0539"),
887871
aaguid: ByteArray = Defaults.aaguid,
888872
): ByteArray = {
889873
val credentialId = sha256(publicKeyCose)
@@ -1083,7 +1067,7 @@ object TestAuthenticator {
10831067
signingKey: PrivateKey,
10841068
signingAlg: COSEAlgorithmIdentifier,
10851069
isCa: Boolean = false,
1086-
extensions: Iterable[(String, Boolean, ASN1Primitive)] = Nil,
1070+
extensions: Iterable[(String, Boolean, ASN1Primitive)],
10871071
): X509Certificate = {
10881072
CertificateParser.parseDer({
10891073
val builder = new X509v3CertificateBuilder(

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ object Generators {
157157
def fidoU2fAttestationObject: Gen[ByteArray] =
158158
for {
159159
authData <- authenticatorDataBytes
160-
alg <- arbitrary[COSEAlgorithmIdentifier]
161160
sig <- arbitrary[ByteArray]
162161
x5c <- arbitrary[List[ByteArray]]
163162
attStmt =
@@ -506,7 +505,6 @@ object Generators {
506505
name <- arbitrary[String]
507506
icon <- arbitrary[Optional[URL]]
508507
id <- arbitrary[ByteArray]
509-
name <- arbitrary[String]
510508
} yield UserIdentity
511509
.builder()
512510
.name(name)

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import com.yubico.webauthn.extension.appid.AppId
4242
import demo.webauthn.data.AssertionRequestWrapper
4343
import demo.webauthn.data.CredentialRegistration
4444
import demo.webauthn.data.RegistrationRequest
45-
import demo.webauthn.data.RegistrationResponse
4645
import org.junit.runner.RunWith
4746
import org.scalatest.FunSpec
4847
import org.scalatest.Matchers
@@ -95,12 +94,6 @@ class WebAuthnServerSpec extends FunSpec with Matchers {
9594
RegistrationTestData.FidoU2f.BasicAttestation
9695
)
9796

98-
val response = new RegistrationResponse(
99-
requestId,
100-
RegistrationTestData.FidoU2f.BasicAttestation.response,
101-
Optional.empty(),
102-
)
103-
10497
val authenticationAttestationResponseJson =
10598
"""{"attestationObject":"v2hhdXRoRGF0YVikSZYN5YgOjGh0NBcPZHZgW4_krrmihjLHm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