Isolate Jwt Test Support
Isolating Jwt test support inside JwtRequestPostProcessor and JwtMutator. Fixes gh-7641
This commit is contained in:
@@ -47,13 +47,13 @@ public class OAuth2ResourceServerControllerTests {
|
||||
|
||||
@Test
|
||||
public void indexGreetsAuthenticatedUser() throws Exception {
|
||||
mockMvc.perform(get("/").with(jwt(jwt -> jwt.subject("ch4mpy"))))
|
||||
mockMvc.perform(get("/").with(jwt().jwt(jwt -> jwt.subject("ch4mpy"))))
|
||||
.andExpect(content().string(is("Hello, ch4mpy!")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void messageCanBeReadWithScopeMessageReadAuthority() throws Exception {
|
||||
mockMvc.perform(get("/message").with(jwt(jwt -> jwt.claim("scope", "message:read"))))
|
||||
mockMvc.perform(get("/message").with(jwt().jwt(jwt -> jwt.claim("scope", "message:read"))))
|
||||
.andExpect(content().string(is("secret message")));
|
||||
|
||||
mockMvc.perform(get("/message")
|
||||
@@ -79,7 +79,7 @@ public class OAuth2ResourceServerControllerTests {
|
||||
public void messageCanNotBeCreatedWithScopeMessageReadAuthority() throws Exception {
|
||||
mockMvc.perform(post("/message")
|
||||
.content("Hello message")
|
||||
.with(jwt(jwt -> jwt.claim("scope", "message:read"))))
|
||||
.with(jwt().jwt(jwt -> jwt.claim("scope", "message:read"))))
|
||||
.andExpect(status().isForbidden());
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class OAuth2ResourceServerControllerTests {
|
||||
throws Exception {
|
||||
mockMvc.perform(post("/message")
|
||||
.content("Hello message")
|
||||
.with(jwt(jwt -> jwt.claim("scope", "message:write"))))
|
||||
.with(jwt().jwt(jwt -> jwt.claim("scope", "message:write"))))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(is("Message was created. Content: Hello message")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user