use of org.apache.activemq.artemis.cli.commands.Mask in project activemq-artemis by apache.
the class ArtemisTest method testMaskCommand.
@Test
public void testMaskCommand() throws Exception {
String password1 = "password";
String encrypt1 = "3a34fd21b82bf2a822fa49a8d8fa115d";
String newKey = "artemisfun";
String encrypt2 = "-2b8e3b47950b9b481a6f3100968e42e9";
TestActionContext context = new TestActionContext();
Mask mask = new Mask();
mask.setPassword(password1);
String result = (String) mask.execute(context);
System.out.println(context.getStdout());
assertEquals(encrypt1, result);
context = new TestActionContext();
mask = new Mask();
mask.setPassword(password1);
mask.setHash(true);
result = (String) mask.execute(context);
System.out.println(context.getStdout());
DefaultSensitiveStringCodec codec = mask.getCodec();
codec.verify(password1.toCharArray(), result);
context = new TestActionContext();
mask = new Mask();
mask.setPassword(password1);
mask.setKey(newKey);
result = (String) mask.execute(context);
System.out.println(context.getStdout());
assertEquals(encrypt2, result);
}
Aggregations