Rocket

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 9f75e0f443b3ccf678fe915668e0e7f5e1f89273
parent 0a978fdb5dae84d0f98c4352b144a2a50b1e3b56
Author: Sergio Benitez <sb@sergio.bz>
Date:   Wed,  8 May 2019 20:10:22 -0700

Clean up 'conditionally-set-server-header' test.

Diffstat:
Acore/lib/tests/conditionally-set-server-header-996.rs | 35+++++++++++++++++++++++++++++++++++
Dcore/lib/tests/conditionally-set-server-header-997.rs | 43-------------------------------------------
2 files changed, 35 insertions(+), 43 deletions(-)

diff --git a/core/lib/tests/conditionally-set-server-header-996.rs b/core/lib/tests/conditionally-set-server-header-996.rs @@ -0,0 +1,35 @@ +#![feature(proc_macro_hygiene, decl_macro)] + +#[macro_use] extern crate rocket; + +use rocket::Response; +use rocket::http::Header; + +#[get("/do_not_overwrite")] +fn do_not_overwrite() -> Response<'static> { + Response::build() + .header(Header::new("Server", "Test")) + .finalize() +} + +#[get("/use_default")] +fn use_default() { } + +mod conditionally_set_server_header { + use super::*; + use rocket::local::Client; + + #[test] + fn do_not_overwrite_server_header() { + let rocket = rocket::ignite().mount("/", routes![do_not_overwrite, use_default]); + let client = Client::new(rocket).unwrap(); + + let response = client.get("/do_not_overwrite").dispatch(); + let server = response.headers().get_one("Server"); + assert_eq!(server, Some("Test")); + + let response = client.get("/use_default").dispatch(); + let server = response.headers().get_one("Server"); + assert_eq!(server, Some("Rocket")); + } +} diff --git a/core/lib/tests/conditionally-set-server-header-997.rs b/core/lib/tests/conditionally-set-server-header-997.rs @@ -1,43 +0,0 @@ -#![feature(proc_macro_hygiene, decl_macro)] - -#[macro_use] -extern crate rocket; -extern crate rocket_http; - -use rocket::response::Redirect; -use rocket::Response; -use rocket_http::{Header, Status}; - -#[get("/do_not_overwrite")] -fn do_not_overwrite<'r>() -> Result<Response<'r>, ()> { - let header = Header::new("Server", "Test"); - - Response::build() - .header(header) - .ok() -} - -#[get("/use_default")] -fn use_default<'r>() -> Result<Response<'r>, ()> { - Response::build() - .ok() -} - -mod conditionally_set_server_header { - use super::*; - use rocket::local::Client; - - #[test] - fn do_not_overwrite_server_header() { - let rocket = rocket::ignite().mount("/", routes![do_not_overwrite, use_default]); - let client = Client::new(rocket).unwrap(); - - let response = client.get("/do_not_overwrite").dispatch(); - let server = response.headers().get_one("Server"); - assert_eq!(server, Some("Test")); - - let response = client.get("/use_default").dispatch(); - let server = response.headers().get_one("Server"); - assert_eq!(server, Some("Rocket")); - } -}