Search in sources :

Example 1 with TestOperationsImpl

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();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) TestOperationsImpl(uk.gov.gchq.gaffer.operation.TestOperationsImpl) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) UnauthorisedException(uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException) Test(org.junit.jupiter.api.Test)

Example 2 with TestOperationsImpl

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
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) TestOperationsImpl(uk.gov.gchq.gaffer.operation.TestOperationsImpl) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) Sort(uk.gov.gchq.gaffer.operation.impl.compare.Sort) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 TestOperationsImpl (uk.gov.gchq.gaffer.operation.TestOperationsImpl)2 DiscardOutput (uk.gov.gchq.gaffer.operation.impl.DiscardOutput)2 GenerateObjects (uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects)2 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)2 Context (uk.gov.gchq.gaffer.store.Context)2 User (uk.gov.gchq.gaffer.user.User)2 UnauthorisedException (uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException)1 Sort (uk.gov.gchq.gaffer.operation.impl.compare.Sort)1 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)1