CrazyHZM commented on a change in pull request #9520:
URL: https://github.com/apache/dubbo/pull/9520#discussion_r780019063
##########
File path:
dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/BroadCastClusterInvokerTest.java
##########
@@ -117,6 +131,96 @@ public void testFailPercent() {
assertTrue(invoker3.isInvoked());
assertFalse(invoker4.isInvoked());
}
+
+ @Test
+ public void testMockedInvokerSelect() {
+ given(dic.list(invocation)).willReturn(Arrays.asList(invoker1,
invoker2, invoker3, invoker4));
+
+ List<Invoker<DemoService>> invokers = dic.list(invocation);
+ Assertions.assertEquals(4, invokers.size());
+ }
+
+
+ @Test
+ public void testFailoverInvokerSelect(){
+ given(dic.list(invocation)).willReturn(Arrays.asList(invoker1,
invoker2, invoker3, invoker4));
+ //取得当前调用链的所有invoker,逐个判断调用是否成功
Review comment:
Please describe in English.
##########
File path:
dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/BroadCastClusterInvokerTest.java
##########
@@ -117,6 +131,96 @@ public void testFailPercent() {
assertTrue(invoker3.isInvoked());
assertFalse(invoker4.isInvoked());
}
+
+ @Test
+ public void testMockedInvokerSelect() {
+ given(dic.list(invocation)).willReturn(Arrays.asList(invoker1,
invoker2, invoker3, invoker4));
+
+ List<Invoker<DemoService>> invokers = dic.list(invocation);
+ Assertions.assertEquals(4, invokers.size());
+ }
+
+
+ @Test
+ public void testFailoverInvokerSelect(){
+ given(dic.list(invocation)).willReturn(Arrays.asList(invoker1,
invoker2, invoker3, invoker4));
+ //取得当前调用链的所有invoker,逐个判断调用是否成功
+
+ invokers = dicIncludeInvokers.getAllInvokers();
+
+ BroadcastClusterInvoker broadcastCluster = new
BroadcastClusterInvoker(dicIncludeInvokers);
+ Assertions.assertDoesNotThrow( () -> {
+ broadcastCluster.doInvoke(invocation, invokers, new
MockLoadBalance());
+ });
+
+ try{
+ broadcastCluster.invoke(new
RpcInvocation("sayhello",DemoService.class.getName(),"",
+ new Class<?>[0], new Object[0]));
+ Thread.sleep(120*1000);
+ }catch (RpcException e ){
+ Assertions.assertEquals(RpcException.TIMEOUT_EXCEPTION,
e.getCode());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+}
+
+
+class MockLoadBalance implements LoadBalance {
+ @Override
+ public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url,
Invocation invocation) throws RpcException {
+ return null;
+ }
+}
+
+
+//设置一个注册中心地址,便于consumer本地进行远程调用测试
Review comment:
Please describe in English.
##########
File path:
dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenFilter.java
##########
@@ -47,10 +47,14 @@ public Result invoke(Invoker<?> invoker, Invocation inv)
Class<?> serviceType = invoker.getInterface();
Map<String, Object> attachments = inv.getObjectAttachments();
String remoteToken = (attachments == null ? null : (String)
attachments.get(TOKEN_KEY));
- if (!token.equals(remoteToken)) {
- throw new RpcException("Invalid token! Forbid invoke remote
service " + serviceType + " method " + inv.getMethodName() +
- "() from consumer " +
RpcContext.getServiceContext().getRemoteHost() + " to provider " +
- RpcContext.getServiceContext().getLocalHost()+ ",
consumer incorrect token is " + remoteToken);
+ if (ConfigUtils.isDefault(token)){
Review comment:
This means that as long as the token=default is configured, the request
can be executed arbitrarily, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]