MultiTenantRpcAuthorizer implements RpcAuthorizer { @Override public CompletableFuture<Void> authorizeConfigRequest(Request request) { return doAsyncAuthorization(request, this::doConfigRequestAuthorization); } MultiTenantRpcAuthorizer(NodeIdentifier nodeIdentifier,
                                    HostRegistries hostRegistries,
                                    RequestHandlerProvider handlerProvider,
                                    int threadPoolSize);   MultiTenantRpcAuthorizer(NodeIdentifier nodeIdentifier,
                             HostRegistry<TenantName> hostRegistry,
                             RequestHandlerProvider handlerProvider,
                             Executor executor); @Override CompletableFuture<Void> authorizeConfigRequest(Request request); @Override CompletableFuture<Void> authorizeFileRequest(Request request);  }
@Test public void proxy_node_can_access_lbservice_config() throws ExecutionException, InterruptedException { RpcAuthorizer authorizer = createAuthorizer(new NodeIdentity.Builder(NodeType.proxy).build(), new HostRegistry<>()); Request configRequest = createConfigRequest( new ConfigKey<>(LbServicesConfig.CONFIG_DEF_NAME, "*", LbServicesConfig.CONFIG_DEF_NAMESPACE), HOSTNAME); authorizer.authorizeConfigRequest(configRequest) .get(); }
@Test public void tenant_node_cannot_access_lbservice_config() throws ExecutionException, InterruptedException { RpcAuthorizer authorizer = createAuthorizer(new NodeIdentity.Builder(NodeType.tenant).build(), new HostRegistry<>()); Request configRequest = createConfigRequest( new ConfigKey<>(LbServicesConfig.CONFIG_DEF_NAME, "*", LbServicesConfig.CONFIG_DEF_NAMESPACE), HOSTNAME); exceptionRule.expectMessage("Node with type 'tenant' is not allowed to access global config [name=lb-services,namespace=cloud.config,configId=*]"); exceptionRule.expectCause(instanceOf(AuthorizationException.class)); authorizer.authorizeConfigRequest(configRequest) .get(); }