use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreateNetworkRequestData in project terra-workspace-manager by DataBiosphere.
the class CreateAzureNetworkStepTest method createNetwork.
@Test
void createNetwork() throws InterruptedException {
final ApiAzureNetworkCreationParameters creationParameters = ControlledResourceFixtures.getAzureNetworkCreationParameters();
var createAzureNetworkStep = new CreateAzureNetworkStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureNetwork(creationParameters));
final StepResult stepResult = createAzureNetworkStep.doStep(mockFlightContext);
// Verify step returns success
assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
// Verify Azure create call was made correctly
verify(mockNetworkStage13).create(contextCaptor.capture());
Context context = contextCaptor.getValue();
Optional<CreateNetworkRequestData> requestDataOpt = context.getValues().values().stream().filter(CreateNetworkRequestData.class::isInstance).map(CreateNetworkRequestData.class::cast).findFirst();
CreateNetworkRequestData expected = CreateNetworkRequestData.builder().setName(creationParameters.getName()).setRegion(Region.fromName(creationParameters.getRegion())).setSubnetName(creationParameters.getSubnetName()).setAddressSpaceCidr(creationParameters.getAddressSpaceCidr()).setNetworkSecurityGroup(mockNsg).setAddressPrefix(creationParameters.getSubnetAddressCidr()).setTenantId(mockAzureCloudContext.getAzureTenantId()).setSubscriptionId(mockAzureCloudContext.getAzureSubscriptionId()).setResourceGroupName(mockAzureCloudContext.getAzureResourceGroupId()).build();
assertThat(requestDataOpt, equalTo(Optional.of(expected)));
}
use of bio.terra.cloudres.azure.resourcemanager.compute.data.CreateNetworkRequestData in project terra-cloud-resource-lib by DataBiosphere.
the class ComputeRequestDataTest method serializeCreateNetwork.
@Test
public void serializeCreateNetwork() {
CreateNetworkRequestData createNetwork = CreateNetworkRequestData.builder().setName("my-network").setTenantId("my-tenant").setSubscriptionId("my-sub").setResourceGroupName("my-rg").setRegion(Region.US_EAST).setAddressSpaceCidr("192.168.0.0/16").setSubnetName("my-subnet").setAddressPrefix("192.168.1.0/24").setNetworkSecurityGroup(mockNetworkSecurityGroup()).build();
assertEquals(ComputeManagerOperation.AZURE_CREATE_NETWORK, createNetwork.cloudOperation());
assertEquals("{\"tenantId\":\"my-tenant\",\"subscriptionId\":\"my-sub\",\"resourceGroupName\":\"my-rg\"," + "\"name\":\"my-network\",\"region\":\"eastus\"," + "\"addressSpaceCidr\":\"192.168.0.0/16\",\"subnetName\":\"my-subnet\"," + "\"addressPrefix\":\"192.168.1.0/24\",\"networkSecurityGroupName\":\"my-nsg\"}", createNetwork.serialize().toString());
assertEquals(Optional.of(new CloudResourceUid().azureNetwork(new AzureNetwork().resourceGroup(azureResourceGroup(createNetwork)).networkName("my-network"))), createNetwork.resourceUidCreation());
}
Aggregations