Skip to content

Commit 8e7a6b7

Browse files
committed
Address deprecated APIs in Spring Boot 3.4.0
1 parent 04a4675 commit 8e7a6b7

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

webauthn4j-spring-security-core/src/test/java/com/webauthn4j/springframework/security/config/configurers/WebAuthnAuthenticationProviderConfigurerSpringTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
4040

4141
import static org.assertj.core.api.Assertions.assertThat;
42+
import static org.mockito.Mockito.mock;
4243

4344
@RunWith(SpringRunner.class)
4445
public class WebAuthnAuthenticationProviderConfigurerSpringTest {
@@ -55,8 +56,10 @@ public void test() {
5556
@EnableWebSecurity
5657
static class Config {
5758

58-
@MockBean
59-
private WebAuthnCredentialRecordService authenticatorService;
59+
@Bean
60+
public WebAuthnCredentialRecordService webAuthnCredentialRecordService(){
61+
return mock(WebAuthnCredentialRecordService.class);
62+
}
6063

6164
@Bean
6265
public ChallengeRepository challengeRepository() {
@@ -100,8 +103,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
100103
}
101104

102105
@Bean
103-
public AuthenticationManager authenticationManager(){
104-
return new ProviderManager(new WebAuthnAuthenticationProvider(authenticatorService, WebAuthnManager.createNonStrictWebAuthnManager()));
106+
public AuthenticationManager authenticationManager(WebAuthnCredentialRecordService webAuthnCredentialRecordService) {
107+
return new ProviderManager(new WebAuthnAuthenticationProvider(webAuthnCredentialRecordService, WebAuthnManager.createNonStrictWebAuthnManager()));
105108
}
106109

107110
@Bean(name = "mvcHandlerMappingIntrospector")

webauthn4j-spring-security-core/src/test/java/com/webauthn4j/springframework/security/config/configurers/WebAuthnLoginConfigurerSpringTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void attestationOptionsEndpointPath_with_anonymous_user_test() throws Exc
9898
mvc
9999
.perform(get("/webauthn/attestation/options").with(anonymous()))
100100
.andExpect(unauthenticated())
101-
.andExpect(content().json("{\"rp\":{\"id\":\"example.com\",\"name\":\"example\"},\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"pubKeyCredParams\":[{\"type\":\"public-key\",\"alg\":-7},{\"type\":\"public-key\",\"alg\":-65535}],\"timeout\":10000,\"excludeCredentials\":[],\"authenticatorSelection\":{\"authenticatorAttachment\":\"cross-platform\",\"requireResidentKey\":false,\"residentKey\":\"preferred\",\"userVerification\":\"preferred\"},\"attestation\":\"direct\",\"extensions\":{\"uvm\":true,\"credProps\":true,\"extensionProvider\":\"/webauthn/attestation/options\",\"unknown\":true}}", true))
101+
.andExpect(content().json("{\"rp\":{\"id\":\"example.com\",\"name\":\"example\"},\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"pubKeyCredParams\":[{\"type\":\"public-key\",\"alg\":-7},{\"type\":\"public-key\",\"alg\":-65535}],\"timeout\":10000,\"excludeCredentials\":[],\"authenticatorSelection\":{\"authenticatorAttachment\":\"cross-platform\",\"requireResidentKey\":false,\"residentKey\":\"preferred\",\"userVerification\":\"preferred\"},\"attestation\":\"direct\",\"extensions\":{\"uvm\":true,\"credProps\":true,\"extensionProvider\":\"/webauthn/attestation/options\",\"unknown\":true}}"))
102102
.andExpect(status().isOk());
103103
}
104104

@@ -111,7 +111,7 @@ public void assertionOptionsEndpointPath_with_anonymous_user_test() throws Excep
111111
mvc
112112
.perform(get("/webauthn/assertion/options").with(anonymous()))
113113
.andExpect(unauthenticated())
114-
.andExpect(content().json("{\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"timeout\":20000,\"rpId\":\"example.com\",\"allowCredentials\":[],\"userVerification\":\"preferred\",\"extensions\":{\"appid\":\"appid\",\"appidExclude\":\"appidExclude\",\"uvm\":true,\"extensionProvider\":\"/webauthn/assertion/options\",\"unknown\":true}}", true))
114+
.andExpect(content().json("{\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"timeout\":20000,\"rpId\":\"example.com\",\"allowCredentials\":[],\"userVerification\":\"preferred\",\"extensions\":{\"appid\":\"appid\",\"appidExclude\":\"appidExclude\",\"uvm\":true,\"extensionProvider\":\"/webauthn/assertion/options\",\"unknown\":true}}"))
115115
.andExpect(status().isOk());
116116
}
117117

@@ -138,7 +138,7 @@ public void attestationOptionsEndpointPath_with_authenticated_user_test() throws
138138
mvc
139139
.perform(get("/webauthn/attestation/options").with(user("john")))
140140
.andExpect(authenticated())
141-
.andExpect(content().json("{\"rp\":{\"id\":\"example.com\",\"name\":\"example\"},\"user\":{\"id\":\"am9obg\",\"name\":\"john\",\"displayName\":\"john\"},\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"pubKeyCredParams\":[{\"type\":\"public-key\",\"alg\":-7},{\"type\":\"public-key\",\"alg\":-65535}],\"timeout\":10000,\"excludeCredentials\":[],\"authenticatorSelection\":{\"authenticatorAttachment\":\"cross-platform\",\"requireResidentKey\":false,\"residentKey\":\"preferred\",\"userVerification\":\"preferred\"},\"attestation\":\"direct\",\"extensions\":{\"uvm\":true,\"credProps\":true,\"extensionProvider\":\"/webauthn/attestation/options\",\"unknown\":true}}", true))
141+
.andExpect(content().json("{\"rp\":{\"id\":\"example.com\",\"name\":\"example\"},\"user\":{\"id\":\"am9obg\",\"name\":\"john\",\"displayName\":\"john\"},\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"pubKeyCredParams\":[{\"type\":\"public-key\",\"alg\":-7},{\"type\":\"public-key\",\"alg\":-65535}],\"timeout\":10000,\"excludeCredentials\":[],\"authenticatorSelection\":{\"authenticatorAttachment\":\"cross-platform\",\"requireResidentKey\":false,\"residentKey\":\"preferred\",\"userVerification\":\"preferred\"},\"attestation\":\"direct\",\"extensions\":{\"uvm\":true,\"credProps\":true,\"extensionProvider\":\"/webauthn/attestation/options\",\"unknown\":true}}"))
142142
.andExpect(status().isOk());
143143
}
144144

@@ -154,7 +154,7 @@ public void assertionOptionsEndpointPath_with_authenticated_user_test() throws E
154154
.andDo(item ->
155155
item.getResponse().getContentAsString()
156156
)
157-
.andExpect(content().json("{\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"timeout\":20000,\"rpId\":\"example.com\",\"allowCredentials\":[],\"userVerification\":\"preferred\",\"extensions\":{\"appid\":\"appid\",\"appidExclude\":\"appidExclude\",\"uvm\":true,\"extensionProvider\":\"/webauthn/assertion/options\",\"unknown\":true}}", true))
157+
.andExpect(content().json("{\"challenge\":\"aFglXMZdQTKD4krvNzJBzA\",\"timeout\":20000,\"rpId\":\"example.com\",\"allowCredentials\":[],\"userVerification\":\"preferred\",\"extensions\":{\"appid\":\"appid\",\"appidExclude\":\"appidExclude\",\"uvm\":true,\"extensionProvider\":\"/webauthn/assertion/options\",\"unknown\":true}}"))
158158
.andExpect(status().isOk());
159159
}
160160

0 commit comments

Comments
 (0)