ddangelorb
3 years ago
6 changed files with 164 additions and 0 deletions
-
9db/sys_config.sql
-
54src/main/java/org/waterproofingdata/wpdauth/controller/ForgotPasswordController.java
-
18src/main/java/org/waterproofingdata/wpdauth/dto/ForgotPasswordQuestionsResponseDTO.java
-
22src/main/java/org/waterproofingdata/wpdauth/dto/ForgotPasswordQuestionsUsersAnswersRequestDTO.java
-
24src/test/java/org/waterproofingdata/wpdauth/integrationtest/ForgotPasswordServiceIntegrationTest.java
-
37src/test/java/org/waterproofingdata/wpdauth/integrationtest/UsersServiceIntegrationTest.java
@ -0,0 +1,18 @@ |
|||||
|
package org.waterproofingdata.wpdauth.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
public class ForgotPasswordQuestionsResponseDTO { |
||||
|
@ApiModelProperty(position = 0) |
||||
|
private Integer id; |
||||
|
|
||||
|
@ApiModelProperty(position = 1) |
||||
|
private String question; |
||||
|
|
||||
|
@ApiModelProperty(position = 2) |
||||
|
private Integer active; |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
package org.waterproofingdata.wpdauth.dto; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
import lombok.Setter; |
||||
|
|
||||
|
@Getter |
||||
|
@Setter |
||||
|
public class ForgotPasswordQuestionsUsersAnswersRequestDTO { |
||||
|
@ApiModelProperty(position = 0) |
||||
|
private Integer id; |
||||
|
|
||||
|
@ApiModelProperty(position = 1) |
||||
|
private Integer forgotpasswordquestionsid; |
||||
|
|
||||
|
@ApiModelProperty(position = 2) |
||||
|
private Integer usersid; |
||||
|
|
||||
|
@ApiModelProperty(position = 3) |
||||
|
private String answer; |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package org.waterproofingdata.wpdauth.integrationtest; |
||||
|
|
||||
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import org.junit.jupiter.api.Test; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.waterproofingdata.wpdauth.model.ForgotPasswordQuestions; |
||||
|
import org.waterproofingdata.wpdauth.service.ForgotPasswordService; |
||||
|
|
||||
|
@SpringBootTest |
||||
|
public class ForgotPasswordServiceIntegrationTest { |
||||
|
@Autowired |
||||
|
private ForgotPasswordService forgotPasswordService; |
||||
|
|
||||
|
@Test |
||||
|
public void testFindAllForgotPasswordQuestions() { |
||||
|
List<ForgotPasswordQuestions> r = forgotPasswordService.findAllForgotPasswordQuestions(); |
||||
|
assertTrue(r.size() > 0); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
package org.waterproofingdata.wpdauth.integrationtest; |
||||
|
|
||||
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
||||
|
import static org.junit.jupiter.api.Assertions.assertThrows; |
||||
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
||||
|
|
||||
|
import org.junit.jupiter.api.Test; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.http.HttpStatus; |
||||
|
import org.waterproofingdata.wpdauth.exception.CustomException; |
||||
|
import org.waterproofingdata.wpdauth.service.UsersService; |
||||
|
|
||||
|
@SpringBootTest |
||||
|
public class UsersServiceIntegrationTest { |
||||
|
@Autowired |
||||
|
private UsersService usersService; |
||||
|
|
||||
|
@Test |
||||
|
public void testInvalidLogin() { |
||||
|
CustomException thrown = assertThrows( |
||||
|
CustomException.class, |
||||
|
() -> usersService.login("xpto", "xpto"), |
||||
|
"Expected usersService.login(xpto, xpto) to throw, but it didn't" |
||||
|
); |
||||
|
|
||||
|
assertTrue(thrown.getMessage().contains("Invalid username/password supplied")); |
||||
|
assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, thrown.getHttpStatus()); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void testAdmUserLogin() { |
||||
|
String login = usersService.login("admin", "admin"); |
||||
|
assertNotNull(login, "Login token returned from usersService.login() should not be null"); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue