use of org.apache.accumulo.server.security.SecurityOperation in project accumulo by apache.
the class TservConstraintEnvTest method testGetAuthorizationsContainer.
@Test
public void testGetAuthorizationsContainer() throws ThriftSecurityException {
SecurityOperation security = createMock(SecurityOperation.class);
TCredentials goodCred = createMock(TCredentials.class);
TCredentials badCred = createMock(TCredentials.class);
ByteSequence bs = new ArrayByteSequence("foo".getBytes());
List<ByteBuffer> bbList = Collections.singletonList(ByteBuffer.wrap(bs.getBackingArray(), bs.offset(), bs.length()));
expect(security.authenticatedUserHasAuthorizations(goodCred, bbList)).andReturn(true);
expect(security.authenticatedUserHasAuthorizations(badCred, bbList)).andReturn(false);
replay(security);
assertTrue(new TservConstraintEnv(security, goodCred).getAuthorizationsContainer().contains(bs));
assertFalse(new TservConstraintEnv(security, badCred).getAuthorizationsContainer().contains(bs));
}
Aggregations