Skip to content

Commit

Permalink
Rename Azure path formats
Browse files Browse the repository at this point in the history
  • Loading branch information
dexamundsen committed Jul 19, 2023
1 parent fd091b6 commit d3c5f87
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package bio.terra.workspace.app.controller;

import static bio.terra.workspace.common.fixtures.WorkspaceFixtures.DEFAULT_USER_EMAIL;
import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_AZURE_VM_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_CONTROLLED_AZURE_VM_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockMvcUtils.USER_REQUEST;
import static bio.terra.workspace.common.utils.MockMvcUtils.addAuth;
import static bio.terra.workspace.common.utils.MockMvcUtils.addJsonContentType;
Expand Down Expand Up @@ -51,7 +51,7 @@ public void createAzureVm400WithNoParameters() throws Exception {
mockMvc
.perform(
addAuth(
post(String.format(CREATE_AZURE_VM_PATH_FORMAT, workspaceId))
post(String.format(CREATE_CONTROLLED_AZURE_VM_PATH_FORMAT, workspaceId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand Down Expand Up @@ -97,7 +97,7 @@ public void createAzureVmWithoutDisk() throws Exception {
.perform(
addJsonContentType(
addAuth(
post(String.format(CREATE_AZURE_VM_PATH_FORMAT, workspaceId))
post(String.format(CREATE_CONTROLLED_AZURE_VM_PATH_FORMAT, workspaceId))
.content(objectMapper.writeValueAsString(vmRequest)),
USER_REQUEST)))
.andExpect(status().is(HttpStatus.SC_OK));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package bio.terra.workspace.app.controller;

import static bio.terra.workspace.common.fixtures.WorkspaceFixtures.DEFAULT_USER_EMAIL;
import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_AZURE_BATCH_POOL_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_CONTROLLED_AZURE_BATCH_POOL_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockMvcUtils.USER_REQUEST;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void createBatchPool400WithNoParameters() throws Exception {
mockMvc
.perform(
MockMvcUtils.addAuth(
post(String.format(CREATE_AZURE_BATCH_POOL_PATH_FORMAT, workspaceId))
post(String.format(CREATE_CONTROLLED_AZURE_BATCH_POOL_PATH_FORMAT, workspaceId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand Down Expand Up @@ -95,7 +95,7 @@ public void createBatchPool400WithInconsistentUAMI() throws Exception {
mockMvc
.perform(
MockMvcUtils.addAuth(
post(String.format(CREATE_AZURE_BATCH_POOL_PATH_FORMAT, workspaceId))
post(String.format(CREATE_CONTROLLED_AZURE_BATCH_POOL_PATH_FORMAT, workspaceId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand Down Expand Up @@ -137,7 +137,7 @@ public void createBatchPoolWithRequiredParametersSuccess() throws Exception {
mockMvc
.perform(
MockMvcUtils.addAuth(
post(String.format(CREATE_AZURE_BATCH_POOL_PATH_FORMAT, workspaceId))
post(String.format(CREATE_CONTROLLED_AZURE_BATCH_POOL_PATH_FORMAT, workspaceId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bio.terra.workspace.app.controller;

import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_AZURE_SAS_TOKEN_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAzureApi.CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockMvcUtils.USER_REQUEST;
import static bio.terra.workspace.common.utils.MockMvcUtils.addAuth;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -56,7 +56,9 @@ void createSASToken400BadDuration() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -69,7 +71,9 @@ void createSASToken400BadDuration() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -90,7 +94,9 @@ void createSASTokenCustomExpirationSuccess() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -103,7 +109,9 @@ void createSASTokenCustomExpirationSuccess() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8"),
Expand Down Expand Up @@ -133,7 +141,9 @@ void createSASToken400BadIPRange() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -149,7 +159,9 @@ void createSASTokenIpRangeSuccess() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -171,7 +183,9 @@ void createSASTokenBlobNameSuccess() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -191,7 +205,9 @@ void createSASTokenBlobNameInvalidName() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -207,7 +223,9 @@ void createSASTokenBlobPermissionsSuccess() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand All @@ -228,7 +246,9 @@ void createSASTokenBlobPermissionsInvalidPerms() throws Exception {
.perform(
addAuth(
post(String.format(
CREATE_AZURE_SAS_TOKEN_PATH_FORMAT, workspaceId, storageContainerId))
CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT,
workspaceId,
storageContainerId))
.contentType(MediaType.APPLICATION_JSON_VALUE)
.accept(MediaType.APPLICATION_JSON)
.characterEncoding("UTF-8")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
public class MockAwsApi extends MockMvcUtils {

// S3 folder

public static final String CREATE_CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT =
public static final String CREATE_CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/aws/storageFolder";
public static final String CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT =
CREATE_CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT + "/%s";
public static final String CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT =
CREATE_CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT + "/%s";

public ApiCreatedControlledAwsS3StorageFolder createControlledAwsS3StorageFolder(
AuthenticatedUserRequest userRequest,
Expand All @@ -34,7 +33,7 @@ public ApiCreatedControlledAwsS3StorageFolder createControlledAwsS3StorageFolder
String serializedResponse =
getSerializedResponseForPost(
userRequest,
CREATE_CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT,
CREATE_CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT,
workspaceId,
objectMapper.writeValueAsString(requestBody));
return objectMapper.readValue(serializedResponse, ApiCreatedControlledAwsS3StorageFolder.class);
Expand All @@ -44,14 +43,13 @@ public ApiAwsS3StorageFolderResource getControlledAwsS3StorageFolder(
AuthenticatedUserRequest userRequest, UUID workspaceId, UUID resourceId) throws Exception {
String serializedResponse =
getSerializedResponseForGet(
userRequest, CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT, workspaceId, resourceId);
userRequest, CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT, workspaceId, resourceId);
return objectMapper.readValue(serializedResponse, ApiAwsS3StorageFolderResource.class);
}

// SageMaker Notebook

public static final String CREATE_CONTROLLED_AWS_NOTEBOOK_V1_PATH_FORMAT =
public static final String CREATE_CONTROLLED_AWS_NOTEBOOK_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/aws/notebook";
public static final String CONTROLLED_AWS_NOTEBOOK_V1_PATH_FORMAT =
CREATE_CONTROLLED_AWS_NOTEBOOK_V1_PATH_FORMAT + "/%s";
public static final String CONTROLLED_AWS_NOTEBOOK_PATH_FORMAT =
CREATE_CONTROLLED_AWS_NOTEBOOK_PATH_FORMAT + "/%s";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,31 @@

@Component
public class MockAzureApi extends MockMvcUtils {
public static final String CREATE_AZURE_DISK_PATH_FORMAT =
// Disks
public static final String CREATE_CONTROLLED_AZURE_DISK_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/disks";
public static final String CREATE_AZURE_VM_PATH_FORMAT =
public static final String CONTROLLED_AZURE_DISK_PATH_FORMAT =
CREATE_CONTROLLED_AZURE_DISK_PATH_FORMAT + "/%s";

// VM
public static final String CREATE_CONTROLLED_AZURE_VM_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/vm";
public static final String CREATE_AZURE_SAS_TOKEN_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/storageContainer/%s/getSasToken";
public static final String CREATE_AZURE_BATCH_POOL_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/batchpool";
public static final String CREATE_AZURE_STORAGE_CONTAINERS_PATH_FORMAT =
public static final String CONTROLLED_AZURE_VM_PATH_FORMAT =
CREATE_CONTROLLED_AZURE_VM_PATH_FORMAT + "/%s";

// Storage Container
public static final String CREATE_CONTROLLED_AZURE_STORAGE_CONTAINER_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/storageContainer";
public static final String AZURE_BATCH_POOL_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/batchpool/%s";
public static final String AZURE_DISK_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/disks/%s";
public static final String AZURE_STORAGE_CONTAINER_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/storageContainer/%s";
public static final String AZURE_VM_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/vm/%s";
public static final String CLONE_AZURE_STORAGE_CONTAINER_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/storageContainer/%s/clone";
public static final String CONTROLLED_AZURE_STORAGE_CONTAINER_PATH_FORMAT =
CREATE_CONTROLLED_AZURE_STORAGE_CONTAINER_PATH_FORMAT + "/%s";
public static final String CLONE_CONTROLLED_AZURE_STORAGE_CONTAINER_PATH_FORMAT =
CONTROLLED_AZURE_STORAGE_CONTAINER_PATH_FORMAT + "/clone";
public static final String CONTROLLED_AZURE_STORAGE_CONTAINER_SAS_TOKEN_PATH_FORMAT =
CONTROLLED_AZURE_STORAGE_CONTAINER_PATH_FORMAT + "/getSasToken";

// Batch Pool
public static final String CREATE_CONTROLLED_AZURE_BATCH_POOL_PATH_FORMAT =
"/api/workspaces/v1/%s/resources/controlled/azure/batchpool";
public static final String CONTROLLED_AZURE_BATCH_POOL_PATH_FORMAT =
CREATE_CONTROLLED_AZURE_BATCH_POOL_PATH_FORMAT + "/%s";
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package bio.terra.workspace.service.resource.controlled.cloud.azure;

import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_AZURE_DISK_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_AZURE_VM_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_CONTROLLED_AZURE_DISK_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAzureApi.CREATE_CONTROLLED_AZURE_VM_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockMvcUtils.CREATE_CLOUD_CONTEXT_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockMvcUtils.GET_CLOUD_CONTEXT_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockMvcUtils.addAuth;
Expand Down Expand Up @@ -96,7 +96,7 @@ public void azureDisabledTest() throws Exception {
.perform(
addJsonContentType(
addAuth(
post(String.format(CREATE_AZURE_DISK_PATH_FORMAT, workspaceUuid))
post(String.format(CREATE_CONTROLLED_AZURE_DISK_PATH_FORMAT, workspaceUuid))
.content(objectMapper.writeValueAsString(diskRequest)),
userRequest)))
.andExpect(status().is(HttpStatus.SC_NOT_IMPLEMENTED));
Expand All @@ -110,7 +110,7 @@ public void azureDisabledTest() throws Exception {
.perform(
addJsonContentType(
addAuth(
post(String.format(CREATE_AZURE_VM_PATH_FORMAT, workspaceUuid))
post(String.format(CREATE_CONTROLLED_AZURE_VM_PATH_FORMAT, workspaceUuid))
.content(objectMapper.writeValueAsString(vmRequest)),
userRequest)))
.andExpect(status().is(HttpStatus.SC_NOT_IMPLEMENTED));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package bio.terra.workspace.service.resource.statetests;

import static bio.terra.workspace.common.utils.MockAwsApi.CONTROLLED_AWS_NOTEBOOK_V1_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAwsApi.CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAwsApi.CREATE_CONTROLLED_AWS_NOTEBOOK_V1_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAwsApi.CREATE_CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAwsApi.CONTROLLED_AWS_NOTEBOOK_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAwsApi.CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAwsApi.CREATE_CONTROLLED_AWS_NOTEBOOK_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockAwsApi.CREATE_CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT;
import static bio.terra.workspace.common.utils.MockMvcUtils.USER_REQUEST;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -82,7 +82,7 @@ void testAwsContextResourceCreateValidation() throws Exception {
mockMvcUtils.postExpect(
USER_REQUEST,
objectMapper.writeValueAsString(storageRequest),
CREATE_CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT.formatted(workspaceUuid),
CREATE_CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT.formatted(workspaceUuid),
HttpStatus.SC_CONFLICT);

// AWS-notebook
Expand All @@ -97,7 +97,7 @@ void testAwsContextResourceCreateValidation() throws Exception {
mockMvcUtils.postExpect(
USER_REQUEST,
objectMapper.writeValueAsString(vmRequest),
CREATE_CONTROLLED_AWS_NOTEBOOK_V1_PATH_FORMAT.formatted(workspaceUuid),
CREATE_CONTROLLED_AWS_NOTEBOOK_PATH_FORMAT.formatted(workspaceUuid),
HttpStatus.SC_CONFLICT);
}

Expand Down Expand Up @@ -132,7 +132,7 @@ void testAwsResourceModifyValidation() throws Exception {
stateTestUtils.postResourceExpectConflict(
workspaceUuid,
storageResource.getResourceId(),
CONTROLLED_AWS_STORAGE_FOLDER_V1_PATH_FORMAT,
CONTROLLED_AWS_STORAGE_FOLDER_PATH_FORMAT,
objectMapper.writeValueAsString(storageDeleteBody));

// AWS-Notebook
Expand All @@ -142,7 +142,7 @@ void testAwsResourceModifyValidation() throws Exception {
stateTestUtils.postResourceExpectConflict(
workspaceUuid,
notebookResource.getResourceId(),
CONTROLLED_AWS_NOTEBOOK_V1_PATH_FORMAT,
CONTROLLED_AWS_NOTEBOOK_PATH_FORMAT,
objectMapper.writeValueAsString(notebookDeleteBody));
}
}
Loading

0 comments on commit d3c5f87

Please sign in to comment.