Rocket/core/lib/tests/session-cookies-issue-1506.rs
Sergio Benitez 83ffe0f7bc Remove 'Config::profile()'. CFG 'secret_key' field.
This commit makes the `Config.secret_key` conditionally compile on the
`secrets` feature. The net effect is simplified internal code, fewer
corner-cases, and easier to write tests.

This commit removes the `Provider::profile()` implementation of
`Config`. This means that the `Config` provider no longer sets a
profile, a likely confusing behavior. The `Config::figment()` continues
to function as before.
2021-03-09 21:40:53 -08:00

25 lines
688 B
Rust

#![cfg(feature = "secrets")]
use rocket::http::{CookieJar, Cookie};
#[rocket::get("/")]
fn index(jar: &CookieJar<'_>) {
let session_cookie = Cookie::build("key", "value").expires(None);
jar.add_private(session_cookie.finish());
}
mod test_session_cookies {
use super::*;
use rocket::local::blocking::Client;
#[test]
fn session_cookie_is_session() {
let rocket = rocket::ignite().mount("/", rocket::routes![index]);
let client = Client::tracked(rocket).unwrap();
let response = client.get("/").dispatch();
let cookie = response.cookies().get_private("key").unwrap();
assert_eq!(cookie.expires_datetime(), None);
}
}