mirror of https://github.com/fafhrd91/actix-web
feat: replate time::Duration with chrono::Duration
This commit is contained in:
parent
aa255298ef
commit
e8217c99cb
|
@ -15,6 +15,9 @@ license = "MIT/Apache-2.0"
|
||||||
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
|
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
features = ["ssl", "brotli", "flate2-zlib", "secure-cookies", "client", "rust-tls"]
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
travis-ci = { repository = "actix/actix-web", branch = "master" }
|
travis-ci = { repository = "actix/actix-web", branch = "master" }
|
||||||
codecov = { repository = "actix/actix-web", branch = "master", service = "github" }
|
codecov = { repository = "actix/actix-web", branch = "master", service = "github" }
|
||||||
|
@ -37,9 +40,6 @@ members = [
|
||||||
"test-server",
|
"test-server",
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
|
||||||
features = ["ssl", "brotli", "flate2-zlib", "secure-cookies", "client", "rust-tls"]
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["brotli", "flate2-zlib", "secure-cookies", "client"]
|
default = ["brotli", "flate2-zlib", "secure-cookies", "client"]
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ url = { version="1.7", features=["query_encoding"] }
|
||||||
# ssl support
|
# ssl support
|
||||||
openssl = { version="0.10", optional = true }
|
openssl = { version="0.10", optional = true }
|
||||||
rustls = { version = "^0.15", optional = true }
|
rustls = { version = "^0.15", optional = true }
|
||||||
|
chrono = "0.4.6"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-http = { version = "0.1.0", features=["ssl", "brotli", "flate2-zlib"] }
|
actix-http = { version = "0.1.0", features=["ssl", "brotli", "flate2-zlib"] }
|
||||||
|
|
|
@ -53,7 +53,7 @@ use std::rc::Rc;
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use futures::future::{ok, Either, FutureResult};
|
use futures::future::{ok, Either, FutureResult};
|
||||||
use futures::{Future, IntoFuture, Poll};
|
use futures::{Future, IntoFuture, Poll};
|
||||||
use time::Duration;
|
use chrono::Duration;
|
||||||
|
|
||||||
use crate::cookie::{Cookie, CookieJar, Key, SameSite};
|
use crate::cookie::{Cookie, CookieJar, Key, SameSite};
|
||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
|
@ -525,4 +525,29 @@ mod tests {
|
||||||
assert_eq!(resp.status(), StatusCode::OK);
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
assert!(resp.headers().contains_key(header::SET_COOKIE))
|
assert!(resp.headers().contains_key(header::SET_COOKIE))
|
||||||
}
|
}
|
||||||
|
#[test]
|
||||||
|
fn test_identity_max_age() {
|
||||||
|
let duration = Duration::days(1);
|
||||||
|
let mut srv = test::init_service(
|
||||||
|
App::new()
|
||||||
|
.wrap(IdentityService::new(
|
||||||
|
CookieIdentityPolicy::new(&[0; 32])
|
||||||
|
.domain("www.rust-lang.org")
|
||||||
|
.name("actix_auth")
|
||||||
|
.path("/")
|
||||||
|
.max_age(duration)
|
||||||
|
.secure(true),
|
||||||
|
))
|
||||||
|
.service(web::resource("/login").to(|id: Identity| {
|
||||||
|
id.remember("test".to_string());
|
||||||
|
HttpResponse::Ok()
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
let resp =
|
||||||
|
test::call_service(&mut srv, TestRequest::with_uri("/login").to_request());
|
||||||
|
assert_eq!(resp.status(), StatusCode::OK);
|
||||||
|
assert!(resp.headers().contains_key(header::SET_COOKIE));
|
||||||
|
let c = resp.response().cookies().next().unwrap().to_owned();
|
||||||
|
assert_eq!(duration, c.max_age().unwrap());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue