use of io.pravega.shared.security.auth.AuthorizationResource in project pravega by pravega.
the class InMemoryControllerServiceImplTest method supplierForMarkStreams.
@Test
public void supplierForMarkStreams() {
GrpcAuthHelper mockAuthHelper = spy(new GrpcAuthHelper(true, "tokenSigningKey", 600));
ControllerServiceImpl objectUnderTest = new ControllerServiceImpl(null, mockAuthHelper, requestTracker, true, true, 200);
AuthorizationResource authResource = new AuthorizationResourceImpl();
String markStreamResource = authResource.ofStreamInScope("testScope", "_MARKtestStream");
String streamResource = authResource.ofStreamInScope("testScope", "testStream");
Controller.StreamInfo readRequest = createStreamInfoProtobufMessage("testScope", "_MARKtestStream", AccessOperation.READ);
Controller.StreamInfo writeRequest = createStreamInfoProtobufMessage("testScope", "_MARKtestStream", AccessOperation.READ_WRITE);
// For mark streams, authorization is done against the corresponding stream
doReturn("").when(mockAuthHelper).checkAuthorization(streamResource, AuthHandler.Permissions.READ);
doReturn("").when(mockAuthHelper).checkAuthorization(streamResource, AuthHandler.Permissions.READ_UPDATE);
doReturn("dummy.delegation.token").when(mockAuthHelper).createDelegationToken(markStreamResource, AuthHandler.Permissions.READ);
doReturn("dummy.delegation.token").when(mockAuthHelper).createDelegationToken(markStreamResource, AuthHandler.Permissions.READ_UPDATE);
assertEquals("dummy.delegation.token", objectUnderTest.delegationTokenSupplier(readRequest).get());
assertEquals("dummy.delegation.token", objectUnderTest.delegationTokenSupplier(writeRequest).get());
}
Aggregations