Skip to content

Commit

Permalink
Remove use of deprecated chrono functions
Browse files Browse the repository at this point in the history
  • Loading branch information
robalar committed Oct 30, 2024
1 parent bcda546 commit 21c6752
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/reqwest_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ mod tests {
.header(CONTENT_TYPE, "application/json")
.header(
DATE,
Utc.ymd(2014, 7, 8)
.and_hms(9, 10, 11)
Utc.with_ymd_and_hms(2014, 7, 8, 9, 10, 11)
.single()
.expect("valid date")
.format("%a, %d %b %Y %T GMT")
.to_string(),
)
Expand Down Expand Up @@ -124,8 +125,9 @@ mod tests {
.header(CONTENT_TYPE, "application/json")
.header(
DATE,
Utc.ymd(2014, 7, 8)
.and_hms(9, 10, 11)
Utc.with_ymd_and_hms(2014, 7, 8, 9, 10, 11)
.single()
.expect("valid date")
.format("%a, %d %b %Y %T GMT")
.to_string(),
)
Expand Down
11 changes: 5 additions & 6 deletions src/rouille_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,13 @@ mod tests {
vec![
("Host".into(), "test.com".into()),
("ContentType".into(), "application/json".into()),
("Date".into(), Utc.ymd(2014, 7, 8)
.and_hms(9, 10, 11)
("Date".into(), Utc.with_ymd_and_hms(2014, 7, 8, 9, 10, 11).single().expect("valid date")
.format("%a, %d %b %Y %T GMT")
.to_string()),
("Digest".into(), "SHA-256=2vgEVkfe4d6VW+tSWAziO7BUx7uT/rA9hn1EoxUJi2o=".into()),
("Authorization".into(), "Signature keyId=\"test_key\",algorithm=\"hmac-sha256\",signature=\"uH2I9FSuCGUrIEygs7hR29oz0Afkz0bZyHpz6cW/mLQ=\",headers=\"(request-target) date digest host".into()),
],
br#"{ "x": 1, "y": 2}"#[..].into()
br#"{ "x": 1, "y": 2}"#[..].into(),
);

request.verify(&config).unwrap();
Expand All @@ -129,13 +128,13 @@ mod tests {
"GET",
"/foo/bar",
vec![
("Date".into(), Utc.ymd(2014, 7, 8)
.and_hms(9, 10, 11)
("Date".into(), Utc.with_ymd_and_hms(2014, 7, 8,
9, 10, 11).single().expect("valid date")
.format("%a, %d %b %Y %T GMT")
.to_string()),
("Authorization".into(), "Signature keyId=\"test_key\",algorithm=\"hmac-sha256\",signature=\"sGQ3hA9KB40CU1pHbRLXLvLdUWYn+c3fcfL+Sw8kIZE=\",headers=\"(request-target) date".into()),
],
Vec::new()
Vec::new(),
);

request.verify(&config).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/verifying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ fn verify_except_digest<T: ServerRequestLike>(
})?;

// Then parse into a datetime
let provided_date = DateTime::<Utc>::from_utc(
let provided_date = DateTime::<Utc>::from_naive_utc_and_offset(
NaiveDateTime::parse_from_str(date_value, DATE_FORMAT)
.ok()
.or_else(|| {
Expand Down

0 comments on commit 21c6752

Please sign in to comment.