1

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.

Psycho Punch
  • 6,418
  • 9
  • 53
  • 86

2 Answers2

2

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

Community
  • 1
  • 1
Alftheo
  • 868
  • 7
  • 17
0

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")));
mlecar
  • 729
  • 6
  • 9