Files
dth/openspec/changes/chg_0010_federated_risk_control/testcases.md
T

4.4 KiB
Raw Blame History

C1_3bank_did_setup_tds_match

  • Scenario: S1
  • Type: e2e
  • Priority: P0
  • Given: backend running on 30000, admin token, 3 bank private keys
  • When: POST /experiment/runs × 3 with operator=did-identity (per-bank), then POST with operator=tds-connector (matching contract_hash)
  • Then: 3 DIDs created + tds match=true + token non-empty (3-part JWT)
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C2_did_verify_loop_tamper_detect

  • Scenario: S2
  • Type: e2e
  • Priority: P0
  • Given: 3 DIDs from C1
  • When: verify each DID, then mutate one DID's publicKey and re-verify
  • Then: original 3 verify returns valid=true; mutated DID verify returns valid=false
  • Automated: true
  • Bound Task: T2

C3_tds_mismatch_abort

  • Scenario: S3
  • Type: e2e
  • Priority: P1
  • Given: contract_hash_a ≠ contract_hash_b
  • When: POST /experiment/runs with operator=tds-connector
  • Then: response.match=false, error="contract-mismatch"
  • And: FRC flow aborts (no PSI / aggregation steps executed)
  • Automated: true
  • Bound Task: T2

C4_psi_intersection_correct

  • Scenario: S4
  • Type: e2e
  • Priority: P0
  • Given: 3 blacklists A=[f01,f02,f03,f04] / B=[f01,f02,f03,f05] / C=[f01,f02,f03,f06,f07]
  • When: POST /experiment/runs with operator=psi
  • Then: response.intersection=[f01,f02,f03] (sorted, deduped)
  • And: intersection_size=3
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C5_psi_no_leak_non_intersection

  • Scenario: S5
  • Type: e2e
  • Priority: P0 (privacy invariant)
  • Given: blacklists from C4
  • When: inspect full PSI response (all keys + values)
  • Then: output NEVER contains f04/f05/f06/f07 (non-intersection)
  • And: output size ≤ min(4,3,4)=3
  • And: no per-bank blacklist size or membership info in output
  • Automated: true
  • Bound Task: T2

C6_paillier_cross_bank_sum_invariant

  • Scenario: S6
  • Type: e2e
  • Priority: P0
  • Given: paillier public key, 3 features (100/200/300)
  • When: POST /experiment/runs with operator=paillier-he, input={action: "homomorphic_sum", values: [100,200,300]}
  • Then: decrypted sum === 600 (mod n)
  • And: homomorphic_invariant passes (Enc(a)·Enc(b) mod n² === Enc(a+b))
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C7_threshold_sig_2shares_reconstruct

  • Scenario: S7
  • Type: e2e
  • Priority: P0
  • Given: 3-of-3 Shamir shares, payload
  • When: POST /experiment/runs with operator=threshold-sig, input={shares: [s1,s2,s3], threshold: 2}
  • Then: 2-share Lagrange reconstruction recovers secret
  • And: verify_code=0 (signature valid)
  • And: recovered payload === original payload
  • Automated: true
  • Bound Task: T2

C8_threshold_sig_1share_fails

  • Scenario: S8
  • Type: e2e
  • Priority: P1
  • Given: 3 shares from C7
  • When: POST with shares=[s1] only
  • Then: verify_code≠0
  • And: error code="insufficient-shares" or equivalent
  • Automated: true
  • Bound Task: T2

C9_abac_policy_decision_matrix

  • Scenario: S9
  • Type: e2e
  • Priority: P0
  • Given: abac policy requiring role=risk-analyst AND region∈[BJ,SH,GZ] AND time∈[09:00,18:00]
  • When: 4 POSTs with combinations (allow / 3× deny)
  • Then: allow for {role:risk-analyst,region:BJ,time:10:00}
  • And: deny "role-deny" for {role:guest}
  • And: deny "region-deny" for {region:NY}
  • And: deny "timewindow-deny" for {time:20:00}
  • Automated: true
  • Bound Task: T2

C10_data_watermark_roundtrip

  • Scenario: S10
  • Type: e2e
  • Priority: P0
  • Given: report text, watermark payload="FRC|2026-09-28|bankA,bankB,bankC"
  • When: POST with operator=data-watermark (embed), then POST same text (extract)
  • Then: report length unchanged after embed (zero-width chars)
  • And: extract returns exact payload string
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C11_audit_chain_hmac_valid

  • Scenario: S11
  • Type: e2e
  • Priority: P1
  • Given: 8 FRC step entries (S1-S10 condensed: did×3 / tds / psi / paillier / threshold / abac / watermark = ~9 audit entries)
  • When: POST with operator=compliance-audit, action=verify_chain
  • Then: chain length ≥ 8
  • And: each entry has prev_hash link
  • And: chainValid=true
  • Automated: true
  • Bound Task: T2

C12_e2e_full_flow_8_steps

  • Scenario: S12
  • Type: e2e
  • Priority: P0
  • Given: canonical 3-bank fixture (BankA/BankC blacklists + features + shares + ABAC subject + report)
  • When: 1 shell run executes all 11 steps in sequence (C1-C11 in order)
  • Then: pass=12 fail=0 (12 main cases)
  • And: total wall-clock < 60s
  • And: no operator-not-found or 500 errors in any substep
  • Automated: true
  • Bound Task: T3 (E2E orchestration test)