V23 · Security rules test

Kiểm thử allow/deny trước khi deploy rules.

V23 chuyển checklist rules thành ma trận scenario để sau này chạy bằng Firebase emulator.

ALLOW · read

participant-read-self-profile

Role: participant

Path: participants/p-demo-001

Người tham gia đọc hồ sơ tối thiểu của chính mình.

DENY · read

participant-deny-other-submission

Role: participant

Path: participants/p-demo-002/r4Submissions/sub-001

Người tham gia không đọc subtree cá nhân của người khác.

ALLOW · read

organization-read-aggregate

Role: organization_observer

Path: cohorts/cohort-demo-001/aggregateSnapshots/snap-001

Tổ chức chỉ đọc aggregate snapshot.

DENY · read

organization-deny-raw-answer

Role: organization_observer

Path: participants/p-demo-001/r4Submissions/sub-001

Tổ chức không đọc câu trả lời thô hoặc báo cáo cá nhân.

DENY · update

audit-deny-update

Role: admin

Path: auditEvents/audit-001

Audit event là append-only; admin cũng không sửa/xóa.

DENY · read

anonymous-deny-all

Role: anonymous

Path: participants/p-demo-001

Không có Firebase Auth thì không đọc dữ liệu.

Ghi chú

  • Bản v23 chưa nhúng @firebase/rules-unit-testing để ZIP chạy sạch; script hiện kiểm tra ma trận kịch bản và sự hiện diện của rules.
  • Khi cài emulator thật, chuyển từng scenario thành test bằng initializeTestEnvironment().
  • Mọi allow/deny ở rules vẫn chỉ là lớp khóa hạ tầng; consent gate vẫn chạy ở repository/write path.