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

4.8 KiB
Raw Blame History

C1_vc_tds_contract_match

  • Scenario: S1
  • Type: e2e
  • Priority: P0
  • Given: backend running on 30000, admin token, vehicle's contract_hash = "vc-contract-v1"
  • When: POST /experiment/runs with operator=tds-connector (matching contract_hash_a == contract_hash_b)
  • Then: response.tds.contract_hash_match=true
  • And: response.tds.access_token is non-empty 3-part JWT (header.payload.signature)
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C2_vc_tds_mismatch_abort

  • Scenario: S2
  • Type: e2e
  • Priority: P1
  • Given: contract_hash_a = "vc-contract-v1", contract_hash_b = "vc-contract-v2" (different)
  • When: POST /experiment/runs with operator=tds-connector
  • Then: response.tds.contract_hash_match=false
  • And: response.tds.error="contract-mismatch"
  • And: response.tds.access_token=null
  • And: VC flow aborts (no data-masking / aggregation runs)
  • Automated: true
  • Bound Task: T2

C3_vc_field_aware_masking

  • Scenario: S3
  • Type: e2e
  • Priority: P0
  • Given: 50 vehicles × 3 PII fields (GPS / plate / owner_id) + 3 business fields (fault_code / battery_voltage / mileage)
  • When: 150 POST calls to data-masking (PII fields masked) + business fields passed through
  • Then: all 50 vehicles' GPS coordinates, plate numbers, owner IDs are masked (50 of each)
  • And: NO original PII value appears in any masked output (assert no GPS lat/lon, no plate, no owner_id strings)
  • And: business fields (fault_code "P0301", battery_voltage "12.6V", mileage "50000km") appear unchanged
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C4_vc_masking_reversible

  • Scenario: S4
  • Type: e2e
  • Priority: P0 (compliance invariant)
  • Given: 1 vehicle with original GPS / plate / owner_id values, data-masked once
  • When: re-run data-masking on the same original values
  • Then: both runs produce the SAME reversible_hash for each field (SHA256 stable)
  • And: reversible_hash is exactly 64 hex chars (SHA256 output)
  • And: re-masking returns identical masked output (deterministic)
  • Automated: true
  • Bound Task: T2

C5_vc_watermark_embed_extract_roundtrip

  • Scenario: S5
  • Type: e2e
  • Priority: P0
  • Given: fleet report text "Fleet avg fault_rate=0.05, fleet size=50", payload="VC|2026-09-29|fleet-50|v1"
  • When: POST data-watermark (action=embed) with text + payload, then POST (action=extract) on watermarked_text
  • Then: extract returns the EXACT payload string "VC|2026-09-29|fleet-50|v1"
  • And: roundtrip payload matches byte-for-byte
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C6_vc_watermark_invisible_length

  • Scenario: S6
  • Type: e2e
  • Priority: P1
  • Given: text="Fleet avg fault_rate=0.05, fleet size=50" (37 chars), data-watermark embed
  • When: POST data-watermark (action=embed) with payload="VC|2026-09-29|fleet-50|v1" (24 bytes)
  • Then: visible (printable) length of watermarked_text == 37 (unchanged)
  • And: total length of watermarked_text == 37 + 24*4 == 133 (zero-width chars added)
  • And: zero-width chars appended is exactly 96 (= 24 * 4)
  • Automated: true
  • Bound Task: T2

C7_vc_fleet_fedavg_aggregation

  • Scenario: S7
  • Type: e2e
  • Priority: P0
  • Given: 50 vehicles each submit a normalized fault-rate in [0, 1]
  • When: POST horizontal-fedavg with input.weights=[0.02, 0.05, ..., 0.08] (50 numbers)
  • Then: response.fedavg.aggregated[0] is the mean of the 50 values (no DP noise, epsilon absent)
  • And: response.fedavg.client_count=50
  • And: response.fedavg.noise_applied=false
  • And: schema_version=v2
  • Automated: true
  • Bound Task: T2

C8_vc_abac_compliance_analyst

  • Scenario: S8
  • Type: e2e
  • Priority: P0
  • Given: abac policy requiring role=compliance-analyst AND env.ip in CIDR 10.0.0.0/24
  • When: 3 POSTs with combinations (1 allow + 2 deny)
  • Then: allow for {role: compliance-analyst, ip: 10.0.0.5}
  • And: deny with allow_miss for {role: engineer, ip: 10.0.0.5}
  • And: deny with env_violation:ip for {role: compliance-analyst, ip: 192.168.1.5}
  • Automated: true
  • Bound Task: T2

C9_vc_audit_chain_hmac_valid

  • Scenario: S9
  • Type: e2e
  • Priority: P1
  • Given: 6 VC step audit entries (S1 tds + S3 masking summary + S5 watermark + S7 fedavg + S8 abac + S8-close)
  • When: POST compliance-audit with action=record (5 appends to chain), then POST verify=true with entries=full chain
  • Then: chain length === 6
  • And: each entry has prev_hash linking prior entry's hash
  • And: chainValid=true on verify replay
  • Automated: true
  • Bound Task: T2

C10_vc_e2e_full_flow_6_steps

  • Scenario: S10
  • Type: e2e
  • Priority: P0
  • Given: canonical 50-vehicle fixture (TDS contract, masked telemetry, watermark payload, fleet weights, ABAC policy, audit entries)
  • When: 1 shell run executes all 9 steps in sequence (C1-C9 in order)
  • Then: pass=10 fail=0 (10 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)