feat(release): 生产授权支持页面通道(管理员会话 + 固定确认语句)
页面原本没有任何生产入口,授权/重排/回滚只能带 Bearer 调接口,实际还要 admin 会话。 现在三个端点支持两条通道,门禁语义不变: - 运维通道:Authorization: Bearer <token>,审计记 PRODUCTION_RELEASE_AUTHORIZER_REF - 页面通道:已认证 admin 会话 + 固定确认语句,审计记该管理员用户名 - 请求门禁 / 备份恢复门禁 / Release Worker 执行门禁三者不受影响 - 发布管理第 6–8 步加「授权发布 / 重排 / 回滚」按钮,点击需逐字输入确认语句, 仅 admin 可见;重排沿用原执行授权人,不改写历史 - openapi 与 P6 契约同步;测试:双通道各一条 + 非 admin/错短语拒绝 + 前端按钮与确认门禁
This commit is contained in:
@@ -10,6 +10,8 @@ import {
|
||||
fetchReleaseCapabilities,
|
||||
fetchReleaseExecution,
|
||||
fetchReleaseExecutions,
|
||||
productionConfirmationPhrases,
|
||||
runProductionAction,
|
||||
fetchReleasePlan,
|
||||
fetchReviewCandidates,
|
||||
parseReleaseBatchDetailResponse,
|
||||
@@ -192,3 +194,28 @@ describe('release audit chain (R6)', () => {
|
||||
await expect(fetchReleaseAuditChain('rx-1')).rejects.toThrow('HTTP 500')
|
||||
})
|
||||
})
|
||||
|
||||
// 生产动作:三条路径 + 服务端原因回传(页面通道 = 管理员会话 + 固定确认语句)。
|
||||
describe('production actions', () => {
|
||||
it('routes each action to its endpoint with the fixed phrase and an idempotency key', async () => {
|
||||
const fetchMock = vi.fn().mockImplementation(() => Promise.resolve(new Response(JSON.stringify({ data: { id: 'rx-1', state: 'pending', operation: 'publish', item_count: 1 } }), { status: 202 })))
|
||||
vi.stubGlobal('fetch', fetchMock)
|
||||
await expect(runProductionAction('authorize', 'rb-1', 'publish-to-production')).resolves.toEqual({ id: 'rx-1', state: 'pending', operation: 'publish', item_count: 1 })
|
||||
await runProductionAction('retry', 'rx-1', 'retry-production-release')
|
||||
await runProductionAction('rollback', 'rx-1', 'rollback-production-release')
|
||||
const urls = fetchMock.mock.calls.map((call) => call[0])
|
||||
expect(urls).toEqual([
|
||||
'/api/v1/release-batches/rb-1/authorize-production',
|
||||
'/api/v1/release-executions/rx-1/retry',
|
||||
'/api/v1/release-executions/rx-1/authorize-rollback',
|
||||
])
|
||||
expect(fetchMock.mock.calls[0][1].headers['Idempotency-Key']).toBeTruthy()
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
it('surfaces the server reason and keeps the phrases fixed', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(new Response(JSON.stringify({ error: 'production release authorization required' }), { status: 401 })))
|
||||
await expect(runProductionAction('authorize', 'rb-1', 'publish-to-production')).rejects.toThrow('production release authorization required')
|
||||
expect(productionConfirmationPhrases).toEqual({ authorize: 'publish-to-production', retry: 'retry-production-release', rollback: 'rollback-production-release' })
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user