Skip to content

Commit

Permalink
update tests/ for new CookieStore trait
Browse files Browse the repository at this point in the history
  • Loading branch information
pfernie authored and seanmonstar committed Mar 4, 2021
1 parent 74947ec commit 1880f1b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ rustls-tls-native-roots = ["rustls-native-certs", "__rustls"]

blocking = ["futures-util/io", "tokio/rt-multi-thread", "tokio/sync"]

cookies = ["cookie_crate", "cookie_store", "time"]
cookies = ["cookie_crate", "time"]

gzip = ["async-compression", "async-compression/gzip", "tokio-util"]

Expand Down Expand Up @@ -117,7 +117,7 @@ rustls-native-certs = { version = "0.5", optional = true }

## cookies
cookie_crate = { version = "0.14", package = "cookie", optional = true }
cookie_store = { version = "0.12", optional = true }

time = { version = "0.2.11", optional = true }

## compression
Expand Down
14 changes: 9 additions & 5 deletions tests/cookie.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use std::sync::Arc;

mod support;
use support::*;

use cookie_store::CookieStoreMutex as CookieStore;

#[tokio::test]
async fn cookie_response_accessor() {
let server = server::http(move |_req| async move {
Expand Down Expand Up @@ -84,7 +88,7 @@ async fn cookie_store_simple() {
});

let client = reqwest::Client::builder()
.cookie_store(true)
.cookie_store(Some(Arc::new(CookieStore::default())))
.build()
.unwrap();

Expand Down Expand Up @@ -117,7 +121,7 @@ async fn cookie_store_overwrite_existing() {
});

let client = reqwest::Client::builder()
.cookie_store(true)
.cookie_store(Some(Arc::new(CookieStore::default())))
.build()
.unwrap();

Expand All @@ -142,7 +146,7 @@ async fn cookie_store_max_age() {
});

let client = reqwest::Client::builder()
.cookie_store(true)
.cookie_store(Some(Arc::new(CookieStore::default())))
.build()
.unwrap();
let url = format!("http://{}/", server.addr());
Expand All @@ -164,7 +168,7 @@ async fn cookie_store_expires() {
});

let client = reqwest::Client::builder()
.cookie_store(true)
.cookie_store(Some(Arc::new(CookieStore::default())))
.build()
.unwrap();

Expand All @@ -190,7 +194,7 @@ async fn cookie_store_path() {
});

let client = reqwest::Client::builder()
.cookie_store(true)
.cookie_store(Some(Arc::new(CookieStore::default())))
.build()
.unwrap();

Expand Down
8 changes: 6 additions & 2 deletions tests/redirect.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#![cfg(not(target_arch = "wasm32"))]
use std::sync::Arc;

mod support;
use futures_util::stream::StreamExt;
use support::*;

use cookie_store::CookieStoreMutex as CookieStore;

#[tokio::test]
async fn test_redirect_301_and_302_and_303_changes_post_to_get() {
let client = reqwest::Client::new();
Expand Down Expand Up @@ -292,7 +296,7 @@ async fn test_redirect_302_with_set_cookies() {
let server = server::http(move |req| async move {
if req.uri() == "/302" {
http::Response::builder()
.status(302)
.status(code)
.header("location", "/dst")
.header("set-cookie", "key=value")
.body(Default::default())
Expand All @@ -308,7 +312,7 @@ async fn test_redirect_302_with_set_cookies() {
let dst = format!("http://{}/{}", server.addr(), "dst");

let client = reqwest::ClientBuilder::new()
.cookie_store(true)
.cookie_store(Some(Arc::new(CookieStore::default())))
.build()
.unwrap();
let res = client.get(&url).send().await.unwrap();
Expand Down

0 comments on commit 1880f1b

Please sign in to comment.