Search in sources :

Example 1 with CreateRelayRequestData

use of bio.terra.cloudres.azure.resourcemanager.relay.data.CreateRelayRequestData in project terra-workspace-manager by DataBiosphere.

the class CreateAzureRelayNamespaceStepTest method createRelayNamespace.

@Test
void createRelayNamespace() throws InterruptedException {
    final ApiAzureRelayNamespaceCreationParameters creationParameters = ControlledResourceFixtures.getAzureRelayNamespaceCreationParameters();
    CreateAzureRelayNamespaceStep createAzureIpStep = new CreateAzureRelayNamespaceStep(mockAzureConfig, mockCrlService, ControlledResourceFixtures.getAzureRelayNamespace(creationParameters.getNamespaceName(), 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(mockStage3).create(contextCaptor.capture());
    Context context = contextCaptor.getValue();
    Optional<CreateRelayRequestData> requestDataOpt = context.getValues().values().stream().filter(CreateRelayRequestData.class::isInstance).map(CreateRelayRequestData.class::cast).findFirst();
    CreateRelayRequestData expected = CreateRelayRequestData.builder().setName(creationParameters.getNamespaceName()).setRegion(Region.fromName(creationParameters.getRegion())).setTenantId(dummyAzureCloudContext.getAzureTenantId()).setSubscriptionId(dummyAzureCloudContext.getAzureSubscriptionId()).setResourceGroupName(dummyAzureCloudContext.getAzureResourceGroupId()).build();
    assertThat(requestDataOpt, equalTo(Optional.of(expected)));
}
Also used : Context(com.azure.core.util.Context) AzureCloudContext(bio.terra.workspace.service.workspace.model.AzureCloudContext) FlightContext(bio.terra.stairway.FlightContext) ApiAzureRelayNamespaceCreationParameters(bio.terra.workspace.generated.model.ApiAzureRelayNamespaceCreationParameters) StepResult(bio.terra.stairway.StepResult) CreateRelayRequestData(bio.terra.cloudres.azure.resourcemanager.relay.data.CreateRelayRequestData) Test(org.junit.jupiter.api.Test) BaseAzureTest(bio.terra.workspace.common.BaseAzureTest)

Example 2 with CreateRelayRequestData

use of bio.terra.cloudres.azure.resourcemanager.relay.data.CreateRelayRequestData in project terra-cloud-resource-lib by DataBiosphere.

the class RelayManagerRequestDataTest method serializeCreateAzureRelay.

@Test
public void serializeCreateAzureRelay() {
    CreateRelayRequestData create = CreateRelayRequestData.builder().setName("my-relay").setTenantId("my-tenant").setSubscriptionId("my-sub").setResourceGroupName("my-rg").setRegion(Region.US_EAST).build();
    assertEquals(RelayManagerOperation.AZURE_CREATE_RELAY, create.cloudOperation());
    assertEquals("{\"tenantId\":\"my-tenant\",\"subscriptionId\":\"my-sub\",\"resourceGroupName\":\"my-rg\",\"name\":\"my-relay\",\"region\":\"eastus\"}", create.serialize().toString());
}
Also used : CreateRelayRequestData(bio.terra.cloudres.azure.resourcemanager.relay.data.CreateRelayRequestData) Test(org.junit.jupiter.api.Test)

Example 3 with CreateRelayRequestData

use of bio.terra.cloudres.azure.resourcemanager.relay.data.CreateRelayRequestData in project terra-cloud-resource-lib by DataBiosphere.

the class RelayManagerRequestDataTest method serializeCreateAzureRelayHybridConnection.

@Test
public void serializeCreateAzureRelayHybridConnection() {
    CreateRelayRequestData create = CreateRelayRequestData.builder().setName("my-relay-hc").setTenantId("my-tenant").setSubscriptionId("my-sub").setResourceGroupName("my-rg").setRegion(Region.US_EAST).build();
    assertEquals(RelayManagerOperation.AZURE_CREATE_RELAY, create.cloudOperation());
    assertEquals("{\"tenantId\":\"my-tenant\",\"subscriptionId\":\"my-sub\",\"resourceGroupName\":\"my-rg\",\"name\":\"my-relay-hc\",\"region\":\"eastus\"}", create.serialize().toString());
}
Also used : CreateRelayRequestData(bio.terra.cloudres.azure.resourcemanager.relay.data.CreateRelayRequestData) Test(org.junit.jupiter.api.Test)

Aggregations

CreateRelayRequestData (bio.terra.cloudres.azure.resourcemanager.relay.data.CreateRelayRequestData)3 Test (org.junit.jupiter.api.Test)3 FlightContext (bio.terra.stairway.FlightContext)1 StepResult (bio.terra.stairway.StepResult)1 BaseAzureTest (bio.terra.workspace.common.BaseAzureTest)1 ApiAzureRelayNamespaceCreationParameters (bio.terra.workspace.generated.model.ApiAzureRelayNamespaceCreationParameters)1 AzureCloudContext (bio.terra.workspace.service.workspace.model.AzureCloudContext)1 Context (com.azure.core.util.Context)1