fix: Update to latest master Rocket version (#85)

- Add explicit branch name to rocket dependency
- Fix linter errors
This commit is contained in:
Zachary Kohnen 2020-10-29 10:42:09 -04:00 committed by GitHub
parent fae7ccf9ce
commit 8427e62521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 59 deletions

View File

@ -22,7 +22,7 @@ serialization = ["serde", "serde_derive", "unicase_serde"]
[dependencies] [dependencies]
regex = "1.1" regex = "1.1"
rocket = { git="https://github.com/SergioBenitez/Rocket.git", default-features = false } rocket = { branch = "master", git = "https://github.com/SergioBenitez/Rocket.git", default-features = false }
log = "0.4" log = "0.4"
unicase = "2.0" unicase = "2.0"
url = "2.1.0" url = "2.1.0"

View File

@ -32,7 +32,7 @@ impl rocket::handler::Handler for FairingErrorRoute {
error_!("Fairing Error Handling Route error: {:?}", e); error_!("Fairing Error Handling Route error: {:?}", e);
500 500
}); });
let status = Status::from_code(status).unwrap_or_else(|| Status::InternalServerError); let status = Status::from_code(status).unwrap_or(Status::InternalServerError);
Outcome::Failure(status) Outcome::Failure(status)
} }
} }
@ -115,7 +115,7 @@ impl rocket::fairing::Fairing for Cors {
)) ))
} }
async fn on_request(&self, request: &mut Request<'_>, _: &rocket::Data) { async fn on_request(&self, request: &mut Request<'_>, _: &mut rocket::Data) {
let result = match validate(self, request) { let result = match validate(self, request) {
Ok(_) => CorsValidation::Success, Ok(_) => CorsValidation::Success,
Err(err) => { Err(err) => {
@ -171,7 +171,7 @@ mod tests {
#[test] #[test]
#[allow(non_snake_case)] #[allow(non_snake_case)]
fn FairingErrorRoute_returns_passed_in_status() { fn FairingErrorRoute_returns_passed_in_status() {
let client = Client::new(rocket(make_cors_options())).expect("to not fail"); let client = Client::tracked(rocket(make_cors_options())).expect("to not fail");
let request = client.get(format!("{}/403", CORS_ROOT)); let request = client.get(format!("{}/403", CORS_ROOT));
let response = request.dispatch(); let response = request.dispatch();
assert_eq!(Status::Forbidden, response.status()); assert_eq!(Status::Forbidden, response.status());
@ -180,7 +180,7 @@ mod tests {
#[test] #[test]
#[allow(non_snake_case)] #[allow(non_snake_case)]
fn FairingErrorRoute_returns_500_for_unknown_status() { fn FairingErrorRoute_returns_500_for_unknown_status() {
let client = Client::new(rocket(make_cors_options())).expect("to not fail"); let client = Client::tracked(rocket(make_cors_options())).expect("to not fail");
let request = client.get(format!("{}/999", CORS_ROOT)); let request = client.get(format!("{}/999", CORS_ROOT));
let response = request.dispatch(); let response = request.dispatch();
assert_eq!(Status::InternalServerError, response.status()); assert_eq!(Status::InternalServerError, response.status());
@ -188,12 +188,10 @@ mod tests {
#[rocket::async_test] #[rocket::async_test]
async fn error_route_is_mounted_on_attach() { async fn error_route_is_mounted_on_attach() {
let mut rocket = rocket(make_cors_options()); let rocket = rocket(make_cors_options());
let expected_uri = format!("{}/<status>", CORS_ROOT); let expected_uri = format!("{}/<status>", CORS_ROOT);
let error_route = rocket let error_route = rocket
.inspect()
.await
.routes() .routes()
.find(|r| r.method == Method::Get && r.uri.to_string() == expected_uri); .find(|r| r.method == Method::Get && r.uri.to_string() == expected_uri);
assert!(error_route.is_some()); assert!(error_route.is_some());

View File

@ -267,7 +267,7 @@ mod tests {
/// Make a client with no routes for unit testing /// Make a client with no routes for unit testing
fn make_client() -> Client { fn make_client() -> Client {
let rocket = rocket::ignite(); let rocket = rocket::ignite();
Client::new(rocket).expect("valid rocket instance") Client::tracked(rocket).expect("valid rocket instance")
} }
// `Origin::from_str` tests // `Origin::from_str` tests

View File

@ -1816,7 +1816,7 @@ fn preflight_validate(
// do not set any additional headers and terminate this set of steps. // do not set any additional headers and terminate this set of steps.
// The request is outside the scope of this specification. // The request is outside the scope of this specification.
let method = method.as_ref().ok_or_else(|| Error::MissingRequestMethod)?; let method = method.as_ref().ok_or(Error::MissingRequestMethod)?;
// 4. Let header field-names be the values as result of parsing the // 4. Let header field-names be the values as result of parsing the
// Access-Control-Request-Headers headers. // Access-Control-Request-Headers headers.
@ -2081,7 +2081,7 @@ mod tests {
/// Make a client with no routes for unit testing /// Make a client with no routes for unit testing
fn make_client() -> Client { fn make_client() -> Client {
let rocket = rocket::ignite(); let rocket = rocket::ignite();
Client::new(rocket).expect("valid rocket instance") Client::tracked(rocket).expect("valid rocket instance")
} }
// CORS options test // CORS options test

View File

@ -44,7 +44,7 @@ fn rocket() -> rocket::Rocket {
#[test] #[test]
fn smoke_test() { fn smoke_test() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
// `Options` pre-flight checks // `Options` pre-flight checks
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
@ -80,7 +80,7 @@ fn smoke_test() {
#[test] #[test]
fn cors_options_check() { fn cors_options_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -106,7 +106,7 @@ fn cors_options_check() {
#[test] #[test]
fn cors_get_check() { fn cors_get_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -126,7 +126,7 @@ fn cors_get_check() {
/// This test is to check that non CORS compliant requests to GET should still work. (i.e. curl) /// This test is to check that non CORS compliant requests to GET should still work. (i.e. curl)
#[test] #[test]
fn cors_get_no_origin() { fn cors_get_no_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
let req = client.get("/").header(authorization); let req = client.get("/").header(authorization);
@ -139,7 +139,7 @@ fn cors_get_no_origin() {
#[test] #[test]
fn cors_options_bad_origin() { fn cors_options_bad_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let method_header = Header::new( let method_header = Header::new(
@ -160,7 +160,7 @@ fn cors_options_bad_origin() {
/// Unlike the "ad-hoc" mode, this should return 404 because we don't have such a route /// Unlike the "ad-hoc" mode, this should return 404 because we don't have such a route
#[test] #[test]
fn cors_options_missing_origin() { fn cors_options_missing_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let method_header = Header::new( let method_header = Header::new(
ACCESS_CONTROL_REQUEST_METHOD.as_str(), ACCESS_CONTROL_REQUEST_METHOD.as_str(),
@ -183,7 +183,7 @@ fn cors_options_missing_origin() {
#[test] #[test]
fn cors_options_bad_request_method() { fn cors_options_bad_request_method() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -207,7 +207,7 @@ fn cors_options_bad_request_method() {
#[test] #[test]
fn cors_options_bad_request_header() { fn cors_options_bad_request_header() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -231,7 +231,7 @@ fn cors_options_bad_request_header() {
#[test] #[test]
fn cors_get_bad_origin() { fn cors_get_bad_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -250,7 +250,7 @@ fn cors_get_bad_origin() {
/// The route used will panic if executed /// The route used will panic if executed
#[test] #[test]
fn routes_failing_checks_are_not_executed() { fn routes_failing_checks_are_not_executed() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let method_header = Header::new( let method_header = Header::new(

View File

@ -15,7 +15,7 @@ static ACCESS_CONTROL_REQUEST_HEADERS: hyper::HeaderName =
hyper::header::ACCESS_CONTROL_REQUEST_HEADERS; hyper::header::ACCESS_CONTROL_REQUEST_HEADERS;
#[get("/")] #[get("/")]
fn cors(cors: cors::Guard<'_>) -> cors::Responder<'_, '_, &str> { fn cors_responder(cors: cors::Guard<'_>) -> cors::Responder<'_, '_, &str> {
cors.responder("Hello CORS") cors.responder("Hello CORS")
} }
@ -80,7 +80,7 @@ fn make_cors() -> cors::Cors {
fn make_rocket() -> rocket::Rocket { fn make_rocket() -> rocket::Rocket {
rocket::ignite() rocket::ignite()
.mount("/", routes![cors, panicking_route]) .mount("/", routes![cors_responder, panicking_route])
.mount( .mount(
"/", "/",
routes![response, responder_string, responder_unit, state], routes![response, responder_string, responder_unit, state],
@ -94,7 +94,7 @@ fn make_rocket() -> rocket::Rocket {
#[test] #[test]
fn smoke_test() { fn smoke_test() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
// `Options` pre-flight checks // `Options` pre-flight checks
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
@ -132,7 +132,7 @@ fn smoke_test() {
#[test] #[test]
fn cors_options_catch_all_check() { fn cors_options_catch_all_check() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -160,7 +160,7 @@ fn cors_options_catch_all_check() {
#[test] #[test]
fn cors_options_catch_all_check_other_routes() { fn cors_options_catch_all_check_other_routes() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -187,7 +187,7 @@ fn cors_options_catch_all_check_other_routes() {
#[test] #[test]
fn cors_get_check() { fn cors_get_check() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -208,7 +208,7 @@ fn cors_get_check() {
#[test] #[test]
fn cors_get_no_origin() { fn cors_get_no_origin() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
let req = client.get("/").header(authorization); let req = client.get("/").header(authorization);
@ -226,7 +226,7 @@ fn cors_get_no_origin() {
#[test] #[test]
fn cors_options_bad_origin() { fn cors_options_bad_origin() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let method_header = Header::new( let method_header = Header::new(
@ -251,7 +251,7 @@ fn cors_options_bad_origin() {
#[test] #[test]
fn cors_options_missing_origin() { fn cors_options_missing_origin() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let method_header = Header::new( let method_header = Header::new(
ACCESS_CONTROL_REQUEST_METHOD.as_str(), ACCESS_CONTROL_REQUEST_METHOD.as_str(),
@ -274,7 +274,7 @@ fn cors_options_missing_origin() {
#[test] #[test]
fn cors_options_bad_request_method() { fn cors_options_bad_request_method() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -299,7 +299,7 @@ fn cors_options_bad_request_method() {
#[test] #[test]
fn cors_options_bad_request_header() { fn cors_options_bad_request_header() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -324,7 +324,7 @@ fn cors_options_bad_request_header() {
#[test] #[test]
fn cors_get_bad_origin() { fn cors_get_bad_origin() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -344,7 +344,7 @@ fn cors_get_bad_origin() {
#[test] #[test]
fn routes_failing_checks_are_not_executed() { fn routes_failing_checks_are_not_executed() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -363,7 +363,7 @@ fn routes_failing_checks_are_not_executed() {
#[test] #[test]
fn overridden_options_routes_are_used() { fn overridden_options_routes_are_used() {
let rocket = make_rocket(); let rocket = make_rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(

View File

@ -33,7 +33,7 @@ fn request_headers(
#[test] #[test]
fn request_headers_round_trip_smoke_test() { fn request_headers_round_trip_smoke_test() {
let rocket = rocket::ignite().mount("/", routes![request_headers]); let rocket = rocket::ignite().mount("/", routes![request_headers]);
let client = Client::new(rocket).expect("A valid Rocket client"); let client = Client::tracked(rocket).expect("A valid Rocket client");
let origin_header = Header::new(ORIGIN.as_str(), "https://foo.bar.xyz"); let origin_header = Header::new(ORIGIN.as_str(), "https://foo.bar.xyz");
let method_header = Header::new( let method_header = Header::new(

View File

@ -105,7 +105,7 @@ fn rocket() -> rocket::Rocket {
#[test] #[test]
fn smoke_test() { fn smoke_test() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
// `Options` pre-flight checks // `Options` pre-flight checks
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
@ -141,7 +141,7 @@ fn smoke_test() {
#[test] #[test]
fn cors_options_borrowed_check() { fn cors_options_borrowed_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -167,7 +167,7 @@ fn cors_options_borrowed_check() {
#[test] #[test]
fn cors_get_borrowed_check() { fn cors_get_borrowed_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -187,7 +187,7 @@ fn cors_get_borrowed_check() {
/// This test is to check that non CORS compliant requests to GET should still work. (i.e. curl) /// This test is to check that non CORS compliant requests to GET should still work. (i.e. curl)
#[test] #[test]
fn cors_get_no_origin() { fn cors_get_no_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
let req = client.get("/").header(authorization); let req = client.get("/").header(authorization);
@ -200,7 +200,7 @@ fn cors_get_no_origin() {
#[test] #[test]
fn cors_options_bad_origin() { fn cors_options_bad_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let method_header = Header::new( let method_header = Header::new(
@ -220,7 +220,7 @@ fn cors_options_bad_origin() {
#[test] #[test]
fn cors_options_missing_origin() { fn cors_options_missing_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let method_header = Header::new( let method_header = Header::new(
ACCESS_CONTROL_REQUEST_METHOD.as_str(), ACCESS_CONTROL_REQUEST_METHOD.as_str(),
@ -242,7 +242,7 @@ fn cors_options_missing_origin() {
#[test] #[test]
fn cors_options_bad_request_method() { fn cors_options_bad_request_method() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -266,7 +266,7 @@ fn cors_options_bad_request_method() {
#[test] #[test]
fn cors_options_bad_request_header() { fn cors_options_bad_request_header() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -290,7 +290,7 @@ fn cors_options_bad_request_header() {
#[test] #[test]
fn cors_get_bad_origin() { fn cors_get_bad_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -309,7 +309,7 @@ fn cors_get_bad_origin() {
/// The route used will panic if executed /// The route used will panic if executed
#[test] #[test]
fn routes_failing_checks_are_not_executed() { fn routes_failing_checks_are_not_executed() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let method_header = Header::new( let method_header = Header::new(
@ -335,7 +335,7 @@ fn routes_failing_checks_are_not_executed() {
#[test] #[test]
fn cors_options_owned_check() { fn cors_options_owned_check() {
let rocket = rocket(); let rocket = rocket();
let client = Client::new(rocket).unwrap(); let client = Client::tracked(rocket).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com");
let method_header = Header::new( let method_header = Header::new(
@ -364,7 +364,7 @@ fn cors_options_owned_check() {
/// Owned manual response works /// Owned manual response works
#[test] #[test]
fn cors_get_owned_check() { fn cors_get_owned_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");

View File

@ -70,7 +70,7 @@ fn rocket() -> rocket::Rocket {
#[test] #[test]
fn smoke_test() { fn smoke_test() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
// `Options` pre-flight checks // `Options` pre-flight checks
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
@ -106,7 +106,7 @@ fn smoke_test() {
#[test] #[test]
fn cors_options_check() { fn cors_options_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -132,7 +132,7 @@ fn cors_options_check() {
#[test] #[test]
fn cors_get_check() { fn cors_get_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -152,7 +152,7 @@ fn cors_get_check() {
/// This test is to check that non CORS compliant requests to GET should still work. (i.e. curl) /// This test is to check that non CORS compliant requests to GET should still work. (i.e. curl)
#[test] #[test]
fn cors_get_no_origin() { fn cors_get_no_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
let req = client.get("/").header(authorization); let req = client.get("/").header(authorization);
@ -165,7 +165,7 @@ fn cors_get_no_origin() {
#[test] #[test]
fn cors_options_bad_origin() { fn cors_options_bad_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let method_header = Header::new( let method_header = Header::new(
@ -185,7 +185,7 @@ fn cors_options_bad_origin() {
#[test] #[test]
fn cors_options_missing_origin() { fn cors_options_missing_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let method_header = Header::new( let method_header = Header::new(
ACCESS_CONTROL_REQUEST_METHOD.as_str(), ACCESS_CONTROL_REQUEST_METHOD.as_str(),
@ -207,7 +207,7 @@ fn cors_options_missing_origin() {
#[test] #[test]
fn cors_options_bad_request_method() { fn cors_options_bad_request_method() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -231,7 +231,7 @@ fn cors_options_bad_request_method() {
#[test] #[test]
fn cors_options_bad_request_header() { fn cors_options_bad_request_header() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.acme.com");
let method_header = Header::new( let method_header = Header::new(
@ -255,7 +255,7 @@ fn cors_options_bad_request_header() {
#[test] #[test]
fn cors_get_bad_origin() { fn cors_get_bad_origin() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.bad-origin.com");
let authorization = Header::new("Authorization", "let me in"); let authorization = Header::new("Authorization", "let me in");
@ -272,7 +272,7 @@ fn cors_get_bad_origin() {
/// Tests that the `ping` route accepts other Origins /// Tests that the `ping` route accepts other Origins
#[test] #[test]
fn cors_options_ping_check() { fn cors_options_ping_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com");
let method_header = Header::new( let method_header = Header::new(
@ -298,7 +298,7 @@ fn cors_options_ping_check() {
/// Tests that the `ping` route accepts other Origins /// Tests that the `ping` route accepts other Origins
#[test] #[test]
fn cors_get_ping_check() { fn cors_get_ping_check() {
let client = Client::new(rocket()).unwrap(); let client = Client::tracked(rocket()).unwrap();
let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com"); let origin_header = Header::new(ORIGIN.as_str(), "https://www.example.com");