@Test public void testEncode() { assertEquals(PasswordEncoder.PREFIX + "UXdlcnR5", PasswordEncoder.encode("Qwerty")); assertEquals( PasswordEncoder.PREFIX + "Qwerty", PasswordEncoder.encode(PasswordEncoder.PREFIX + "Qwerty")); }
@Test public void testDisablePwEncoder() { System.setProperty("zookeeper.password.encode", "false"); assertEquals("UXdlcnR5", PasswordEncoder.decode("UXdlcnR5")); assertEquals( PasswordEncoder.PREFIX + "UXdlcnR5", PasswordEncoder.decode(PasswordEncoder.PREFIX + "UXdlcnR5")); assertEquals("Qwerty", PasswordEncoder.encode("Qwerty")); assertEquals( PasswordEncoder.PREFIX + "Qwerty", PasswordEncoder.encode(PasswordEncoder.PREFIX + "Qwerty")); }
@Test public void testSha1Hash2() { final PasswordEncoder pe = new DefaultPasswordEncoder("SHA1"); final String hash = pe.encode("TEST of the SYSTEM"); assertEquals("82ae28dfad565dd9882b94498a271caa29025d5f", hash); }
@Test public void testSha1Hash() { final PasswordEncoder pe = new DefaultPasswordEncoder("SHA1"); final String hash = pe.encode("this is a test"); assertEquals("fa26be19de6bff93f70bc2308434e4a440bbad02", hash); }
@Test public void testInvalidEncodingType() { final PasswordEncoder pe = new DefaultPasswordEncoder("scott"); try { pe.encode("test"); fail("exception expected."); } catch (final Exception e) { return; } }