use of io.pravega.controller.stream.api.grpc.v1.ControllerServiceGrpc.ControllerServiceBlockingStub in project pravega by pravega.
the class ControllerGrpcAuthFocusedTest method listKVTFiltersResultWhenUserHasAccessToSubsetOfTables.
@Test(timeout = 20000)
public void listKVTFiltersResultWhenUserHasAccessToSubsetOfTables() {
// Arrange
String scope = "scope1";
ControllerServiceBlockingStub stub = prepareBlockingCallStub(UserNames.ADMIN, DEFAULT_PASSWORD);
createScope(stub, scope);
doAnswer(x -> CompletableFuture.completedFuture(true)).when(this.kvtStore).checkScopeExists(any(), any(), any());
doAnswer(x -> CompletableFuture.completedFuture(new ImmutablePair<>(Lists.newArrayList("table1", "table2"), "2"))).when(this.kvtStore).listKeyValueTables(anyString(), eq(""), anyInt(), any(), any());
doAnswer(x -> CompletableFuture.completedFuture(new ImmutablePair<>(Lists.newArrayList("table3", "table4"), "4"))).when(this.kvtStore).listKeyValueTables(anyString(), eq("2"), anyInt(), any(), any());
doAnswer(x -> CompletableFuture.completedFuture(new ImmutablePair<>(Collections.emptyList(), "4"))).when(this.kvtStore).listKeyValueTables(anyString(), eq("4"), anyInt(), any(), any());
stub = prepareBlockingCallStub(UserNames.SCOPE1_TABLE1_LIST_READ, DEFAULT_PASSWORD);
Controller.KVTablesInScopeRequest request = Controller.KVTablesInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope(scope).build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act
Controller.KVTablesInScopeResponse response = stub.listKeyValueTablesInScope(request);
// Assert
assertEquals(1, response.getKvtablesCount());
stub = prepareBlockingCallStub(UserNames.SCOPE1_TABLE1_3_LIST_READ, DEFAULT_PASSWORD);
request = Controller.KVTablesInScopeRequest.newBuilder().setScope(Controller.ScopeInfo.newBuilder().setScope(scope).build()).setContinuationToken(Controller.ContinuationToken.newBuilder().build()).build();
// Act
response = stub.listKeyValueTablesInScope(request);
// Assert
assertEquals(2, response.getKvtablesCount());
}
Aggregations