2025-05-17 11:00:02 +08:00
|
|
|
package xiaozhi.modules.sys;
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
import org.springframework.test.context.ActiveProfiles;
|
2025-05-18 22:25:09 +08:00
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2025-05-17 11:00:02 +08:00
|
|
|
import xiaozhi.modules.security.controller.LoginController;
|
|
|
|
|
import xiaozhi.modules.security.dto.LoginDTO;
|
2025-05-18 22:25:09 +08:00
|
|
|
import xiaozhi.modules.security.dto.SmsVerificationDTO;
|
2025-05-17 11:00:02 +08:00
|
|
|
import xiaozhi.modules.sys.dto.RetrievePasswordDTO;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@SpringBootTest
|
|
|
|
|
@ActiveProfiles("dev")
|
|
|
|
|
class loginControllerTest {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
LoginController loginController;
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testRegister() {
|
|
|
|
|
LoginDTO loginDTO = new LoginDTO();
|
|
|
|
|
loginDTO.setUsername("手机号码");
|
|
|
|
|
loginDTO.setPassword("密码");
|
|
|
|
|
loginDTO.setCaptcha("123456");
|
|
|
|
|
loginController.register(loginDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2025-05-18 22:25:09 +08:00
|
|
|
public void testSmsVerification() {
|
2025-05-17 11:00:02 +08:00
|
|
|
try {
|
2025-05-18 22:25:09 +08:00
|
|
|
SmsVerificationDTO smsVerificationDTO = new SmsVerificationDTO();
|
|
|
|
|
smsVerificationDTO.setPhone("手机号码");
|
|
|
|
|
smsVerificationDTO.setCaptchaId("123456");
|
|
|
|
|
smsVerificationDTO.setCaptcha("123456");
|
|
|
|
|
loginController.smsVerification(smsVerificationDTO);
|
|
|
|
|
} catch (Exception e) {
|
2025-05-17 11:00:02 +08:00
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
2025-05-18 22:25:09 +08:00
|
|
|
public void testRetrievePassword() {
|
2025-05-17 11:00:02 +08:00
|
|
|
try {
|
|
|
|
|
RetrievePasswordDTO retrievePasswordDTO = new RetrievePasswordDTO();
|
|
|
|
|
retrievePasswordDTO.setCode("123456");
|
|
|
|
|
retrievePasswordDTO.setPhone("手机号码");
|
|
|
|
|
retrievePasswordDTO.setPassword("密码");
|
|
|
|
|
loginController.retrievePassword(retrievePasswordDTO);
|
2025-05-18 22:25:09 +08:00
|
|
|
} catch (Exception e) {
|
2025-05-17 11:00:02 +08:00
|
|
|
System.out.println(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|