use of bio.terra.model.DatasetSummaryModel in project jade-data-repo by DataBiosphere.
the class SnapshotConnectedTest method setupMinimalDataset.
private DatasetSummaryModel setupMinimalDataset() throws Exception {
DatasetSummaryModel datasetMinimalSummary = createTestDataset("dataset-minimal.json");
loadCsvData(datasetMinimalSummary.getId(), "participant", "dataset-minimal-participant.csv");
loadCsvData(datasetMinimalSummary.getId(), "sample", "dataset-minimal-sample.csv");
return datasetMinimalSummary;
}
use of bio.terra.model.DatasetSummaryModel in project jade-data-repo by DataBiosphere.
the class DatasetIntegrationTest method datasetUnauthorizedPermissionsTest.
@Test
public void datasetUnauthorizedPermissionsTest() throws Exception {
dataRepoFixtures.createDatasetError(custodian(), "dataset-minimal.json", HttpStatus.UNAUTHORIZED);
dataRepoFixtures.createDatasetError(reader(), "dataset-minimal.json", HttpStatus.UNAUTHORIZED);
EnumerateDatasetModel enumDatasetsResp = dataRepoFixtures.enumerateDatasets(reader());
List<DatasetSummaryModel> items = enumDatasetsResp.getItems();
if (items != null) {
for (DatasetSummaryModel datasetModel : items) {
logger.info(String.format("found dataset for reader: %s, created: %s", datasetModel.getId(), datasetModel.getCreatedDate()));
}
}
assertThat("Reader does not have access to datasets", enumDatasetsResp.getTotal(), equalTo(0));
DatasetSummaryModel summaryModel = null;
summaryModel = dataRepoFixtures.createDataset(steward(), "dataset-minimal.json");
datasetId = summaryModel.getId();
DataRepoResponse<DatasetModel> getDatasetResp = dataRepoFixtures.getDatasetRaw(reader(), summaryModel.getId());
assertThat("Reader is not authorized to get dataset", getDatasetResp.getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
// make sure reader cannot delete dataset
DataRepoResponse<JobModel> deleteResp1 = dataRepoFixtures.deleteDatasetLaunch(reader(), summaryModel.getId());
assertThat("Reader is not authorized to delete datasets", deleteResp1.getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
// right now the authorization for dataset delete is done directly in the controller.
// so we need to check the response to the delete request for the unauthorized failure
// once we move the authorization for dataset delete into a separate step,
// then the check will need two parts, as below:
// check job launched successfully, check job result is failure with unauthorized
// DataRepoResponse<JobModel> jobResp1 = dataRepoFixtures.deleteDatasetLaunch(
// reader(), summaryModel.getId());
// assertTrue("dataset delete launch succeeded", jobResp1.getStatusCode().is2xxSuccessful());
// assertTrue("dataset delete launch response is present", jobResp1.getResponseObject().isPresent());
// DataRepoResponse<ErrorModel> deleteResp1 = dataRepoClient.waitForResponse(
// reader(), jobResp1, ErrorModel.class);
// assertThat("Reader is not authorized to delete datasets",
// deleteResp1.getStatusCode(),
// equalTo(HttpStatus.UNAUTHORIZED));
// make sure custodian cannot delete dataset
DataRepoResponse<JobModel> deleteResp2 = dataRepoFixtures.deleteDatasetLaunch(custodian(), summaryModel.getId());
assertThat("Custodian is not authorized to delete datasets", deleteResp2.getStatusCode(), equalTo(HttpStatus.UNAUTHORIZED));
// same comment as above for the reader() delete
// DataRepoResponse<JobModel> jobResp2 = dataRepoFixtures.deleteDatasetLaunch(
// custodian(), summaryModel.getId());
// assertTrue("dataset delete launch succeeded", jobResp2.getStatusCode().is2xxSuccessful());
// assertTrue("dataset delete launch response is present", jobResp2.getResponseObject().isPresent());
// DataRepoResponse<ErrorModel> deleteResp2 = dataRepoClient.waitForResponse(
// custodian(), jobResp2, ErrorModel.class);
// assertThat("Custodian is not authorized to delete datasets",
// deleteResp2.getStatusCode(),
// equalTo(HttpStatus.UNAUTHORIZED));
}
use of bio.terra.model.DatasetSummaryModel in project jade-data-repo by DataBiosphere.
the class DatasetIntegrationTest method testAssetCreationUndo.
@Test
public void testAssetCreationUndo() throws Exception {
// create a dataset
DatasetSummaryModel summaryModel = dataRepoFixtures.createDataset(steward(), "it-dataset-omop.json");
datasetId = summaryModel.getId();
DatasetModel datasetModel = dataRepoFixtures.getDataset(steward(), summaryModel.getId());
List<AssetModel> originalAssetList = datasetModel.getSchema().getAssets();
assertThat("Asset specification is as originally expected", originalAssetList.size(), equalTo(1));
AssetModel assetModel = new AssetModel().name("assetName").rootTable("person").rootColumn("person_id").tables(Arrays.asList(DatasetFixtures.buildAssetParticipantTable(), DatasetFixtures.buildAssetSampleTable())).follow(Collections.singletonList("fpk_visit_person"));
// have the asset creation fail
// by calling the fault insertion
dataRepoFixtures.setFault(steward(), ConfigEnum.CREATE_ASSET_FAULT.name(), true);
// add an asset spec
dataRepoFixtures.addDatasetAsset(steward(), datasetModel.getId(), assetModel);
// make sure undo is completed successfully
DatasetModel datasetModelWAsset = dataRepoFixtures.getDataset(steward(), datasetModel.getId());
DatasetSpecificationModel datasetSpecificationModel = datasetModelWAsset.getSchema();
List<AssetModel> assetList = datasetSpecificationModel.getAssets();
// assert that the asset isn't there
assertThat("Additional asset specification has never been added", assetList.size(), equalTo(1));
}
use of bio.terra.model.DatasetSummaryModel in project jade-data-repo by DataBiosphere.
the class DatasetIntegrationTest method datasetHappyPath.
@Test
public void datasetHappyPath() throws Exception {
DatasetSummaryModel summaryModel = dataRepoFixtures.createDataset(steward(), "it-dataset-omop.json");
datasetId = summaryModel.getId();
logger.info("dataset id is " + summaryModel.getId());
assertThat(summaryModel.getName(), startsWith(omopDatasetName));
assertThat(summaryModel.getDescription(), equalTo(omopDatasetDesc));
DatasetModel datasetModel = dataRepoFixtures.getDataset(steward(), summaryModel.getId());
assertThat(datasetModel.getName(), startsWith(omopDatasetName));
assertThat(datasetModel.getDescription(), equalTo(omopDatasetDesc));
// There is a delay from when a resource is created in SAM to when it is available in an enumerate call.
boolean metExpectation = TestUtils.eventualExpect(5, 60, true, () -> {
EnumerateDatasetModel enumerateDatasetModel = dataRepoFixtures.enumerateDatasets(steward());
boolean found = false;
for (DatasetSummaryModel oneDataset : enumerateDatasetModel.getItems()) {
if (oneDataset.getId().equals(datasetModel.getId())) {
assertThat(oneDataset.getName(), startsWith(omopDatasetName));
assertThat(oneDataset.getDescription(), equalTo(omopDatasetDesc));
found = true;
break;
}
}
return found;
});
assertTrue("dataset was found in enumeration", metExpectation);
// test allowable permissions
dataRepoFixtures.addDatasetPolicyMember(steward(), summaryModel.getId(), IamRole.CUSTODIAN, custodian().getEmail());
DataRepoResponse<EnumerateDatasetModel> enumDatasets = dataRepoFixtures.enumerateDatasetsRaw(custodian());
assertThat("Custodian is authorized to enumerate datasets", enumDatasets.getStatusCode(), equalTo(HttpStatus.OK));
}
use of bio.terra.model.DatasetSummaryModel in project jade-data-repo by DataBiosphere.
the class OneProjectPerProfileIdSelectorTest method shouldGetCorrectIdForSnapshot.
@Test
public void shouldGetCorrectIdForSnapshot() throws Exception {
String coreBillingAccountId = resourceConfiguration.getCoreBillingAccount();
String profileName = ProfileFixtures.randomHex(16);
BillingProfileRequestModel billingProfileRequestModel = ProfileFixtures.randomBillingProfileRequest().billingAccountId(coreBillingAccountId).profileName(profileName);
BillingProfileModel profile = profileService.createProfile(billingProfileRequestModel);
DatasetSummaryModel datasetSummaryModel = connectedOperations.createDataset(profile, "snapshot-test-dataset.json");
SnapshotSummaryModel snapshotSummaryModel = connectedOperations.createSnapshot(datasetSummaryModel, "snapshot-test-snapshot.json", "");
SnapshotModel snapshotModel = connectedOperations.getSnapshot(snapshotSummaryModel.getId());
Snapshot snapshot = snapshotService.retrieve(UUID.fromString(snapshotModel.getId()));
// TODO: we can test this once configuring firestore is programatic
String projectId = oneProjectPerProfileIdSelector.projectIdForSnapshot(snapshot);
String expectedProfileId = resourceConfiguration.getProjectId() + "-" + profileName;
assertThat("Project ID is what we expect", projectId, equalTo(expectedProfileId));
}
Aggregations