Search in sources :

Example 1 with AzureCredentialResponseParameters

use of com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialResponseParameters in project cloudbreak by hortonworks.

the class CredentialServiceTest method testAzureCredential.

@Test
public void testAzureCredential() {
    CredentialResponse credentialResponse = new CredentialResponse();
    credentialResponse.setCrn(CRN);
    credentialResponse.setName(NAME);
    credentialResponse.setAttributes(secretResponse);
    AzureCredentialResponseParameters azureResponse = new AzureCredentialResponseParameters();
    azureResponse.setSubscriptionId(SUBSCRIPTION_ID);
    credentialResponse.setAzure(azureResponse);
    when(credentialEndpoint.getByEnvironmentCrn(ENVIRONMENT_CRN)).thenReturn(credentialResponse);
    Credential credential = underTest.getCredentialByEnvCrn(ENVIRONMENT_CRN);
    assertEquals(CRN, credential.getCrn());
    assertEquals(NAME, credential.getName());
    assertEquals(ATTRIBUTES, credential.getAttributes());
    assertTrue(credential.getAzure().isPresent());
    assertEquals(SUBSCRIPTION_ID, credential.getAzure().get().getSubscriptionId());
}
Also used : Credential(com.sequenceiq.redbeams.dto.Credential) CredentialResponse(com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse) AzureCredentialResponseParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialResponseParameters) Test(org.junit.Test)

Example 2 with AzureCredentialResponseParameters

use of com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialResponseParameters in project cloudbreak by hortonworks.

the class AzureCredentialV1ParametersToAzureCredentialAttributesConverter method convert.

public AzureCredentialResponseParameters convert(AzureCredentialAttributes source) {
    AzureCredentialResponseParameters response = new AzureCredentialResponseParameters();
    doIfNotNull(source.getCodeGrantFlowBased(), param -> response.setRoleBased(getRoleBased(param)));
    doIfNotNull(source.getAppBased(), param -> response.setAccessKey(param.getAccessKey()));
    doIfNotNull(source.getCodeGrantFlowBased(), param -> response.setAccessKey(param.getAccessKey()));
    response.setSubscriptionId(source.getSubscriptionId());
    response.setTenantId(source.getTenantId());
    return response;
}
Also used : AzureCredentialResponseParameters(com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialResponseParameters)

Aggregations

AzureCredentialResponseParameters (com.sequenceiq.environment.api.v1.credential.model.parameters.azure.AzureCredentialResponseParameters)2 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)1 Credential (com.sequenceiq.redbeams.dto.Credential)1 Test (org.junit.Test)1