Use hyper re-export from rocket_http
This way, the hyper version corresponding to the current rocket version is used for the tests.
This commit is contained in:
parent
172f423887
commit
7e13b63313
|
@ -33,7 +33,6 @@ serde_derive = { version = "1.0", optional = true }
|
|||
unicase_serde = { version = "0.1.0", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
hyper = "0.10"
|
||||
serde_json = "1.0"
|
||||
serde_test = "1.0"
|
||||
|
||||
|
|
|
@ -205,8 +205,8 @@ impl<'a, 'r> FromRequest<'a, 'r> for AccessControlRequestHeaders {
|
|||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use hyper;
|
||||
use rocket;
|
||||
use rocket::http::hyper;
|
||||
use rocket::local::Client;
|
||||
|
||||
use super::*;
|
||||
|
@ -313,7 +313,7 @@ mod tests {
|
|||
fn request_method_parsing() {
|
||||
let client = make_client();
|
||||
let mut request = client.get("/");
|
||||
let method = hyper::header::AccessControlRequestMethod(hyper::method::Method::Get);
|
||||
let method = hyper::header::AccessControlRequestMethod(hyper::Method::Get);
|
||||
request.add_header(method);
|
||||
let outcome: request::Outcome<AccessControlRequestMethod, crate::Error> =
|
||||
FromRequest::from_request(request.inner());
|
||||
|
|
17
src/lib.rs
17
src/lib.rs
|
@ -2018,6 +2018,7 @@ fn catch_all_options_route_handler<'r>(
|
|||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
||||
use rocket::http::hyper;
|
||||
use rocket::http::Header;
|
||||
use rocket::local::Client;
|
||||
#[cfg(feature = "serialization")]
|
||||
|
@ -2575,7 +2576,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -2610,7 +2611,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -2642,7 +2643,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -2690,7 +2691,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Post,
|
||||
hyper::Method::Post,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -2716,7 +2717,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers = hyper::header::AccessControlRequestHeaders(vec![
|
||||
FromStr::from_str("Authorization").unwrap(),
|
||||
|
@ -2802,7 +2803,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -2842,7 +2843,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -2882,7 +2883,7 @@ mod tests {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
//! This crate tests using `rocket_cors` using Fairings
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
use hyper;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use rocket::http::hyper;
|
||||
use rocket::http::Method;
|
||||
use rocket::http::{Header, Status};
|
||||
use rocket::local::Client;
|
||||
|
@ -49,7 +48,7 @@ fn smoke_test() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -90,7 +89,7 @@ fn cors_options_check() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -155,7 +154,7 @@ fn cors_options_bad_origin() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.bad-origin.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -178,7 +177,7 @@ fn cors_options_missing_origin() {
|
|||
let client = Client::new(rocket()).unwrap();
|
||||
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -206,7 +205,7 @@ fn cors_options_bad_request_method() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Post,
|
||||
hyper::Method::Post,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -234,7 +233,7 @@ fn cors_options_bad_request_header() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![FromStr::from_str("Foobar").unwrap()]);
|
||||
|
@ -280,7 +279,7 @@ fn routes_failing_checks_are_not_executed() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.bad-origin.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! This crate tests using `rocket_cors` using the per-route handling with request guard
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
use hyper;
|
||||
use rocket_cors as cors;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use rocket::http::hyper;
|
||||
use rocket::http::Method;
|
||||
use rocket::http::{Header, Status};
|
||||
use rocket::local::Client;
|
||||
|
@ -95,7 +95,7 @@ fn smoke_test() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -138,7 +138,7 @@ fn cors_options_catch_all_check() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -170,7 +170,7 @@ fn cors_options_catch_all_check_other_routes() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -242,7 +242,7 @@ fn cors_options_bad_origin() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.bad-origin.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -269,7 +269,7 @@ fn cors_options_missing_origin() {
|
|||
let client = Client::new(rocket).unwrap();
|
||||
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -297,7 +297,7 @@ fn cors_options_bad_request_method() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Post,
|
||||
hyper::Method::Post,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -326,7 +326,7 @@ fn cors_options_bad_request_header() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![FromStr::from_str("Foobar").unwrap()]);
|
||||
|
@ -394,7 +394,7 @@ fn overridden_options_routes_are_used() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
//! This crate tests that all the request headers are parsed correctly in the round trip
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
use hyper;
|
||||
|
||||
use std::ops::Deref;
|
||||
use std::str::FromStr;
|
||||
|
||||
use rocket::http::hyper;
|
||||
use rocket::http::Header;
|
||||
use rocket::local::Client;
|
||||
use rocket::response::Body;
|
||||
|
@ -36,7 +35,7 @@ fn request_headers_round_trip_smoke_test() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://foo.bar.xyz").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers = hyper::header::AccessControlRequestHeaders(vec![
|
||||
FromStr::from_str("accept-language").unwrap(),
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
//! This crate tests using `rocket_cors` using manual mode
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
use hyper;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use rocket::http::hyper;
|
||||
use rocket::http::Method;
|
||||
use rocket::http::{Header, Status};
|
||||
use rocket::local::Client;
|
||||
|
@ -105,7 +104,7 @@ fn smoke_test() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -146,7 +145,7 @@ fn cors_options_borrowed_check() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -211,7 +210,7 @@ fn cors_options_bad_origin() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.bad-origin.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -233,7 +232,7 @@ fn cors_options_missing_origin() {
|
|||
let client = Client::new(rocket()).unwrap();
|
||||
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -260,7 +259,7 @@ fn cors_options_bad_request_method() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Post,
|
||||
hyper::Method::Post,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -288,7 +287,7 @@ fn cors_options_bad_request_header() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![FromStr::from_str("Foobar").unwrap()]);
|
||||
|
@ -334,7 +333,7 @@ fn routes_failing_checks_are_not_executed() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.bad-origin.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -364,7 +363,7 @@ fn cors_options_owned_check() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
|
16
tests/mix.rs
16
tests/mix.rs
|
@ -3,11 +3,11 @@
|
|||
//! In this example, you typically have an application wide `Cors` struct except for one specific
|
||||
//! `ping` route that you want to allow all Origins to access.
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
use hyper;
|
||||
use rocket_cors;
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use rocket::http::hyper;
|
||||
use rocket::http::{Header, Method, Status};
|
||||
use rocket::local::Client;
|
||||
use rocket::response::Body;
|
||||
|
@ -76,7 +76,7 @@ fn smoke_test() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -117,7 +117,7 @@ fn cors_options_check() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -182,7 +182,7 @@ fn cors_options_bad_origin() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.bad-origin.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -204,7 +204,7 @@ fn cors_options_missing_origin() {
|
|||
let client = Client::new(rocket()).unwrap();
|
||||
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -231,7 +231,7 @@ fn cors_options_bad_request_method() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Post,
|
||||
hyper::Method::Post,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![
|
||||
|
@ -259,7 +259,7 @@ fn cors_options_bad_request_header() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.acme.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
let request_headers =
|
||||
hyper::header::AccessControlRequestHeaders(vec![FromStr::from_str("Foobar").unwrap()]);
|
||||
|
@ -303,7 +303,7 @@ fn cors_options_ping_check() {
|
|||
let origin_header =
|
||||
Header::from(hyper::header::Origin::from_str("https://www.example.com").unwrap());
|
||||
let method_header = Header::from(hyper::header::AccessControlRequestMethod(
|
||||
hyper::method::Method::Get,
|
||||
hyper::Method::Get,
|
||||
));
|
||||
|
||||
let req = client
|
||||
|
|
Loading…
Reference in New Issue