Search in sources :

Example 1 with SecurityOperation

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));
}
Also used : TCredentials(org.apache.accumulo.core.security.thrift.TCredentials) SecurityOperation(org.apache.accumulo.server.security.SecurityOperation) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) ByteBuffer(java.nio.ByteBuffer) ByteSequence(org.apache.accumulo.core.data.ByteSequence) ArrayByteSequence(org.apache.accumulo.core.data.ArrayByteSequence) Test(org.junit.Test)

Aggregations

ByteBuffer (java.nio.ByteBuffer)1 ArrayByteSequence (org.apache.accumulo.core.data.ArrayByteSequence)1 ByteSequence (org.apache.accumulo.core.data.ByteSequence)1 TCredentials (org.apache.accumulo.core.security.thrift.TCredentials)1 SecurityOperation (org.apache.accumulo.server.security.SecurityOperation)1 Test (org.junit.Test)1