diff --git a/youlai-auth/src/test/java/com/youlai/auth/oauth2/CaptchaAuthenticationTests.java b/youlai-auth/src/test/java/com/youlai/auth/oauth2/CaptchaAuthenticationTests.java deleted file mode 100644 index e35effc98..000000000 --- a/youlai-auth/src/test/java/com/youlai/auth/oauth2/CaptchaAuthenticationTests.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.youlai.auth.oauth2; - - -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpHeaders; -import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames; -import org.springframework.test.web.servlet.MockMvc; - -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.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@SpringBootTest -@AutoConfigureMockMvc -@Slf4j -public class CaptchaAuthenticationTests { - - @Autowired - private MockMvc mvc; - - - @Test - void testPasswordAuthentication() throws Exception { - HttpHeaders headers = new HttpHeaders(); - headers.setBasicAuth("mall-admin", "123456"); - - // @formatter:off - this.mvc.perform(post("/oauth2/token") - .param(OAuth2ParameterNames.GRANT_TYPE, "captcha") - .param(OAuth2ParameterNames.USERNAME, "admin") - .param(OAuth2ParameterNames.PASSWORD, "123456") - .param(CaptchaParameterNames.CODE, "123456") - .param(CaptchaParameterNames.KEY, "123456") - .headers(headers)) - .andDo(print()) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.access_token").isNotEmpty()); - // @formatter:on - } - - -} \ No newline at end of file diff --git a/youlai-auth/src/test/java/com/youlai/auth/oauth2/PasswordAuthenticationTests.java b/youlai-auth/src/test/java/com/youlai/auth/oauth2/PasswordAuthenticationTests.java index cf05f5efe..84f1c037d 100644 --- a/youlai-auth/src/test/java/com/youlai/auth/oauth2/PasswordAuthenticationTests.java +++ b/youlai-auth/src/test/java/com/youlai/auth/oauth2/PasswordAuthenticationTests.java @@ -1,5 +1,6 @@ package com.youlai.auth.oauth2; +import com.youlai.common.constant.OAuth2Constants; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -38,6 +39,8 @@ public class PasswordAuthenticationTests { .param(OAuth2ParameterNames.GRANT_TYPE, "password") // 密码模式 .param(OAuth2ParameterNames.USERNAME, "admin") // 用户名 .param(OAuth2ParameterNames.PASSWORD, "123456") // 密码 + .param( OAuth2Constants.CAPTCHA_ID, "******") // 密码 + .param(OAuth2Constants.CAPTCHA_CODE, "******") // 密码 .headers(headers)) .andDo(print()) .andExpect(status().isOk()) diff --git a/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsCodeAuthenticationTests.java b/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsAuthenticationTests.java similarity index 97% rename from youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsCodeAuthenticationTests.java rename to youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsAuthenticationTests.java index 078e122f4..a23d803f1 100644 --- a/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsCodeAuthenticationTests.java +++ b/youlai-auth/src/test/java/com/youlai/auth/oauth2/SmsAuthenticationTests.java @@ -18,7 +18,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest @AutoConfigureMockMvc @Slf4j -public class SmsCodeAuthenticationTests { +public class SmsAuthenticationTests { @Autowired