use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasAuthScoreGreaterThanChainScore.
@Test
public void shouldAcceptOperationChainWhenUserHasAuthScoreGreaterThanChainScore() {
// Given
final OperationChainLimiter hook = fromJson(OP_CHAIN_LIMITER_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetElements()).build();
final User user = new User.Builder().opAuths("User").build();
// When
hook.preExecute(opChain, new Context(user));
// Then - no exceptions
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldRejectOperationChainWhenUserHasAuthScoreLessThanChainScore.
@Test
public void shouldRejectOperationChainWhenUserHasAuthScoreLessThanChainScore() {
// Given
final OperationChainLimiter hook = fromJson(OP_CHAIN_LIMITER_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentIds()).then(new GetAdjacentIds()).then(new GetAdjacentIds()).then(new GetElements()).then(new GenerateObjects<>()).build();
final User user = new User.Builder().opAuths("User").build();
// When/Then
assertThatExceptionOfType(UnauthorisedException.class).isThrownBy(() -> hook.preExecute(opChain, new Context(user))).extracting("message").isNotNull();
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldRejectOperationChainWhenUserHasMaxAuthScoreLessThanChainScore.
@Test
public void shouldRejectOperationChainWhenUserHasMaxAuthScoreLessThanChainScore() {
// Given
final OperationChainLimiter hook = fromJson(OP_CHAIN_LIMITER_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetAllElements()).then(new GetElements()).then(new GenerateObjects<>()).build();
final User user = new User.Builder().opAuths("SuperUser", "User").build();
// When/Then
assertThatExceptionOfType(UnauthorisedException.class).isThrownBy(() -> hook.preExecute(opChain, new Context(user))).extracting("message").isNotNull();
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class SchemaHidingIT method testOperations.
protected void testOperations(final Graph fullGraph, final Graph filteredGraph, final List<Edge> fullExpectedResults, final List<Edge> filteredExpectedResults) throws OperationException {
testOperation(fullGraph, filteredGraph, new GetAllElements(), fullExpectedResults, filteredExpectedResults);
final GetElements getElements = new GetElements.Builder().input(new EntitySeed("source1a"), new EntitySeed("source1b"), new EntitySeed("source2"), new EdgeSeed("source2", "dest2", true)).build();
testOperation(fullGraph, filteredGraph, getElements, fullExpectedResults, filteredExpectedResults);
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetElements in project Gaffer by gchq.
the class IfHandlerTest method shouldExecuteThenWithBooleanCondition.
@Test
public void shouldExecuteThenWithBooleanCondition() throws OperationException {
// Given
final Object input = Arrays.asList(new EntitySeed("1"), new EntitySeed("2"));
final GetElements then = mock(GetElements.class);
final GetAllElements otherwise = mock(GetAllElements.class);
final If filter = new If.Builder<>().input(input).condition(true).then(then).otherwise(otherwise).build();
final IfHandler handler = new IfHandler();
// When
handler.doOperation(filter, context, store);
// Then
verify(store).execute(then, context);
verify(store, never()).execute(otherwise, context);
}
Aggregations