use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds in project Gaffer by gchq.
the class OperationAuthoriserTest method shouldRejectOperationChainWhenUserDoesntHaveAnyOpAuths.
@Test
public void shouldRejectOperationChainWhenUserDoesntHaveAnyOpAuths() throws OperationException {
// Given
final OperationAuthoriser hook = fromJson(OP_AUTHS_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentIds()).then(new GetElements()).build();
final User user = new User();
// When/Then
assertThatExceptionOfType(UnauthorisedException.class).isThrownBy(() -> hook.preExecute(opChain, new Context(user))).extracting("message").isNotNull();
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasAuthScoreEqualToChainScore.
@Test
public void shouldAcceptOperationChainWhenUserHasAuthScoreEqualToChainScore() {
// Given
final OperationChainLimiter hook = fromJson(OP_CHAIN_LIMITER_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentIds()).then(new GetElements()).then(new GenerateObjects<>()).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.GetAdjacentIds in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasMaxAuthScoreGreaterThanChainScore.
@Test
public void shouldAcceptOperationChainWhenUserHasMaxAuthScoreGreaterThanChainScore() {
// Given
final OperationChainLimiter hook = fromJson(OP_CHAIN_LIMITER_PATH);
final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentIds()).then(new GetAdjacentIds()).then(new GetElements()).then(new GenerateObjects<>()).build();
final User user = new User.Builder().opAuths("SuperUser", "User").build();
// When
hook.preExecute(opChain, new Context(user));
// Then - no exceptions
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds in project Gaffer by gchq.
the class AddNamedOperationTest method shouldGetOperationsWhenNoDefaultParameter.
@Test
public void shouldGetOperationsWhenNoDefaultParameter() {
// Given
final AddNamedOperation addNamedOperation = new AddNamedOperation.Builder().operationChain("{\"operations\":[{\"class\": \"uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds\", \"input\": [{\"vertex\": \"${testParameter}\", \"class\": \"uk.gov.gchq.gaffer.operation.data.EntitySeed\"}]}]}").description("Test Named Operation").name("Test").labels(asList("Test label")).overwrite(false).readAccessRoles(USER).writeAccessRoles(USER).parameter("testParameter", new ParameterDetail.Builder().description("the seed").valueClass(String.class).required(false).build()).score(2).build();
// When
Collection<Operation> operations = addNamedOperation.getOperations();
// Then
assertEquals(Collections.singletonList(GetAdjacentIds.class), operations.stream().map(o -> o.getClass()).collect(Collectors.toList()));
final GetAdjacentIds nestedOp = (GetAdjacentIds) operations.iterator().next();
final List<? extends EntityId> input = Lists.newArrayList(nestedOp.getInput());
assertEquals(Collections.singletonList(new EntitySeed(null)), input);
}
use of uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds in project Gaffer by gchq.
the class AddNamedOperationTest method shouldGetOperationsWithDefaultParameters.
@Test
public void shouldGetOperationsWithDefaultParameters() {
// Given
final AddNamedOperation addNamedOperation = new AddNamedOperation.Builder().operationChain("{\"operations\":[{\"class\": \"uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds\", \"input\": [{\"vertex\": \"${testParameter}\", \"class\": \"uk.gov.gchq.gaffer.operation.data.EntitySeed\"}]}]}").description("Test Named Operation").name("Test").labels(asList("Test label")).overwrite(false).readAccessRoles(USER).writeAccessRoles(USER).parameter("testParameter", new ParameterDetail.Builder().description("the seed").defaultValue("seed1").valueClass(String.class).required(false).build()).score(2).build();
// When
Collection<Operation> operations = addNamedOperation.getOperations();
// Then
assertEquals(Collections.singletonList(GetAdjacentIds.class), operations.stream().map(o -> o.getClass()).collect(Collectors.toList()));
final GetAdjacentIds nestedOp = (GetAdjacentIds) operations.iterator().next();
final List<? extends EntityId> input = Lists.newArrayList(nestedOp.getInput());
assertEquals(Collections.singletonList(new EntitySeed("seed1")), input);
}
Aggregations