use of org.elasticsearch.common.settings.SecureString in project crate by crate.
the class UserAuthenticationMethodTest method testPasswordAuthenticationWrongPassword.
@Test
public void testPasswordAuthenticationWrongPassword() throws Exception {
PasswordAuthenticationMethod pwAuth = new PasswordAuthenticationMethod(this::userLookup);
assertThat(pwAuth.name(), is("password"));
expectedException.expectMessage("password authentication failed for user \"crate\"");
pwAuth.authenticate("crate", new SecureString("wrong".toCharArray()), null);
}
use of org.elasticsearch.common.settings.SecureString in project crate by crate.
the class UserAuthenticationMethodTest method userLookup.
private User userLookup(String userName) {
if (userName.equals("crate")) {
User user = null;
try {
SecureHash pwHash = SecureHash.of(new SecureString("pw".toCharArray()));
user = User.of("crate", Collections.emptySet(), pwHash);
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
// do nothing
}
assertNotNull(user);
return user;
}
return null;
}
use of org.elasticsearch.common.settings.SecureString in project crate by crate.
the class UserActionsTest method testNoPasswordIfPropertyIsNull.
@Test
public void testNoPasswordIfPropertyIsNull() throws Exception {
GenericProperties<Symbol> properties = new GenericProperties<>(Map.of("password", Literal.of(DataTypes.UNDEFINED, null)));
SecureString password = UserActions.getUserPasswordProperty(properties, Row.EMPTY, txnCtx, nodeCtx);
assertNull(password);
}
use of org.elasticsearch.common.settings.SecureString in project crate by crate.
the class UserActionsTest method testUserPasswordProperty.
@Test
public void testUserPasswordProperty() throws Exception {
GenericProperties<Symbol> properties = new GenericProperties<>(Map.of("password", Literal.of("my-pass")));
SecureString password = UserActions.getUserPasswordProperty(properties, Row.EMPTY, txnCtx, nodeCtx);
assertEquals(new SecureString("my-pass".toCharArray()), password);
}
use of org.elasticsearch.common.settings.SecureString in project crate by crate.
the class SecureHashTest method testNonAsciiChars.
@Test
public void testNonAsciiChars() throws InvalidKeySpecException, NoSuchAlgorithmException {
SecureString pw = new SecureString("ฯรค๐ูุต".toCharArray());
SecureHash hash = SecureHash.of(pw);
assertTrue(hash.verifyHash(pw));
}
Aggregations