use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method createReaderGroupStrict.
private void createReaderGroupStrict(String scope, String group, ReaderGroupConfig config) {
Exceptions.checkNotNullOrEmpty(scope, "scope");
Exceptions.checkNotNullOrEmpty(group, "group name");
Preconditions.checkNotNull(config, "ReaderGroupConfig");
ControllerServiceBlockingStub stub = prepareBlockingCallStubStrict(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 getUriSucceedsForPrivilegedUser.
@Test(timeout = 20000)
public void getUriSucceedsForPrivilegedUser() {
String scope = "scope1";
String stream = "stream1";
// Arrange
createScopeAndStream(scope, stream, prepareFromFixedScaleTypePolicy(2));
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
// Act
NodeUri nodeUri1 = stub.getURI(segmentId(scope, stream, 0));
NodeUri nodeUri2 = stub.getURI(segmentId(scope, stream, 1));
// Verify
assertEquals("localhost", nodeUri1.getEndpoint());
assertEquals(12345, nodeUri1.getPort());
assertEquals("localhost", nodeUri2.getEndpoint());
assertEquals(12345, nodeUri2.getPort());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method listStreamThrowsExceptionWhenUserHasNoAccessToScope.
@Test(timeout = 20000)
public void listStreamThrowsExceptionWhenUserHasNoAccessToScope() {
// Arrange
createScopeAndStreams("scope1", Arrays.asList("stream1", "stream2", "stream3"), prepareFromFixedScaleTypePolicy(2));
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.SCOPE2_READ, DEFAULT_PASSWORD);
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("PERMISSION_DENIED"));
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method createScopeFailsForNonExistentUser.
@Test(timeout = 20000)
public void createScopeFailsForNonExistentUser() {
// Arrange
ControllerServiceBlockingStub blockingStub = prepareBlockingCallStub("whatever", "whatever");
// Verify
thrown.expect(StatusRuntimeException.class);
thrown.expectMessage("UNAUTHENTICATED");
// Act
blockingStub.createScope(Controller.ScopeInfo.newBuilder().setScope("dummy").build());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method prepareBlockingCallStubStrict.
private ControllerServiceBlockingStub prepareBlockingCallStubStrict(String username, String password) {
Exceptions.checkNotNullOrEmpty(username, "username");
Exceptions.checkNotNullOrEmpty(password, "password");
ControllerServiceBlockingStub stub = ControllerServiceGrpc.newBlockingStub(inProcessChannelStrict);
// Set call credentials
Credentials credentials = new DefaultCredentials(password, username);
if (credentials != null) {
PravegaCredentialsWrapper wrapper = new PravegaCredentialsWrapper(credentials);
stub = stub.withCallCredentials(MoreCallCredentials.from(wrapper));
}
return stub;
}
Aggregations