max / makenotwork
- Co-Authored-By
- Claude Opus 5 (1M context) <noreply@anthropic.com>
1 file changed,
+11 insertions,
-105 deletions
| @@ -15,7 +15,6 @@ | |||
| 15 | 15 | //! - Response shape: `stream_url` + `expires_in` fields | |
| 16 | 16 | //! - `play_count` increments on stream | |
| 17 | 17 | //! - `unique_play` tracking for authenticated viewers | |
| 18 | - | //! - Version download surfaces `license_url` when item has a license preset | |
| 19 | 18 | ||
| 20 | 19 | use crate::harness::TestHarness; | |
| 21 | 20 | use serde_json::Value; | |
| @@ -323,110 +322,17 @@ | |||
| 323 | 322 | ); | |
| 324 | 323 | } | |
| 325 | 324 | ||
| 326 | - | #[tokio::test] | |
| 327 | - | async fn version_download_includes_license_url_when_preset_set() { | |
| 328 | - | let mut h = TestHarness::with_storage().await; | |
| 329 | - | let setup = h | |
| 330 | - | .create_creator_with_item("licdownloader", "digital", 0) | |
| 331 | - | .await; | |
| 332 | - | sqlx::query( | |
| 333 | - | "UPDATE items SET is_public = true, scan_status = 'clean', \ | |
| 334 | - | license_preset = 'mit' WHERE id = $1::uuid", | |
| 335 | - | ) | |
| 336 | - | .bind(&setup.item_id) | |
| 337 | - | .execute(&h.db) | |
| 338 | - | .await | |
| 339 | - | .unwrap(); | |
| 340 | - | sqlx::query("UPDATE projects SET is_public = true WHERE id = $1::uuid") | |
| 341 | - | .bind(&setup.project_id) | |
| 342 | - | .execute(&h.db) | |
| 343 | - | .await | |
| 344 | - | .unwrap(); | |
| 345 | - | ||
| 346 | - | // Create a version with a fake s3_key. | |
| 347 | - | let s3_key = format!("test/{}/download/build.zip", setup.item_id); | |
| 348 | - | h.storage | |
| 349 | - | .as_ref() | |
| 350 | - | .unwrap() | |
| 351 | - | .put(&s3_key, b"zip data".to_vec()); | |
| 352 | - | let version_id: String = sqlx::query_scalar( | |
| 353 | - | "INSERT INTO versions (item_id, version_number, s3_key, file_size_bytes, file_name, \ | |
| 354 | - | is_current, scan_status) \ | |
| 355 | - | VALUES ($1::uuid, '1.0', $2, 100, 'build.zip', true, 'clean') RETURNING id::text", | |
| 356 | - | ) | |
| 357 | - | .bind(&setup.item_id) | |
| 358 | - | .bind(&s3_key) | |
| 359 | - | .fetch_one(&h.db) | |
| 360 | - | .await | |
| 361 | - | .unwrap(); | |
| 362 | - | ||
| 363 | - | let resp = h | |
| 364 | - | .client | |
| 365 | - | .get(&format!("/api/versions/{version_id}/download")) | |
| 366 | - | .await; | |
| 367 | - | assert_eq!(resp.status, 200, "{} {}", resp.status, resp.text); | |
| 368 | - | let data: Value = resp.json(); | |
| 369 | - | assert!( | |
| 370 | - | data["license_url"].is_string(), | |
| 371 | - | "license_url should be present when item.license_preset is set" | |
| 372 | - | ); | |
| 373 | - | let license_url = data["license_url"].as_str().unwrap(); | |
| 374 | - | assert!( | |
| 375 | - | license_url.contains(&setup.item_id), | |
| 376 | - | "license_url should point at the item: {license_url}" | |
| 377 | - | ); | |
| 378 | - | assert!( | |
| 379 | - | license_url.ends_with("/license.txt"), | |
| 380 | - | "license_url should target the .txt endpoint: {license_url}" | |
| 381 | - | ); | |
| 382 | - | } | |
| 383 | - | ||
| 384 | - | #[tokio::test] | |
| 385 | - | async fn version_download_omits_license_url_without_preset() { | |
| 386 | - | let mut h = TestHarness::with_storage().await; | |
| 387 | - | let setup = h.create_creator_with_item("nolicdl", "digital", 0).await; | |
| 388 | - | sqlx::query( | |
| 389 | - | "UPDATE items SET is_public = true, scan_status = 'clean', \ | |
| 390 | - | license_preset = NULL WHERE id = $1::uuid", | |
| 391 | - | ) | |
| 392 | - | .bind(&setup.item_id) | |
| 393 | - | .execute(&h.db) | |
| 394 | - | .await | |
| 395 | - | .unwrap(); | |
| 396 | - | sqlx::query("UPDATE projects SET is_public = true WHERE id = $1::uuid") | |
| 397 | - | .bind(&setup.project_id) | |
| 398 | - | .execute(&h.db) | |
| 399 | - | .await | |
| 400 | - | .unwrap(); | |
| 401 | - | ||
| 402 | - | let s3_key = format!("test/{}/download/build.zip", setup.item_id); | |
| 403 | - | h.storage | |
| 404 | - | .as_ref() | |
| 405 | - | .unwrap() | |
| 406 | - | .put(&s3_key, b"zip data".to_vec()); | |
| 407 | - | let version_id: String = sqlx::query_scalar( | |
| 408 | - | "INSERT INTO versions (item_id, version_number, s3_key, file_size_bytes, file_name, \ | |
| 409 | - | is_current, scan_status) \ | |
| 410 | - | VALUES ($1::uuid, '1.0', $2, 100, 'build.zip', true, 'clean') RETURNING id::text", | |
| 411 | - | ) | |
| 412 | - | .bind(&setup.item_id) | |
| 413 | - | .bind(&s3_key) | |
| 414 | - | .fetch_one(&h.db) | |
| 415 | - | .await | |
| 416 | - | .unwrap(); | |
| 417 | - | ||
| 418 | - | let resp = h | |
| 419 | - | .client | |
| 420 | - | .get(&format!("/api/versions/{version_id}/download")) | |
| 421 | - | .await; | |
| 422 | - | assert_eq!(resp.status, 200, "{}", resp.text); | |
| 423 | - | let data: Value = resp.json(); | |
| 424 | - | assert!( | |
| 425 | - | data["license_url"].is_null(), | |
| 426 | - | "license_url should be absent when no preset is set, got: {:?}", | |
| 427 | - | data["license_url"] | |
| 428 | - | ); | |
| 429 | - | } | |
| 325 | + | // `version_download_includes_license_url_when_preset_set` and | |
| 326 | + | // `version_download_omits_license_url_without_preset` were here until | |
| 327 | + | // 2026-08-26. `GET /api/versions/{id}/download` answered JSON carrying a | |
| 328 | + | // `license_url`; it now answers 303 to the presigned URL (`8fc6b1af`, option | |
| 329 | + | // (a)), so a redirect has nowhere to put that field and these two assert a | |
| 330 | + | // shape that no longer exists. | |
| 331 | + | // | |
| 332 | + | // The licence itself is not lost and was never reached through this field: | |
| 333 | + | // `/api/items/{id}/license.txt` is linked directly from `pages/item.html` and | |
| 334 | + | // `pages/library_downloads.html`, fetched by `static/page-item-1.js`, and | |
| 335 | + | // published as a v1 OpenAPI path. Nothing consumed the copy in this response. | |
| 430 | 336 | ||
| 431 | 337 | #[tokio::test] | |
| 432 | 338 | async fn stream_url_404_for_nonexistent_item() { |