From 0668dce5fce004001fcc857b326c08e636384b91 Mon Sep 17 00:00:00 2001 From: Rafael Amador Date: Thu, 19 Nov 2026 14:00:14 -0600 Subject: [PATCH 1/2] Use jiff instead of chrono in the tests; run CI only for master chrono was only a dev-dependency, used by the tests to build timestamps and durations. Replace it with jiff 1 (`Timestamp::now().as_second()`, `as_millisecond()`, `SignedDuration::from_mins`). No change to the public API. CI and security workflows: pull requests are checked only against master (the dev branch is no longer a target). --- .github/workflows/ci.yml | 2 +- .github/workflows/security.yml | 2 +- Cargo.toml | 2 +- src/jwt_util.rs | 10 +++++----- tests/errors.rs | 2 +- tests/oauth.rs | 6 +++--- tests/requests.rs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54a3f47..f10cb01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ name: CI # what a consumer of the crate gets. on: pull_request: - branches: [master, dev] + branches: [master] paths-ignore: - "**.md" push: diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index 941ea3b..18c72a7 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -7,7 +7,7 @@ on: schedule: - cron: "0 6 * * 1" pull_request: - branches: [master, dev] + branches: [master] paths: - "Cargo.toml" - "deny.toml" diff --git a/Cargo.toml b/Cargo.toml index f878407..e210329 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ dotenvy = "0.15" pretty_env_logger = "0.5" rusty-hook = "0.11" tokio = { version = "1.54", features = ["full"] } -chrono = "0.4" +jiff = { version = "1", default-features = false, features = ["std"] } uuid = { version = "1.29", features = ["v4", "fast-rng"] } [features] diff --git a/src/jwt_util.rs b/src/jwt_util.rs index c2ae243..ed40202 100644 --- a/src/jwt_util.rs +++ b/src/jwt_util.rs @@ -196,7 +196,7 @@ mod tests { fn test_jwt_validity_wrong_exp() { let header = Header::new(Algorithm::RS256); let (mut claim, client_id) = generate_valid_claims(); - claim.exp = (chrono::Utc::now() - chrono::Duration::minutes(5)).timestamp(); + claim.exp = (jiff::Timestamp::now() - jiff::SignedDuration::from_mins(5)).as_second(); let (private_key, public_key) = load_key(); let encoding_key = EncodingKey::from_rsa_pem(private_key.as_bytes()).unwrap(); @@ -239,13 +239,13 @@ mod tests { fn generate_valid_claims() -> (TokenClaims, String) { let client_id = String::from("client_id"); - let issued = chrono::Utc::now(); - let expiry = issued + chrono::Duration::minutes(5); + let issued = jiff::Timestamp::now(); + let expiry = issued + jiff::SignedDuration::from_mins(5); let claim = TokenClaims { aud: vec![client_id.clone(), "EVE Online".to_string()], azp: client_id.clone(), - exp: expiry.timestamp(), - iat: issued.timestamp(), + exp: expiry.as_second(), + iat: issued.as_second(), iss: "https://login.eveonline.com".to_string(), jti: uuid::Uuid::new_v4().to_string(), kid: "JWT-Signature-Key".to_string(), diff --git a/tests/errors.rs b/tests/errors.rs index 1ea0761..d6870be 100644 --- a/tests/errors.rs +++ b/tests/errors.rs @@ -32,7 +32,7 @@ impl Harness { /// A client that is signed in for another hour. fn signed_in(server: &Server) -> Esi { - let expiration = chrono::Utc::now().timestamp_millis() + 3_600_000; + let expiration = jiff::Timestamp::now().as_millisecond() + 3_600_000; Self::builder(server) .access_token(Some("the-token")) .access_expiration(Some(expiration)) diff --git a/tests/oauth.rs b/tests/oauth.rs index 167a1cc..f8c1e74 100644 --- a/tests/oauth.rs +++ b/tests/oauth.rs @@ -211,9 +211,9 @@ async fn refreshing_posts_the_form_with_basic_credentials_and_stores_the_answer( .refresh_token(Some("old-refresh")) .build() .unwrap(); - let before = chrono::Utc::now().timestamp_millis(); + let before = jiff::Timestamp::now().as_millisecond(); esi.refresh_access_token(None).await.unwrap(); - let after = chrono::Utc::now().timestamp_millis(); + let after = jiff::Timestamp::now().as_millisecond(); let request = server.only(); assert_eq!(request.method, "POST"); @@ -360,7 +360,7 @@ mod validated { impl Sso { /// The claims of an EVE SSO token; `expires_in` is seconds from now. fn claims(audience: &str, issuer: &str, expires_in: i64) -> serde_json::Value { - let now = chrono::Utc::now().timestamp(); + let now = jiff::Timestamp::now().as_second(); serde_json::json!({ "aud": [audience, "EVE Online"], "azp": audience, diff --git a/tests/requests.rs b/tests/requests.rs index 3c92955..140450b 100644 --- a/tests/requests.rs +++ b/tests/requests.rs @@ -28,7 +28,7 @@ impl Harness { /// A client that is signed in for another hour. fn signed_in(server: &Server) -> Esi { - let expiration = chrono::Utc::now().timestamp_millis() + 3_600_000; + let expiration = jiff::Timestamp::now().as_millisecond() + 3_600_000; Self::builder(server) .access_token(Some("the-token")) .access_expiration(Some(expiration)) @@ -149,7 +149,7 @@ async fn a_token_without_an_expiration_is_sent_and_does_not_panic() { #[tokio::test] async fn an_expired_token_never_reaches_the_server() { let server = Server::start(Reply::json("[]")).await; - let expired = chrono::Utc::now().timestamp_millis() - 1_000; + let expired = jiff::Timestamp::now().as_millisecond() - 1_000; let esi = Harness::builder(&server) .access_token(Some("old")) .access_expiration(Some(expired)) From 7cc44457915e309befef50cb4549c42fc33c9ebe Mon Sep 17 00:00:00 2001 From: Rafael Amador Date: Thu, 19 Nov 2026 14:06:41 -0600 Subject: [PATCH 2/2] bumping version to 0.3.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e210329..ff2cc36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "esi-openapi" -version = "0.3.0" +version = "0.3.1" authors = ["Rafael ", "Celeo "] edition = "2021" description = "Rust API for EVE Online's ESI, based on the OpenAPI specification (fork of rfesi)"