use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData in project timbuctoo by HuygensING.
the class BasicPermissionFetcherTest method getPermissionsDoesNotReturnReadPermissionForUnauthorizedUserInPrivateDataset.
@Test
public void getPermissionsDoesNotReturnReadPermissionForUnauthorizedUserInPrivateDataset() throws Exception {
DataSetMetaData dataSetMetaData2 = mock(BasicDataSetMetaData.class);
given(dataSetMetaData2.getDataSetId()).willReturn("testdatasetid");
given(dataSetMetaData2.getOwnerId()).willReturn("testownerid");
given(dataSetMetaData2.isPublished()).willReturn(false);
Set<Permission> permissions = permissionFetcher.getPermissions(mock(User.class), dataSetMetaData2);
assertThat(permissions, is(empty()));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData in project timbuctoo by HuygensING.
the class RootQuery method getCollections.
public CollectionMetadataList getCollections(DataSetMetaData input, Optional<User> userOpt) {
final User user = userOpt.orElse(null);
final DataSet dataSet = dataSetRepository.getDataSet(user, input.getOwnerId(), input.getDataSetId()).get();
final TypeNameStore typeNameStore = dataSet.getTypeNameStore();
final List<CollectionMetadata> colls = dataSet.getSchemaStore().getStableTypes().values().stream().map(x -> {
return getCollection(dataSet, typeNameStore, x);
}).collect(Collectors.toList());
return ImmutableCollectionMetadataList.builder().nextCursor(Optional.empty()).prevCursor(Optional.empty()).items(colls).build();
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method removeDataSetRemovesTheDataSetsAuthorizations.
@Test
public void removeDataSetRemovesTheDataSetsAuthorizations() throws Exception {
User user = User.create(null, "user");
final DataSet dataSet = dataSetRepository.createDataSet(user, "dataset");
DataSetMetaData metadata = dataSet.getMetadata();
String owner = metadata.getOwnerId();
given(permissionFetcher.getPermissions(user, metadata)).willReturn(Sets.newHashSet(Permission.ADMIN));
dataSetRepository.removeDataSet(owner, "dataset", user);
verify(permissionFetcher).removeAuthorizations(metadata.getCombinedId());
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData in project timbuctoo by HuygensING.
the class DataSetRepositoryTest method publishDataSetWillReturnDataSetMetaDataWithPublishedFlagSet.
@Test
public void publishDataSetWillReturnDataSetMetaDataWithPublishedFlagSet() throws Exception {
User user = User.create(null, "user");
DataSet dataSet = dataSetRepository.createDataSet(user, "dataset");
DataSetMetaData metadata = dataSet.getMetadata();
given(permissionFetcher.getPermissions(user, dataSet.getMetadata())).willReturn(Sets.newHashSet(Permission.ADMIN, Permission.READ));
assertThat(metadata.isPublished(), is(false));
dataSetRepository.publishDataSet(user, "uuser", "dataset");
assertThat(metadata.isPublished(), is(true));
}
use of nl.knaw.huygens.timbuctoo.v5.dataset.dto.DataSetMetaData in project timbuctoo by HuygensING.
the class PermissionBasedFieldVisibilityTest method createDataSetWithUserPermissions.
private DataSet createDataSetWithUserPermissions(String combinedId, Set<Permission> permissions) {
DataSetMetaData dataSetMetaData = createDataSetMetadata(combinedId);
given(userPermissionCheck.getPermissions(dataSetMetaData)).willReturn(permissions);
return createDataSet(dataSetMetaData);
}
Aggregations