summaryrefslogtreecommitdiffstats
path: root/tests/http.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/http.rs')
-rw-r--r--tests/http.rs24
1 files changed, 0 insertions, 24 deletions
diff --git a/tests/http.rs b/tests/http.rs
index 068f999..9bb199e 100644
--- a/tests/http.rs
+++ b/tests/http.rs
@@ -29,7 +29,6 @@ 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.
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();
@@ -43,17 +42,14 @@ fn the_review_detail_shows_the_panels_and_the_hashes() {
let c = web.open_review("plain-make");
let page = web.get(&format!("/reviews/{}", c.id));
assert_eq!(page.status, 200);
- // The panel set (§6), all comparing accepted → candidate.
for want in ["Recipe diff", "Version delta", "Source digest delta", "Dependency delta", "Build-env delta"] {
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 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\""));
assert!(!page.body.contains("<script"), "P2 ships no JavaScript at all");
- // The aur_commit is shown and linked into AUR's cgit.
assert!(page.body.contains("aur.archlinux.org/cgit/aur.git"), "no cgit link");
}
@@ -81,13 +77,11 @@ fn risk_signals_are_shown_inline() {
fn every_post_requires_a_csrf_token() {
let web = Web::new("plain-make");
let c = web.open_review("plain-make");
- // A form post with no token at all is refused outright.
let page = web.post_bare(
&format!("/reviews/{}/approve", c.id),
&[("identity_hash", "x"), ("diff_digest", "y")],
);
assert_eq!(page.status, 403, "a POST without CSRF must be refused");
- // And so is one with a token from someone else's session.
let page = web.post(&format!("/reviews/{}/approve", c.id), &[
("csrf", "not-the-token"),
("identity_hash", &c.identity_hash),
@@ -127,8 +121,6 @@ fn a_stale_approval_is_a_409_that_renders_the_current_diff() {
let page = web.get(&format!("/reviews/{}", c.id));
let shown_digest = extract(&page.body, "name=\"diff_digest\" value=\"", "\"").unwrap();
- // Upstream moves while the reviewer is reading: the identity changes under
- // them (§7.1a).
web.fx.bump(&[("pkgver", "9.9")]);
aur_build::watch::detect::check_pkgbase(&web.env.cfg, &web.env.db, "plain-make").unwrap();
@@ -138,8 +130,6 @@ 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, 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: {}",
@@ -181,7 +171,6 @@ 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 (§7.4).
let res = web.post(
"/reviews/bulk",
&[("csrf", &web.csrf), ("decision", "approve"), ("ids", &id), ("confirm", &id)],
@@ -195,9 +184,7 @@ fn a_password_gate_redirects_anonymous_visitors() {
let mut web = Web::with_password("plain-make", "s3cret");
let page = web.get("/reviews");
assert_eq!(page.status, 200);
- // The gate redirects; ureq follows, so we land on the login page.
assert!(page.body.contains("Sign in"), "not the login page: {}", &page.body[..200.min(page.body.len())]);
- // Wrong password is refused, right password lets us through.
let bad = web.post("/login", &[("csrf", &web.csrf), ("password", "nope")]);
assert_eq!(bad.status, 401);
assert!(web.get("/packages").body.contains("Sign in"), "still not gated");
@@ -210,19 +197,14 @@ 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 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.
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.
let res = web.raw_request("GET", "/reviews", &[("Cookie", "auth=yes".into())], None);
assert_eq!(res.status, 303);
}
@@ -230,7 +212,6 @@ fn a_forged_auth_cookie_is_not_a_session() {
#[test]
fn login_rotates_the_session_and_logout_ends_it() {
let mut web = Web::with_password("plain-make", "s3cret");
- // Arrive with an anonymous session (the CSRF token needs one), then log in.
let anon = web.raw_request("GET", "/", &[], None).cookie().unwrap_or_default();
let res = web.login("s3cret");
assert_eq!(res.status, 303);
@@ -238,12 +219,10 @@ fn login_rotates_the_session_and_logout_ends_it() {
let session = res.cookie().unwrap_or_default();
assert!(!session.is_empty(), "a successful login issued no session cookie");
assert_ne!(session, anon, "login promoted the anonymous session instead of rotating it");
- // The new session sees the surface; the sid it replaced is dead.
assert_eq!(web.raw_request("GET", "/reviews", &[("Cookie", session.clone())], None).status, 200);
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.
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");
@@ -251,8 +230,6 @@ 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.
let web = Web::new("plain-make");
let err = web
.env
@@ -263,7 +240,6 @@ fn handlers_read_on_a_read_only_connection() {
})
.err();
assert!(err.is_some(), "a read connection was able to write: the split is not real");
- // And the page still renders while that is true.
assert_eq!(web.get("/").status, 200);
}