Skip to content

Commit 51c6a62

Browse files
committed
gradle spotlessApply
1 parent a09e2fd commit 51c6a62

38 files changed

+6174
-3205
lines changed

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

Lines changed: 84 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -24,65 +24,89 @@
2424

2525
package com.yubico.webauthn.attestation
2626

27-
import java.util.Collections
28-
2927
import com.yubico.internal.util.CertificateParser
3028
import com.yubico.internal.util.JacksonCodecs
31-
import com.yubico.webauthn.attestation.resolver.SimpleAttestationResolver
32-
import com.yubico.webauthn.attestation.resolver.SimpleTrustResolver
33-
import com.yubico.webauthn.test.RealExamples
3429
import com.yubico.webauthn.FinishRegistrationOptions
3530
import com.yubico.webauthn.RelyingParty
3631
import com.yubico.webauthn.attestation.Transport.LIGHTNING
3732
import com.yubico.webauthn.attestation.Transport.NFC
3833
import com.yubico.webauthn.attestation.Transport.USB
34+
import com.yubico.webauthn.attestation.resolver.SimpleAttestationResolver
35+
import com.yubico.webauthn.attestation.resolver.SimpleTrustResolver
3936
import com.yubico.webauthn.data.PublicKeyCredentialCreationOptions
4037
import com.yubico.webauthn.data.PublicKeyCredentialParameters
4138
import com.yubico.webauthn.test.Helpers
39+
import com.yubico.webauthn.test.RealExamples
4240
import org.junit.runner.RunWith
4341
import org.scalatest.FunSpec
4442
import org.scalatest.Matchers
4543
import org.scalatestplus.junit.JUnitRunner
4644

45+
import java.util.Collections
4746
import scala.jdk.CollectionConverters._
4847

