Skip to content

Commit 378833c

Browse files
committed
Test WebAuthn deserializer with unknown primitive ext
Signed-off-by: Ziqin Wang <ziqin@wangziqin.net>
1 parent e118133 commit 378833c

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

webauthn/src/test/java/org/springframework/security/web/webauthn/jackson/Jackson2Tests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,23 @@ void readCredPropsWhenAuthenticatorDisplayName() throws Exception {
122122
assertThat(outputs).usingRecursiveComparison().isEqualTo(credProps);
123123
}
124124

125+
@Test
126+
void readAuthenticationExtensionsClientOutputsWhenAppId() throws Exception {
127+
String json = """
128+
{
129+
"appid": false,
130+
"credProps": {
131+
"rk": false
132+
}
133+
}
134+
""";
135+
CredentialPropertiesOutput credProps = new CredentialPropertiesOutput(false);
136+
137+
AuthenticationExtensionsClientOutputs outputs = this.mapper.readValue(json,
138+
AuthenticationExtensionsClientOutputs.class);
139+
assertThat(outputs.getOutputs()).usingRecursiveFieldByFieldElementComparator().contains(credProps);
140+
}
141+
125142
@Test
126143
void readAuthenticationExtensionsClientOutputsWhenUnknownExtension() throws Exception {
127144
String json = """

webauthn/src/test/java/org/springframework/security/web/webauthn/jackson/JacksonTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,23 @@ void readCredPropsWhenAuthenticatorDisplayName() throws Exception {
121121
assertThat(outputs).usingRecursiveComparison().isEqualTo(credProps);
122122
}
123123

124+
@Test
125+
void readAuthenticationExtensionsClientOutputsWhenAppId() {
126+
String json = """
127+
{
128+
"appid": false,
129+
"credProps": {
130+
"rk": false
131+
}
132+
}
133+
""";
134+
CredentialPropertiesOutput credProps = new CredentialPropertiesOutput(false);
135+
136+
AuthenticationExtensionsClientOutputs outputs = this.mapper.readValue(json,
137+
AuthenticationExtensionsClientOutputs.class);
138+
assertThat(outputs.getOutputs()).usingRecursiveFieldByFieldElementComparator().contains(credProps);
139+
}
140+
124141
@Test
125142
void readAuthenticationExtensionsClientOutputsWhenUnknownExtension() {
126143
String json = """

0 commit comments

Comments
 (0)