address和USDTmanage/address token管理页面,参考归集任务页面布局和功能,添加统计功能,优化页面布局。 商户和管理员都去掉删除和修改,商户的详情页面去掉对地址的各种金额操作,只保留刷新链上数据功能
This commit is contained in:
1 parent
37754f3af0
commit
c516124eff
5 files changed
+127
-11
No files matched your search
+57
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.system.controller;
|
||||
|
||||
import com.ruoyi.system.domain.vo.WalletOperationRequest;
|
||||
import org.junit.Test;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/** 防止商户只读权限再次被误加入私钥操作的授权表达式。 */
|
||||
public class WalletAddressPermissionTest {
|
||||
|
||||
@Test
|
||||
public void merchantReadPermissionCannotEstimateOrBroadcast() throws Exception {
|
||||
String[] methods = {"transferTrx", "transferUsdt", "stake", "unstake",
|
||||
"delegate", "undelegate", "cancelUnstake"};
|
||||
for (String name : methods) {
|
||||
Method method = WalletAddressController.class.getMethod(name, WalletOperationRequest.class);
|
||||
assertFalse(name, allowed(method, false));
|
||||
assertTrue(name, allowed(method, true));
|
||||
}
|
||||
Method estimate = WalletAddressController.class.getMethod("estimate", String.class, WalletOperationRequest.class);
|
||||
assertFalse(allowed(estimate, false));
|
||||
assertTrue(allowed(estimate, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void merchantReadPermissionStillAllowsChainRefresh() throws Exception {
|
||||
assertTrue(allowed(WalletAddressController.class.getMethod("chain", Long.class), false));
|
||||
assertTrue(allowed(WalletAddressController.class.getMethod("delegations", Long.class), false));
|
||||
}
|
||||
|
||||
private boolean allowed(Method method, boolean operator) {
|
||||
StandardEvaluationContext context = new StandardEvaluationContext();
|
||||
context.setBeanResolver((evaluationContext, beanName) -> new PermissionStub(operator));
|
||||
return Boolean.TRUE.equals(new SpelExpressionParser()
|
||||
.parseExpression(method.getAnnotation(PreAuthorize.class).value())
|
||||
.getValue(context, Boolean.class));
|
||||
}
|
||||
|
||||
public static class PermissionStub {
|
||||
private final boolean operator;
|
||||
|
||||
public PermissionStub(boolean operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public boolean hasPermi(String permission) {
|
||||
return operator ? "system:address:operate".equals(permission)
|
||||
: "system:address:user-query".equals(permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user