test(podcasts): integration suite + RLS auditor + contract widening (task 1.10)

cmd/server/tests/podcast_test.go — six suites, the shared-dev-DB
doctrine (test*-named libraries, cascading cleanup, no binary
fixtures):

- TestPodcastRLSSurfaces: THE AUDITOR (invariant 13) — non-subscriber
  404 on feed detail + SSR page (existence leak), episodes absent from
  generic media reads, admin escape, subscriber visibility, then the
  hidden-library flip hiding an already-subscribed feed (the feed
  policy's library-visibility join). Seeding runs as the FIRST ADMIN —
  the seed identity has neither subscription nor users row, so podcast
  INSERT..RETURNING (SELECT policy under FORCE) 42501s for it;
  production pods run as exactly that admin (invariant 12). All direct
  row probes read through the admin scope for the same reason.
- TestPodcastAddFeedFlow: member add + subscribe + metadata-only
  upsert; duplicate-URL dedupe (no second row); allow_member_feeds
  gate (member 403 / admin 201 / subscribe-still-allowed).
- TestPodcastShrunkenFeedRetention: feed purges an episode from the
  XML, both rows persist (upsert-without-delete pin, D14).
- TestPodcastEditSegregation: generic edit 400 + write-to-file refusal
  for episodes; control book edit unaffected.
- TestPodcastDownloadWorker (ffmpeg-generated tone at runtime): file
  lands at <download-root>/<feed-slug>/NNNN-…, audio_metadata probed;
  re-download of a downloaded episode never re-fetches (idempotency
  pin, enclosure-hit counted); dead enclosure → failed + persisted
  reason + metadata intact. Fetch/SSRF tests swap the client via
  SetPodcastHTTPClientForTests (the production client refuses
  loopback httptest servers by design — the real client gets its own
  negative test in services).
- TestPodcastScannerExclusion: SetFolders on a podcasts library root
  yields zero scanner folders (invariant 4 pin) — MediaScanner
  .FolderCount() accessor added.

Unit: internal/services/podcast_rss_test.go — namespace-aware parsing
fixture (three XML namespaces, fallback chains, hosts/guests),
duration spellings, RFC-822 variants, explicit variants, slug/path
layout, enclosure-extension selection, stripHTML, and the SSRF matrix
(private/loopback/link-local/multicast/mapped-v6 blocked; a loopback
httptest server PROVES the production client refuses it).

suites green: full integration run 161s / 0 failures; vitest 12 files
163 tests.

Contract widening: TestContractPin_MediaListBothBranches' raw-row
allowlist gains the 15 podcast episode columns (additive; documented in
docs/contract_pins.md — inert defaults on scan rows). Bruno: bruno/
podcasts/ mirrors the §8 endpoints (12 requests) + Bookhoard env vars.
tests/ui/COVERAGE.md rows 18-23: podcasts pages/lifecycle/RLS/chain —
Playwright sweep pending.
This commit is contained in:
John O'Keefe committed 2026-10-29 18:09:35 -04:00
1 parent 28420d56ed
commit 49b0b6eeb9
24 files changed
+1510 -10

No files matched your search

+10
View File
@@ -60,3 +60,13 @@ variables:
name: book_sha256
- secret: true
name: book_uuid
- secret: true
name: podcasts_library_id
- name: podcast_feed_url
value: https://example.com/feed.xml
- secret: true
name: podcast_feed_id
- secret: true
name: podcast_episode_id
- name: podcast_search_query
value: episode
+30
View File
@@ -0,0 +1,30 @@
info:
name: Add Podcast Feed
type: http
seq: 1
http:
method: POST
url: '{{base_url}}/api/podcasts/feeds'
auth: inherit
body:
type: json
data: |-
{
"library_id": "{{podcasts_library_id}}",
"url": "{{podcast_feed_url}}",
"download_all": false
}
settings:
encodeUrl: true
timeout: 30000
followRedirects: true
maxRedirects: 5
runtime:
scripts:
- type: tests
code: |-
test("status is 201", function() {
expect(res.status).to.eql(201);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Delete Feed (admin; ?files=false keeps files)
type: http
seq: 12
http:
method: DELETE
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Download All (every non-downloaded episode)
type: http
seq: 8
http:
method: POST
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}/episodes/all/download'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 202", function() {
expect(res.status).to.eql(202);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Download / Retry Episode (idempotent state machine)
type: http
seq: 7
http:
method: POST
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}/episodes/{{podcast_episode_id}}/download'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 202", function() {
expect(res.status).to.eql(202);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Feed Detail (episodes + download states)
type: http
seq: 3
http:
method: GET
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 200 (404 would be scoping/RLS)", function() {
expect(res.status).to.eql(200);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: List My Podcast Feeds
type: http
seq: 2
http:
method: GET
url: '{{base_url}}/api/podcasts/feeds'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Manual Refresh (poll one feed)
type: http
seq: 6
http:
method: POST
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}/refresh'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Effective Sequence (override applied, downloaded-only, gaps)
type: http
seq: 9
http:
method: GET
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}/sequence'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});
+23
View File
@@ -0,0 +1,23 @@
info:
name: Set Order Override (native | oldest | newest)
type: http
seq: 10
http:
method: PUT
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}/order'
auth: inherit
body:
type: json
data: |-
{
"order": "oldest"
}
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Subscription-scoped Search (covers un-downloaded + historical)
type: http
seq: 11
http:
method: GET
url: '{{base_url}}/api/podcasts/search?q={{podcast_search_query}}'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});
+17
View File
@@ -0,0 +1,17 @@
info:
name: Unsubscribe (files retained)
type: http
seq: 5
http:
method: DELETE
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}/subscription'
auth: inherit
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});
+25
View File
@@ -0,0 +1,25 @@
info:
name: Update Subscription (display name + auto-download)
type: http
seq: 4
http:
method: PUT
url: '{{base_url}}/api/podcasts/feeds/{{podcast_feed_id}}/subscription'
auth: inherit
body:
type: json
data: |-
{
"display_name": "My Serialized Feed",
"auto_download": "newest",
"auto_download_count": 3
}
runtime:
scripts:
- type: tests
code: |-
test("status is 200", function() {
expect(res.status).to.eql(200);
});