| @@ -1,6 +1,8 @@ |
| 1 | | −// The routes, run with mock handlers: no server, no store actor, no asset |
| 2 | | −// disk reads. Run with `louise test --native` (argon2 is a native |
| 3 | | −// dependency); the pure filesystem fake tests also run in the interpreter. |
| 1 | +// The routes, run with mock handlers: no server or store actor. Fake cases |
| 2 | +// need no asset disk reads; `run_on_disk` is the separate real-file control. |
| 3 | +// Run the full suite with `louise test --native` because Argon2 is native. |
| 4 | +// The pure fs operation+route fixture has no Argon2 call and selects with |
| 5 | +// `--filter fake_files_cover_operations_and_static_routes_without_leaking_writes`. |
| 4 | 6 | |
| 5 | 7 | import app. |
| 6 | 8 | { type User |
| @@ -369,7 +371,7 @@ fn a_missing_static_file_and_a_traversal_are_404s :: -> () / <ffi> |
| 369 | 371 | /// Pure fake coverage: this test needs no argon2 call or real filesystem, |
| 370 | 372 | /// so the interpreter can run it as well as the native demo suite. |
| 371 | 373 | @test |
| 372 | | −fn fake_files_cover_every_operation_and_writes_stay_lexical :: |
| 374 | +fn fake_files_cover_operations_and_static_routes_without_leaking_writes :: |
| 373 | 375 | { |
| 374 | 376 | with_fake_files [("./static/a.txt", bytes.from_string "a")] fn |
| 375 | 377 | { |
| @@ -397,6 +399,47 @@ fn fake_files_cover_every_operation_and_writes_stay_lexical :: |
| 397 | 399 | assert_equal (file.exists "./static/new.txt") False |
| 398 | 400 | assert_equal (file.exists "/definitely/not/read") False |
| 399 | 401 | } |
| 402 | + |
| 403 | + // The full demo is native because authentication calls Argon2 through C. |
| 404 | + // This static-route transcript deliberately has no seed-user hashing, |
| 405 | + // RNG, native FFI call, real file access, or host environment lookup. |
| 406 | + let (rs, logs) = |
| 407 | + with_mock_log |
| 408 | + fn |
| 409 | + { |
| 410 | + with_mock_users [] |
| 411 | + fn |
| 412 | + { |
| 413 | + with_fake_files (fake_assets ()) |
| 414 | + fn |
| 415 | + { |
| 416 | + list.map |
| 417 | + [ get "/static/style.css" "" |
| 418 | + , get "/static/robots.txt" "" |
| 419 | + , get "/static/nope.txt" "" |
| 420 | + , get "/static/../louise.toml" "" |
| 421 | + ] |
| 422 | + app.route |
| 423 | + } |
| 424 | + } |
| 425 | + } |
| 426 | + let style = at rs 0 |
| 427 | + let robots = at rs 1 |
| 428 | + assert_equal style.status 200 |
| 429 | + assert_equal (header style "Content-Type") "text/css; charset=utf-8" |
| 430 | + assert (string.contains (text style) "fake-stylesheet") "the fake stylesheet" |
| 431 | + assert_equal robots.status 200 |
| 432 | + assert_equal (header robots "Content-Type") "text/plain; charset=utf-8" |
| 433 | + assert (string.contains (text robots) "fake-robots") "the fake robots file" |
| 434 | + assert_equal ((at rs 2).status) 404 |
| 435 | + assert_equal ((at rs 3).status) 404 |
| 436 | + assert_equal |
| 437 | + logs |
| 438 | + [ "GET /static/style.css" |
| 439 | + , "GET /static/robots.txt" |
| 440 | + , "GET /static/nope.txt" |
| 441 | + , "GET /static/../louise.toml" |
| 442 | + ] |
| 400 | 443 | } |
| 401 | 444 | |
| 402 | 445 | @test |