Skip to content

Commit 7e43be2

Browse files
Copilotmshabarovtepi
authored
feat: Make RequestUtil#getUrlMapping public for manual security configuration (#22446)
* Initial plan * Make RequestUtil#getUrlMapping public method with documentation and tests Co-authored-by: mshabarov <61410877+mshabarov@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mshabarov <61410877+mshabarov@users.noreply.github.com> Co-authored-by: Teppo Kurki <teppo.kurki@vaadin.com>
1 parent 9c9f5ac commit 7e43be2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

vaadin-spring/src/main/java/com/vaadin/flow/spring/security/RequestUtil.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,13 @@ private String getRequestRoutePath(HttpServletRequest request) {
393393
.orElse(null);
394394
}
395395

396-
String getUrlMapping() {
396+
/**
397+
* Gets the url mapping for the Vaadin servlet.
398+
*
399+
* @return the url mapping
400+
* @see VaadinConfigurationProperties#getUrlMapping()
401+
*/
402+
public String getUrlMapping() {
397403
return configurationProperties.getUrlMapping();
398404
}
399405

vaadin-spring/src/test/java/com/vaadin/flow/spring/security/RequestUtilTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,4 +656,25 @@ static MockHttpServletRequest createRequest(String pathInfo,
656656
return r;
657657
}
658658

659+
@Test
660+
public void testGetUrlMapping_fooMappedServlet_returnsMappingValue() {
661+
Mockito.when(vaadinConfigurationProperties.getUrlMapping())
662+
.thenReturn("/foo/*");
663+
Assert.assertEquals("/foo/*", requestUtil.getUrlMapping());
664+
}
665+
666+
@Test
667+
public void testGetUrlMapping_rootMappedServlet_returnsMappingValue() {
668+
Mockito.when(vaadinConfigurationProperties.getUrlMapping())
669+
.thenReturn("/*");
670+
Assert.assertEquals("/*", requestUtil.getUrlMapping());
671+
}
672+
673+
@Test
674+
public void testGetUrlMapping_nullMapping_returnsNull() {
675+
Mockito.when(vaadinConfigurationProperties.getUrlMapping())
676+
.thenReturn(null);
677+
Assert.assertNull(requestUtil.getUrlMapping());
678+
}
679+
659680
}

0 commit comments

Comments
 (0)