use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method listStreamFiltersResultWhenUserHasAccessToSubsetOfStreams.
@Test(timeout = 20000)
public void listStreamFiltersResultWhenUserHasAccessToSubsetOfStreams() {
// Arrange
String scope = "scope1";
createScopeAndStreams(scope, Arrays.asList("stream1", "stream2", "stream3", "stream4"), prepareFromFixedScaleTypePolicy(2));
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.SCOPE1_STREAM1_LIST_READ, DEFAULT_PASSWORD);
Controller.StreamsInScopeRequest request = Controller.StreamsInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope(scope).build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act
Controller.StreamsInScopeResponse response = stub.listStreamsInScope(request);
// Assert
assertEquals(1, response.getStreamsList().size());
stub = prepareBlockingCallStub(UserNames.SCOPE1_STREAM1_3_LIST_READ, DEFAULT_PASSWORD);
request = Controller.StreamsInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope(scope).build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act
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 createReaderGroup.
private void createReaderGroup(String scope, String group, ReaderGroupConfig config) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(group, "group name");
Preconditions.checkNotNull(config, "ReaderGroupConfig");
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
Controller.CreateReaderGroupResponse status = stub.createReaderGroup(ModelHelper.decode(scope, group, config));
if (!status.getStatus().equals(Controller.CreateReaderGroupResponse.Status.SUCCESS)) {
throw new RuntimeException("Failed to create reader-group");
}
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method listStreamReturnsEmptyResultWhenUserHasNoAccessToStreams.
@Test(timeout = 20000)
public void listStreamReturnsEmptyResultWhenUserHasNoAccessToStreams() {
// Arrange
createScopeAndStreams("scope1", Arrays.asList("stream1", "stream2", "stream3"), prepareFromFixedScaleTypePolicy(2));
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.SCOPE1_READ, DEFAULT_PASSWORD);
Controller.StreamsInScopeRequest request = Controller.StreamsInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope("scope1").build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act
Controller.StreamsInScopeResponse response = stub.listStreamsInScope(request);
// Assert
assertEquals(0, response.getStreamsList().size());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method createScopeAndStreamsStrict.
private void createScopeAndStreamsStrict(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 = prepareBlockingCallStubStrict(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 listStreamThrowsExceptionWhenUserIsNonExistent.
@Test(timeout = 20000)
public void listStreamThrowsExceptionWhenUserIsNonExistent() {
// Arrange
createScopeAndStreams("scope1", Arrays.asList("stream1", "stream2", "stream3"), prepareFromFixedScaleTypePolicy(2));
ControllerServiceBlockingStub stub = prepareBlockingCallStubWithNoCredentials();
Controller.StreamsInScopeRequest request = Controller.StreamsInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope("scope1").build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act and assert
AssertExtensions.assertThrows("Expected auth failure.", () -> stub.listStreamsInScope(request), e -> e.getMessage().contains("UNAUTHENTICATED"));
}
Aggregations