steid

@jamesgill /

steid/tests/http.rs
Rust24.8 KBCode·Blame·History·Raw
1//! The first tests that speak HTTP.
2//!
3//! Everything below is a fact about a *response* — a header, a status, a body — and none
4//! of it was assertable until [`app::build`](steid::infrastructure::app::build) came out
5//! of `main.rs`. Both organisation reviews asked for this; §6 of the second one checked
6//! that `topcoat::serve_until` takes any `Listener` and that `tokio::net::TcpListener`
7//! is one, which is the whole of the mechanism here.
8//!
9//! **`tests/` rather than a `#[cfg(test)]` module inside `web/`**, for two reasons. It
10//! reaches the application exactly the way `main` does — through the public API, with no
11//! access to a private helper that could quietly make a test pass — and it keeps a
12//! server boot, a migration and a pool out of the unit-test binary, which runs 1,300
13//! tests in seven seconds and should keep doing so.
14//!
15//! **It does not replace `web/csrf_scan.rs`,** and could not: this exercises one refused
16//! POST, and the scan's guarantee is about the thirty-odd handlers it has never called.
17//! What it does do is close the scan's own stated gap — that it "has never executed the
18//! 403 page it protects" — so the two are complements. See the note in the CSRF test.
19
20use std::{net::SocketAddr, path::Path};
21
22use steid::{
23 application::{AppConfig, is_claimed, mint_reset_for_handle},
24 domain::{SetupToken, repository::OrgRepository},
25 infrastructure::{
26 app, database,
27 repository::{SqliteOrgRepo, SqlitePasswordResetRepo, SqliteUserRepo},
28 },
29};
30use tempfile::TempDir;
31use tokio::{net::TcpListener, sync::oneshot, task::JoinHandle};
32use topcoat::asset::AssetBundle;
33
34/// A Steid serving on a port the operating system picked, against a database and a data
35/// directory that vanish with it.
36struct Instance {
37 base: String,
38 /// The claim token, live until the instance is claimed.
39 setup_token: String,
40 /// The configuration it was built from, for the tests that drive a subcommand.
41 config: AppConfig,
42 /// Its database, for the same reason: `steid reset-password` has no HTTP surface.
43 pool: sqlx::SqlitePool,
44 /// Held so the temporary directory outlives the server.
45 _dir: TempDir,
46 stop: Option<oneshot::Sender<()>>,
47 serving: Option<JoinHandle<()>>,
48}
49
50impl Instance {
51 /// A URL on this instance.
52 fn url(&self, path: &str) -> String {
53 format!("{}{path}", self.base)
54 }
55}
56
57impl Drop for Instance {
58 fn drop(&mut self) {
59 // The server holds the pool, which holds an open file in the temp directory the
60 // next line removes. Signalling here rather than in each test keeps every test
61 // to its assertions.
62 if let Some(stop) = self.stop.take() {
63 let _ = stop.send(());
64 }
65 if let Some(serving) = self.serving.take() {
66 serving.abort();
67 }
68 }
69}
70
71/// Boots one, unclaimed, and returns once it is accepting connections.
72async fn boot() -> Instance {
73 boot_with(None).await
74}
75
76/// Boots one that was handed an owner in its configuration, exactly as a scripted
77/// install does — so it is claimed before it answers its first request.
78///
79/// Seeds through [`app::seed_owner_on_boot`] rather than calling the use case directly:
80/// that function *is* what `main` calls, so this reaches the application the way the
81/// binary does and a change to the boot policy — the silence on a claimed instance, the
82/// order against the setup token — cannot pass here and fail there.
83async fn boot_with_owner(handle: &str, email: &str) -> Instance {
84 boot_with(Some((handle.to_owned(), email.to_owned()))).await
85}
86
87async fn boot_with(owner: Option<(String, String)>) -> Instance {
88 let dir = tempfile::tempdir().expect("a temp dir");
89 let config = config_in(dir.path(), owner.clone());
90
91 let pool = database::connect(&config.database_url)
92 .await
93 .expect("the database opens");
94
95 // What `main` does, in `main`'s order: the owner is seeded first, because seeding is
96 // what makes the instance claimed, and a claimed instance is handed no setup token.
97 let seeded = app::seed_owner_on_boot(&config, &pool)
98 .await
99 .expect("the configured owner is created");
100 assert_eq!(
101 seeded.is_some(),
102 owner.is_some(),
103 "a configured owner must actually be created"
104 );
105
106 let token = SetupToken::generate();
107 let setup_token = token.reveal().to_owned();
108 let setup = if seeded.is_some() { None } else { Some(token) };
109
110 let router = app::build(config.clone(), pool.clone(), assets(), setup)
111 .await
112 .build();
113
114 // Port zero: the kernel picks, so tests never collide with each other or with a dev
115 // server on 3000.
116 let listener = TcpListener::bind("127.0.0.1:0").await.expect("a port");
117 let addr: SocketAddr = listener.local_addr().expect("the address it got");
118
119 let (stop, stopped) = oneshot::channel();
120 let serving = tokio::spawn(async move {
121 let _ = topcoat::serve_until(listener, router, async {
122 let _ = stopped.await;
123 })
124 .await;
125 });
126
127 Instance {
128 base: format!("http://{addr}"),
129 setup_token,
130 config,
131 pool,
132 _dir: dir,
133 stop: Some(stop),
134 serving: Some(serving),
135 }
136}
137
138/// The configuration of an instance whose database and data directory live in `dir`.
139fn config_in(dir: &Path, owner: Option<(String, String)>) -> AppConfig {
140 let data_dir = dir.join("data");
141 std::fs::create_dir_all(&data_dir).expect("mkdir");
142
143 AppConfig {
144 database_url: format!("sqlite:{}?mode=rwc", dir.join("steid.db").display()),
145 data_dir,
146 // The default, and the one under test: the session cookie is `__Host-` prefixed
147 // and `Secure`. A test that flipped this would be testing the development
148 // fallback rather than what is deployed.
149 insecure_cookies: false,
150 allow_private_webhooks: false,
151 trusted_proxy: false,
152 // Absent, so the operator surface does not exist. `/metrics` answering 404 is the
153 // fact this makes assertable.
154 operator_token: None,
155 setup_token: None,
156 backup_marker: None,
157 smtp_url: None,
158 mail_from: None,
159 // Set together or not at all — the configuration refuses half of an owner, and
160 // that refusal is `AppConfig::owner_seed`'s unit test rather than a boot here.
161 owner_email: owner.as_ref().map(|(_, email)| email.clone()),
162 owner_handle: owner.as_ref().map(|(handle, _)| handle.clone()),
163 owner_org: None,
164 owner_org_name: None,
165 public_url: None,
166 }
167}
168
169/// The asset bundle these tests serve.
170///
171/// Empty, deliberately: nothing asserted here renders a `view!`, so no page reaches
172/// `Asset`'s renderer and the catalog is never consulted. Loading the real bundle would
173/// tie `cargo test` to `topcoat asset bundle` having been run — a build step that is not
174/// part of the test gate — and the failure would be a `NotFound` at boot rather than
175/// anything about the assertion. The day a test here does render a page, this is where
176/// the real bundle goes.
177fn assets() -> AssetBundle {
178 // Leaked rather than held: `load_dir` reads the manifest and keeps only the path,
179 // and the directory has to outlive every instance in the process.
180 let dir = Box::leak(Box::new(tempfile::tempdir().expect("a temp dir")));
181 std::fs::write(
182 dir.path().join("manifest.toml"),
183 "version = 1\nassets = []\n",
184 )
185 .expect("the manifest is written");
186
187 AssetBundle::load_dir(dir.path()).expect("an empty bundle loads")
188}
189
190/// One response, reduced to what these tests ask about.
191struct Answer {
192 status: u16,
193 headers: Vec<(String, String)>,
194 body: String,
195}
196
197impl Answer {
198 /// The first value of a header, case-insensitively.
199 fn header(&self, name: &str) -> Option<&str> {
200 self.headers
201 .iter()
202 .find(|(key, _)| key.eq_ignore_ascii_case(name))
203 .map(|(_, value)| value.as_str())
204 }
205}
206
207/// Makes a request from a blocking thread.
208///
209/// A `body` makes it a POST and a `None` a GET, which is the whole of the verb handling
210/// these tests need.
211///
212/// `ureq` is the client already in the tree, and it is blocking — so it runs on a
213/// blocking thread rather than stalling the runtime worker the server is being polled
214/// on. Without `spawn_blocking` a single-threaded runtime deadlocks here.
215///
216/// `ureq` sends neither `Origin` nor `Sec-Fetch-Site` of its own, so `extra` is the
217/// whole of what the request says about where it came from.
218async fn request(url: String, body: Option<(&str, String)>, extra: &[(&str, &str)]) -> Answer {
219 let body = body.map(|(content_type, body)| (content_type.to_owned(), body));
220 let extra: Vec<(String, String)> = extra
221 .iter()
222 .map(|(name, value)| ((*name).to_owned(), (*value).to_owned()))
223 .collect();
224
225 tokio::task::spawn_blocking(move || {
226 let agent = ureq::Agent::config_builder()
227 // Every status these tests are about is a 4xx. The default collapses them
228 // into an error variant that carries no headers, which is exactly what is
229 // being asserted.
230 .http_status_as_error(false)
231 .max_redirects(0)
232 .build()
233 .new_agent();
234
235 let mut response = match body {
236 Some((content_type, body)) => {
237 let mut post = agent.post(&url).header("content-type", &content_type);
238 for (name, value) in &extra {
239 post = post.header(name, value);
240 }
241 post.send(&body).expect("the request completes")
242 }
243 None => agent.get(&url).call().expect("the request completes"),
244 };
245
246 let status = response.status().as_u16();
247 let headers = response
248 .headers()
249 .iter()
250 .map(|(name, value)| {
251 (
252 name.as_str().to_owned(),
253 String::from_utf8_lossy(value.as_bytes()).into_owned(),
254 )
255 })
256 .collect();
257 let body = response.body_mut().read_to_string().unwrap_or_default();
258
259 Answer {
260 status,
261 headers,
262 body,
263 }
264 })
265 .await
266 .expect("the blocking thread finishes")
267}
268
269async fn get(instance: &Instance, path: &str) -> Answer {
270 request(instance.url(path), None, &[]).await
271}
272
273/// A form POST that says nothing about where it came from: what a bare HTTP client
274/// sends, and a browser too old for `Origin` and `Sec-Fetch-Site`.
275async fn post_form(instance: &Instance, path: &str, body: &str) -> Answer {
276 post_form_with(instance, path, body, &[]).await
277}
278
279/// A form POST as a browser submits it from this instance's own page.
280///
281/// `/auth/login` refuses one that carries neither `Sec-Fetch-Site` nor `Origin`
282/// (launch 2.18), and every browser that can sign in sends at least one.
283async fn post_form_from_page(instance: &Instance, path: &str, body: &str) -> Answer {
284 post_form_with(instance, path, body, &[("sec-fetch-site", "same-origin")]).await
285}
286
287async fn post_form_with(
288 instance: &Instance,
289 path: &str,
290 body: &str,
291 headers: &[(&str, &str)],
292) -> Answer {
293 request(
294 instance.url(path),
295 Some(("application/x-www-form-urlencoded", body.to_owned())),
296 headers,
297 )
298 .await
299}
300
301async fn post_json(instance: &Instance, path: &str, body: String) -> Answer {
302 request(instance.url(path), Some(("application/json", body)), &[]).await
303}
304
305/// Whether a response starts a session.
306fn sets_a_session(answer: &Answer) -> bool {
307 answer
308 .header("set-cookie")
309 .is_some_and(|cookie| cookie.to_ascii_lowercase().contains("session"))
310}
311
312/// Claims the instance headlessly, as `install.sh` does.
313///
314/// Asserted rather than ignored: if this ever stops answering 201 the tests below are
315/// running against an unclaimed instance and would still pass, which is the worst kind
316/// of green.
317async fn claim(instance: &Instance) {
318 let body = format!(
319 r#"{{"setup_token":"{}","email":"ada@example.com","handle":"ada","password":"a-long-enough-password"}}"#,
320 instance.setup_token
321 );
322
323 let answer = post_json(instance, "/api/setup", body).await;
324
325 assert_eq!(answer.status, 201, "the claim was refused: {}", answer.body);
326 assert!(
327 answer.body.contains("\"handle\":\"ada\""),
328 "{}",
329 answer.body
330 );
331}
332
333#[tokio::test]
334async fn an_instance_boots_and_can_be_claimed_without_a_browser() {
335 let instance = boot().await;
336
337 let before = get(&instance, "/api/instance").await;
338 assert_eq!(before.status, 200);
339 assert_eq!(before.body.trim(), r#"{"claimed":false}"#);
340
341 claim(&instance).await;
342
343 let after = get(&instance, "/api/instance").await;
344 assert_eq!(after.status, 200);
345 assert_eq!(after.body.trim(), r#"{"claimed":true}"#);
346}
347
348#[tokio::test]
349async fn an_instance_given_an_owner_in_its_configuration_boots_claimed() {
350 // The whole point of the boot-time owner: there is no window, however short, in
351 // which this instance is unclaimed and reachable.
352 let instance = boot_with_owner("ada", "ada@example.com").await;
353
354 let answer = get(&instance, "/api/instance").await;
355
356 assert_eq!(answer.status, 200);
357 assert_eq!(answer.body.trim(), r#"{"claimed":true}"#);
358}
359
360#[tokio::test]
361async fn a_boot_seeded_instance_cannot_be_claimed_by_anyone() {
362 // A seeded instance holds no setup token at all — `boot_with` withholds it exactly
363 // as `main` does — so both claim surfaces are shut before any credential is read.
364 let instance = boot_with_owner("ada", "ada@example.com").await;
365
366 let over_json = post_json(
367 &instance,
368 "/api/setup",
369 format!(
370 r#"{{"setup_token":"{}","email":"eve@example.com","handle":"eve","password":"a-long-enough-password"}}"#,
371 instance.setup_token
372 ),
373 )
374 .await;
375 assert_ne!(
376 over_json.status, 201,
377 "the claim went through: {}",
378 over_json.body
379 );
380
381 // The form is the other way in. A claimed instance answers it with a 303 to the
382 // root — asserted as it stands today, so a deliberate change has to come through
383 // here rather than silently.
384 let over_form = post_form(
385 &instance,
386 "/auth/setup",
387 &format!(
388 "token={}&handle=eve&email=eve@example.com&password=a-long-enough-password",
389 instance.setup_token
390 ),
391 )
392 .await;
393 assert_eq!(over_form.status, 303);
394 assert_eq!(over_form.header("location"), Some("/"));
395
396 assert_eq!(
397 get(&instance, "/api/instance").await.body.trim(),
398 r#"{"claimed":true}"#,
399 "and nobody became the owner"
400 );
401}
402
403#[tokio::test]
404async fn a_refused_organisation_is_refused_again_on_the_next_boot() {
405 // Launch 2.14. `admin` is reserved, so the seed is refused — and must be refused
406 // before the owner is written. Until 0.8.2 the owner was committed first: the first
407 // boot exited 4, systemd restarted it, and the second found an owner, called the
408 // instance claimed and served it with no organisation and no home.
409 let dir = tempfile::tempdir().expect("a temp dir");
410 let config = AppConfig {
411 owner_org: Some("admin".to_owned()),
412 ..config_in(
413 dir.path(),
414 Some(("ada".to_owned(), "ada@example.com".to_owned())),
415 )
416 };
417
418 for boot in ["first", "second"] {
419 // A fresh pool each time, against the same file, as a restart opens one.
420 let pool = database::connect(&config.database_url)
421 .await
422 .expect("the database opens");
423
424 let error = app::seed_owner_on_boot(&config, &pool)
425 .await
426 .expect_err("a reserved organisation must stop the boot");
427 assert!(
428 error.to_string().contains("reserved"),
429 "the {boot} boot failed for another reason: {error}"
430 );
431
432 assert!(
433 !is_claimed(&SqliteUserRepo::new(pool.clone()))
434 .await
435 .expect("the query runs"),
436 "the {boot} boot left an owner behind"
437 );
438 assert_eq!(
439 SqliteOrgRepo::new(pool.clone())
440 .count()
441 .await
442 .expect("the query runs"),
443 0,
444 "the {boot} boot left an organisation behind"
445 );
446
447 pool.close().await;
448 }
449}
450
451#[tokio::test]
452async fn the_seeded_owner_cannot_sign_in_with_any_password() {
453 // There is no password to guess: the one that was hashed was 32 random bytes, made
454 // at boot and dropped. A wrong password is a 303 back to the form with no session.
455 // Sent as the sign-in page sends it, so what is refused is the password and not the
456 // request's origin.
457 let instance = boot_with_owner("ada", "ada@example.com").await;
458
459 for guess in ["", "password", "a-long-enough-password"] {
460 let answer = post_form_from_page(
461 &instance,
462 "/auth/login",
463 &format!("email=ada@example.com&password={guess}"),
464 )
465 .await;
466
467 assert_eq!(answer.status, 303, "{guess:?} was not refused");
468 assert_eq!(answer.header("location"), Some("/auth/login"));
469 assert!(
470 !sets_a_session(&answer),
471 "{guess:?} produced a session cookie: {:?}",
472 answer.header("set-cookie")
473 );
474 }
475}
476
477#[tokio::test]
478async fn the_seeded_owner_gets_in_through_a_reset_link() {
479 // The only way in, and therefore the one that has to work end to end: what
480 // `steid reset-password ada` mints is spent here, and the new password signs in.
481 let instance = boot_with_owner("ada", "ada@example.com").await;
482
483 let issued = mint_reset_for_handle(
484 "ada",
485 std::time::SystemTime::now(),
486 &SqliteUserRepo::new(instance.pool.clone()),
487 &SqliteOrgRepo::new(instance.pool.clone()),
488 &SqlitePasswordResetRepo::new(instance.pool.clone()),
489 )
490 .await
491 .expect("the query runs")
492 .expect("the seeded owner holds the handle");
493
494 // `steid reset-password` prints exactly this, with STEID_PUBLIC_URL in front; the
495 // instance's own base is that address here.
496 assert!(instance.config.public_url.is_none());
497 let link = issued.link(&instance.base);
498 let path = link
499 .strip_prefix(&instance.base)
500 .expect("the link is on this instance")
501 .to_owned();
502 assert!(path.starts_with("/auth/reset/"), "{link}");
503
504 let spent = post_form(
505 &instance,
506 &path,
507 "password=a-long-enough-password&confirmation=a-long-enough-password",
508 )
509 .await;
510 assert_eq!(spent.status, 303, "the reset was refused");
511 assert_eq!(spent.header("location"), Some("/auth/login?reset"));
512
513 let signed_in = post_form_from_page(
514 &instance,
515 "/auth/login",
516 "email=ada@example.com&password=a-long-enough-password",
517 )
518 .await;
519 assert_eq!(signed_in.status, 303);
520 assert_eq!(
521 signed_in.header("location"),
522 Some("/"),
523 "the owner could not sign in with the password they just set"
524 );
525}
526
527#[tokio::test]
528async fn every_response_carries_the_security_headers_including_a_404() {
529 let instance = boot().await;
530
531 // A 404 specifically, because until the layer learned to build the response itself an
532 // error never passed through it: a 404 went out with no CSP, no `X-Frame-Options` and
533 // no `Referrer-Policy` at all. That regression is invisible to every other test.
534 for path in ["/api/instance", "/nothing-is-here"] {
535 let answer = get(&instance, path).await;
536
537 assert!(
538 answer.status == 200 || answer.status == 404,
539 "{path} answered {}",
540 answer.status
541 );
542
543 let policy = answer
544 .header("content-security-policy")
545 .unwrap_or_else(|| panic!("{path} carries no CSP"));
546 assert!(
547 policy.contains("default-src 'none'"),
548 "{path}'s CSP is {policy}"
549 );
550 assert!(
551 policy.contains("frame-ancestors 'none'"),
552 "{path}'s CSP is {policy}"
553 );
554
555 assert_eq!(
556 answer.header("x-content-type-options"),
557 Some("nosniff"),
558 "{path}"
559 );
560 assert_eq!(answer.header("x-frame-options"), Some("DENY"), "{path}");
561 // `no-referrer`, not the usual `strict-origin-when-cross-origin`: a private
562 // repository's URL contains its name, and a README may link anywhere.
563 assert_eq!(
564 answer.header("referrer-policy"),
565 Some("no-referrer"),
566 "{path}"
567 );
568 assert_eq!(
569 answer.header("cache-control"),
570 Some("private, no-cache"),
571 "{path}"
572 );
573 }
574}
575
576#[tokio::test]
577async fn a_post_without_a_csrf_token_is_refused_with_a_403() {
578 let instance = boot().await;
579
580 // `/auth/logout` because it is a guarded POST that needs no session to reach: the
581 // check runs before anything else it does. This is the first time the refusal has
582 // been *executed* — `csrf_scan` asserts that the line is written, which is a
583 // different guarantee and still the one that covers the other thirty handlers.
584 let empty = post_form(&instance, "/auth/logout", "").await;
585 assert_eq!(empty.status, 403, "{}", empty.body);
586 assert!(
587 empty.body.contains("submitted from somewhere else"),
588 "{}",
589 empty.body
590 );
591
592 let wrong = post_form(&instance, "/auth/logout", "csrf_token=not-a-token").await;
593 assert_eq!(wrong.status, 403, "{}", wrong.body);
594
595 // And the refusal is not an exception to the headers: it is built by hand rather than
596 // by the router, so it is exactly the shape of response that could miss them.
597 assert_eq!(empty.header("x-frame-options"), Some("DENY"));
598}
599
600#[tokio::test]
601async fn sign_in_refuses_a_post_that_does_not_say_where_it_came_from() {
602 // Launch 2.18, login CSRF. A forged form signs the victim's browser in as the
603 // attacker, so every attempt below carries good credentials: what is refused is
604 // where the request came from, never the password.
605 let instance = boot().await;
606 claim(&instance).await;
607 let credentials = "email=ada@example.com&password=a-long-enough-password";
608
609 // Neither `Sec-Fetch-Site` nor `Origin`: Topcoat's origin layer lets this through,
610 // as a non-browser client, and `csrf_verified_signed_out` is what refuses it.
611 let bare = post_form(&instance, "/auth/login", credentials).await;
612 assert_eq!(bare.status, 403, "{}", bare.body);
613 assert!(
614 bare.body.contains("submitted from somewhere else"),
615 "{}",
616 bare.body
617 );
618 assert!(
619 !sets_a_session(&bare),
620 "a refused sign-in started a session: {:?}",
621 bare.header("set-cookie")
622 );
623
624 // A sibling subdomain and a stranger: the origin layer's refusals, asserted here so
625 // a change to that layer cannot quietly reopen them.
626 for site in ["same-site", "cross-site"] {
627 let forged = post_form_with(
628 &instance,
629 "/auth/login",
630 credentials,
631 &[("sec-fetch-site", site)],
632 )
633 .await;
634 assert_eq!(forged.status, 403, "{site}: {}", forged.body);
635 assert!(!sets_a_session(&forged), "{site} started a session");
636 }
637
638 // An older browser sends `Origin` alone. Its own host passes; another is refused.
639 let foreign = post_form_with(
640 &instance,
641 "/auth/login",
642 credentials,
643 &[("origin", "https://attacker.example")],
644 )
645 .await;
646 assert_eq!(foreign.status, 403, "{}", foreign.body);
647 assert!(
648 !sets_a_session(&foreign),
649 "a foreign Origin started a session"
650 );
651
652 let own_origin = instance.base.clone();
653 let from_origin = post_form_with(
654 &instance,
655 "/auth/login",
656 credentials,
657 &[("origin", own_origin.as_str())],
658 )
659 .await;
660 assert_eq!(from_origin.status, 303, "{}", from_origin.body);
661 assert_eq!(from_origin.header("location"), Some("/"));
662
663 // And the sign-in page itself.
664 let from_page = post_form_from_page(&instance, "/auth/login", credentials).await;
665 assert_eq!(from_page.status, 303, "{}", from_page.body);
666 assert_eq!(from_page.header("location"), Some("/"));
667 assert!(
668 sets_a_session(&from_page),
669 "a same-origin sign-in set no session: {:?}",
670 from_page.headers
671 );
672}
673
674#[tokio::test]
675async fn metrics_without_the_bearer_does_not_exist() {
676 let instance = boot().await;
677
678 // No `operator_token` is configured, so the surface is off. 404 rather than 401, and
679 // byte for byte what an unrouted path answers — a 401 would confirm there is a token
680 // to guess.
681 let metrics = get(&instance, "/metrics").await;
682 let unrouted = get(&instance, "/definitely-not-a-route").await;
683
684 assert_eq!(metrics.status, 404);
685 assert_eq!(metrics.status, unrouted.status);
686 assert_eq!(metrics.body, unrouted.body);
687
688 assert!(
689 !metrics.body.contains("steid_http_requests_total"),
690 "the counters leaked into the refusal: {}",
691 metrics.body
692 );
693}