use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub in project pravega by pravega.
the class ControllerImpl method getClientWithCredentials.
private ControllerServiceStub getClientWithCredentials(ControllerImplConfig config) {
ControllerServiceStub client = ControllerServiceGrpc.newStub(this.channel);
try {
Credentials credentials = config.getClientConfig().getCredentials();
if (credentials != null) {
PravegaCredentialsWrapper wrapper = new PravegaCredentialsWrapper(credentials);
client = client.withCallCredentials(MoreCallCredentials.from(wrapper));
}
} catch (Exception e) {
log.error("Error while setting credentials to controller client", e);
closeChannel();
throw e;
}
return client;
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method listStreamsReturnsAllWhenUserHasWildCardAccessUsingAsyncStub.
@Test(timeout = 20000)
public void listStreamsReturnsAllWhenUserHasWildCardAccessUsingAsyncStub() {
// 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();
ControllerServiceStub stub = prepareNonBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
ResultObserver<Controller.StreamsInScopeResponse> responseObserver = new ResultObserver<>();
stub.listStreamsInScope(request, responseObserver);
List<Controller.StreamInfo> streamsInResponse = responseObserver.get().getStreamsList();
assertFalse(Strings.isNullOrEmpty(responseObserver.get().getContinuationToken().getToken()));
assertEquals(2, streamsInResponse.size());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method prepareNonBlockingCallStub.
private ControllerServiceStub prepareNonBlockingCallStub(String username, String password) {
Exceptions.checkNotNullOrEmpty(username, "username");
Exceptions.checkNotNullOrEmpty(password, "password");
ControllerServiceGrpc.ControllerServiceStub stub = ControllerServiceGrpc.newStub(inProcessChannel);
// 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