forked from retoor/devplacepy
Add the trust and safety subsystem and the App Store compliance work
Implements the moderation and consent obligations a social platform carries, so the web version and any client that speaks to it enforce the same rules. Moderation core (services/moderation/, database/moderation.py): a reportable target registry, the content filter and its choke points, the report queue with atomic resolution, enforcement actions, consent tracking, maturity gating, and account deletion with a grace window. Surfaces: POST /reports plus the member report list, /admin/moderation and the per-report admin view, /workspaces, terms acceptance at /auth/terms, consent and account deletion under /profile, the report button and dialog partials, the maturity gate, and the moderation stylesheet and ReportDialog client. Every user-generated surface stays reportable by construction: new content tables are registered in REPORTABLE_TARGETS or listed in UNREPORTABLE_TABLES with a reason, and the registry test fails the suite on anything left unclassified. Docs: community guidelines, content moderation, intellectual property, privacy, terms, contact, and the admin-only moderation operations page, plus the moderation API group and the Devii moderation actions. Compliance record: applecomp.md is the requirement register, applechanges.md the gap analysis against this codebase, and appleimpl.md the implementation design they resolve to. Tests cover the report flow, admin moderation, consent, account deletion, terms acceptance, workspaces, and the registry invariant across the unit, api, and e2e tiers.
This commit is contained in:
@@ -38,6 +38,7 @@ def _seed_owner():
|
||||
{
|
||||
"uid": uid,
|
||||
"username": f"seo_{uid[:8]}",
|
||||
"terms_version": "1",
|
||||
"email": f"{uid[:8]}@seo.test",
|
||||
"password_hash": "x",
|
||||
"role": "Member",
|
||||
@@ -278,6 +279,8 @@ def test_profile_json_exposes_online_presence(app_server):
|
||||
"email": f"{name}@t.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
"birth_date": "1990-01-01",
|
||||
"accept_terms": "1",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
@@ -326,6 +329,8 @@ def test_profile_hero_avatar_has_presence_dot(app_server):
|
||||
"email": f"{name}@t.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
"birth_date": "1990-01-01",
|
||||
"accept_terms": "1",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
@@ -354,6 +359,8 @@ def test_followers_list_avatar_has_presence_dot(app_server):
|
||||
"email": f"{name}@t.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
"birth_date": "1990-01-01",
|
||||
"accept_terms": "1",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
@@ -381,6 +388,8 @@ def test_viewing_profile_marks_notification_read(app_server):
|
||||
"email": f"{name}@t.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
"birth_date": "1990-01-01",
|
||||
"accept_terms": "1",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
@@ -511,6 +520,8 @@ def _signup_badge_user():
|
||||
"email": f"{name}@t.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
"birth_date": "1990-01-01",
|
||||
"accept_terms": "1",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
@@ -571,4 +582,116 @@ def test_profile_badge_description_exact_string(app_server):
|
||||
)
|
||||
|
||||
|
||||
PRIVACY_FIELDS = (
|
||||
"age_band",
|
||||
"terms_version",
|
||||
"terms_accepted_at",
|
||||
"suspended_until",
|
||||
"suspension_reason",
|
||||
)
|
||||
|
||||
|
||||
def _privacy_member(prefix="priv"):
|
||||
import time
|
||||
|
||||
name = f"{prefix}{int(time.time() * 1000000)}"
|
||||
session = requests.Session()
|
||||
session.post(
|
||||
f"{BASE_URL}/auth/signup",
|
||||
data={
|
||||
"username": name,
|
||||
"email": f"{name}@t.dev",
|
||||
"password": "secret123",
|
||||
"confirm_password": "secret123",
|
||||
"birth_date": "1990-01-01",
|
||||
"accept_terms": "1",
|
||||
},
|
||||
allow_redirects=True,
|
||||
)
|
||||
return session, name
|
||||
|
||||
|
||||
def _admin_session():
|
||||
session = requests.Session()
|
||||
session.post(
|
||||
f"{BASE_URL}/auth/login",
|
||||
data={"email": "alice@test.devplace", "password": "secret123"},
|
||||
allow_redirects=True,
|
||||
)
|
||||
return session
|
||||
|
||||
|
||||
def test_the_owner_reads_their_own_privacy_state(app_server):
|
||||
session, name = _privacy_member()
|
||||
body = session.get(
|
||||
f"{BASE_URL}/profile/{name}?tab=privacy",
|
||||
headers={"Accept": "application/json"},
|
||||
).json()
|
||||
assert body["age_band"] == "adult"
|
||||
assert body["terms_version"]
|
||||
assert body["terms_accepted_at"]
|
||||
assert body["consents"]
|
||||
|
||||
|
||||
def test_privacy_state_is_withheld_from_a_stranger(app_server):
|
||||
_, name = _privacy_member()
|
||||
stranger, _ = _privacy_member("prvs")
|
||||
body = stranger.get(
|
||||
f"{BASE_URL}/profile/{name}?tab=privacy",
|
||||
headers={"Accept": "application/json"},
|
||||
).json()
|
||||
for field in PRIVACY_FIELDS:
|
||||
assert body[field] in ("", None), f"{field} leaked to a stranger: {body[field]!r}"
|
||||
assert body["mature_opt_in"] is False
|
||||
assert body["consents"] == []
|
||||
|
||||
|
||||
def test_privacy_state_is_withheld_from_a_guest(app_server):
|
||||
_, name = _privacy_member()
|
||||
body = requests.get(
|
||||
f"{BASE_URL}/profile/{name}?tab=privacy",
|
||||
headers={"Accept": "application/json"},
|
||||
).json()
|
||||
for field in PRIVACY_FIELDS:
|
||||
assert body[field] in ("", None), f"{field} leaked to a guest: {body[field]!r}"
|
||||
assert body["consents"] == []
|
||||
|
||||
|
||||
def test_a_strangers_profile_html_never_renders_the_privacy_panel(app_server):
|
||||
_, name = _privacy_member()
|
||||
stranger, _ = _privacy_member("prvh")
|
||||
html = stranger.get(f"{BASE_URL}/profile/{name}?tab=privacy").text
|
||||
assert "privacy-panel" not in html
|
||||
assert f"/profile/{name}/consent" not in html
|
||||
assert f"/profile/{name}/delete" not in html
|
||||
|
||||
|
||||
def test_an_admin_reads_the_state_but_gets_no_controls(app_server, seeded_db):
|
||||
_, name = _privacy_member()
|
||||
admin = _admin_session()
|
||||
body = admin.get(
|
||||
f"{BASE_URL}/profile/{name}?tab=privacy",
|
||||
headers={"Accept": "application/json"},
|
||||
).json()
|
||||
assert body["age_band"] == "adult"
|
||||
assert body["consents"]
|
||||
|
||||
html = admin.get(f"{BASE_URL}/profile/{name}?tab=privacy").text
|
||||
assert "privacy-panel" in html
|
||||
assert "Only the account holder can change this." in html
|
||||
assert "Only the account holder can change this preference." in html
|
||||
assert f'action="/profile/{name}/consent"' not in html
|
||||
assert f'action="/profile/{name}/mature-content"' not in html
|
||||
assert f"/profile/{name}/delete" not in html
|
||||
|
||||
|
||||
def test_the_owner_gets_the_privacy_controls(app_server):
|
||||
session, name = _privacy_member()
|
||||
html = session.get(f"{BASE_URL}/profile/{name}?tab=privacy").text
|
||||
assert f'action="/profile/{name}/consent"' in html
|
||||
assert f'action="/profile/{name}/mature-content"' in html
|
||||
assert f"/profile/{name}/delete" in html
|
||||
assert "Only the account holder can change this." not in html
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user