Search in sources :

Example 11 with ControllerServiceBlockingStub

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());
}
Also used : ControllerServiceBlockingStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub) AuthFileUtils.credentialsAndAclAsString(io.pravega.auth.AuthFileUtils.credentialsAndAclAsString) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) Test(org.junit.Test)

Example 12 with ControllerServiceBlockingStub

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");
    }
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) ControllerServiceBlockingStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub) Controller(io.pravega.controller.stream.api.grpc.v1.Controller)

Example 13 with ControllerServiceBlockingStub

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());
}
Also used : ControllerServiceBlockingStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) Test(org.junit.Test)

Example 14 with ControllerServiceBlockingStub

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));
}
Also used : ControllerServiceBlockingStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub)

Example 15 with ControllerServiceBlockingStub

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"));
}
Also used : ControllerServiceBlockingStub(io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub) Controller(io.pravega.controller.stream.api.grpc.v1.Controller) Test(org.junit.Test)

Aggregations

ControllerServiceBlockingStub (io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub)20 Test (org.junit.Test)14 Controller (io.pravega.controller.stream.api.grpc.v1.Controller)10 AuthFileUtils.credentialsAndAclAsString (io.pravega.auth.AuthFileUtils.credentialsAndAclAsString)9 StatusRuntimeException (io.grpc.StatusRuntimeException)3 MoreCallCredentials (io.grpc.auth.MoreCallCredentials)2 PravegaCredentialsWrapper (io.pravega.client.control.impl.PravegaCredentialsWrapper)2 NodeUri (io.pravega.controller.stream.api.grpc.v1.Controller.NodeUri)2 PingTxnStatus (io.pravega.controller.stream.api.grpc.v1.Controller.PingTxnStatus)2 TxnId (io.pravega.controller.stream.api.grpc.v1.Controller.TxnId)2 Credentials (io.pravega.shared.security.auth.Credentials)2 DefaultCredentials (io.pravega.shared.security.auth.DefaultCredentials)2 StreamConfig (io.pravega.controller.stream.api.grpc.v1.Controller.StreamConfig)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1