Skip to content

Commit f0da07b

Browse files
committed
Rename tests of PublicKeyCredential parsing functions
1 parent e7d84a7 commit f0da07b

File tree

1 file changed

+48
-46
lines changed

1 file changed

+48
-46
lines changed

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

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -133,52 +133,6 @@ class JsonIoSpec
133133
}
134134

135135
describe("The class PublicKeyCredential") {
136-
it(
137-
"has an alternative parseRegistrationResponseJson function as an alias."
138-
) {
139-
def test[A](tpe: TypeReference[A])(implicit a: Arbitrary[A]): Unit = {
140-
forAll { value: A =>
141-
val encoded: String = json.writeValueAsString(value)
142-
val decoded: A = json.readValue(encoded, tpe)
143-
val altDecoded =
144-
PublicKeyCredential.parseRegistrationResponseJson(encoded)
145-
val altRecoded: String = json.writeValueAsString(altDecoded)
146-
147-
altDecoded should equal(decoded)
148-
altRecoded should equal(encoded)
149-
}
150-
}
151-
test(
152-
new TypeReference[PublicKeyCredential[
153-
AuthenticatorAttestationResponse,
154-
ClientRegistrationExtensionOutputs,
155-
]]() {}
156-
)
157-
}
158-
159-
it(
160-
"has an alternative parseAuthenticationResponseJson function as an alias."
161-
) {
162-
def test[A](tpe: TypeReference[A])(implicit a: Arbitrary[A]): Unit = {
163-
forAll { value: A =>
164-
val encoded: String = json.writeValueAsString(value)
165-
val decoded: A = json.readValue(encoded, tpe)
166-
val altDecoded =
167-
PublicKeyCredential.parseAssertionResponseJson(encoded)
168-
val altRecoded: String = json.writeValueAsString(altDecoded)
169-
170-
altDecoded should equal(decoded)
171-
altRecoded should equal(encoded)
172-
}
173-
}
174-
test(
175-
new TypeReference[PublicKeyCredential[
176-
AuthenticatorAssertionResponse,
177-
ClientAssertionExtensionOutputs,
178-
]]() {}
179-
)
180-
}
181-
182136
it("allows rawId to be present without id.") {
183137
def test[P <: PublicKeyCredential[_, _]](tpe: TypeReference[P])(implicit
184138
a: Arbitrary[P]
@@ -416,6 +370,54 @@ class JsonIoSpec
416370
}
417371
}
418372

373+
describe("The function PublicKeyCredential.parseRegistrationResponseJson") {
374+
it("can parse registration responses.") {
375+
def test[A](tpe: TypeReference[A])(implicit a: Arbitrary[A]): Unit = {
376+
forAll { value: A =>
377+
val encoded: String = json.writeValueAsString(value)
378+
val decoded: A = json.readValue(encoded, tpe)
379+
val altDecoded =
380+
PublicKeyCredential.parseRegistrationResponseJson(encoded)
381+
val altRecoded: String = json.writeValueAsString(altDecoded)
382+
383+
altDecoded should equal(decoded)
384+
altRecoded should equal(encoded)
385+
}
386+
}
387+
388+
test(
389+
new TypeReference[PublicKeyCredential[
390+
AuthenticatorAttestationResponse,
391+
ClientRegistrationExtensionOutputs,
392+
]]() {}
393+
)
394+
}
395+
}
396+
397+
describe("The function PublicKeyCredential.parseAssertionResponseJson") {
398+
it("can parse assertion responses.") {
399+
def test[A](tpe: TypeReference[A])(implicit a: Arbitrary[A]): Unit = {
400+
forAll { value: A =>
401+
val encoded: String = json.writeValueAsString(value)
402+
val decoded: A = json.readValue(encoded, tpe)
403+
val altDecoded =
404+
PublicKeyCredential.parseAssertionResponseJson(encoded)
405+
val altRecoded: String = json.writeValueAsString(altDecoded)
406+
407+
altDecoded should equal(decoded)
408+
altRecoded should equal(encoded)
409+
}
410+
}
411+
412+
test(
413+
new TypeReference[PublicKeyCredential[
414+
AuthenticatorAssertionResponse,
415+
ClientAssertionExtensionOutputs,
416+
]]() {}
417+
)
418+
}
419+
}
420+
419421
describe("The class PublicKeyCredentialCreationOptions") {
420422
it("""has a toCredentialsCreateJson() method which returns a JSON object with the PublicKeyCredentialCreationOptions set as a top-level "publicKey" property.""") {
421423
forAll { pkcco: PublicKeyCredentialCreationOptions =>

0 commit comments

Comments
 (0)