use of uk.gov.gchq.gaffer.operation.TestOperationsImpl in project Gaffer by gchq.
the class OperationAuthoriserTest method shouldRejectOperationChainWhenUserDoesntHaveAllOpAuthsForNestedOperations.
@Test
public void shouldRejectOperationChainWhenUserDoesntHaveAllOpAuthsForNestedOperations() {
// Given
final OperationAuthoriser hook = fromJson(OP_AUTHS_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetElements()).then(new GenerateObjects<>()).then(new DiscardOutput()).then(new TestOperationsImpl(Collections.singletonList(new GetAllElements()))).build();
final User user = new User.Builder().opAuths("SuperUser", "ReadUser", "User").build();
// When/Then
assertThatExceptionOfType(UnauthorisedException.class).isThrownBy(() -> hook.preExecute(opChain, new Context(user))).extracting("message").isNotNull();
}
use of uk.gov.gchq.gaffer.operation.TestOperationsImpl in project Gaffer by gchq.
the class OperationAuthoriserTest method shouldAcceptOperationChainWhenUserHasAllOpAuths.
@Test
public void shouldAcceptOperationChainWhenUserHasAllOpAuths() {
// Given
final OperationAuthoriser hook = fromJson(OP_AUTHS_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetElements()).then(new GenerateObjects<>()).then(new DiscardOutput()).then(new TestOperationsImpl(Collections.singletonList(new Sort()))).build();
final User user = new User.Builder().opAuths("SuperUser", "ReadUser", "User").build();
// When
hook.preExecute(opChain, new Context(user));
// Then - no exceptions
}
Aggregations