Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
schedule:
- cron: "0 6 * * 1"
pull_request:
branches: [master, dev]
branches: [master]
paths:
- "Cargo.toml"
- "deny.toml"
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "esi-openapi"
version = "0.3.0"
version = "0.3.1"
authors = ["Rafael <rafaga@users.noreply.github.com>", "Celeo <mattboulanger@fastmail.com>"]
edition = "2021"
description = "Rust API for EVE Online's ESI, based on the OpenAPI specification (fork of rfesi)"
Expand Down Expand Up @@ -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]
Expand Down
10 changes: 5 additions & 5 deletions src/jwt_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion tests/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions tests/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
Loading