*/
public class PlaintextPasswordEncoderTests extends TestCase {
//~ Methods ========================================================================================================
public void testBasicFunctionality() {
PlaintextPasswordEncoder pe = new PlaintextPasswordEncoder();
String raw = "abc123";
String rawDiffCase = "AbC123";
String badRaw = "abc321";
String salt = "THIS_IS_A_SALT";
String encoded = pe.encodePassword(raw, salt);
assertEquals("abc123{THIS_IS_A_SALT}", encoded);
assertTrue(pe.isPasswordValid(encoded, raw, salt));
assertFalse(pe.isPasswordValid(encoded, badRaw, salt));
// make sure default is not to ignore password case
assertFalse(pe.isIgnorePasswordCase());
encoded = pe.encodePassword(rawDiffCase, salt);
assertFalse(pe.isPasswordValid(encoded, raw, salt));
// now check for ignore password case
pe = new PlaintextPasswordEncoder();
pe.setIgnorePasswordCase(true);
// should be able to validate even without encoding
encoded = pe.encodePassword(rawDiffCase, salt);
assertTrue(pe.isPasswordValid(encoded, raw, salt));
assertFalse(pe.isPasswordValid(encoded, badRaw, salt));
}