Skip to content

Commit a67ac4a

Browse files
committed
Add tests of hints in RelyingPartyV2.startAssertion
1 parent 8a7ce19 commit a67ac4a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,59 @@ class RelyingPartyStartOperationSpec
15961596
}
15971597
}
15981598

1599+
describe("allows setting the hints") {
1600+
val rp = relyingParty(userId = userId)
1601+
1602+
it("to string values in the spec or not.") {
1603+
val pkcro = rp.startAssertion(
1604+
StartAssertionOptions
1605+
.builder()
1606+
.hints("hej", "security-key", "hoj", "client-device", "hybrid")
1607+
.build()
1608+
)
1609+
pkcro.getPublicKeyCredentialRequestOptions.getHints.asScala should equal(
1610+
List(
1611+
"hej",
1612+
PublicKeyCredentialHint.SECURITY_KEY.getValue,
1613+
"hoj",
1614+
PublicKeyCredentialHint.CLIENT_DEVICE.getValue,
1615+
PublicKeyCredentialHint.HYBRID.getValue,
1616+
)
1617+
)
1618+
}
1619+
1620+
it("to PublicKeyCredentialHint values in the spec or not.") {
1621+
val pkcro = rp.startAssertion(
1622+
StartAssertionOptions
1623+
.builder()
1624+
.hints(
1625+
PublicKeyCredentialHint.of("hej"),
1626+
PublicKeyCredentialHint.HYBRID,
1627+
PublicKeyCredentialHint.SECURITY_KEY,
1628+
PublicKeyCredentialHint.of("hoj"),
1629+
PublicKeyCredentialHint.CLIENT_DEVICE,
1630+
)
1631+
.build()
1632+
)
1633+
pkcro.getPublicKeyCredentialRequestOptions.getHints.asScala should equal(
1634+
List(
1635+
"hej",
1636+
PublicKeyCredentialHint.HYBRID.getValue,
1637+
PublicKeyCredentialHint.SECURITY_KEY.getValue,
1638+
"hoj",
1639+
PublicKeyCredentialHint.CLIENT_DEVICE.getValue,
1640+
)
1641+
)
1642+
}
1643+
1644+
it("or not, defaulting to the empty list.") {
1645+
val pkcro = rp.startAssertion(StartAssertionOptions.builder().build())
1646+
pkcro.getPublicKeyCredentialRequestOptions.getHints.asScala should equal(
1647+
List()
1648+
)
1649+
}
1650+
}
1651+
15991652
it("allows setting the timeout to empty.") {
16001653
val req = relyingParty(userId = userId).startAssertion(
16011654
StartAssertionOptions

0 commit comments

Comments
 (0)