use of io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512 in project strimzi by strimzi.
the class UtilTest method testAuthTlsHashScramSha512SecretFoundAndPasswordNotFound.
@Test
public void testAuthTlsHashScramSha512SecretFoundAndPasswordNotFound() {
SecretOperator secretOpertator = mock(SecretOperator.class);
Map<String, String> data = new HashMap<>();
data.put("passwordKey", "my-password");
Secret secret = new Secret();
secret.setData(data);
CompletionStage<Secret> cf = CompletableFuture.supplyAsync(() -> secret);
when(secretOpertator.getAsync(anyString(), anyString())).thenReturn(Future.fromCompletionStage(cf));
KafkaClientAuthenticationScramSha512 auth = new KafkaClientAuthenticationScramSha512();
PasswordSecretSource passwordSecretSource = new PasswordSecretSource();
passwordSecretSource.setSecretName("my-secret");
passwordSecretSource.setPassword("password1");
auth.setPasswordSecret(passwordSecretSource);
Future<Integer> result = Util.authTlsHash(secretOpertator, "anyNamespace", auth, List.of());
result.onComplete(handler -> {
assertTrue(handler.failed());
assertEquals("Secret my-secret does not contain key password1", handler.cause().getMessage());
});
}
use of io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512 in project strimzi by strimzi.
the class UtilTest method testAuthTlsHashScramSha512SecretAndPasswordFound.
@Test
public void testAuthTlsHashScramSha512SecretAndPasswordFound() {
SecretOperator secretOpertator = mock(SecretOperator.class);
Map<String, String> data = new HashMap<>();
data.put("passwordKey", "my-password");
Secret secret = new Secret();
secret.setData(data);
CompletionStage<Secret> cf = CompletableFuture.supplyAsync(() -> secret);
when(secretOpertator.getAsync(anyString(), anyString())).thenReturn(Future.fromCompletionStage(cf));
KafkaClientAuthenticationScramSha512 auth = new KafkaClientAuthenticationScramSha512();
PasswordSecretSource passwordSecretSource = new PasswordSecretSource();
passwordSecretSource.setSecretName("my-secret");
passwordSecretSource.setPassword("passwordKey");
auth.setPasswordSecret(passwordSecretSource);
Future<Integer> result = Util.authTlsHash(secretOpertator, "anyNamespace", auth, List.of());
result.onComplete(handler -> {
assertTrue(handler.succeeded());
assertEquals("my-password".hashCode(), handler.result());
});
}
use of io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512 in project strimzi-kafka-operator by strimzi.
the class UtilTest method testAuthTlsHashScramSha512SecretAndPasswordFound.
@Test
public void testAuthTlsHashScramSha512SecretAndPasswordFound() {
SecretOperator secretOpertator = mock(SecretOperator.class);
Map<String, String> data = new HashMap<>();
data.put("passwordKey", "my-password");
Secret secret = new Secret();
secret.setData(data);
CompletionStage<Secret> cf = CompletableFuture.supplyAsync(() -> secret);
when(secretOpertator.getAsync(anyString(), anyString())).thenReturn(Future.fromCompletionStage(cf));
KafkaClientAuthenticationScramSha512 auth = new KafkaClientAuthenticationScramSha512();
PasswordSecretSource passwordSecretSource = new PasswordSecretSource();
passwordSecretSource.setSecretName("my-secret");
passwordSecretSource.setPassword("passwordKey");
auth.setPasswordSecret(passwordSecretSource);
Future<Integer> result = Util.authTlsHash(secretOpertator, "anyNamespace", auth, List.of());
result.onComplete(handler -> {
assertTrue(handler.succeeded());
assertEquals("my-password".hashCode(), handler.result());
});
}
use of io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512 in project strimzi-kafka-operator by strimzi.
the class UtilTest method testAuthTlsHashScramSha512SecretFoundAndPasswordNotFound.
@Test
public void testAuthTlsHashScramSha512SecretFoundAndPasswordNotFound() {
SecretOperator secretOpertator = mock(SecretOperator.class);
Map<String, String> data = new HashMap<>();
data.put("passwordKey", "my-password");
Secret secret = new Secret();
secret.setData(data);
CompletionStage<Secret> cf = CompletableFuture.supplyAsync(() -> secret);
when(secretOpertator.getAsync(anyString(), anyString())).thenReturn(Future.fromCompletionStage(cf));
KafkaClientAuthenticationScramSha512 auth = new KafkaClientAuthenticationScramSha512();
PasswordSecretSource passwordSecretSource = new PasswordSecretSource();
passwordSecretSource.setSecretName("my-secret");
passwordSecretSource.setPassword("password1");
auth.setPasswordSecret(passwordSecretSource);
Future<Integer> result = Util.authTlsHash(secretOpertator, "anyNamespace", auth, List.of());
result.onComplete(handler -> {
assertTrue(handler.failed());
assertEquals("Secret my-secret does not contain key password1", handler.cause().getMessage());
});
}
Aggregations