use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class AuditCredentialV1ControllerTest method testGetPrerequisitesForCloudPlatform.
@Test
void testGetPrerequisitesForCloudPlatform() {
CredentialPrerequisitesResponse credentialPrerequisitesResponse = mock(CredentialPrerequisitesResponse.class);
when(credentialService.getPrerequisites(PLATFORM, false, DEPLOYMENT_ADDRESS, USER_CRN, CredentialType.AUDIT)).thenReturn(credentialPrerequisitesResponse);
CredentialPrerequisitesResponse response = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.getPrerequisitesForCloudPlatform(PLATFORM, false, DEPLOYMENT_ADDRESS));
assertThat(response).isEqualTo(credentialPrerequisitesResponse);
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class CredentialV1ControllerTest method testGetPrerequisitesForCloudPlatform.
@Test
void testGetPrerequisitesForCloudPlatform() {
CredentialPrerequisitesResponse credentialPrerequisitesResponse = mock(CredentialPrerequisitesResponse.class);
when(credentialService.getPrerequisites(PLATFORM, false, DEPLOYMENT_ADDRESS, USER_CRN, CredentialType.ENVIRONMENT)).thenReturn(credentialPrerequisitesResponse);
CredentialPrerequisitesResponse response = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.getPrerequisitesForCloudPlatform(PLATFORM, false, DEPLOYMENT_ADDRESS));
assertThat(response).isEqualTo(credentialPrerequisitesResponse);
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class GcpCredentialConnectorTest method testPrerequisites.
@Test
public void testPrerequisites() {
final AuthenticatedContext authContext = createAuthContext();
when(gcpPlatformParameters.getPrerequisitesCreationCommand(CredentialType.ENVIRONMENT)).thenReturn("prerequisites");
CredentialPrerequisitesResponse prerequisites = underTest.getPrerequisites(authContext.getCloudContext(), "externalId", "auditExternalId", "deploymentAddress", CredentialType.ENVIRONMENT);
CredentialPrerequisitesResponse credentialPrerequisitesResponse = new CredentialPrerequisitesResponse("platform", new GcpCredentialPrerequisites(Base64.encodeBase64String("prerequisites".getBytes())));
Assert.assertEquals(credentialPrerequisitesResponse, prerequisites);
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class CredentialExperienceTest method getCredentialPrerequisitesResponse.
private CredentialPrerequisitesResponse getCredentialPrerequisitesResponse(String cloudProvider, String policy) {
CredentialPrerequisitesResponse response = new CredentialPrerequisitesResponse();
switch(cloudProvider) {
case "AWS":
response.setAws(new AwsCredentialPrerequisites());
response.getAws().setPolicyJson(policy);
response.getAws().setPolicies(Map.of("Environment", MINIMAL_POLICY));
break;
case "AZURE":
response.setAzure(new AzureCredentialPrerequisites());
response.getAzure().setRoleDefitionJson(policy);
break;
case "GCP":
response.setGcp(new GcpCredentialPrerequisites());
break;
default:
}
return response;
}
use of com.sequenceiq.cloudbreak.cloud.response.CredentialPrerequisitesResponse in project cloudbreak by hortonworks.
the class AzureCredentialConnectorTest method testGetPrerequisitesReturnsTheExpectedValue.
@Test
public void testGetPrerequisitesReturnsTheExpectedValue() {
String expectedCommand = "someAppCreationCommandValue";
String expectedRoleDef = "roleDefJson";
when(appCreationCommand.generateEnvironmentCredentialCommand(anyString())).thenReturn(expectedCommand);
when(azurePlatformParameters.getRoleDefJson()).thenReturn(expectedRoleDef);
CredentialPrerequisitesResponse result = underTest.getPrerequisites(TEST_CLOUD_CONTEXT, "2", "3", DEPLOYMENT_ADDRESS, CredentialType.ENVIRONMENT);
assertEquals(PLATFORM, result.getCloudPlatform());
assertEquals(expectedCommand, new String(Base64.decodeBase64(result.getAzure().getAppCreationCommand())));
assertEquals(expectedRoleDef, result.getAzure().getRoleDefitionJson());
}
Aggregations