use of io.pravega.shared.security.auth.AuthorizationResourceImpl in project pravega by pravega.
the class InMemoryControllerServiceImplTest method supplierCreatesTokenWithReadWhenRequestedPermissionIsUnexpected.
@Test
public void supplierCreatesTokenWithReadWhenRequestedPermissionIsUnexpected() {
GrpcAuthHelper mockAuthHelper = spy(new GrpcAuthHelper(true, "tokenSigningKey", 600));
ControllerServiceImpl objectUnderTest = new ControllerServiceImpl(null, mockAuthHelper, requestTracker, true, true, 200);
String streamResource = new AuthorizationResourceImpl().ofStreamInScope("testScope", "testStream");
Controller.StreamInfo request = createStreamInfoProtobufMessage("testScope", "testStream", AccessOperation.NONE);
doReturn("").when(mockAuthHelper).checkAuthorization(streamResource, AuthHandler.Permissions.NONE);
doReturn("").when(mockAuthHelper).checkAuthorization(streamResource, AuthHandler.Permissions.READ);
doReturn("dummy.delegation.token").when(mockAuthHelper).createDelegationToken(streamResource, AuthHandler.Permissions.NONE);
assertEquals("dummy.delegation.token", objectUnderTest.delegationTokenSupplier(request).get());
}
use of io.pravega.shared.security.auth.AuthorizationResourceImpl in project pravega by pravega.
the class InMemoryControllerServiceImplTest method supplierCreatesTokenWithReadUpdateForInternalStreamsByDefault.
@Test
public void supplierCreatesTokenWithReadUpdateForInternalStreamsByDefault() {
GrpcAuthHelper mockAuthHelper = spy(new GrpcAuthHelper(true, "tokenSigningKey", 600));
ControllerServiceImpl objectUnderTest = new ControllerServiceImpl(null, mockAuthHelper, requestTracker, true, true, 200);
String streamResource = new AuthorizationResourceImpl().ofStreamInScope("testScope", "_testStream");
Controller.StreamInfo request = createStreamInfoProtobufMessage("testScope", "_testStream", null);
System.out.println(request.getAccessOperation().name());
doReturn("").when(mockAuthHelper).checkAuthorization(streamResource, AuthHandler.Permissions.READ_UPDATE);
doReturn("dummy.delegation.token").when(mockAuthHelper).createDelegationToken(streamResource, AuthHandler.Permissions.READ_UPDATE);
assertEquals("dummy.delegation.token", objectUnderTest.delegationTokenSupplier(request).get());
}
use of io.pravega.shared.security.auth.AuthorizationResourceImpl in project pravega by pravega.
the class InMemoryControllerServiceImplTest method supplierCreatesAppropriateTokenForInternalStreamsBasedOnAccessOperation.
@Test
public void supplierCreatesAppropriateTokenForInternalStreamsBasedOnAccessOperation() {
GrpcAuthHelper mockAuthHelper = spy(new GrpcAuthHelper(true, "tokenSigningKey", 600));
ControllerServiceImpl objectUnderTest = new ControllerServiceImpl(null, mockAuthHelper, requestTracker, true, true, 200);
String streamResource = new AuthorizationResourceImpl().ofInternalStream("testScope", "_testStream");
Controller.StreamInfo request = createStreamInfoProtobufMessage("testScope", "_testStream", AccessOperation.READ_WRITE);
doReturn("").when(mockAuthHelper).checkAuthorization(streamResource, AuthHandler.Permissions.READ_UPDATE);
doReturn("dummy.delegation.token").when(mockAuthHelper).createDelegationToken(streamResource, AuthHandler.Permissions.READ_UPDATE);
assertEquals("dummy.delegation.token", objectUnderTest.delegationTokenSupplier(request).get());
}
Aggregations