Search in sources :

Example 1 with GenerateObjects

use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.

the class OperationChainLimiterTest method shouldRejectOperationChainWhenUserHasAuthScoreLessThanChainScore.

@Test
public void shouldRejectOperationChainWhenUserHasAuthScoreLessThanChainScore() {
    // Given
    final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(new GetAdjacentEntitySeeds()).then(new GetAdjacentEntitySeeds()).then(new GetAdjacentEntitySeeds()).then(new GenerateObjects()).build();
    final User user = new User.Builder().opAuths("User").build();
    try {
        OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
        fail("Exception expected");
    } catch (final UnauthorisedException e) {
        assertNotNull(e.getMessage());
    }
}
Also used : GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) UnauthorisedException(uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException) Test(org.junit.Test)

Example 2 with GenerateObjects

use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.

the class OperationChainLimiterTest method shouldRejectOperationChainWhenUserHasMaxAuthScoreLessThanChainScore.

@Test
public void shouldRejectOperationChainWhenUserHasMaxAuthScoreLessThanChainScore() {
    // Given
    final OperationChain opChain = new OperationChain.Builder().first(new GetAllEdges()).then(new GenerateObjects()).build();
    final User user = new User.Builder().opAuths("SuperUser", "User").build();
    // When/Then
    try {
        OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
        fail("Exception expected");
    } catch (final UnauthorisedException e) {
        assertNotNull(e.getMessage());
    }
}
Also used : GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) User(uk.gov.gchq.gaffer.user.User) GetAllEdges(uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) UnauthorisedException(uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException) Test(org.junit.Test)

Example 3 with GenerateObjects

use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.

the class OperationAuthoriserTest method shouldAcceptOperationChainWhenUserHasAllOpAuths.

@Test
public void shouldAcceptOperationChainWhenUserHasAllOpAuths() {
    // Given
    final OperationAuthoriser opAuthoriser = new OperationAuthoriser(StreamUtil.opAuths(getClass()));
    final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(new GenerateObjects()).build();
    final User user = new User.Builder().opAuths("SuperUser", "ReadUser", "User").build();
    // When
    opAuthoriser.preExecute(opChain, user);
// Then - no exceptions
}
Also used : GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.Test)

Example 4 with GenerateObjects

use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.

the class OperationAuthoriserTest method shouldReturnResultWithoutModification.

@Test
public void shouldReturnResultWithoutModification() {
    // Given
    final OperationAuthoriser opAuthoriser = new OperationAuthoriser(StreamUtil.opAuths(getClass()));
    final Object result = mock(Object.class);
    final OperationChain opChain = new OperationChain.Builder().first(new GenerateObjects<>()).build();
    final User user = new User.Builder().opAuths("NoScore").build();
    // When
    final Object returnedResult = opAuthoriser.postExecute(result, opChain, user);
    // Then
    assertSame(result, returnedResult);
}
Also used : GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.Test)

Example 5 with GenerateObjects

use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.

the class Log4jLoggerTest method shouldReturnResultWithoutModification.

@Test
public void shouldReturnResultWithoutModification() {
    // Given
    final Log4jLogger hook = new Log4jLogger();
    final Object result = mock(Object.class);
    final OperationChain opChain = new OperationChain.Builder().first(new GenerateObjects<>()).build();
    final User user = new User.Builder().opAuths("NoScore").build();
    // When
    final Object returnedResult = hook.postExecute(result, opChain, user);
    // Then
    assertSame(result, returnedResult);
}
Also used : GenerateObjects(uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects) User(uk.gov.gchq.gaffer.user.User) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Test(org.junit.Test)

Aggregations

GenerateObjects (uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects)11 Test (org.junit.Test)10 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)10 User (uk.gov.gchq.gaffer.user.User)10 GetAdjacentEntitySeeds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds)5 UnauthorisedException (uk.gov.gchq.gaffer.commonutil.exception.UnauthorisedException)4 ArrayList (java.util.ArrayList)1 Element (uk.gov.gchq.gaffer.data.element.Element)1 GetAllEdges (uk.gov.gchq.gaffer.operation.impl.get.GetAllEdges)1 ExampleDomainObject (uk.gov.gchq.gaffer.rest.example.ExampleDomainObject)1 ExampleDomainObjectGenerator (uk.gov.gchq.gaffer.rest.example.ExampleDomainObjectGenerator)1