summaryrefslogtreecommitdiffstats
path: root/tests/http.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:09:59 +0000
commite757979f1a2afdbe7146066345bb9acd19d3b151 (patch)
tree30d5f5fbccd25ea7bf01c5202684af463b74e7d3 /tests/http.rs
parent94c318f13264bb3c00a9f3057ba2e1aafb57c9e4 (diff)
downloadaur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.tar.gz
aur-build-e757979f1a2afdbe7146066345bb9acd19d3b151.zip
comments: say why, not what
Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath.
Diffstat (limited to 'tests/http.rs')
-rw-r--r--tests/http.rs39
1 files changed, 12 insertions, 27 deletions
diff --git a/tests/http.rs b/tests/http.rs
index 0ca8a6b..068f999 100644
--- a/tests/http.rs
+++ b/tests/http.rs
@@ -1,11 +1,3 @@
-//! The web surface (§12, §13): routes render, the CSRF gate holds, and a stale
-//! approval comes back as a 409 with the current diff instead of a silent
-//! retarget.
-//!
-//! These drive a real `tiny_http` server on an ephemeral loopback port over a
-//! real fixture corpus — no mocked transport, because the transport is part of
-//! what we are claiming works.
-
mod common;
use aur_build::review::{candidates, diff};
@@ -37,8 +29,7 @@ fn every_surface_renders() {
#[test]
fn the_review_detail_shows_the_panels_and_the_hashes() {
let web = Web::new("plain-make");
- // Publish a first version so the review has something to diff against;
- // every panel compares the accepted release to the candidate (§6).
+ // Publish a first version so the review has something to diff against.
let first = web.open_review("plain-make");
let page = web.get(&format!("/reviews/{}", first.id));
let dd = extract(&page.body, "name=\"diff_digest\" value=\"", "\"").unwrap();
@@ -57,8 +48,7 @@ fn the_review_detail_shows_the_panels_and_the_hashes() {
assert!(page.body.contains(want), "missing panel {want}");
}
assert!(page.body.contains("previous accepted release"), "no base shown");
- // The approve form carries both hashes (§7.1a) and is a plain POST form,
- // so it works with JavaScript switched off.
+ // The approve form carries both hashes (§7.1a) and works with JavaScript off.
assert!(page.body.contains("name=\"identity_hash\""));
assert!(page.body.contains("name=\"diff_digest\""));
assert!(page.body.contains("<form method=\"post\""));
@@ -148,8 +138,8 @@ fn a_stale_approval_is_a_409_that_renders_the_current_diff() {
);
assert_eq!(res.status, 409, "a stale approval must come back as 409");
assert!(res.body.contains("refused"), "no explanation: {}", &res.body[..200.min(res.body.len())]);
- // Either way the reviewer is told the ground moved under them, and shown
- // the review as it is NOW rather than the one they asked to approve.
+ // Either way the reviewer is told the ground moved, and shown the review as it
+ // is NOW rather than the one they asked to approve.
assert!(
res.body.contains("while you were looking") || res.body.contains("no longer pending"),
"not a §7.1a explanation: {}",
@@ -191,8 +181,7 @@ fn bulk_approve_refuses_high_risk_without_individual_confirmation() {
assert!(res.body.contains("refused"), "bulk approve accepted a high-risk item: {}", &res.body[..300.min(res.body.len())]);
assert_eq!(web.env.query_i64("SELECT count(*) FROM approval", &[]), Some(0));
- // Confirming it individually lets it through — bulk is per-item, never
- // "approve everything forever" (§7.4).
+ // Confirming it individually lets it through — bulk is per-item (§7.4).
let res = web.post(
"/reviews/bulk",
&[("csrf", &web.csrf), ("decision", "approve"), ("ids", &id), ("confirm", &id)],
@@ -221,19 +210,16 @@ fn a_password_gate_redirects_anonymous_visitors() {
#[test]
fn a_forged_auth_cookie_is_not_a_session() {
- // What this pins: the gate used to read `Cookie: auth=1`, a value login
- // merely echoed, so any client that typed the cookie itself could read the
- // reviews, the audit log and the build output without ever supplying the
- // password. The session id is the credential now, and only this process
- // can mint one.
+ // What this pins: the gate used to read `Cookie: auth=1`, a value login merely
+ // echoed, so any client that typed the cookie could read the reviews without
+ // ever supplying the password. The session id is the credential now.
let web = Web::with_password("plain-make", "s3cret");
for path in ["/", "/reviews", "/audit", "/settings", "/builds", "/packages"] {
let res = web.raw_request("GET", path, &[("Cookie", "auth=1".into())], None);
assert_eq!(res.status, 303, "{path} let a forged cookie through ({}): {}", res.status, &res.body[..120.min(res.body.len())]);
assert_eq!(res.header("location"), Some("/login"), "{path} did not redirect to the login page");
}
- // A POST with the forged cookie is turned away at the gate too, before the
- // CSRF step ever gets a chance to mint the attacker a session of their own.
+ // A POST with the forged cookie is turned away at the gate too.
let res = web.raw_request("POST", "/logout", &[("Cookie", "auth=1".into())], Some(""));
assert_eq!(res.status, 303, "a forged cookie reached a mutating route");
// And the word "auth" is not a cookie the server recognises anywhere.
@@ -257,8 +243,7 @@ fn login_rotates_the_session_and_logout_ends_it() {
if !anon.is_empty() {
assert_eq!(web.raw_request("GET", "/reviews", &[("Cookie", anon)], None).status, 303, "the pre-login sid still worked");
}
- // Logout drops the sid server-side, which invalidates its CSRF token with
- // it, so the same cookie is an anonymous visitor again.
+ // Logout drops the sid server-side, which invalidates its CSRF token with it.
let out = web.raw_request("POST", "/logout", &[("Cookie", session.clone()), ("Content-Type", "application/x-www-form-urlencoded".into())], Some(&format!("csrf={}", web.csrf)));
assert_eq!(out.status, 303, "logout did not redirect: {}", out.status);
assert_eq!(web.raw_request("GET", "/reviews", &[("Cookie", session)], None).status, 303, "the logged-out sid still worked");
@@ -266,8 +251,8 @@ fn login_rotates_the_session_and_logout_ends_it() {
#[test]
fn handlers_read_on_a_read_only_connection() {
- // The claim under test: a handler can never take the write lock, because
- // the connection it reads through is read-only at the SQLite level.
+ // The claim under test: a handler can never take the write lock, because the
+ // connection it reads through is read-only at the SQLite level.
let web = Web::new("plain-make");
let err = web
.env