Browse Source

/oauth2/rest_token API doc

pull/4/head
shengzhaoli.shengz 1 year ago
parent
commit
addf0f4623
  1. 7
      src/test/java/com/monkeyk/sos/web/controller/OAuthRestControllerTest.java

7
src/test/java/com/monkeyk/sos/web/controller/OAuthRestControllerTest.java

@ -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())

Loading…
Cancel
Save