use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.
the class OperationAuthoriserTest method shouldRejectOperationChainWhenUserDoesntHaveAllOpAuthsForAllOperations.
@Test
public void shouldRejectOperationChainWhenUserDoesntHaveAllOpAuthsForAllOperations() {
// Given
final OperationAuthoriser opAuthoriser = new OperationAuthoriser(StreamUtil.opAuths(getClass()));
final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(// Requires AdminUser
new GenerateObjects()).build();
final User user = new User.Builder().opAuths("WriteUser", "ReadUser", "User").build();
// When/Then
try {
opAuthoriser.preExecute(opChain, user);
fail("Exception expected");
} catch (final UnauthorisedException e) {
assertNotNull(e.getMessage());
}
}
use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasMaxAuthScoreGreaterThanChainScore.
@Test
public void shouldAcceptOperationChainWhenUserHasMaxAuthScoreGreaterThanChainScore() {
// Given
final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(new GetAdjacentEntitySeeds()).then(new GetAdjacentEntitySeeds()).then(new GenerateObjects()).build();
final User user = new User.Builder().opAuths("SuperUser", "User").build();
// When
OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
// Then - no exceptions
}
use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldRejectOperationChainWhenUserHasNoAuthWithAConfiguredScore.
@Test
public void shouldRejectOperationChainWhenUserHasNoAuthWithAConfiguredScore() {
// Given
final OperationChain opChain = new OperationChain.Builder().first(new GenerateObjects()).build();
final User user = new User.Builder().opAuths("NoScore").build();
// When/Then
try {
OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
fail("Exception expected");
} catch (final UnauthorisedException e) {
assertNotNull(e.getMessage());
}
}
use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldAcceptOperationChainWhenUserHasAuthScoreEqualToChainScore.
@Test
public void shouldAcceptOperationChainWhenUserHasAuthScoreEqualToChainScore() {
// Given
final OperationChain opChain = new OperationChain.Builder().first(new GetAdjacentEntitySeeds()).then(new GenerateObjects()).build();
final User user = new User.Builder().opAuths("User").build();
// When
OPERATION_CHAIN_LIMITER.preExecute(opChain, user);
// Then - no exceptions
}
use of uk.gov.gchq.gaffer.operation.impl.generate.GenerateObjects in project Gaffer by gchq.
the class OperationChainLimiterTest method shouldReturnResultWithoutModification.
@Test
public void shouldReturnResultWithoutModification() {
// Given
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 = OPERATION_CHAIN_LIMITER.postExecute(result, opChain, user);
// Then
assertSame(result, returnedResult);
}
Aggregations