use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method createScopeAndStreams.
private void createScopeAndStreams(String scopeName, List<String> streamNames, ScalingPolicy scalingPolicy) {
Exceptions.checkNotNullOrEmpty(scopeName, "scope");
Preconditions.checkNotNull(streamNames, "stream");
Preconditions.checkArgument(streamNames.size() > 0);
Preconditions.checkNotNull(scalingPolicy, "scalingPolicy");
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
createScope(stub, scopeName);
streamNames.stream().forEach(n -> createStream(stub, scopeName, n, scalingPolicy));
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method createStream.
private void createStream(ControllerServiceBlockingStub stub, String scopeName, String streamName, ScalingPolicy scalingPolicy) {
StreamConfig streamConfig = StreamConfig.newBuilder().setStreamInfo(Controller.StreamInfo.newBuilder().setScope(scopeName).setStream(streamName).build()).setScalingPolicy(scalingPolicy).build();
Controller.CreateStreamStatus status = stub.createStream(streamConfig);
if (!status.getStatus().equals(Controller.CreateStreamStatus.Status.SUCCESS)) {
throw new RuntimeException("Failed to create stream");
}
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method isSegmentValidSucceedsForAuthorizedUser.
@Test(timeout = 20000)
public void isSegmentValidSucceedsForAuthorizedUser() {
String scope = "scope1";
String stream = "stream1";
createScopeAndStream(scope, stream, prepareFromFixedScaleTypePolicy(2));
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.SCOPE1_STREAM1_READ, DEFAULT_PASSWORD);
assertTrue(stub.isSegmentValid(segmentId(scope, stream, 0)).getResponse());
assertFalse(stub.isSegmentValid(segmentId(scope, stream, 3)).getResponse());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method listStreamsReturnsAllWhenUserHasWildCardAccessUsingBlockingStub.
@Test(timeout = 20000)
public void listStreamsReturnsAllWhenUserHasWildCardAccessUsingBlockingStub() {
// Arrange
String scopeName = "scope1";
createScopeAndStreams(scopeName, Arrays.asList("stream1", "stream2"), prepareFromFixedScaleTypePolicy(2));
Controller.StreamsInScopeRequest request = Controller.StreamsInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope(scopeName).build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
// Act
Controller.StreamsInScopeResponse response = stub.listStreamsInScope(request);
// Assert
assertEquals(2, response.getStreamsList().size());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method isSegmentValidFailsForUnauthorizedUser.
@Test(timeout = 20000)
public void isSegmentValidFailsForUnauthorizedUser() {
String scope = "scope1";
String stream = "stream1";
createScopeAndStream(scope, stream, prepareFromFixedScaleTypePolicy(2));
// Note that the user has READ access to scope1/stream2, not scope1/stream1.
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.SCOPE1_STREAM2_READ, DEFAULT_PASSWORD);
// Set the expected exception
thrown.expect(StatusRuntimeException.class);
// thrown.expectMessage();
thrown.expectMessage("PERMISSION_DENIED");
stub.isSegmentValid(segmentId(scope, stream, 0));
}
Aggregations