views/rental/nodeDetail 租赁地址,添加可以删除待验证的地址功能
This commit is contained in:
1 parent
dafa5261bd
commit
624110e43c
4 files changed
+76
No files matched your search
@@ -43,6 +43,45 @@ public class RentalBusinessTest {
|
||||
private static final String OWNER = "TR7NHqjeKQxGTCi8q8ZY4pL8otgjLj6t";
|
||||
private final ObjectMapper json = new ObjectMapper();
|
||||
|
||||
/** 待验证地址仅本人可删除,验证后或状态变化后必须保留。 */
|
||||
@Test
|
||||
public void pendingWalletDeletionChecksOwnershipAndVerification() {
|
||||
long pending = store.insert("wallet", map("node_id", node, "network", "NILE",
|
||||
"address", "pending-delete", "status", "PENDING"));
|
||||
expectFailure(() -> tx.execute(status -> {
|
||||
rentalDeletion().deletePendingWallet(pending, 10); return null;
|
||||
}));
|
||||
store.update("wallet", pending, map("ownership_verified_at", now()));
|
||||
expectFailure(() -> tx.execute(status -> {
|
||||
rentalDeletion().deletePendingWallet(pending, 20); return null;
|
||||
}));
|
||||
store.update("wallet", pending, map("ownership_verified_at", null, "status", "PAUSED"));
|
||||
expectFailure(() -> tx.execute(status -> {
|
||||
rentalDeletion().deletePendingWallet(pending, 20); return null;
|
||||
}));
|
||||
store.update("wallet", pending, map("status", "PENDING"));
|
||||
tx.execute(status -> { rentalDeletion().deletePendingWallet(pending, 20); return null; });
|
||||
assertNull(store.one("SELECT id FROM rent_wallet WHERE id=?", pending));
|
||||
assertEquals(1, store.rows("SELECT id FROM rent_event WHERE object_type='WALLET' AND object_id=? AND action='DELETE'", pending).size());
|
||||
}
|
||||
|
||||
/** 在线和恢复连接时拒绝轮换且保留原凭证,离线后允许正常轮换。 */
|
||||
@Test
|
||||
public void nodeCredentialRotationRequiresOffline() {
|
||||
Map<String, Object> original = store.one(
|
||||
"SELECT id FROM rent_credential WHERE owner_type='NODE' AND owner_id=? AND status='ACTIVE'", node);
|
||||
for (String connection : Arrays.asList("ONLINE", "SYNCING")) {
|
||||
store.update("node", node, map("connection_status", connection));
|
||||
expectFailure(() -> tx.execute(status -> identity.issue("NODE", node, 20)));
|
||||
assertEquals("ACTIVE", text(store.get("credential", number(original, "id"), false), "status"));
|
||||
assertEquals(1, store.rows("SELECT id FROM rent_credential WHERE owner_type='NODE' AND owner_id=?", node).size());
|
||||
}
|
||||
store.update("node", node, map("connection_status", "OFFLINE"));
|
||||
Map<String, Object> issued = tx.execute(status -> identity.issue("NODE", node, 20));
|
||||
assertEquals("ACTIVE", text(store.get("credential", number(issued, "id"), false), "status"));
|
||||
assertEquals("VERIFY_ONLY", text(store.get("credential", number(original, "id"), false), "status"));
|
||||
}
|
||||
|
||||
/** 真实查询验证应用隔离、节点凭证隔离与 Secret 不外泄。 */
|
||||
@Test
|
||||
public void appDetailIsOwnedAndNeverReturnsSecrets() {
|
||||
@@ -56,6 +95,7 @@ public class RentalBusinessTest {
|
||||
login, null, Collections.emptyList()));
|
||||
try {
|
||||
tx.execute(status -> identity.issue("APP", app, 10));
|
||||
store.update("node", node, map("connection_status", "OFFLINE"));
|
||||
tx.execute(status -> identity.issue("NODE", node, 20));
|
||||
RentalController controller = new RentalController(
|
||||
store, null, identity, orders, funds, reviews, tasks, null, null);
|
||||
@@ -132,6 +172,7 @@ public class RentalBusinessTest {
|
||||
map("package_id", product, "merchant_order_no", "credential-delete", "receiver_address", ADDRESS)));
|
||||
tx.execute(status -> { orders.cancel(number(order, "id"), 10); return null; });
|
||||
expectFailure(() -> tx.execute(status -> identity.deleteAppCredential(number(historical, "id"), 10)));
|
||||
store.update("node", node, map("connection_status", "OFFLINE"));
|
||||
Map<String, Object> nodeKey = tx.execute(status -> identity.issue("NODE", node, 20));
|
||||
expectFailure(() -> tx.execute(status -> identity.deleteAppCredential(number(nodeKey, "id"), 20)));
|
||||
}
|
||||
@@ -454,7 +495,10 @@ public class RentalBusinessTest {
|
||||
"ONLINE",
|
||||
"heartbeat_expires_at",
|
||||
after(60)));
|
||||
// 先离线签发,再模拟 Agent 上线,遵循实际节点生命周期。
|
||||
store.update("node", node, map("connection_status", "OFFLINE"));
|
||||
identity.issue("NODE", node, 20);
|
||||
store.update("node", node, map("connection_status", "ONLINE"));
|
||||
product =
|
||||
store.insert(
|
||||
"package",
|
||||
|
||||
Reference in new issue
Block a user