use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class PlatformParameterServiceTest method getPlatformResourceRequestCredentialByCrn.
@Test
void getPlatformResourceRequestCredentialByCrn() {
final Credential credential = new Credential();
credential.setCloudPlatform("anotherVariant");
when(credentialService.getOptionalByCrnForAccountId(eq(CREDENTIAL_CRN), eq(ACCOUNT_ID), eq(ENVIRONMENT))).thenReturn(Optional.of(credential));
when(credentialService.extractCredential(any(), any())).thenReturn(credential);
PlatformResourceRequest result = platformParameterServiceUnderTest.getPlatformResourceRequest(ACCOUNT_ID, null, CREDENTIAL_CRN, REGION, PLATFORM_VARIANT, AVAILIBILTY_ZONE);
assertEquals(credential, result.getCredential());
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class AuditCredentialAuthorizationIntegrationTest method getAwsCredential.
private Credential getAwsCredential(String name, String accountId, String userCrn) {
Credential credential = new Credential();
credential.setName(name);
credential.setResourceCrn(getResourceCrn(name, accountId));
credential.setAccountId(accountId);
credential.setCloudPlatform("AWS");
credential.setCreator(userCrn);
credential.setDescription("description");
credential.setType(CredentialType.AUDIT);
credential.setGovCloud(false);
credential.setArchived(false);
return credential;
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class CredentialAuthorizationIntegrationTest method getAwsCredential.
private Credential getAwsCredential(String name, String accountId, String userCrn) {
Credential credential = new Credential();
credential.setName(name);
credential.setResourceCrn(getResourceCrn(name, accountId));
credential.setAccountId(accountId);
credential.setCloudPlatform("AWS");
credential.setCreator(userCrn);
credential.setDescription("description");
credential.setType(CredentialType.ENVIRONMENT);
credential.setGovCloud(false);
credential.setArchived(false);
return credential;
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method createEnvironment.
private Environment createEnvironment() {
Environment environment = new Environment();
environment.setName(ENV_NAME);
environment.setId(1L);
environment.setAccountId("2");
environment.setDescription("description");
environment.setCloudPlatform("AZURE");
environment.setCredential(new Credential());
environment.setLatitude(2.4);
environment.setLongitude(3.5);
environment.setLocation(LOCATION);
environment.setLocationDisplayName("London");
environment.setNetwork(new AzureNetwork());
environment.setRegions(Collections.singleton(new Region()));
return environment;
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class PlatformParameterService method getPlatformResourceRequest.
// CHECKSTYLE:OFF
public PlatformResourceRequest getPlatformResourceRequest(String accountId, String credentialName, String credentialCrn, String region, String platformVariant, String availabilityZone, String sharedProjectId, Map<String, String> filter, AccessConfigTypeQueryParam accessConfigType, CdpResourceType cdpResourceType) {
// CHECKSTYLE:ON
PlatformResourceRequest platformResourceRequest = new PlatformResourceRequest();
if (!Strings.isNullOrEmpty(credentialName)) {
Optional<Credential> credential = credentialService.getOptionalByNameForAccountId(credentialName, accountId, ENVIRONMENT);
if (credential.isEmpty()) {
credential = credentialService.getOptionalByNameForAccountId(credentialName, accountId, AUDIT);
}
platformResourceRequest.setCredential(credentialService.extractCredential(credential, credentialName));
} else if (!Strings.isNullOrEmpty(credentialCrn)) {
Optional<Credential> credential = credentialService.getOptionalByCrnForAccountId(credentialCrn, accountId, ENVIRONMENT);
if (credential.isEmpty()) {
credential = credentialService.getOptionalByCrnForAccountId(credentialCrn, accountId, AUDIT);
}
platformResourceRequest.setCredential(credentialService.extractCredential(credential, credentialCrn));
} else {
throw new BadRequestException("The credentialCrn or the credentialName must be specified in the request");
}
if (!Strings.isNullOrEmpty(platformVariant)) {
platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().getCloudPlatform());
} else {
platformResourceRequest.setPlatformVariant(Strings.isNullOrEmpty(platformVariant) ? platformResourceRequest.getCredential().getCloudPlatform() : platformVariant);
}
platformResourceRequest.setCdpResourceType(Objects.requireNonNullElse(cdpResourceType, CdpResourceType.DEFAULT));
platformResourceRequest.setRegion(region);
platformResourceRequest.setCloudPlatform(platformResourceRequest.getCredential().getCloudPlatform());
if (!Strings.isNullOrEmpty(availabilityZone)) {
platformResourceRequest.setAvailabilityZone(availabilityZone);
}
String accessConfigTypeString = NullUtil.getIfNotNull(accessConfigType, Enum::name);
if (filter != null) {
initFilterMap(platformResourceRequest);
for (Map.Entry<String, String> entry : filter.entrySet()) {
platformResourceRequest.getFilters().put(entry.getKey(), entry.getValue());
}
}
if (accessConfigTypeString != null) {
initFilterMap(platformResourceRequest);
platformResourceRequest.getFilters().put(ACCESS_CONFIG_TYPE, accessConfigTypeString);
}
if (!Strings.isNullOrEmpty(sharedProjectId)) {
initFilterMap(platformResourceRequest);
platformResourceRequest.getFilters().put(SHARED_PROJECT_ID, sharedProjectId);
}
return platformResourceRequest;
}
Aggregations