Skip to content

Commit 8c459a1

Browse files
committed
Update tests & docs to match new behavior
1 parent 4dacb50 commit 8c459a1

4 files changed

Lines changed: 27 additions & 43 deletions

File tree

demo/integration-tests/webapp-vaadin-it/src/test/java/software/xdev/sse/demo/vaadin/cases/urlmapping/BaseUrlMappingTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package software.xdev.sse.demo.vaadin.cases.urlmapping;
22

3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNull;
5+
import static org.junit.jupiter.api.Assertions.assertTrue;
6+
37
import java.io.IOException;
48
import java.net.URI;
59
import java.util.Collection;
10+
import java.util.List;
611

712
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
813
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
@@ -53,5 +58,16 @@ void check() throws IOException
5358
}
5459
}
5560

56-
protected abstract Collection<Executable> checkResponse(final ClassicHttpResponse response);
61+
// As of Spring Boot 7.x the underlying problem is fixed out-of-the-box and both responses should now be identical
62+
protected Collection<Executable> checkResponse(final ClassicHttpResponse response)
63+
{
64+
return List.of(
65+
() -> assertEquals(302, response.getCode()),
66+
() -> assertNull(response.getHeader("Set-Cookie")),
67+
() -> assertTrue(response.getHeader("Location")
68+
.getValue()
69+
.endsWith("/oauth2/authorization/local")),
70+
() -> assertEquals("1", response.getHeader("X-Force-Reload").getValue())
71+
);
72+
}
5773
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
package software.xdev.sse.demo.vaadin.cases.urlmapping;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertNull;
5-
6-
import java.util.Collection;
7-
import java.util.List;
8-
9-
import org.apache.hc.core5.http.ClassicHttpResponse;
10-
import org.junit.jupiter.api.function.Executable;
11-
123
import software.xdev.sse.demo.tci.webapp.containers.VaadinWebAppContainer;
134

145

@@ -20,14 +11,4 @@ protected void customizeWebAppContainer(final VaadinWebAppContainer c)
2011
super.customizeWebAppContainer(c);
2112
c.withEnv("SSE_SIDECAR_HTTP-SECURITY-MATCHER_DEFAULT_CREATOR_ENABLED", "false");
2213
}
23-
24-
@Override
25-
protected Collection<Executable> checkResponse(final ClassicHttpResponse response)
26-
{
27-
return List.of(
28-
() -> assertEquals(401, response.getCode()),
29-
() -> assertNull(response.getHeader("Set-Cookie")),
30-
() -> assertEquals("Basic realm=\"Realm\"", response.getHeader("WWW-Authenticate").getValue())
31-
);
32-
}
3314
}
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
package software.xdev.sse.demo.vaadin.cases.urlmapping;
22

3-
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertNull;
5-
import static org.junit.jupiter.api.Assertions.assertTrue;
6-
7-
import java.util.Collection;
8-
import java.util.List;
9-
10-
import org.apache.hc.core5.http.ClassicHttpResponse;
11-
import org.junit.jupiter.api.function.Executable;
12-
13-
143
class UrlMappingPatchedTest extends BaseUrlMappingTest
154
{
16-
@Override
17-
protected Collection<Executable> checkResponse(final ClassicHttpResponse response)
18-
{
19-
return List.of(
20-
() -> assertEquals(302, response.getCode()),
21-
() -> assertNull(response.getHeader("Set-Cookie")),
22-
() -> assertTrue(response.getHeader("Location")
23-
.getValue()
24-
.endsWith("/oauth2/authorization/local")),
25-
() -> assertEquals("1", response.getHeader("X-Force-Reload").getValue())
26-
);
27-
}
285
}

web-sidecar-common/src/main/java/software/xdev/sse/web/sidecar/httpsecurity/package-info.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
* limitations under the License.
1515
*/
1616
/**
17+
* <h4>Spring 7.x Update</h4>
18+
* With Spring 7 the underlying root issue has been fixed - Spring now always uses a PathPatternRequestMatcher.
19+
* <p>
20+
* However, it's still possible for frameworks or applications to use a custom implementation in
21+
* {@link org.springframework.security.config.annotation.web.builders.HttpSecurity#securityMatcher(java.lang.String...)}
22+
* so for now this implementation will stay available.
23+
* </p>
24+
*
25+
* <h4>Original behavior - Spring 6.x</h4>
1726
* Controls how
1827
* {@link org.springframework.security.config.annotation.web.builders.HttpSecurity
1928
* #securityMatcher(org.springframework.security.web.util.matcher.RequestMatcher)} is applied for sidecars.
@@ -27,6 +36,7 @@
2736
* <p>
2837
* <i>This package is only designed to be used in Sidecars and not in the main application!</i>
2938
* </p>
39+
*
3040
* @see <a href="https://github.com/xdev-software/spring-security-extras/issues/221">#221</a>
3141
*/
3242
package software.xdev.sse.web.sidecar.httpsecurity;

0 commit comments

Comments
 (0)