1.租赁应用详情创建凭证,第一次没有显示api Secret ,使用密码框,请修正 2. 提供凭证删除功能。
This commit is contained in:
1 parent
6321cde4c0
commit
a83e1fef40
5 files changed
+94
-2
No files matched your search
@@ -102,6 +102,37 @@ public class RentalBusinessTest {
|
||||
}
|
||||
}
|
||||
|
||||
/** 签发响应可用,未使用凭证可删除;有历史或近期调用时拒绝且不影响节点凭证。 */
|
||||
@Test
|
||||
public void unusedAppCredentialCanBeDeletedButHistoryIsProtected() {
|
||||
Map<String, Object> issued = tx.execute(status -> identity.issue("APP", app, 10));
|
||||
assertFalse(text(issued, "api_secret").isEmpty());
|
||||
assertEquals(text(issued, "api_secret"), identity.secret(store.get("credential", number(issued, "id"), false)));
|
||||
long credentialId = number(issued, "id");
|
||||
expectFailure(() -> tx.execute(status -> identity.deleteAppCredential(credentialId, 20)));
|
||||
assertEquals(Integer.valueOf(1), tx.execute(status -> identity.deleteAppCredential(credentialId, 10)));
|
||||
assertNull(store.one("SELECT id FROM rent_credential WHERE id=?", credentialId));
|
||||
tx.execute(status -> { rentalDeletion().deleteApp(app, 10L); return null; });
|
||||
assertNull(store.one("SELECT id FROM rent_app WHERE id=?", app));
|
||||
|
||||
long recentApp = store.insert("app", map("user_id", 10, "name", "recent", "status", "ACTIVE"));
|
||||
Map<String, Object> recent = tx.execute(status -> identity.issue("APP", recentApp, 10));
|
||||
long recentId = number(recent, "id");
|
||||
store.insert("nonce", map("api_key", text(recent, "api_key"), "scope", "APP", "nonce", "test-nonce", "expires_at", after(180)));
|
||||
expectFailure(() -> tx.execute(status -> identity.deleteAppCredential(recentId, 10)));
|
||||
store.execute("UPDATE rent_nonce SET expires_at=? WHERE api_key=?", after(-1), text(recent, "api_key"));
|
||||
assertEquals(Integer.valueOf(1), tx.execute(status -> identity.deleteAppCredential(recentId, 10)));
|
||||
|
||||
long historicalApp = store.insert("app", map("user_id", 10, "name", "history", "status", "ACTIVE"));
|
||||
Map<String, Object> historical = tx.execute(status -> identity.issue("APP", historicalApp, 10));
|
||||
Map<String, Object> order = tx.execute(status -> orders.create(historicalApp, 10,
|
||||
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)));
|
||||
Map<String, Object> nodeKey = tx.execute(status -> identity.issue("NODE", node, 20));
|
||||
expectFailure(() -> tx.execute(status -> identity.deleteAppCredential(number(nodeKey, "id"), 20)));
|
||||
}
|
||||
|
||||
private RentalProvisioning rentalDeletion() { return new RentalProvisioning(store, orders); }
|
||||
|
||||
@Before
|
||||
|
||||
Reference in new issue
Block a user