Skip to content

Commit 57d7211

Browse files
committed
Fix tests failing due to spring-framework#25981
1 parent b43086d commit 57d7211

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

spring-boot-admin-server-ui/src/main/java/de/codecentric/boot/admin/server/ui/web/UiController.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import java.util.List;
2121
import java.util.Map;
2222

23-
import javax.annotation.Nullable;
24-
2523
import com.fasterxml.jackson.annotation.JsonInclude;
2624
import com.fasterxml.jackson.annotation.JsonInclude.Include;
2725
import org.springframework.boot.context.properties.ConstructorBinding;
@@ -89,7 +87,11 @@ public List<UiExtension> getJsExtensions() {
8987
}
9088

9189
@ModelAttribute(value = "user", binding = false)
92-
public Map<String, Object> getUser(@Nullable Principal principal) {
90+
public Map<String, Object> getUser(
91+
/*
92+
* @Nullable FIXME:
93+
* https://github.com/spring-projects/spring-framework/issues/25981
94+
*/ Principal principal) {
9395
if (principal != null) {
9496
return singletonMap("name", principal.getName());
9597
}

spring-boot-admin-server-ui/src/test/java/de/codecentric/boot/admin/server/ui/AdminUiServletApplicationTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static class SecurityConfiguration extends WebSecurityConfigurerAdapter {
5959
@Override
6060
protected void configure(HttpSecurity http) throws Exception {
6161
http.authorizeRequests().anyRequest().permitAll()//
62-
.and().csrf().disable();
62+
.and().csrf().disable().anonymous().principal("anonymousUser");
6363
}
6464

6565
}

spring-boot-admin-server-ui/src/test/java/de/codecentric/boot/admin/server/ui/web/UiControllerTest.java

+1-19
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,9 @@
1616

1717
package de.codecentric.boot.admin.server.ui.web;
1818

19-
import java.security.Principal;
20-
2119
import org.junit.jupiter.api.Test;
22-
import org.springframework.core.MethodParameter;
2320
import org.springframework.test.web.servlet.MockMvc;
2421
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
25-
import org.springframework.web.bind.support.WebDataBinderFactory;
26-
import org.springframework.web.context.request.NativeWebRequest;
27-
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
28-
import org.springframework.web.method.support.ModelAndViewContainer;
2922

3023
import de.codecentric.boot.admin.server.ui.extensions.UiExtensions;
3124
import de.codecentric.boot.admin.server.web.servlet.AdminControllerHandlerMapping;
@@ -73,18 +66,7 @@ private MockMvc setupController(String publicUrl) {
7366
return MockMvcBuilders
7467
.standaloneSetup(
7568
new UiController(publicUrl, UiExtensions.EMPTY, UiController.Settings.builder().build()))
76-
.setCustomArgumentResolvers(new HandlerMethodArgumentResolver() {
77-
@Override
78-
public boolean supportsParameter(MethodParameter parameter) {
79-
return parameter.getParameterType().equals(Principal.class);
80-
}
81-
82-
@Override
83-
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
84-
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
85-
return null;
86-
}
87-
}).setCustomHandlerMapping(() -> new AdminControllerHandlerMapping("")).build();
69+
.setCustomHandlerMapping(() -> new AdminControllerHandlerMapping("")).build();
8870
}
8971

9072
}

0 commit comments

Comments
 (0)