Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jun 22, 2023
1 parent 17108a6 commit 1270f0c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions ntex-cors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ where

#[cfg(test)]
mod tests {
use ntex::service::{fn_service, Container, Middleware};
use ntex::service::{fn_service, Middleware, Pipeline};
use ntex::web::{self, test, test::TestRequest};

use super::*;
Expand Down Expand Up @@ -821,7 +821,7 @@ mod tests {

#[ntex::test]
async fn test_preflight() {
let mut cors: Container<_> = Cors::new()
let mut cors: Pipeline<_> = Cors::new()

Check warning on line 824 in ntex-cors/src/lib.rs

View workflow job for this annotation

GitHub Actions / stable - x86_64-apple-darwin

variable does not need to be mutable

Check warning on line 824 in ntex-cors/src/lib.rs

View workflow job for this annotation

GitHub Actions / nightly - x86_64-apple-darwin

variable does not need to be mutable

Check warning on line 824 in ntex-cors/src/lib.rs

View workflow job for this annotation

GitHub Actions / nightly - x86_64-pc-windows-msvc

variable does not need to be mutable

Check warning on line 824 in ntex-cors/src/lib.rs

View workflow job for this annotation

GitHub Actions / stable - x86_64-pc-windows-msvc

variable does not need to be mutable
.send_wildcard()
.max_age(3600)
.allowed_methods(vec![Method::GET, Method::OPTIONS, Method::POST])
Expand All @@ -836,8 +836,8 @@ mod tests {
.header(header::ACCESS_CONTROL_REQUEST_HEADERS, "X-Not-Allowed")
.to_srv_request();

assert!(cors.inner.validate_allowed_method(req.head()).is_err());
assert!(cors.inner.validate_allowed_headers(req.head()).is_err());
assert!(cors.get_ref().inner.validate_allowed_method(req.head()).is_err());
assert!(cors.get_ref().inner.validate_allowed_headers(req.head()).is_err());
let resp = test::call_service(&cors, req).await;
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);

Expand All @@ -846,8 +846,8 @@ mod tests {
.method(Method::OPTIONS)
.to_srv_request();

assert!(cors.inner.validate_allowed_method(req.head()).is_err());
assert!(cors.inner.validate_allowed_headers(req.head()).is_ok());
assert!(cors.get_ref().inner.validate_allowed_method(req.head()).is_err());
assert!(cors.get_ref().inner.validate_allowed_headers(req.head()).is_ok());

let req = TestRequest::with_header("Origin", "https://www.example.com")
.header(header::ACCESS_CONTROL_REQUEST_METHOD, "POST")
Expand Down Expand Up @@ -905,7 +905,7 @@ mod tests {
#[ntex::test]
#[should_panic(expected = "OriginNotAllowed")]
async fn test_validate_not_allowed_origin() {
let cors: Container<_> = Cors::new()
let cors: Pipeline<_> = Cors::new()
.allowed_origin("https://www.example.com")
.finish()
.create(test::ok_service::<web::DefaultError>())
Expand All @@ -914,9 +914,9 @@ mod tests {
let req = TestRequest::with_header("Origin", "https://www.unknown.com")
.method(Method::GET)
.to_srv_request();
cors.inner.validate_origin(req.head()).unwrap();
cors.inner.validate_allowed_method(req.head()).unwrap();
cors.inner.validate_allowed_headers(req.head()).unwrap();
cors.get_ref().inner.validate_origin(req.head()).unwrap();
cors.get_ref().inner.validate_allowed_method(req.head()).unwrap();
cors.get_ref().inner.validate_allowed_headers(req.head()).unwrap();
}

#[ntex::test]
Expand Down
2 changes: 1 addition & 1 deletion ntex-files/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ mod tests {
.default_handler(|req: WebRequest<DefaultError>| {
ok(req.into_response(HttpResponse::Ok().body("default content")))
})
.container(())
.pipeline(())
.await
.unwrap();
let req = TestRequest::with_uri("/missing").to_srv_request();
Expand Down
6 changes: 3 additions & 3 deletions ntex-identity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ mod tests {
use super::*;
use ntex::web::test::{self, TestRequest};
use ntex::web::{self, error, App, Error, HttpResponse};
use ntex::{http::StatusCode, service::into_service, service::Container, time};
use ntex::{http::StatusCode, service::into_service, service::Pipeline, time};

const COOKIE_KEY_MASTER: [u8; 32] = [0; 32];
const COOKIE_NAME: &str = "ntex_auth";
Expand Down Expand Up @@ -700,7 +700,7 @@ mod tests {
F: Fn(CookieIdentityPolicy) -> CookieIdentityPolicy + Sync + Send + Clone + 'static,
>(
f: F,
) -> Container<
) -> Pipeline<
impl ntex::service::Service<ntex::http::Request, Response = WebResponse, Error = Error>,
> {
test::init_service(
Expand Down Expand Up @@ -1007,7 +1007,7 @@ mod tests {
}
}

let srv: Container<_> = IdentityServiceMiddleware {
let srv: Pipeline<_> = IdentityServiceMiddleware {
backend: Rc::new(Ident),
service: into_service(|_: WebRequest<DefaultError>| async move {
time::sleep(time::Seconds(100)).await;
Expand Down

0 comments on commit 1270f0c

Please sign in to comment.