Search in sources :

Example 1 with KafkaClientAuthenticationScramSha512

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());
    });
}
Also used : SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) Secret(io.fabric8.kubernetes.api.model.Secret) KafkaClientAuthenticationScramSha512(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512) HashMap(java.util.HashMap) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 2 with KafkaClientAuthenticationScramSha512

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());
    });
}
Also used : SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) Secret(io.fabric8.kubernetes.api.model.Secret) KafkaClientAuthenticationScramSha512(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512) HashMap(java.util.HashMap) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 3 with KafkaClientAuthenticationScramSha512

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());
    });
}
Also used : SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) Secret(io.fabric8.kubernetes.api.model.Secret) KafkaClientAuthenticationScramSha512(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512) HashMap(java.util.HashMap) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 4 with KafkaClientAuthenticationScramSha512

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());
    });
}
Also used : SecretOperator(io.strimzi.operator.common.operator.resource.SecretOperator) Secret(io.fabric8.kubernetes.api.model.Secret) KafkaClientAuthenticationScramSha512(io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512) HashMap(java.util.HashMap) PasswordSecretSource(io.strimzi.api.kafka.model.PasswordSecretSource) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Aggregations

Secret (io.fabric8.kubernetes.api.model.Secret)4 PasswordSecretSource (io.strimzi.api.kafka.model.PasswordSecretSource)4 KafkaClientAuthenticationScramSha512 (io.strimzi.api.kafka.model.authentication.KafkaClientAuthenticationScramSha512)4 SecretOperator (io.strimzi.operator.common.operator.resource.SecretOperator)4 HashMap (java.util.HashMap)4 Test (org.junit.jupiter.api.Test)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4