Reputation: 6902
I've been trying to verify the redirect URL of the controller I'm testing but no matter what pattern I use, the test always fails. Even calling andExpect(redirectedUrlPattern("*"))
fails. According to the docs, it's using Ant pattern, so I'm not sure why it keeps failing. I'm sure that the redirect URL is being set because redirectUrl
works properly.
Upvotes: 1
Views: 2858
Reputation: 829
I know it is an old topic but I was able to do this validation like the example below:
this.mockMvc
.perform(get("/oauth2/authorization/a-registration-id")
.param("redirect_uri", "http://localhost:3000/api/callback")
.with(csrf())
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isFound())
.andExpect(header().string("Location", containsString("redirect_uri=http://localhost:3000/api/callback")));
Upvotes: 0
Reputation: 888
There doesn't seem to be a way to match everything. It definitively distinguishes between absolute and relative paths.
/**/* matches all absolute paths
**/* matches all relative paths
Examples of what is possible:
If you give a concrete example of something you want to match I can give you a pattern that will work
Upvotes: 2