Search in sources :

Example 36 with Secret

use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.

the class SecretTestUtil method setSecretField.

public static void setSecretField(Class<?> clazz, String fieldName, Object target, String raw, String secret) {
    Field field = ReflectionUtils.findField(clazz, fieldName);
    field.setAccessible(true);
    try {
        field.set(target, new Secret(raw, secret));
    } catch (IllegalAccessException ignore) {
    }
}
Also used : Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) Field(java.lang.reflect.Field)

Example 37 with Secret

use of com.sequenceiq.cloudbreak.service.secret.domain.Secret in project cloudbreak by hortonworks.

the class SecretAspectServiceTest method testVaultDeleteWhenAccountIdDefinedThenMustWriteTheRightPath.

@Test
public void testVaultDeleteWhenAccountIdDefinedThenMustWriteTheRightPath() throws Exception {
    VaultTest vaultTest = new VaultTest("justice-league", new Secret("super", "justice-league/vaulttest/power/123-123-123-123"));
    VaultTestProceedingJoinPoint proceedingJoinPoint = new VaultTestProceedingJoinPoint(vaultTest);
    ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
    doNothing().when(secretService).delete(keyCaptor.capture());
    underTest.proceedDelete(proceedingJoinPoint);
    Assert.assertTrue(keyCaptor.getValue().startsWith("justice-league/vaulttest/power/123-123-123-123"));
}
Also used : Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

Secret (com.sequenceiq.cloudbreak.service.secret.domain.Secret)37 Test (org.junit.Test)11 Field (java.lang.reflect.Field)8 Test (org.junit.jupiter.api.Test)8 Stack (com.sequenceiq.freeipa.entity.Stack)7 SecretProxy (com.sequenceiq.cloudbreak.service.secret.domain.SecretProxy)5 SecretOperationException (com.sequenceiq.cloudbreak.service.secret.SecretOperationException)4 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)4 VaultSecret (com.sequenceiq.cloudbreak.service.secret.vault.VaultSecret)4 HostKeytabRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabRequest)4 HostKeytabResponse (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.HostKeytabResponse)4 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)4 Host (com.sequenceiq.freeipa.client.model.Host)4 KeytabCache (com.sequenceiq.freeipa.entity.KeytabCache)4 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)3 DetailedStackStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)3 Status (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status)3 InstanceStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus)3 RoleRequest (com.sequenceiq.freeipa.api.v1.kerberosmgmt.model.RoleRequest)3 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)3