use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.
the class NamedOperationCacheTest method shouldNotReturnNamedOperationConfiguredWithReadNoAccessPredicate.
@Test
public void shouldNotReturnNamedOperationConfiguredWithReadNoAccessPredicate() throws CacheOperationFailedException {
final NamedOperationDetail noReadAccess = new NamedOperationDetail.Builder().creatorId(standardUser.getUserId()).description("an operation that does no allow read access").operationName("test").writers(writers).operationChain(standardOpChain).readAccessPredicate(new NoAccessPredicate()).build();
cache.addNamedOperation(noReadAccess, false, standardUser);
assertFalse(cache.getAllNamedOperations(standardUser).iterator().hasNext());
}
use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.
the class NamedOperationCacheTest method shouldAddNamedOperation.
@Test
public void shouldAddNamedOperation() throws CacheOperationFailedException {
cache.addNamedOperation(standard, false, standardUser);
NamedOperationDetail namedOperation = cache.getNamedOperation(OPERATION_NAME, standardUser);
assertEquals(standard, namedOperation);
}
use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.
the class NamedOperationCacheTest method shouldBeAbleToReturnFullExtendedOperationChain.
@Test
public void shouldBeAbleToReturnFullExtendedOperationChain() throws CacheOperationFailedException {
cache.addNamedOperation(standard, false, standardUser);
NamedOperationDetail alt = new NamedOperationDetail.Builder().operationName("different").description("alt").creatorId(advancedUser.getUserId()).readers(readers).writers(writers).operationChain(alternativeOpChain).build();
cache.addNamedOperation(alt, false, advancedUser);
Set<NamedOperationDetail> actual = Sets.newHashSet(cache.getAllNamedOperations(standardUser));
assert (actual.contains(standard));
assert (actual.contains(alt));
assert (actual.size() == 2);
}
use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.
the class NamedOperationCacheTest method shouldAllowAddingWhenUserHasAdminAuth.
@Test
public void shouldAllowAddingWhenUserHasAdminAuth() throws CacheOperationFailedException {
cache.addNamedOperation(alternative, false, advancedUser, EMPTY_ADMIN_AUTH);
NamedOperationDetail alt = new NamedOperationDetail.Builder().operationName(alternative.getOperationName()).description("alt").creatorId(standardUser.getUserId()).operationChain(alternativeOpChain).build();
cache.addNamedOperation(alt, true, userWithAdminAuth, ADMIN_AUTH);
}
use of uk.gov.gchq.gaffer.named.operation.NamedOperationDetail in project Gaffer by gchq.
the class NamedOperationCacheTest method shouldNotReturnANamedOperationThatAUserCannotExecute.
@Test
public void shouldNotReturnANamedOperationThatAUserCannotExecute() throws CacheOperationFailedException {
cache.addNamedOperation(standard, false, standardUser);
NamedOperationDetail noReadAccess = new NamedOperationDetail.Builder().creatorId(advancedUser.getUserId()).description("an operation that a standard user cannot execute").operationName("test").readers(writers).writers(writers).operationChain(standardOpChain).build();
cache.addNamedOperation(noReadAccess, false, advancedUser);
Set<NamedOperationDetail> actual = Sets.newHashSet(cache.getAllNamedOperations(standardUser));
assert actual.contains(standard);
assert actual.size() == 1;
}
Aggregations