feat: add generic queue and subscription retirement

This commit is contained in:
2026-09-27 14:39:49 +08:00
parent d54bdd9847
commit c9e877c3f7
53 changed files with 1013 additions and 88 deletions

View File

@@ -151,6 +151,19 @@ call('/v1/subscriptions/' + subscription_id + ':configure', pause, headers=manag
assert call('/v1/subscriptions/' + subscription_id, token=rotate['token'], session=False)['credential_id'] == op['credential_id']
assert call('/console/scope')['entry']['namespace_id'] == original_scope['entry']['namespace_id']
print('PASS: scoped task/schedule/workflow/subscription/retention/archive reads, subscription management/replay, SDK ownership, CSRF and cross-application isolation')
# 通用退役管理:只操作本测试新建空资源,验证跨应用管理员范围和 CSRF。
retire_queue = call('/v1/queues', {'name':'retire-'+uuid.uuid4().hex[:8], 'max_concurrency':1, 'rate_per_second':10}, token=rotate['token'], session=False, headers={'Idempotency-Key':uuid.uuid4().hex}, expected=201)['queue']
retire_sub = call('/v1/subscriptions', {'name':'retire-'+uuid.uuid4().hex[:8], 'queue_id':retire_queue['id']}, token=rotate['token'], session=False, headers={'Idempotency-Key':uuid.uuid4().hex}, expected=201)['subscription']
capacity_before = call('/console/applications/'+op['namespace_id'])['active_subscriptions']
retire_body = {'expected_revision':retire_sub['revision'], 'reason':'completed isolated acceptance'}
retire_headers = {**scope_headers,'Idempotency-Key':uuid.uuid4().hex}
call('/v1/subscriptions/'+retire_sub['id']+':retire', retire_body, headers={**retire_headers,'Origin':'https://other.invalid'}, expected=403)
assert call('/v1/subscriptions/'+retire_sub['id']+':retire', retire_body, headers=retire_headers)['subscription']['retired_at']
assert call('/v1/subscriptions/'+retire_sub['id']+':retire', retire_body, headers=retire_headers)['deduplicated']
assert call('/console/applications/'+op['namespace_id'])['active_subscriptions'] == capacity_before-1
assert call('/v1/queues/'+retire_queue['id']+':retire', {'expected_revision':retire_queue['revision'],'reason':'completed isolated acceptance'}, headers={**scope_headers,'Idempotency-Key':uuid.uuid4().hex})['queue']['retired_at']
assert call('/v1/queues/'+retire_queue['id'], headers=scope_headers)['retired_at']
print('PASS: scoped resource retirement, CSRF, idempotency, historical reads and released subscription capacity')
call('/console/auth/logout', {})
call(token_path + 'reveal', {'expected_revision':'4'}, expected=401)
call('/console/applications', expected=401)