2026-06-13 16:32:33 +02:00
|
|
|
# retoor <retoor@molodetz.nl>
|
|
|
|
|
|
|
|
|
|
import time
|
|
|
|
|
import pytest
|
|
|
|
|
import requests
|
|
|
|
|
from tests.conftest import BASE_URL
|
|
|
|
|
from devplacepy.database import get_table
|
|
|
|
|
from devplacepy.utils import clear_user_cache
|
|
|
|
|
from devplacepy import project_files
|
|
|
|
|
from devplacepy.project_files import ProjectFileError
|
|
|
|
|
from devplacepy.services.devii.actions.dispatcher import (
|
|
|
|
|
confirmation_error,
|
|
|
|
|
_is_confirmed,
|
|
|
|
|
)
|
|
|
|
|
_counter_project_visibility = [0]
|
|
|
|
|
def _signup_project_visibility():
|
|
|
|
|
_counter_project_visibility[0] += 1
|
|
|
|
|
name = f"pv{int(time.time() * 1000)}{_counter_project_visibility[0]}"
|
|
|
|
|
session = requests.Session()
|
|
|
|
|
session.post(
|
|
|
|
|
f"{BASE_URL}/auth/signup",
|
|
|
|
|
data={
|
|
|
|
|
"username": name,
|
|
|
|
|
"email": f"{name}@t.dev",
|
|
|
|
|
"password": "secret123",
|
|
|
|
|
"confirm_password": "secret123",
|
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.
2026-08-09 00:18:20 +02:00
|
|
|
"birth_date": "1990-01-01",
|
|
|
|
|
"accept_terms": "1",
|
2026-06-13 16:32:33 +02:00
|
|
|
},
|
|
|
|
|
allow_redirects=True,
|
|
|
|
|
)
|
|
|
|
|
row = get_table("users").find_one(username=name)
|
|
|
|
|
return name, row["uid"], row["api_key"]
|
|
|
|
|
def _make_admin_project_visibility():
|
|
|
|
|
name, uid, key = _signup_project_visibility()
|
|
|
|
|
get_table("users").update({"uid": uid, "role": "Admin"}, ["uid"])
|
|
|
|
|
clear_user_cache(uid)
|
|
|
|
|
return name, uid, key
|
|
|
|
|
def _h_project_visibility(key=None):
|
|
|
|
|
headers = {"Accept": "application/json"}
|
|
|
|
|
if key:
|
|
|
|
|
headers["X-API-KEY"] = key
|
|
|
|
|
return headers
|
|
|
|
|
def _create_project_project_visibility(key, title, is_private=False):
|
|
|
|
|
data = {
|
|
|
|
|
"title": title,
|
|
|
|
|
"description": "visibility test",
|
|
|
|
|
"project_type": "software",
|
|
|
|
|
"status": "In Development",
|
|
|
|
|
}
|
|
|
|
|
if is_private:
|
|
|
|
|
data["is_private"] = "on"
|
|
|
|
|
r = requests.post(f"{BASE_URL}/projects/create", headers=_h_project_visibility(key), data=data)
|
|
|
|
|
assert r.status_code == 200, r.text
|
|
|
|
|
return r.json()["data"]
|
|
|
|
|
def _project_uid(slug):
|
|
|
|
|
return get_table("projects").find_one(slug=slug)["uid"]
|
|
|
|
|
def _write_project_visibility(key, slug, path, content):
|
|
|
|
|
return requests.post(
|
|
|
|
|
f"{BASE_URL}/projects/{slug}/files/write",
|
|
|
|
|
headers=_h_project_visibility(key),
|
|
|
|
|
data={"path": path, "content": content},
|
|
|
|
|
allow_redirects=False,
|
|
|
|
|
)
|
|
|
|
|
def _set_private(key, slug, value):
|
|
|
|
|
return requests.post(
|
|
|
|
|
f"{BASE_URL}/projects/{slug}/private",
|
|
|
|
|
headers=_h_project_visibility(key),
|
|
|
|
|
data={"value": 1 if value else 0},
|
|
|
|
|
allow_redirects=False,
|
|
|
|
|
)
|
|
|
|
|
def _set_readonly(key, slug, value):
|
|
|
|
|
return requests.post(
|
|
|
|
|
f"{BASE_URL}/projects/{slug}/readonly",
|
|
|
|
|
headers=_h_project_visibility(key),
|
|
|
|
|
data={"value": 1 if value else 0},
|
|
|
|
|
allow_redirects=False,
|
|
|
|
|
)
|
|
|
|
|
def _list_slugs(key=None, user_uid=None):
|
|
|
|
|
params = {"user_uid": user_uid} if user_uid else None
|
|
|
|
|
r = requests.get(f"{BASE_URL}/projects", headers=_h_project_visibility(key), params=params)
|
|
|
|
|
return [p["slug"] for p in r.json()["projects"]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_owner_can_edit_project(app_server):
|
|
|
|
|
_, _, key = _signup_project_visibility()
|
|
|
|
|
slug = _create_project_project_visibility(key, "Editable Via Api")["slug"]
|
|
|
|
|
r = requests.post(
|
|
|
|
|
f"{BASE_URL}/projects/edit/{slug}",
|
|
|
|
|
headers=_h_project_visibility(key),
|
|
|
|
|
data={
|
|
|
|
|
"title": "Edited Via Api",
|
|
|
|
|
"description": "updated description body",
|
|
|
|
|
"project_type": "website",
|
|
|
|
|
"status": "Released",
|
|
|
|
|
"platforms": "Linux,Web",
|
|
|
|
|
},
|
|
|
|
|
allow_redirects=False,
|
|
|
|
|
)
|
|
|
|
|
assert r.status_code == 200 and r.json()["ok"] is True
|
|
|
|
|
row = get_table("projects").find_one(slug=slug)
|
|
|
|
|
assert row["title"] == "Edited Via Api"
|
|
|
|
|
assert row["status"] == "Released"
|
|
|
|
|
assert row["project_type"] == "website"
|
|
|
|
|
assert row["platforms"] == "Linux,Web"
|
|
|
|
|
|
|
|
|
|
|
Dedicate the project page to the project: hero, tabs, screenshots, sidebar
The project detail page becomes a full project showcase on the site's
content measure. The hero card opens with a cover banner from the
project's first image attachment (brand-gradient band as fallback),
then title + status chip, type/platform chips, dates and forked-from
meta, the author row with an owner-set Visit Website CTA, and the
unchanged action row. A sticky anchor tab bar (Overview, Devlog,
Screenshots when images exist, Comments, Files) navigates the page
with plain server-rendered anchors so crawlers index one complete
document. The two-column body keeps About (description + non-image
attachments), the Devlog timeline and the comment thread in the main
column, adds a Screenshots gallery built from image attachments
(lightbox-wired thumbnails), and a sidebar with Links (website, files,
fork source), the Stats card with a last-update line, and the Author
card.
New optional projects.website_url rides the whole stack: normalized
and validated in models (scheme-less input gets https://, non-http(s)
rejected), settable in the create and edit modals, on ProjectOut, in
the Devii create/edit actions and the API docs, rendered as the hero
CTA and Links entry with rel noopener nofollow, and emitted as
schema.org sameAs. The app schema also gains screenshot urls from the
image attachments. The e2e project comment/files tests scope their
locators (.comment-form textarea, .project-detail-actions a) per the
documented dual-control idiom - the composer modal made the bare
selectors ambiguous - and new unit/api tests cover URL normalization,
sameAs/screenshot schema output, the cover, and the gallery.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-09 21:56:50 +02:00
|
|
|
def test_owner_can_set_and_clear_website_url(app_server):
|
|
|
|
|
_, _, key = _signup_project_visibility()
|
|
|
|
|
slug = _create_project_project_visibility(key, "Website Via Api")["slug"]
|
|
|
|
|
r = requests.post(
|
|
|
|
|
f"{BASE_URL}/projects/edit/{slug}",
|
|
|
|
|
headers=_h_project_visibility(key),
|
|
|
|
|
data={
|
|
|
|
|
"title": "Website Via Api",
|
|
|
|
|
"description": "has a website now",
|
|
|
|
|
"website_url": "myproject.dev/docs",
|
Align the project hero with the showcase design: owner cover, logo, repo link
The hero now matches the showcase reference: the title block, tagline
(first description line), type/platform chips, author row and started
date render OVERLAID on the cover banner behind a bottom scrim, with
the optional project logo as a framed tile beside them and the Visit
Website CTA on the right. The section tab bar switches to the underline
style with Overview active.
Owners control the missing pieces from the create and edit modals,
which are now multipart: cover_image and logo_image file uploads
(stored as bare uploaded filenames via save_inline_image, the
posts.image pattern; a new upload replaces the previous one) plus a
repo_url sibling of website_url (same normalization/validation). The
cover feeds og:image and the schema image, the logo becomes schema
thumbnailUrl, and sameAs now carries website + repository. repo_url
rides ProjectOut, the Devii create/edit actions and the API docs;
tests cover repo normalization, the multipart upload round-trip and
the hero render.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-09 22:12:25 +02:00
|
|
|
"repo_url": "github.com/me/website-via-api",
|
Dedicate the project page to the project: hero, tabs, screenshots, sidebar
The project detail page becomes a full project showcase on the site's
content measure. The hero card opens with a cover banner from the
project's first image attachment (brand-gradient band as fallback),
then title + status chip, type/platform chips, dates and forked-from
meta, the author row with an owner-set Visit Website CTA, and the
unchanged action row. A sticky anchor tab bar (Overview, Devlog,
Screenshots when images exist, Comments, Files) navigates the page
with plain server-rendered anchors so crawlers index one complete
document. The two-column body keeps About (description + non-image
attachments), the Devlog timeline and the comment thread in the main
column, adds a Screenshots gallery built from image attachments
(lightbox-wired thumbnails), and a sidebar with Links (website, files,
fork source), the Stats card with a last-update line, and the Author
card.
New optional projects.website_url rides the whole stack: normalized
and validated in models (scheme-less input gets https://, non-http(s)
rejected), settable in the create and edit modals, on ProjectOut, in
the Devii create/edit actions and the API docs, rendered as the hero
CTA and Links entry with rel noopener nofollow, and emitted as
schema.org sameAs. The app schema also gains screenshot urls from the
image attachments. The e2e project comment/files tests scope their
locators (.comment-form textarea, .project-detail-actions a) per the
documented dual-control idiom - the composer modal made the bare
selectors ambiguous - and new unit/api tests cover URL normalization,
sameAs/screenshot schema output, the cover, and the gallery.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-09 21:56:50 +02:00
|
|
|
},
|
|
|
|
|
allow_redirects=False,
|
|
|
|
|
)
|
|
|
|
|
assert r.status_code == 200 and r.json()["ok"] is True
|
|
|
|
|
row = get_table("projects").find_one(slug=slug)
|
|
|
|
|
assert row["website_url"] == "https://myproject.dev/docs"
|
Align the project hero with the showcase design: owner cover, logo, repo link
The hero now matches the showcase reference: the title block, tagline
(first description line), type/platform chips, author row and started
date render OVERLAID on the cover banner behind a bottom scrim, with
the optional project logo as a framed tile beside them and the Visit
Website CTA on the right. The section tab bar switches to the underline
style with Overview active.
Owners control the missing pieces from the create and edit modals,
which are now multipart: cover_image and logo_image file uploads
(stored as bare uploaded filenames via save_inline_image, the
posts.image pattern; a new upload replaces the previous one) plus a
repo_url sibling of website_url (same normalization/validation). The
cover feeds og:image and the schema image, the logo becomes schema
thumbnailUrl, and sameAs now carries website + repository. repo_url
rides ProjectOut, the Devii create/edit actions and the API docs;
tests cover repo normalization, the multipart upload round-trip and
the hero render.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-09 22:12:25 +02:00
|
|
|
assert row["repo_url"] == "https://github.com/me/website-via-api"
|
Dedicate the project page to the project: hero, tabs, screenshots, sidebar
The project detail page becomes a full project showcase on the site's
content measure. The hero card opens with a cover banner from the
project's first image attachment (brand-gradient band as fallback),
then title + status chip, type/platform chips, dates and forked-from
meta, the author row with an owner-set Visit Website CTA, and the
unchanged action row. A sticky anchor tab bar (Overview, Devlog,
Screenshots when images exist, Comments, Files) navigates the page
with plain server-rendered anchors so crawlers index one complete
document. The two-column body keeps About (description + non-image
attachments), the Devlog timeline and the comment thread in the main
column, adds a Screenshots gallery built from image attachments
(lightbox-wired thumbnails), and a sidebar with Links (website, files,
fork source), the Stats card with a last-update line, and the Author
card.
New optional projects.website_url rides the whole stack: normalized
and validated in models (scheme-less input gets https://, non-http(s)
rejected), settable in the create and edit modals, on ProjectOut, in
the Devii create/edit actions and the API docs, rendered as the hero
CTA and Links entry with rel noopener nofollow, and emitted as
schema.org sameAs. The app schema also gains screenshot urls from the
image attachments. The e2e project comment/files tests scope their
locators (.comment-form textarea, .project-detail-actions a) per the
documented dual-control idiom - the composer modal made the bare
selectors ambiguous - and new unit/api tests cover URL normalization,
sameAs/screenshot schema output, the cover, and the gallery.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-09 21:56:50 +02:00
|
|
|
|
|
|
|
|
html = requests.get(f"{BASE_URL}/projects/{slug}").text
|
|
|
|
|
assert "Visit Website" in html
|
|
|
|
|
assert '"sameAs"' in html
|
|
|
|
|
|
|
|
|
|
r = requests.post(
|
|
|
|
|
f"{BASE_URL}/projects/edit/{slug}",
|
|
|
|
|
headers=_h_project_visibility(key),
|
|
|
|
|
data={
|
|
|
|
|
"title": "Website Via Api",
|
|
|
|
|
"description": "website removed",
|
|
|
|
|
"website_url": "",
|
|
|
|
|
},
|
|
|
|
|
allow_redirects=False,
|
|
|
|
|
)
|
|
|
|
|
assert r.status_code == 200
|
|
|
|
|
assert get_table("projects").find_one(slug=slug)["website_url"] is None
|
|
|
|
|
assert "Visit Website" not in requests.get(f"{BASE_URL}/projects/{slug}").text
|
|
|
|
|
|
|
|
|
|
|
2026-06-13 16:32:33 +02:00
|
|
|
def test_non_owner_cannot_edit_project(app_server):
|
|
|
|
|
_, _, owner_key = _signup_project_visibility()
|
|
|
|
|
slug = _create_project_project_visibility(owner_key, "Owner Edit Guard")["slug"]
|
|
|
|
|
_, _, other_key = _signup_project_visibility()
|
|
|
|
|
r = requests.post(
|
|
|
|
|
f"{BASE_URL}/projects/edit/{slug}",
|
|
|
|
|
headers=_h_project_visibility(other_key),
|
|
|
|
|
data={"title": "Hijacked", "description": "should not persist"},
|
|
|
|
|
allow_redirects=False,
|
|
|
|
|
)
|
|
|
|
|
assert r.status_code == 403
|
|
|
|
|
assert get_table("projects").find_one(slug=slug)["title"] == "Owner Edit Guard"
|