49-
5048
@RunWith(classOf[JUnitRunner])
5149
class DeviceIdentificationSpec extends FunSpec with Matchers {
5250

5351
def metadataService(metadataJson: String): StandardMetadataService = {
54-
val metadata = Collections.singleton(JacksonCodecs.json().readValue(metadataJson, classOf[MetadataObject]))
52+
val metadata = Collections.singleton(
53+
JacksonCodecs.json().readValue(metadataJson, classOf[MetadataObject])
54+
)
5555
new StandardMetadataService(
56-
new SimpleAttestationResolver(metadata, SimpleTrustResolver.fromMetadata(metadata))
56+
new SimpleAttestationResolver(
57+
metadata,
58+
SimpleTrustResolver.fromMetadata(metadata),
59+
)
5760
)
5861
}
5962

6063
describe("A RelyingParty with the default StandardMetadataService") {
6164

6265
describe("correctly identifies") {
63-
def check(expectedName: String, testData: RealExamples.Example, transports: Set[Transport]): Unit = {
64-
val rp = RelyingParty.builder()
66+
def check(
67+
expectedName: String,
68+
testData: RealExamples.Example,
69+
transports: Set[Transport],
70+
): Unit = {
71+
val rp = RelyingParty
72+
.builder()
6573
.identity(testData.rp)
6674
.credentialRepository(Helpers.CredentialRepository.empty)
6775
.metadataService(new StandardMetadataService())
6876
.build()
6977

70-
val result = rp.finishRegistration(FinishRegistrationOptions.builder()
71-
.request(PublicKeyCredentialCreationOptions.builder()
72-
.rp(testData.rp)
73-
.user(testData.user)
74-
.challenge(testData.attestation.challenge)
75-
.pubKeyCredParams(List(PublicKeyCredentialParameters.ES256).asJava)
76-
.build())
77-
.response(testData.attestation.credential)
78-
.build());
78+
val result = rp.finishRegistration(
79+
FinishRegistrationOptions
80+
.builder()
81+
.request(
82+
PublicKeyCredentialCreationOptions
83+
.builder()
84+
.rp(testData.rp)
85+
.user(testData.user)
86+
.challenge(testData.attestation.challenge)
87+
.pubKeyCredParams(
88+
List(PublicKeyCredentialParameters.ES256).asJava
89+
)
90+
.build()
91+
)
92+
.response(testData.attestation.credential)
93+
.build()
94+
);
7995

80-
result.isAttestationTrusted should be (true)
81-
result.getAttestationMetadata.isPresent should be (true)
82-
result.getAttestationMetadata.get.getDeviceProperties.isPresent should be (true)
83-
result.getAttestationMetadata.get.getDeviceProperties.get().get("displayName") should equal (expectedName)
84-
result.getAttestationMetadata.get.getTransports.isPresent should be (true)
85-
result.getAttestationMetadata.get.getTransports.get.asScala should equal (transports)
96+
result.isAttestationTrusted should be(true)
97+
result.getAttestationMetadata.isPresent should be(true)
98+
result.getAttestationMetadata.get.getDeviceProperties.isPresent should be(
99+
true
100+
)
101+
result.getAttestationMetadata.get.getDeviceProperties
102+
.get()
103+
.get("displayName") should equal(expectedName)
104+
result.getAttestationMetadata.get.getTransports.isPresent should be(
105+
true
106+
)
107+
result.getAttestationMetadata.get.getTransports.get.asScala should equal(
108+
transports
109+
)
86110
}
87111

88112
it("a YubiKey NEO.") {
@@ -98,7 +122,11 @@ class DeviceIdentificationSpec extends FunSpec with Matchers {
98122
check("YubiKey 5 NFC", RealExamples.YubiKey5Nfc, Set(USB, NFC))
99123
}
100124
it("a newer YubiKey 5 NFC.") {
101-
check("YubiKey 5/5C NFC", RealExamples.YubiKey5NfcPost5cNfc, Set(USB, NFC))
125+
check(
126+
"YubiKey 5/5C NFC",
127+
RealExamples.YubiKey5NfcPost5cNfc,
128+
Set(USB, NFC),
129+
)
102130
}
103131
it("a YubiKey 5C NFC.") {
104132
check("YubiKey 5/5C NFC", RealExamples.YubiKey5cNfc, Set(USB, NFC))
@@ -116,21 +144,33 @@ class DeviceIdentificationSpec extends FunSpec with Matchers {
116144
check("Security Key by Yubico", RealExamples.SecurityKey2, Set(USB))
117145
}
118146
it("a Security Key NFC by Yubico.") {
119-
check("Security Key NFC by Yubico", RealExamples.SecurityKeyNfc, Set(USB, NFC))
147+
check(
148+
"Security Key NFC by Yubico",
149+
RealExamples.SecurityKeyNfc,
150+
Set(USB, NFC),
151+
)
120152
}
121153
}
122154
}
123155

124156
describe("The default AttestationResolver") {
125157
describe("successfully identifies") {
126-
def check(expectedName: String, testData: RealExamples.Example, transports: Set[Transport]): Unit = {
158+
def check(
159+
expectedName: String,
160+
testData: RealExamples.Example,
161+
transports: Set[Transport],
162+
): Unit = {
127163
val cert = CertificateParser.parseDer(testData.attestationCert.getBytes)
128-
val resolved = StandardMetadataService.createDefaultAttestationResolver().resolve(cert)
129-
resolved.isPresent should be (true)
130-
resolved.get.getDeviceProperties.isPresent should be (true)
131-
resolved.get.getDeviceProperties.get.get("displayName") should equal (expectedName)
132-
resolved.get.getTransports.isPresent should be (true)
133-
resolved.get.getTransports.get.asScala should equal (transports)
164+
val resolved = StandardMetadataService
165+
.createDefaultAttestationResolver()
166+
.resolve(cert)
167+
resolved.isPresent should be(true)
168+
resolved.get.getDeviceProperties.isPresent should be(true)
169+
resolved.get.getDeviceProperties.get.get("displayName") should equal(
170+
expectedName
171+
)
172+
resolved.get.getTransports.isPresent should be(true)
173+
resolved.get.getTransports.get.asScala should equal(transports)
134174
}
135175

136176
it("a YubiKey NEO.") {
@@ -146,7 +186,11 @@ class DeviceIdentificationSpec extends FunSpec with Matchers {
146186
check("YubiKey 5 NFC", RealExamples.YubiKey5Nfc, Set(USB, NFC))
147187
}
148188
it("a newer YubiKey 5 NFC.") {
149-
check("YubiKey 5/5C NFC", RealExamples.YubiKey5NfcPost5cNfc, Set(USB, NFC))
189+
check(
190+
"YubiKey 5/5C NFC",
191+
RealExamples.YubiKey5NfcPost5cNfc,
192+
Set(USB, NFC),
193+
)
150194
}
151195
it("a YubiKey 5C NFC.") {
152196
check("YubiKey 5/5C NFC", RealExamples.YubiKey5cNfc, Set(USB, NFC))
@@ -164,7 +208,11 @@ class DeviceIdentificationSpec extends FunSpec with Matchers {
164208
check("Security Key by Yubico", RealExamples.SecurityKey2, Set(USB))
165209
}
166210
it("a Security Key NFC by Yubico.") {
167-
check("Security Key NFC by Yubico", RealExamples.SecurityKeyNfc, Set(USB, NFC))
211+
check(
212+
"Security Key NFC by Yubico",
213+
RealExamples.SecurityKeyNfc,
214+
Set(USB, NFC),
215+
)
168216
}
169217
}
170218
}

0 commit comments

Comments
 (0)