ccpa-test-patterns
Reference catalog of CCPA + CPRA-aligned test patterns - do-not-sell-or-share opt-out via Global Privacy Control (GPC) signal; data-disclosure category tests per Cal. Civ. Code §1798.110; sensitive personal information (SPI) handling per CPRA §1798.121; deletion-request workflows per §1798.105; CPRA's right to correct (§1798.106) + limit-use (§1798.121). Use when authoring CCPA/CPRA-readiness tests for any product processing California consumer data.
Install with skills.sh (any agent)
npx skills add testland/qa --skill ccpa-test-patternsccpa-test-patterns
Overview
Per oag.ca.gov/privacy/ccpa (opens in new window) (California Attorney General authoritative source):
CCPA (California Consumer Privacy Act, in force 2020-01-01) and CPRA (California Privacy Rights Act, in force 2023-01-01) apply to businesses meeting one of three thresholds:
Failure carries civil penalties up to $7,500 per intentional violation + $2,500 per non-intentional violation; private right of action for data breaches.
This is a reference skill - defines the test-pattern catalog by Cal. Civ. Code section. Pair with gdpr-test-patterns for international compliance footprint.
When to use
Test patterns by Cal. Civ. Code section
§1798.135 - Right to opt out via Global Privacy Control (GPC)
CPRA mandates honoring the GPC browser signal (per globalprivacycontrol.org (opens in new window)):
def test_gpc_signal_blocks_sale_and_share():
response = client.get('/page', headers={'Sec-GPC': '1'})
# Page MUST treat the visitor as opted-out:
assert 'do-not-sell-cookie' in response.cookies
# Tracking pixels for sale/share must NOT fire:
assert 'analytics-share.js' not in response.text
assert 'ads-third-party.js' not in response.text
# Status MUST be recorded for compliance evidence:
assert OptOutRecord.objects.filter(visitor_id=session_id).exists()§1798.110 - Right to know (categories of PI collected)
def test_consumer_request_returns_all_pi_categories():
response = client.post('/privacy/right-to-know', json={
'consumer_email': 'alice@example.com'
})
body = response.json()
# CCPA Cat. 11 personal info categories:
expected = {
'identifiers',
'commercial_info',
'biometric_info',
'internet_activity',
'geolocation_data',
'professional_or_employment',
'inferences',
}
# Test asserts every category present in response (NULL acceptable):
for cat in expected:
assert cat in body§1798.105 - Right to delete
def test_deletion_request_completes_within_45_days():
request = DeletionRequest.create(consumer_email='alice@example.com')
# CCPA: 45 days, extendable by 45 more (90 max) with notice
deadline = request.received_at + timedelta(days=45)
completion = DeletionRequest.objects.get(id=request.id)
assert completion.status == 'completed'
assert completion.completed_at <= deadline§1798.121 - Right to limit sensitive PI use (CPRA)
def test_limit_sensitive_pi_use():
# Consumer requests limit on sensitive PI (per CPRA SPI categories)
submit_limit_request(consumer='alice@example.com')
# Subsequent processing MUST NOT use SPI for inference / advertising:
response = client.get('/recommendations', headers={'X-Consumer-Email': 'alice@example.com'})
# Recommendations engine MUST NOT use SPI (geolocation, racial, religious, etc.):
used_features = response.json()['feature_attribution']
forbidden_spi = {'precise_geolocation', 'racial_ethnic', 'religious', 'union_membership'}
for feature in used_features:
assert feature not in forbidden_spi§1798.106 - Right to correct (CPRA)
def test_correction_request_updates_records_within_45_days():
submit_correction(consumer='alice@example.com', field='name', value='Alice Smith')
deadline = timezone.now() + timedelta(days=45)
# All systems must reflect the correction:
assert User.objects.get(email='alice@example.com').name == 'Alice Smith'
assert BillingRecord.objects.get(user_email='alice@example.com').name == 'Alice Smith'
# Third parties that received the prior incorrect value must be notified:
assert NotificationLog.objects.filter(
type='correction_propagation',
recipient='third-party-vendor@example.com',
).exists()§1798.130 - Notice requirements
def test_privacy_policy_disclosed_at_collection():
# Every PI collection point must disclose categories + purposes
response = client.get('/signup')
assert 'privacy-notice' in response.text
assert any(link in response.text for link in [
'/do-not-sell-or-share',
'/limit-sensitive-pi-use',
])
# Disclosed categories MUST match what's actually collected
disclosed = parse_privacy_notice(response.text)
actual = analyze_signup_form(response.text)
assert disclosed >= actual # disclosure is superset of collectionSensitive Personal Information categories (CPRA §1798.140(ae))
| Category | Examples |
|---|---|
| Government IDs | SSN, driver's license, passport, alien registration |
| Account login + credentials | Username + password / security questions |
| Precise geolocation | <1850 ft / 564 m radius |
| Racial / ethnic origin | Self-reported demographics |
| Religious / philosophical beliefs | Religious affiliation |
| Union membership | Trade union status |
| Communication content | Email body, SMS body, message content |
| Genetic data | DNA test results |
| Biometric for unique identification | Faceprint, voiceprint, fingerprint |
| Health info | Medical history, medications |
| Sexual orientation / sex life | Self-reported orientation |
Test patterns above (§1798.121) protect these categories specifically.
Anti-patterns
| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Honor opt-out cookie but ignore GPC header | CPRA mandates GPC support | Step §1798.135 GPC test |
| Right-to-know returns only main app data | Misses analytics, CRM | Multi-system response (Step §1798.110) |
| Correction propagated only locally | Third parties retain incorrect data | Notification log assertion (Step §1798.106) |
| SPI categorical restriction tested only at API edge | Inference engines bypass | Feature-attribution-level test (Step §1798.121) |
| Test fixtures use real California PII | CCPA violation in tests | synthetic-pii-generator |
Limitations
References
Related skills
audit-trail-test-author
Build-an-X for audit-log tests across compliance frameworks - required-events catalog (auth events / privilege change / data access / admin action / config change / export / impersonation); structured-log-format assertions per OWASP A09:2021; tamper-evident chain (hash-chain + signed-batch patterns) for HIPAA §164.312(b) + PCI Req 10 + SOC 2 CC7.3; immutability + retention per framework; query-replay tests for forensic reconstruction. Use when authoring audit log tests for any compliance framework (HIPAA / PCI / SOC 2 / GDPR / etc.).
compliance-coverage-scoring
Scores existing tests and evidence against a named compliance framework's criteria list (GDPR, CCPA/CPRA, SOC 2 Trust Services Criteria, HIPAA Security Rule, PCI DSS, ISO/IEC 27001), marking every criterion met, partial, not met, or not applicable with a stated evidence requirement per state, and recording each scope exclusion with its criterion reference, reason, named approver, and re-review date. Produces a readiness self-assessment only: not certification, not an audit opinion, not legal advice. Use when a framework version has been named and an evidence set already exists, and someone needs a per-criterion readiness score before an observation period opens, before a qualified assessor arrives, or in response to a regulator inquiry.
compliance-evidence-generator
Build-an-X workflow that produces auditor-facing evidence packages from automated test results: maps control IDs to test outcomes across any compliance framework (SOC 2, ISO 27001, HIPAA, PCI DSS, GDPR, FedRAMP); generates the control-evidence matrix, timestamped evidence bundles (screenshots, log excerpts, CI exports), and chain-of-custody notes per NIST SP 800-72. Distinct from soc2-evidence-collector (SOC2-only raw log harvest) and from read-only coverage gap analysis that produces no artifacts. Use when an audit engagement requires auditor-ready evidence packages built from existing automated test output.
gdpr-test-patterns
Reference catalog of GDPR-aligned test patterns - data-subject-rights workflows (Art. 15 access, Art. 16 rectification, Art. 17 erasure / "right to be forgotten", Art. 18 restriction, Art. 20 portability, Art. 21 objection); consent recording + revocation per Art. 7; data-residency assertions per Art. 44 - 50 international transfers; breach-notification timing tests per Art. 33 (72 hours); data-minimization assertions in fixtures per Art. 5(1)(c). Use when authoring GDPR-readiness tests for any product processing EU personal data.
hipaa-test-patterns
Reference catalog of HIPAA Security Rule-aligned test patterns - administrative safeguards (45 CFR §164.308: workforce training, access management, contingency planning), physical safeguards (§164.310: facility access, workstation security, device disposal), technical safeguards (§164.312: access control, audit logs, integrity, transmission security); PHI handling assertions in fixtures; minimum-necessary tests per §164.502(b); BAA-scope boundary verification. Use when authoring HIPAA-readiness tests for any product handling Protected Health Information.
iso27001-test-patterns
Reference catalog of ISO/IEC 27001:2022 Annex A test patterns: testable technical controls with code-level assertions for access control (A.8.2-A.8.5), logging and monitoring (A.8.15-A.8.16), cryptography (A.8.24), and secure development (A.8.25-A.8.31), plus evidence patterns for Stage 1 and Stage 2 certification audits and Statement of Applicability scoping. The full 93-control Annex A index (four themes: organizational A.5, people A.6, physical A.7, technological A.8) and the exhaustive per-control test code live in references/. Use when authoring ISMS test coverage for an ISO 27001:2022 certification engagement or gap assessment.
pci-dss-control-test-author
Build-an-X for PCI DSS v4.0 scope verification - cardholder data environment (CDE) boundary tests, segmentation tests (PCI Req 1), prohibited-data-storage assertions per Req 3 (no full track data, no CVV/CAV2/CVC2/CID, no PIN/PIN block post-authorization), key-management tests per Req 3.6, encryption-of-transmissions per Req 4. Use when authoring PCI DSS scope-reduction + control tests for any system handling payment-card data.
soc2-evidence-collector
Build-an-X for SOC 2 Type II evidence collection - per-Trust-Services-Criterion test artifacts (Common Criteria CC1.1 - CC9.2; plus Availability A1, Confidentiality C1, Processing Integrity PI1, Privacy P1 - P9 if in scope); auto-collection from CI logs + audit trails + access logs + change-management records; alignment with Vanta / Drata / Secureframe evidence shapes; observation-period sampling. Use when the team is preparing for SOC 2 Type II audit and needs continuous evidence collection automation.