use of com.sanctionco.thunder.models.Email in project thunder by RohanNagar.
the class RequestValidatorTest method testValidateUserInvalidEmailAddress.
@Test
void testValidateUserInvalidEmailAddress() {
Email email = new Email("notARealEmail", false, "token");
User user = new User(email, "password");
RequestValidationException e = assertThrows(RequestValidationException.class, () -> validator.validate(user));
assertEquals("Invalid email address format. Please try again.", e.getMessage());
assertEquals(RequestValidationException.Error.INVALID_PARAMETERS, e.getError());
}
use of com.sanctionco.thunder.models.Email in project thunder by RohanNagar.
the class RequestValidatorTest method testValidateEmptyPassword.
@Test
void testValidateEmptyPassword() {
var propertyValidator = mock(PropertyValidator.class);
var validator = new RequestValidator(EMAIL_VALIDATOR, propertyValidator, HASH_SERVICE, true);
when(propertyValidator.isValidPropertiesMap(anyMap())).thenReturn(true);
Email email = new Email("test@test.com", false, "token");
User user = new User(email, "password");
RequestValidationException e = assertThrows(RequestValidationException.class, () -> validator.validate("", "test@test.com", user));
assertEquals("Credentials are required to access this resource.", e.getMessage());
assertEquals(RequestValidationException.Error.INVALID_PARAMETERS, e.getError());
}
use of com.sanctionco.thunder.models.Email in project thunder by RohanNagar.
the class RequestValidatorTest method testValidateUserEmptyEmailAddress.
@Test
void testValidateUserEmptyEmailAddress() {
Email email = new Email("", false, "token");
User user = new User(email, "password");
RequestValidationException e = assertThrows(RequestValidationException.class, () -> validator.validate(user));
assertEquals("Invalid email address format. Please try again.", e.getMessage());
assertEquals(RequestValidationException.Error.INVALID_PARAMETERS, e.getError());
}
use of com.sanctionco.thunder.models.Email in project thunder by RohanNagar.
the class RequestValidatorTest method testValidateUserSuccess.
@Test
void testValidateUserSuccess() {
var propertyValidator = mock(PropertyValidator.class);
var validator = new RequestValidator(EMAIL_VALIDATOR, propertyValidator, HASH_SERVICE, true);
when(propertyValidator.isValidPropertiesMap(anyMap())).thenReturn(true);
Email email = new Email("test@test.com", false, "token");
User user = new User(email, "password");
assertDoesNotThrow(() -> validator.validate(user));
}
use of com.sanctionco.thunder.models.Email in project thunder by RohanNagar.
the class RequestValidatorTest method testValidateUserMismatchPropertyMap.
@Test
void testValidateUserMismatchPropertyMap() {
var propertyValidator = mock(PropertyValidator.class);
var validator = new RequestValidator(EMAIL_VALIDATOR, propertyValidator, HASH_SERVICE, true);
when(propertyValidator.isValidPropertiesMap(anyMap())).thenReturn(false);
Email email = new Email("test@test.com", false, "token");
User user = new User(email, "password");
RequestValidationException e = assertThrows(RequestValidationException.class, () -> validator.validate(user));
assertEquals("Cannot post a user with invalid properties.", e.getMessage());
assertEquals(RequestValidationException.Error.INVALID_PARAMETERS, e.getError());
}
Aggregations