use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class NetworkServiceTest method testSaveNetworkIfNewNetwork.
@Test
public void testSaveNetworkIfNewNetwork() {
NetworkDto networkDto = mock(NetworkDto.class);
EnvironmentNetworkConverter environmentNetworkConverter = mock(EnvironmentNetworkConverter.class);
Network network = mock(Network.class);
Credential credential = mock(Credential.class);
BaseNetwork baseNetwork = new AwsNetwork();
baseNetwork.setRegistrationType(RegistrationType.CREATE_NEW);
Environment environment = new Environment();
environment.setCloudPlatform("AWS");
environment.setCredential(credential);
when(environmentNetworkConverterMap.get(any(CloudPlatform.class))).thenReturn(environmentNetworkConverter);
when(environmentNetworkConverter.convert(environment, networkDto, Map.of(), Map.of())).thenReturn(baseNetwork);
when(networkRepository.save(baseNetwork)).thenReturn(baseNetwork);
BaseNetwork result = underTest.saveNetwork(environment, networkDto, "accountId", Map.of(), Map.of());
Assertions.assertNull(result.getNetworkCidr());
verify(environmentNetworkService, times(0)).getNetworkCidr(eq(network), anyString(), eq(credential));
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class NetworkServiceTest method testRefreshMetadataFromAwsCloudProviderMustUseSubnetId.
@Test
public void testRefreshMetadataFromAwsCloudProviderMustUseSubnetId() {
NetworkDto networkDto = mock(NetworkDto.class);
AuthenticationDto authenticationDto = mock(AuthenticationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
EnvironmentBackup environmentBackup = mock(EnvironmentBackup.class);
SecurityAccessDto securityAccessDto = mock(SecurityAccessDto.class);
ParametersDto parametersDto = mock(ParametersDto.class);
EnvironmentNetworkConverter environmentNetworkConverter = mock(EnvironmentNetworkConverter.class);
Network network = mock(Network.class);
Credential credential = mock(Credential.class);
BaseNetwork baseNetwork = new GcpNetwork();
baseNetwork.setRegistrationType(RegistrationType.EXISTING);
Environment environment = new Environment();
environment.setCloudPlatform("AWS");
environment.setCredential(credential);
EnvironmentEditDto environmentEditDto = new EnvironmentEditDto("description", "accountId", networkDto, authenticationDto, environmentTelemetry, environmentBackup, securityAccessDto, Tunnel.CCMV2, IdBrokerMappingSource.MOCK, CloudStorageValidation.ENABLED, "adminGroupName", parametersDto);
when(environmentNetworkConverterMap.get(any(CloudPlatform.class))).thenReturn(environmentNetworkConverter);
when(environmentNetworkConverter.convertToDto(baseNetwork)).thenReturn(networkDto);
when(cloudNetworkService.retrieveSubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(cloudNetworkService.retrieveEndpointGatewaySubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(environmentNetworkConverter.convertToNetwork(any(BaseNetwork.class))).thenReturn(network);
when(environmentNetworkService.getNetworkCidr(any(Network.class), anyString(), any(Credential.class))).thenReturn(new NetworkCidr("10.0.0.0", new ArrayList<>()));
BaseNetwork result = underTest.refreshMetadataFromCloudProvider(baseNetwork, environmentEditDto, environment);
Assertions.assertEquals(result.getSubnetMetas().keySet().stream().findFirst().get(), "s1");
Assertions.assertEquals(result.getSubnetMetas().keySet().size(), 1);
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class AwsParameterValidatorTest method setUp.
@BeforeEach
void setUp() {
Credential credential = new Credential();
credential.setCloudPlatform("platform");
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setId(ENV_ID);
environmentDto.setLocation(new LocationDto("location", "location", 1.0, 1.0));
environmentDto.setCredential(credential);
environmentValidationDto = new EnvironmentValidationDto();
environmentValidationDto.setValidationType(ValidationType.ENVIRONMENT_CREATION);
environmentValidationDto.setEnvironmentDto(environmentDto);
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class EnvironmentNetworkServiceTest method testGetNetworkCidr.
@Test
void testGetNetworkCidr() {
Credential credential = mock(Credential.class);
CloudCredential cloudCredential = mock(CloudCredential.class);
Network network = mock(Network.class);
String networkCidr = "10.0.0.0/16";
when(credentialToCloudCredentialConverter.convert(credential)).thenReturn(cloudCredential);
when(cloudConnector.networkConnector()).thenReturn(networkConnector);
when(networkConnector.getNetworkCidr(network, cloudCredential)).thenReturn(new NetworkCidr(networkCidr));
NetworkCidr result = underTest.getNetworkCidr(network, "AWS", credential);
assertEquals(networkCidr, result.getCidr());
}
use of com.sequenceiq.environment.credential.domain.Credential in project cloudbreak by hortonworks.
the class EnvironmentNetworkServiceTest method testGetNetworkCidrWhenNetworkNull.
@Test
void testGetNetworkCidrWhenNetworkNull() {
Credential credential = mock(Credential.class);
NetworkCidr result = underTest.getNetworkCidr(null, "AWS", credential);
assertNull(result);
}
Aggregations