use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method pingTransactionSucceedsForAuthorizedUser.
@Test(timeout = 20000)
public void pingTransactionSucceedsForAuthorizedUser() {
String scope = "scope1";
String stream = "stream1";
createScopeAndStream(scope, stream, prepareFromFixedScaleTypePolicy(2));
TxnId transactionId = createTransaction(StreamInfo.newBuilder().setScope(scope).setStream(stream).build(), 2000);
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.SCOPE1_STREAM1_READUPDATE, DEFAULT_PASSWORD);
PingTxnStatus status = stub.pingTransaction(Controller.PingTxnRequest.newBuilder().setStreamInfo(StreamInfo.newBuilder().setScope(scope).setStream(stream).build()).setTxnId(transactionId).setLease(1000).build());
assertEquals(PingTxnStatus.Status.OK, status.getStatus());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method getUriFailsForNonExistentUser.
@Test(timeout = 20000)
public void getUriFailsForNonExistentUser() {
String scope = "scope1";
String stream = "stream1";
// Arrange
createScopeAndStream(scope, stream, prepareFromFixedScaleTypePolicy(2));
ControllerServiceBlockingStub stub = prepareBlockingCallStub("nonexistentuser", "whatever");
// Verify
thrown.expect(StatusRuntimeException.class);
thrown.expectMessage("UNAUTHENTICATED");
// Act
NodeUri nodeUri1 = stub.getURI(segmentId(scope, stream, 0));
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method listScopes.
@Test(timeout = 20000)
public void listScopes() {
// Arrange
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
createScope(stub, "scope1");
createScope(stub, "scope2");
createScope(stub, "scope3");
createScope(stub, "scope4");
stub = prepareBlockingCallStub(UserNames.SCOPE_READER1_READ, DEFAULT_PASSWORD);
Controller.ScopesRequest request = Controller.ScopesRequest.newBuilder().setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act
Controller.ScopesResponse response = stub.listScopes(request);
// Assert
assertEquals(1, response.getScopesList().size());
assertEquals("4", response.getContinuationToken().getToken());
stub = prepareBlockingCallStub(UserNames.SCOPE_READER1_3_READ, DEFAULT_PASSWORD);
request = Controller.ScopesRequest.newBuilder().setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act
response = stub.listScopes(request);
// Assert
assertEquals(2, response.getScopesList().size());
assertEquals("3", response.getContinuationToken().getToken());
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method prepareBlockingCallStub.
private ControllerServiceBlockingStub prepareBlockingCallStub(String username, String password) {
Exceptions.checkNotNullOrEmpty(username, "username");
Exceptions.checkNotNullOrEmpty(password, "password");
ControllerServiceBlockingStub stub = ControllerServiceGrpc.newBlockingStub(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;
}
use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method pingTransactionFailsForUnAuthorizedUser.
@Test(timeout = 20000)
public void pingTransactionFailsForUnAuthorizedUser() {
String scope = "scope1";
String stream = "stream1";
createScopeAndStream(scope, stream, prepareFromFixedScaleTypePolicy(2));
TxnId transactionId = createTransaction(StreamInfo.newBuilder().setScope(scope).setStream(stream).build(), 2000);
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.SCOPE1_STREAM1_READ, DEFAULT_PASSWORD);
// Set the expected exception
thrown.expect(StatusRuntimeException.class);
thrown.expectMessage("PERMISSION_DENIED");
PingTxnStatus status = stub.pingTransaction(Controller.PingTxnRequest.newBuilder().setStreamInfo(StreamInfo.newBuilder().setScope(scope).setStream(stream).build()).setTxnId(transactionId).setLease(1000).build());
}
Aggregations