use of nl.knaw.huygens.timbuctoo.v5.security.dto.User in project timbuctoo by HuygensING.
the class AuthCheckTest method checkAdminAccessReturnsNullIfTheUserHasAdminPermissionsForTheDataSet.
@Test
public void checkAdminAccessReturnsNullIfTheUserHasAdminPermissionsForTheDataSet() throws Exception {
User notOwner = User.create(null, "user");
UserValidator userValidator = mock(UserValidator.class);
given(userValidator.getUserFromAccessToken(anyString())).willReturn(Optional.of(notOwner));
PermissionFetcher permissionFetcher = mock(PermissionFetcher.class);
given(permissionFetcher.getPermissions(any(User.class), any(BasicDataSetMetaData.class))).willReturn(permissionsForAdmin());
Response response = checkAdminAccess(permissionFetcher, userValidator, "auth", new BasicDataSetMetaData("ownerid", "datasetid", "http://ex.org", "http://example.org/prefix/", false, false));
assertThat(response.getStatus(), is(200));
}
use of nl.knaw.huygens.timbuctoo.v5.security.dto.User in project timbuctoo by HuygensING.
the class SummaryPropDataRetrieverTest method createSummaryPropertyWalksTheUserConfiguredPathFirst.
@Test
public void createSummaryPropertyWalksTheUserConfiguredPathFirst() throws JsonProcessingException {
List<SummaryProp> defaultProperties = Lists.newArrayList(summaryPropertyWithPath("http://example.org/path"));
SummaryPropDataRetriever instance = new SummaryPropDataRetriever("http://example.org/userConfigured", defaultProperties);
SummaryProp summaryProp = summaryPropertyWithPath("http://example.org/userPath");
CursorQuad collectionQuad = quadWithObject("http://example.org/collection", Optional.empty());
CursorQuad userConfiguredSummaryProp = quadWithObject(OBJECT_MAPPER.writeValueAsString(summaryProp), Optional.empty());
QuadStore quadStore = mock(QuadStore.class);
given(quadStore.getQuads("http://example.org/source", RdfConstants.RDF_TYPE, Direction.OUT, "")).willReturn(Stream.of(collectionQuad));
given(quadStore.getQuads("http://example.org/collection", "http://example.org/userConfigured", Direction.OUT, "")).willReturn(Stream.of(userConfiguredSummaryProp));
instance.createSummaryProperty(subjectWithUri("http://example.org/source"), dataSetWithQuadStore(quadStore));
InOrder inOrder = inOrder(quadStore);
// walk the path of the user configured SummaryProp
inOrder.verify(quadStore).getQuads("http://example.org/source", "http://example.org/userPath", Direction.OUT, "");
// walk the path of the default SummaryProp
inOrder.verify(quadStore).getQuads("http://example.org/source", "http://example.org/path", Direction.OUT, "");
}
Aggregations