test/org/ohmage/validator/UserValidatorsTest.java
@Test
	public void testValidateHashedPassword() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserValidators.validateHashedPassword(emptyValue));
			}
			
			try {
				UserValidators.validateHashedPassword("Invalid value.");
				fail("The plaintext password was invalid.");
			}
			catch(ValidationException e) {
				// Passed.
			}
			
			for(String validHashedPassword : ParameterSets.getValidHashedPasswords()) {
				try {
					UserValidators.validateHashedPassword(validHashedPassword);
				}
				catch(ValidationException e) {
					fail("A valid hashed password '" + validHashedPassword + "' failed validation: " + e.getMessage());
				}
			}
			
			for(String invalidHashedPassword : ParameterSets.getInvalidHashedPasswords()) {
				try {
					UserValidators.validateHashedPassword(invalidHashedPassword);
					fail("An invalid hashed password '" + invalidHashedPassword + "' passed validation.");
				}
				catch(ValidationException e) {
					// Passed.
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
/**
	 * Tests the hashed password validator.
	 */
Tests the hashed password validator.
Tests the hashed password validator .
@Test
	public void testValidateHashedPassword() {
		try {
			for(String emptyValue : ParameterSets.getEmptyValues()) {
				Assert.assertNull(UserValidators.validateHashedPassword(emptyValue));
			}
			try {
				UserValidators.validateHashedPassword("Invalid value.");
				fail("The plaintext password was invalid.");
			}
			catch(ValidationException e) {
			}
			for(String validHashedPassword : ParameterSets.getValidHashedPasswords()) {
				try {
					UserValidators.validateHashedPassword(validHashedPassword);
				}
				catch(ValidationException e) {
					fail("A valid hashed password '" + validHashedPassword + "' failed validation: " + e.getMessage());
				}
			}
			for(String invalidHashedPassword : ParameterSets.getInvalidHashedPasswords()) {
				try {
					UserValidators.validateHashedPassword(invalidHashedPassword);
					fail("An invalid hashed password '" + invalidHashedPassword + "' passed validation.");
				}
				catch(ValidationException e) {
				}
			}
		}
		catch(ValidationException e) {
			fail("A validation exception was thrown: " + e.getMessage());
		}
	}
@ Test public void testValidateHashedPassword ( ) { try { for ( String emptyValue : ParameterSets . getEmptyValues ( ) ) { Assert . assertNull ( UserValidators . validateHashedPassword ( emptyValue ) ) ; } try { UserValidators . validateHashedPassword ( "Invalid value." ) ; fail ( "The plaintext password was invalid." ) ; } catch ( ValidationException e ) { } for ( String validHashedPassword : ParameterSets . getValidHashedPasswords ( ) ) { try { UserValidators . validateHashedPassword ( validHashedPassword ) ; } catch ( ValidationException e ) { fail ( "A valid hashed password '" + validHashedPassword + "' failed validation: " + e . getMessage ( ) ) ; } } for ( String invalidHashedPassword : ParameterSets . getInvalidHashedPasswords ( ) ) { try { UserValidators . validateHashedPassword ( invalidHashedPassword ) ; fail ( "An invalid hashed password '" + invalidHashedPassword + "' passed validation." ) ; } catch ( ValidationException e ) { } } } catch ( ValidationException e ) { fail ( "A validation exception was thrown: " + e . getMessage ( ) ) ; } }
Tests the hashed password validator.
Tests the hashed password validator .
// Passed. // Passed.