|
|
|
@ -15,6 +15,7 @@ import org.springframework.restdocs.RestDocumentationExtension;
|
|
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder; |
|
|
|
|
import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationConsentService; |
|
|
|
|
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; |
|
|
|
|
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; |
|
|
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension; |
|
|
|
|
import org.springframework.test.web.servlet.MockMvc; |
|
|
|
|
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; |
|
|
|
@ -28,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
|
|
|
|
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; |
|
|
|
|
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; |
|
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; |
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; |
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
|
|
|
|
|
|
|
|
@ -67,6 +69,9 @@ class OAuthRestControllerTest {
|
|
|
|
|
@MockBean |
|
|
|
|
private PasswordEncoder passwordEncoder; |
|
|
|
|
|
|
|
|
|
@MockBean |
|
|
|
|
private AuthorizationServerSettings authorizationServerSettings; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
|
public void setup(WebApplicationContext applicationContext, RestDocumentationContextProvider contextProvider) { |
|
|
|
@ -96,9 +101,9 @@ class OAuthRestControllerTest {
|
|
|
|
|
.content(content); |
|
|
|
|
|
|
|
|
|
mockMvc.perform(requestBuilder) |
|
|
|
|
//.andDo(print())
|
|
|
|
|
.andExpect(status().isOk()) |
|
|
|
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) |
|
|
|
|
// .andDo(print())
|
|
|
|
|
.andExpect(jsonPath("access_token").exists()) |
|
|
|
|
// .andExpect(jsonPath("username").value(username))
|
|
|
|
|
.andExpect(jsonPath("refresh_token").exists()) |
|
|
|
|