Avoid common App Store and Google Play rejections. Open playbook and pre-submission guard with 117 documented rejection patterns and fixes, privacy manifest and Data safety checks, 95 tracked deadlines (EU AI Act, DSA, COPPA, age laws), and a skill for AI coding agents.
Shell accessibilityai-agentsandroidapp-review-guidelinesapp-storeapp-store-connectapp-store-rejectionapp-store-reviewclaude-codecoppadata-safetyeu-ai-actgdprgoogle-playgoogle-play-policyiosmobile-complianceplay-consolepre-submission-checklistprivacy-manifest
#!/usr/bin/env bash
# Test suite for scripts/monitor-privacy.py
# Verifies mock RSS input parsing, Mobile/Web Privacy keyword matching, codebase scanning,
# documentation generation, and the presence of exactly 15 required non-vague sections in the PR draft.
# Also verifies that all generated outputs are completely emoji-free.
set -uo pipefail
PASS=0
FAIL=0
ok() { PASS=$((PASS+1)); printf 'PASS %s\n' "$1"; }
bad() { FAIL=$((FAIL+1)); printf 'FAIL %s\n' "$1"; }
MOCK_JSON="/tmp/test_privacy_announcements.json"
OUT_DOCS="/tmp/test_privacy_migration.md"
OUT_PR="/tmp/test_privacy_pr.md"
# Cleanup files first
cleanup() {
rm -f "$MOCK_JSON" "$OUT_DOCS" "$OUT_PR" 2>/dev/null || true
}
trap cleanup EXIT
# Create a mock dataset containing updates for testing
cat << 'EOF' > "$MOCK_JSON"
[
{
"id": "PRIV-MOCK-TEST-GDPR",
"category": "GDPR",
"title": "GDPR Compliance Guidance on User Auditing",
"description": "Essential GDPR regulations require robust consent models and dynamic rights checks.",
"link": "https://edpb.europa.eu/news/news/feed_en",
"pubDate": "Fri, 15 May 2026 10:00:00 PDT"
},
{
"id": "PRIV-MOCK-TEST-MANIFEST",
"category": "Privacy Manifest",
"title": "Apple Mandatory Privacy Manifest Guidelines Update",
"description": "All submitted apps must bundle an approved Privacy Manifest.",
"link": "https://developer.apple.com/support/privacy-manifest-files",
"pubDate": "Sat, 16 May 2026 11:00:00 PDT"
}
]
EOF
echo "== Running Privacy Policy Monitor Test Suite =="
# Execute scripts/monitor-privacy.py with mock dataset
python3 scripts/monitor-privacy.py --mock "$MOCK_JSON" --dir . --output-docs "$OUT_DOCS" --pr-output "$OUT_PR" > /tmp/monitor_privacy_run.log 2>&1
RC=$?
if [ "$RC" -ne 0 ]; then
bad "monitor-privacy.py failed with exit code $RC. Output:"
cat /tmp/monitor_privacy_run.log
exit 1
fi
ok "monitor-privacy.py ran successfully with exit code 0"
# Assert relevant policies were matched
if grep -q "GDPR Compliance Guidance" /tmp/monitor_privacy_run.log && grep -q "Apple Mandatory Privacy Manifest" /tmp/monitor_privacy_run.log; then
ok "Correctly matched relevant Privacy policy updates"
else
bad "Failed to match relevant Privacy policy updates. Output: $(cat /tmp/monitor_privacy_run.log)"
fi
# Assert that documentation was generated
if [ -f "$OUT_DOCS" ]; then
ok "Documentation output file created at $OUT_DOCS"
if grep -q "GDPR Compliance Guidance" "$OUT_DOCS" && grep -q "Apple Mandatory Privacy Manifest" "$OUT_DOCS"; then
ok "Documentation contains details of matched policy updates"
else
bad "Documentation is missing policy details"
fi
else
bad "Documentation file was not created"
fi
# Assert that PR Draft contains EXACTLY 15 required sections
if [ -f "$OUT_PR" ]; then
ok "PR Draft output file created at $OUT_PR"
declare -a SECTIONS=(
"Summary"
"Background"
"Regulatory change"
"Official citations"
"Affected files"
"Risk assessment"
"Migration steps"
"Backward compatibility"
"Implementation checklist"
"Testing checklist"
"Documentation checklist"
"Compliance impact"
"Breaking changes"
"Review checklist"
"Approver recommendations"
)
MISSING=0
for idx in "${!SECTIONS[@]}"; do
sec_num=$((idx + 1))
sec_name="${SECTIONS[$idx]}"
if grep -q "## ${sec_num}\. ${sec_name}" "$OUT_PR"; then
true
else
echo " Missing PR section: ## ${sec_num}. ${sec_name}"
MISSING=$((MISSING + 1))
fi
done
if [ "$MISSING" -eq 0 ]; then
ok "PR Draft contains exactly the 15 required compliance sections"
else
bad "PR Draft is missing $MISSING of the 15 required compliance sections"
fi
else
bad "PR Draft file was not created"
fi
# Source trust is decided by the URL host, never by text
if python3 - scripts/monitor-privacy.py <<'TRUSTPY'
import importlib.util, sys
spec = importlib.util.spec_from_file_location("mon", sys.argv[1])
mon = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mon)
cases = [
("spoofed host suffix", {"title": "Rule", "description": "", "link": "https://ftc.gov.attacker.invalid/article"}, False),
("agency word in title", {"title": "FTC announces a new rule", "description": "", "link": "https://news.example.invalid/story"}, False),
("official domain in text only", {"title": "Rule", "description": "see ftc.gov and developer.apple.com", "link": "https://news.example.invalid/story"}, False),
("userinfo trick", {"title": "Rule", "description": "", "link": "https://[email protected]/"}, False),
("lookalike vendor host", {"title": "Rule", "description": "", "link": "https://developer.apple.com.attacker.invalid/x"}, False),
("legitimate subdomain", {"title": "Rule", "description": "", "link": "https://www.ftc.gov/news"}, True),
("uppercase host", {"title": "Rule", "description": "", "link": "https://DEVELOPER.APPLE.COM/news"}, True),
]
failed = 0
for name, ann, official in cases:
prio, verified = mon.classify_source_and_verify(ann, None)
if official and (prio, verified) != (1, True):
print(" %s: expected (1, True), got (%s, %s)" % (name, prio, verified)); failed += 1
if not official and (prio == 1 or verified):
print(" %s: expected untrusted, got (%s, %s)" % (name, prio, verified)); failed += 1
sys.exit(1 if failed else 0)
TRUSTPY
then
ok "Source trust follows the URL host with a domain boundary match"
else
bad "Source trust can be raised by a spoofed host or by text"
fi
# Assert no emojis are present in outputs or scripts
echo "Checking for emojis in scripts and generated files..."
has_emojis() {
# Scans for high-unicode character range (emojis and similar symbols)
python3 -c "
import sys
with open(sys.argv[1], 'r', encoding='utf-8') as f:
text = f.read()
import re
emojis = re.findall(r'[\U00010000-\U0010ffff]', text)
if emojis:
print('Found emojis in', sys.argv[1], ':', emojis)
sys.exit(1)
sys.exit(0)
" "$1"
}
if has_emojis "scripts/monitor-privacy.py" && \
has_emojis "scripts/monitor-privacy-test.sh" && \
has_emojis "$OUT_DOCS" && \
has_emojis "$OUT_PR"; then
ok "All scripts and generated markdown files are 100% emoji-free"
else
bad "Emoji check failed: high-unicode emojis or symbols detected"
fi
echo ""
echo "Privacy Policy Monitor test suite: $PASS passed, $FAIL failed"
if [ "$FAIL" -eq 0 ]; then
exit 0
else
exit 1
fi