Skip to content

Commit 76119b9

Browse files
committed
Test that 1023 bytes long credential IDs are supported
1 parent b3cc7fc commit 76119b9

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3553,8 +3553,57 @@ class RelyingPartyRegistrationSpec
35533553
}
35543554

35553555
describe("RelyingParty.finishRegistration") {
3556-
it("throws RegistrationFailedException in case of errors.") {
3556+
it("supports 1023 bytes long credential IDs.") {
3557+
val rp = RelyingParty
3558+
.builder()
3559+
.identity(
3560+
RelyingPartyIdentity
3561+
.builder()
3562+
.id("localhost")
3563+
.name("Test party")
3564+
.build()
3565+
)
3566+
.credentialRepository(Helpers.CredentialRepository.empty)
3567+
.build()
35573568

3569+
val pkcco = rp.startRegistration(
3570+
StartRegistrationOptions
3571+
.builder()
3572+
.user(
3573+
UserIdentity
3574+
.builder()
3575+
.name("test")
3576+
.displayName("Test Testsson")
3577+
.id(new ByteArray(Array()))
3578+
.build()
3579+
)
3580+
.build()
3581+
)
3582+
3583+
forAll(byteArray(1023)) { credId =>
3584+
val credential = TestAuthenticator
3585+
.createUnattestedCredential(challenge = pkcco.getChallenge)
3586+
._1
3587+
.toBuilder()
3588+
.id(credId)
3589+
.build()
3590+
3591+
val result = Try(
3592+
rp.finishRegistration(
3593+
FinishRegistrationOptions
3594+
.builder()
3595+
.request(pkcco)
3596+
.response(credential)
3597+
.build()
3598+
)
3599+
)
3600+
result shouldBe a[Success[_]]
3601+
result.get.getKeyId.getId should equal(credId)
3602+
result.get.getKeyId.getId.size should be(1023)
3603+
}
3604+
}
3605+
3606+
it("throws RegistrationFailedException in case of errors.") {
35583607
val rp = RelyingParty
35593608
.builder()
35603609
.identity(

0 commit comments

Comments
 (0)