From b36ced356929b9a9cc5ab821c7eebd8a16559497 Mon Sep 17 00:00:00 2001 From: Dex Amundsen Date: Tue, 18 Jul 2023 20:06:08 -0700 Subject: [PATCH] Commit changes --- ...ceApiControllerBqDatasetConnectedTest.java | 2 +- ...ceApiControllerGcsBucketConnectedTest.java | 6 +- ...ontrolledGcpResourceApiControllerTest.java | 8 +- ...ourceControllerBqDatasetConnectedTest.java | 2 +- ...esourceControllerBqTableConnectedTest.java | 2 +- ...ourceControllerGcsBucketConnectedTest.java | 2 +- ...ourceControllerGcsObjectConnectedTest.java | 2 +- .../ReferencedResourceCloneConnectedTest.java | 2 +- .../workspace/common/utils/MockGcpApi.java | 105 ++++++++++++++++++ .../workspace/common/utils/MockMvcUtils.java | 101 +++++------------ .../AnyResourceStateFailureTest.java | 12 +- .../GcpResourceStateFailureTest.java | 18 +-- .../GcpCloudContextConnectedTest.java | 2 +- 13 files changed, 161 insertions(+), 103 deletions(-) create mode 100644 service/src/test/java/bio/terra/workspace/common/utils/MockGcpApi.java diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerBqDatasetConnectedTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerBqDatasetConnectedTest.java index dba740c9d7..17acb89d1c 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerBqDatasetConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerBqDatasetConnectedTest.java @@ -2,7 +2,7 @@ import static bio.terra.workspace.common.GcsBucketUtils.waitForProjectAccess; import static bio.terra.workspace.common.fixtures.ControlledResourceFixtures.RESOURCE_DESCRIPTION; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.assertApiBqDatasetEquals; import static bio.terra.workspace.common.utils.MockMvcUtils.assertControlledResourceMetadata; import static bio.terra.workspace.common.utils.MockMvcUtils.assertResourceMetadata; diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerGcsBucketConnectedTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerGcsBucketConnectedTest.java index 2497833317..cde4897134 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerGcsBucketConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerGcsBucketConnectedTest.java @@ -6,9 +6,9 @@ import static bio.terra.workspace.common.GcsBucketUtils.buildSignedUrlListObject; import static bio.terra.workspace.common.GcsBucketUtils.waitForProjectAccess; import static bio.terra.workspace.common.fixtures.ControlledResourceFixtures.RESOURCE_DESCRIPTION; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.LOAD_SIGNED_URL_LIST_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.LOAD_SIGNED_URL_LIST_RESULT_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.LOAD_SIGNED_URL_LIST_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.LOAD_SIGNED_URL_LIST_RESULT_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.assertApiGcsBucketEquals; import static bio.terra.workspace.common.utils.MockMvcUtils.assertControlledResourceMetadata; import static bio.terra.workspace.common.utils.MockMvcUtils.assertResourceMetadata; diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerTest.java index 0e02e9ae13..ade97be2a2 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ControlledGcpResourceApiControllerTest.java @@ -1,9 +1,9 @@ package bio.terra.workspace.app.controller; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.GENERATE_GCP_AI_NOTEBOOK_NAME_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.GENERATE_GCP_BQ_DATASET_NAME_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.GENERATE_GCP_GCS_BUCKET_NAME_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.GENERATE_GCP_AI_NOTEBOOK_NAME_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.GENERATE_GCP_BQ_DATASET_NAME_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.GENERATE_GCP_GCS_BUCKET_NAME_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.service.workspace.model.WorkspaceConstants.ResourceProperties.FOLDER_ID_KEY; diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqDatasetConnectedTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqDatasetConnectedTest.java index d86a4964b5..25f0904c6a 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqDatasetConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqDatasetConnectedTest.java @@ -1,6 +1,6 @@ package bio.terra.workspace.app.controller; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.assertApiBqDatasetEquals; import static bio.terra.workspace.common.utils.MockMvcUtils.assertResourceMetadata; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqTableConnectedTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqTableConnectedTest.java index 4750346159..e236838bdd 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqTableConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerBqTableConnectedTest.java @@ -1,7 +1,7 @@ package bio.terra.workspace.app.controller; import static bio.terra.workspace.common.fixtures.ControlledResourceFixtures.RESOURCE_DESCRIPTION; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.assertApiBqDataTableEquals; import static bio.terra.workspace.common.utils.MockMvcUtils.assertResourceMetadata; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsBucketConnectedTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsBucketConnectedTest.java index 16d34b640c..b9eadef65f 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsBucketConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsBucketConnectedTest.java @@ -1,7 +1,7 @@ package bio.terra.workspace.app.controller; import static bio.terra.workspace.common.fixtures.ControlledResourceFixtures.RESOURCE_DESCRIPTION; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.assertApiGcsBucketEquals; import static bio.terra.workspace.common.utils.MockMvcUtils.assertResourceMetadata; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsObjectConnectedTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsObjectConnectedTest.java index f0ef09d6f7..da1af33022 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsObjectConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedGcpResourceControllerGcsObjectConnectedTest.java @@ -1,7 +1,7 @@ package bio.terra.workspace.app.controller; import static bio.terra.workspace.common.fixtures.ControlledResourceFixtures.RESOURCE_DESCRIPTION; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.assertResourceMetadata; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsInAnyOrder; diff --git a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedResourceCloneConnectedTest.java b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedResourceCloneConnectedTest.java index 85fce96124..c3eced71e9 100644 --- a/service/src/test/java/bio/terra/workspace/app/controller/ReferencedResourceCloneConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/app/controller/ReferencedResourceCloneConnectedTest.java @@ -4,7 +4,7 @@ import static bio.terra.workspace.common.fixtures.PolicyFixtures.IOWA_REGION; import static bio.terra.workspace.common.fixtures.WorkspaceFixtures.DEFAULT_SPEND_PROFILE_NAME; import static bio.terra.workspace.common.utils.MockMvcUtils.CLONE_WORKSPACE_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/service/src/test/java/bio/terra/workspace/common/utils/MockGcpApi.java b/service/src/test/java/bio/terra/workspace/common/utils/MockGcpApi.java new file mode 100644 index 0000000000..ae710f15b6 --- /dev/null +++ b/service/src/test/java/bio/terra/workspace/common/utils/MockGcpApi.java @@ -0,0 +1,105 @@ +package bio.terra.workspace.common.utils; + +import org.springframework.stereotype.Component; + +@Component +public class MockGcpApi extends MockMvcUtils { + + // GCS Bucket + + public static final String GET_REFERENCED_GCP_GCS_BUCKET_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/buckets/%s"; + public static final String CLONE_CONTROLLED_GCP_GCS_BUCKET_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/%s/clone"; + public static final String CLONE_RESULT_CONTROLLED_GCP_GCS_BUCKET_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/clone-result/%s"; + public static final String GENERATE_GCP_GCS_BUCKET_NAME_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/generateName"; + public static final String CONTROLLED_GCP_GCS_BUCKETS_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/buckets"; + public static final String CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT = // todo-dex + "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/%s"; + public static final String REFERENCED_GCP_GCS_BUCKETS_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/buckets"; + public static final String LOAD_SIGNED_URL_LIST_PATH_FORMAT = + "/api/workspaces/alpha1/%s/resources/controlled/gcp/buckets/%s/load"; + public static final String LOAD_SIGNED_URL_LIST_RESULT_PATH_FORMAT = + "/api/workspaces/alpha1/%s/resources/controlled/gcp/buckets/%s/load/result/%s"; + public static final String REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/buckets/%s"; + public static final String CLONE_REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/buckets/%s/clone"; + + // GCS Object + + public static final String REFERENCED_GCP_GCS_OBJECTS_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bucket/objects"; + public static final String REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bucket/objects/%s"; + public static final String CLONE_REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bucket/objects/%s/clone"; + + // Big Query + + public static final String CONTROLLED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets"; + public static final String CONTROLLED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/%s"; + public static final String CLONE_CONTROLLED_GCP_BIG_QUERY_DATASET_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/%s/clone"; + public static final String CLONE_RESULT_CONTROLLED_GCP_BIG_QUERY_DATASET_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/clone-result/%s"; + + // BQ Dataset + + public static final String GENERATE_GCP_BQ_DATASET_NAME_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/generateName"; + public static final String REFERENCED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatasets"; + public static final String REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatasets/%s"; + public static final String CLONE_REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatasets/%s/clone"; + + // BQ Datatable + + public static final String REFERENCED_GCP_BIG_QUERY_DATA_TABLES_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatatables"; + public static final String REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatatables/%s"; + public static final String CLONE_REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatatables/%s/clone"; + + // AI Notebook + + public static final String GENERATE_GCP_AI_NOTEBOOK_NAME_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances/generateName"; + public static final String CONTROLLED_GCP_AI_NOTEBOOKS_V1_PATH_FORMAT = // TODO-dex + "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances"; + public static final String CONTROLLED_GCP_AI_NOTEBOOK_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances/%s"; + public static final String CONTROLLED_GCP_AI_NOTEBOOKS_V1_RESULT_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances/create-result/%s"; + + // GCE Instance + + public static final String GENERATE_GCP_GCE_INSTANCE_NAME_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances/generateName"; + public static final String CONTROLLED_GCP_GCE_INSTANCES_V1_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances"; + public static final String CONTROLLED_GCP_GCE_INSTANCE_V1_PATH_FORMAT = // TODO-dex + "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances/%s"; + public static final String CONTROLLED_GCP_GCE_INSTANCES_V1_RESULT_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances/create-result/%s"; + + // DataProc Cluster + + public static final String GENERATE_GCP_DATAPROC_CLUSTER_NAME_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters/generateName"; + public static final String CONTROLLED_GCP_DATAPROC_CLUSTERS_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters"; + public static final String CONTROLLED_GCP_DATAPROC_CLUSTER_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters/%s"; + public static final String CONTROLLED_GCP_DATAPROC_CLUSTERS_RESULT_PATH_FORMAT = + "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters/create-result/%s"; +} diff --git a/service/src/test/java/bio/terra/workspace/common/utils/MockMvcUtils.java b/service/src/test/java/bio/terra/workspace/common/utils/MockMvcUtils.java index 209808cb0a..f4342428a5 100644 --- a/service/src/test/java/bio/terra/workspace/common/utils/MockMvcUtils.java +++ b/service/src/test/java/bio/terra/workspace/common/utils/MockMvcUtils.java @@ -3,6 +3,32 @@ import static bio.terra.workspace.common.fixtures.ControlledResourceFixtures.DEFAULT_RESOURCE_PROPERTIES; import static bio.terra.workspace.common.fixtures.WorkspaceFixtures.DEFAULT_USER_EMAIL; import static bio.terra.workspace.common.fixtures.WorkspaceFixtures.DEFAULT_USER_SUBJECT_ID; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_CONTROLLED_GCP_BIG_QUERY_DATASET_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_CONTROLLED_GCP_GCS_BUCKET_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_RESULT_CONTROLLED_GCP_BIG_QUERY_DATASET_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CLONE_RESULT_CONTROLLED_GCP_GCS_BUCKET_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_AI_NOTEBOOKS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_AI_NOTEBOOKS_V1_RESULT_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_DATAPROC_CLUSTERS_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_DATAPROC_CLUSTERS_RESULT_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCE_INSTANCES_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCE_INSTANCES_V1_RESULT_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATA_TABLES_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_OBJECTS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT; import static bio.terra.workspace.db.WorkspaceActivityLogDao.ACTIVITY_LOG_CHANGE_DETAILS_ROW_MAPPER; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.anyOf; @@ -241,88 +267,18 @@ public class MockMvcUtils { "/api/workspaces/v1/%s/cloudcontexts/GCP"; public static final String GET_CLOUD_CONTEXT_PATH_FORMAT = "/api/workspaces/v1/%s/cloudcontexts/result/%s"; - public static final String GET_REFERENCED_GCP_GCS_BUCKET_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/buckets/%s"; - public static final String CLONE_CONTROLLED_GCP_GCS_BUCKET_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/%s/clone"; - public static final String CLONE_RESULT_CONTROLLED_GCP_GCS_BUCKET_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/clone-result/%s"; - public static final String GENERATE_GCP_GCS_BUCKET_NAME_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/generateName"; - public static final String GENERATE_GCP_BQ_DATASET_NAME_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/generateName"; - public static final String GENERATE_GCP_AI_NOTEBOOK_NAME_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances/generateName"; - public static final String GENERATE_GCP_GCE_INSTANCE_NAME_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances/generateName"; - public static final String GENERATE_GCP_DATAPROC_CLUSTER_NAME_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters/generateName"; public static final String FOLDERS_V1_PATH_FORMAT = "/api/workspaces/v1/%s/folders"; public static final String FOLDER_V1_PATH_FORMAT = "/api/workspaces/v1/%s/folders/%s"; public static final String FOLDER_PROPERTIES_V1_PATH_FORMAT = "/api/workspaces/v1/%s/folders/%s/properties"; public static final String RESOURCE_PROPERTIES_V1_PATH_FORMAT = "/api/workspaces/v1/%s/resources/%s/properties"; - public static final String CONTROLLED_GCP_AI_NOTEBOOKS_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances"; - public static final String CONTROLLED_GCP_AI_NOTEBOOK_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances/%s"; - public static final String CONTROLLED_GCP_AI_NOTEBOOKS_V1_RESULT_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/ai-notebook-instances/create-result/%s"; - public static final String CONTROLLED_GCP_GCE_INSTANCES_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances"; - public static final String CONTROLLED_GCP_GCE_INSTANCE_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances/%s"; - public static final String CONTROLLED_GCP_GCE_INSTANCES_V1_RESULT_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/gce-instances/create-result/%s"; - public static final String CONTROLLED_GCP_DATAPROC_CLUSTERS_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters"; - public static final String CONTROLLED_GCP_DATAPROC_CLUSTER_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters/%s"; - public static final String CONTROLLED_GCP_DATAPROC_CLUSTERS_RESULT_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/dataproc-clusters/create-result/%s"; - public static final String CONTROLLED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets"; - public static final String CONTROLLED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/%s"; - public static final String CLONE_CONTROLLED_GCP_BIG_QUERY_DATASET_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/%s/clone"; - public static final String CLONE_RESULT_CONTROLLED_GCP_BIG_QUERY_DATASET_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/bqdatasets/clone-result/%s"; - public static final String CONTROLLED_GCP_GCS_BUCKETS_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/buckets"; - public static final String CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/controlled/gcp/buckets/%s"; public static final String REFERENCED_DATA_REPO_SNAPSHOTS_V1_PATH_FORMAT = "/api/workspaces/v1/%s/resources/referenced/datarepo/snapshots"; public static final String REFERENCED_DATA_REPO_SNAPSHOT_V1_PATH_FORMAT = "/api/workspaces/v1/%s/resources/referenced/datarepo/snapshots/%s"; public static final String CLONE_REFERENCED_DATA_REPO_SNAPSHOT_V1_PATH_FORMAT = "/api/workspaces/v1/%s/resources/referenced/datarepo/snapshots/%s/clone"; - public static final String REFERENCED_GCP_GCS_BUCKETS_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/buckets"; - public static final String REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/buckets/%s"; - public static final String CLONE_REFERENCED_GCP_GCS_BUCKET_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/buckets/%s/clone"; - public static final String REFERENCED_GCP_GCS_OBJECTS_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bucket/objects"; - public static final String REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bucket/objects/%s"; - public static final String CLONE_REFERENCED_GCP_GCS_OBJECT_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bucket/objects/%s/clone"; - public static final String REFERENCED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatasets"; - public static final String REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatasets/%s"; - public static final String CLONE_REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatasets/%s/clone"; - public static final String REFERENCED_GCP_BIG_QUERY_DATA_TABLES_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatatables"; - public static final String REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatatables/%s"; - public static final String CLONE_REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT = - "/api/workspaces/v1/%s/resources/referenced/gcp/bigquerydatatables/%s/clone"; public static final String REFERENCED_GIT_REPOS_V1_PATH_FORMAT = "/api/workspaces/v1/%s/resources/referenced/gitrepos"; public static final String REFERENCED_GIT_REPO_V1_PATH_FORMAT = @@ -339,10 +295,7 @@ public class MockMvcUtils { "/api/workspaces/v1/%s/resources/controlled/any/flexibleResources/%s/clone"; public static final String UPDATE_POLICIES_PATH_FORMAT = "/api/workspaces/v1/%s/policies"; public static final String POLICY_V1_GET_REGION_INFO_PATH = "/api/policies/v1/getLocationInfo"; - public static final String LOAD_SIGNED_URL_LIST_PATH_FORMAT = - "/api/workspaces/alpha1/%s/resources/controlled/gcp/buckets/%s/load"; - public static final String LOAD_SIGNED_URL_LIST_RESULT_PATH_FORMAT = - "/api/workspaces/alpha1/%s/resources/controlled/gcp/buckets/%s/load/result/%s"; + // Only use this if you are mocking SAM. If you're using real SAM, // use userAccessUtils.defaultUserAuthRequest() instead. public static final AuthenticatedUserRequest USER_REQUEST = diff --git a/service/src/test/java/bio/terra/workspace/service/resource/statetests/AnyResourceStateFailureTest.java b/service/src/test/java/bio/terra/workspace/service/resource/statetests/AnyResourceStateFailureTest.java index 4c56ffd60f..1a8e118888 100644 --- a/service/src/test/java/bio/terra/workspace/service/resource/statetests/AnyResourceStateFailureTest.java +++ b/service/src/test/java/bio/terra/workspace/service/resource/statetests/AnyResourceStateFailureTest.java @@ -3,12 +3,12 @@ import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_FLEXIBLE_RESOURCES_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_DATA_REPO_SNAPSHOTS_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_DATA_REPO_SNAPSHOT_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_BIG_QUERY_DATA_TABLES_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GCP_GCS_OBJECTS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATA_TABLES_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_BIG_QUERY_DATA_TABLE_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.REFERENCED_GCP_GCS_OBJECTS_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GIT_REPOS_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.REFERENCED_GIT_REPO_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.USER_REQUEST; diff --git a/service/src/test/java/bio/terra/workspace/service/resource/statetests/GcpResourceStateFailureTest.java b/service/src/test/java/bio/terra/workspace/service/resource/statetests/GcpResourceStateFailureTest.java index 16bbe9d3ce..137edd2791 100644 --- a/service/src/test/java/bio/terra/workspace/service/resource/statetests/GcpResourceStateFailureTest.java +++ b/service/src/test/java/bio/terra/workspace/service/resource/statetests/GcpResourceStateFailureTest.java @@ -1,14 +1,14 @@ package bio.terra.workspace.service.resource.statetests; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_AI_NOTEBOOKS_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_AI_NOTEBOOK_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_DATAPROC_CLUSTERS_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_GCE_INSTANCES_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_GCE_INSTANCE_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_AI_NOTEBOOKS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_AI_NOTEBOOK_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_BIG_QUERY_DATASETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_BIG_QUERY_DATASET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_DATAPROC_CLUSTERS_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCE_INSTANCES_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCE_INSTANCE_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCS_BUCKETS_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT; import static bio.terra.workspace.common.utils.MockMvcUtils.USER_REQUEST; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; diff --git a/service/src/test/java/bio/terra/workspace/service/workspace/GcpCloudContextConnectedTest.java b/service/src/test/java/bio/terra/workspace/service/workspace/GcpCloudContextConnectedTest.java index 0e10d672f5..8e34b1ef6a 100644 --- a/service/src/test/java/bio/terra/workspace/service/workspace/GcpCloudContextConnectedTest.java +++ b/service/src/test/java/bio/terra/workspace/service/workspace/GcpCloudContextConnectedTest.java @@ -1,6 +1,6 @@ package bio.terra.workspace.service.workspace; -import static bio.terra.workspace.common.utils.MockMvcUtils.CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT; +import static bio.terra.workspace.common.utils.MockGcpApi.CONTROLLED_GCP_GCS_BUCKET_V1_PATH_FORMAT; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; import static org.hibernate.validator.internal.util.Contracts.assertNotNull;