From 85e341b0b0a26ce8fbc6725acf3935d4f747e7cf Mon Sep 17 00:00:00 2001 From: kevinpoitra Date: Wed, 8 Jan 2020 02:20:57 -0600 Subject: [PATCH] Fix the actix-http::cookie::do_not_panic_on_large_max_ages test --- actix-http/src/cookie/parse.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/actix-http/src/cookie/parse.rs b/actix-http/src/cookie/parse.rs index 58843ceea..0fb951b27 100644 --- a/actix-http/src/cookie/parse.rs +++ b/actix-http/src/cookie/parse.rs @@ -413,8 +413,9 @@ mod tests { #[test] fn do_not_panic_on_large_max_ages() { - let max_seconds = Duration::max_value().whole_seconds(); - let expected = Cookie::build("foo", "bar").max_age(max_seconds).finish(); - assert_eq_parse!(format!(" foo=bar; Max-Age={:?}", max_seconds + 1), expected); + let max_duration = Duration::max_value(); + let expected = Cookie::build("foo", "bar").max_age_time(max_duration).finish(); + let overflow_duration = max_duration.checked_add(Duration::nanoseconds(1)).unwrap_or(max_duration); + assert_eq_parse!(format!(" foo=bar; Max-Age={:?}", overflow_duration.whole_seconds()), expected); } }