use of org.apache.ignite.internal.commandline.NoopConsole in project ignite by apache.
the class GridCommandHandlerSslWithSecurityTest method testInputKeyTrustStorePwdOnlyOnce.
/**
* Verify that the command work correctly when entering passwords for
* keystore and truststore, and that these passwords are requested only
* once.
*
* @throws Exception If failed.
*/
@Test
public void testInputKeyTrustStorePwdOnlyOnce() throws Exception {
IgniteEx crd = startGrid();
crd.cluster().state(ACTIVE);
CommandHandler cmd = new CommandHandler();
AtomicInteger keyStorePwdCnt = new AtomicInteger();
AtomicInteger trustStorePwdCnt = new AtomicInteger();
cmd.console = new NoopConsole() {
/**
* {@inheritDoc}
*/
@Override
public char[] readPassword(String fmt, Object... args) {
if (fmt.contains("keystore")) {
keyStorePwdCnt.incrementAndGet();
return keyStorePassword().toCharArray();
} else if (fmt.contains("truststore")) {
trustStorePwdCnt.incrementAndGet();
return keyStorePassword().toCharArray();
}
return pwd.toCharArray();
}
};
List<String> args = new ArrayList<>();
args.add(DEACTIVATE.text());
args.add("--force");
args.add("--yes");
args.add("--user");
args.add(login);
args.add("--keystore");
args.add(keyStorePath("connectorServer"));
args.add("--truststore");
args.add(keyStorePath("trustthree"));
assertEquals(EXIT_CODE_OK, cmd.execute(args));
assertEquals(1, keyStorePwdCnt.get());
assertEquals(1, trustStorePwdCnt.get());
}
Aggregations