use of bio.terra.workspace.generated.model.ApiAzureIpCreationParameters in project terra-workspace-manager by DataBiosphere.
the class CreateAzureRelayNamespaceStepTest method createRelayNamespace_alreadyExists.
@Test
public void createRelayNamespace_alreadyExists() throws InterruptedException {
final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
CreateAzureRelayNamespaceStep createStep = new CreateAzureRelayNamespaceStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureRelayNamespace(creationParameters.getName(), creationParameters.getRegion()));
// Stub creation to throw Conflict exception.
when(mockStage3.create(any(Context.class))).thenThrow(mockException);
final StepResult stepResult = createStep.doStep(mockFlightContext);
// Verify step still returns success
assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
}
use of bio.terra.workspace.generated.model.ApiAzureIpCreationParameters in project terra-workspace-manager by DataBiosphere.
the class CreateAzureIpStepTest method createIp_alreadyExists.
@Test
public void createIp_alreadyExists() throws InterruptedException {
final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
CreateAzureIpStep createAzureIpStep = new CreateAzureIpStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureIp(creationParameters.getName(), creationParameters.getRegion()));
// Stub creation to throw Conflict exception.
when(mockIpStage3.create(any(Context.class))).thenThrow(mockException);
final StepResult stepResult = createAzureIpStep.doStep(mockFlightContext);
// Verify step still returns success
assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
}
use of bio.terra.workspace.generated.model.ApiAzureIpCreationParameters in project terra-workspace-manager by DataBiosphere.
the class CreateAzureIpStepTest method createIp.
@Test
void createIp() throws InterruptedException {
final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
CreateAzureIpStep createAzureIpStep = new CreateAzureIpStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureIp(creationParameters.getName(), creationParameters.getRegion()));
final StepResult stepResult = createAzureIpStep.doStep(mockFlightContext);
// Verify step returns success
assertThat(stepResult, equalTo(StepResult.getStepResultSuccess()));
// Verify Azure create call was made correctly
verify(mockIpStage3).create(contextCaptor.capture());
Context context = contextCaptor.getValue();
Optional<CreatePublicIpRequestData> publicIpRequestDataOpt = context.getValues().values().stream().filter(CreatePublicIpRequestData.class::isInstance).map(CreatePublicIpRequestData.class::cast).findFirst();
CreatePublicIpRequestData expected = CreatePublicIpRequestData.builder().setName(creationParameters.getName()).setRegion(Region.fromName(creationParameters.getRegion())).setIpAllocationMethod(IpAllocationMethod.DYNAMIC).setTenantId(mockAzureCloudContext.getAzureTenantId()).setSubscriptionId(mockAzureCloudContext.getAzureSubscriptionId()).setResourceGroupName(mockAzureCloudContext.getAzureResourceGroupId()).build();
assertThat(publicIpRequestDataOpt, equalTo(Optional.of(expected)));
}
use of bio.terra.workspace.generated.model.ApiAzureIpCreationParameters in project terra-workspace-manager by DataBiosphere.
the class CreateAndDeleteAzureControlledResourceFlightTest method createIp.
ControlledAzureIpResource createIp(UUID workspaceId, AuthenticatedUserRequest userRequest) throws InterruptedException {
final ApiAzureIpCreationParameters ipCreationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
// TODO: make this application-private resource once the POC supports it
final UUID resourceId = UUID.randomUUID();
ControlledAzureIpResource resource = ControlledAzureIpResource.builder().common(ControlledResourceFields.builder().workspaceId(workspaceId).resourceId(resourceId).name(getAzureName("ip")).description(getAzureName("ip-desc")).cloningInstructions(CloningInstructions.COPY_RESOURCE).accessScope(AccessScopeType.fromApi(ApiAccessScope.SHARED_ACCESS)).managedBy(ManagedByType.fromApi(ApiManagedBy.USER)).build()).ipName(ipCreationParameters.getName()).region(ipCreationParameters.getRegion()).build();
// Submit an IP creation flight.
FlightState flightState = StairwayTestUtils.blockUntilFlightCompletes(jobService.getStairway(), CreateControlledResourceFlight.class, azureTestUtils.createControlledResourceInputParameters(workspaceId, userRequest, resource), STAIRWAY_FLIGHT_TIMEOUT, null);
assertEquals(FlightStatus.SUCCESS, flightState.getFlightStatus());
return resource;
}
use of bio.terra.workspace.generated.model.ApiAzureIpCreationParameters in project terra-workspace-manager by DataBiosphere.
the class GetAzureIpStepTest method getIp_alreadyExists.
@Test
public void getIp_alreadyExists() throws InterruptedException {
final ApiAzureIpCreationParameters creationParameters = ControlledResourceFixtures.getAzureIpCreationParameters();
GetAzureIpStep getAzureIpStep = new GetAzureIpStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureIp(creationParameters.getName(), creationParameters.getRegion()));
when(mockPublicIpAddresses.getByResourceGroup(mockAzureCloudContext.getAzureResourceGroupId(), creationParameters.getName())).thenReturn(mockPublicIpAddress);
final StepResult stepResult = getAzureIpStep.doStep(mockFlightContext);
// Verify step returns error
assertThat(stepResult.getStepStatus(), equalTo(StepStatus.STEP_RESULT_FAILURE_FATAL));
assertThat(stepResult.getException().get(), instanceOf(DuplicateResourceException.class));
}
Aggregations