use std::time::Duration;
use chrono::Utc;
use mockito::{Server, ServerGuard};
use crate::config::Config;
use crate::model::oauth2::EveJwtClaims;
use crate::Client;
pub(crate) async fn setup() -> (Client, ServerGuard) {
let mock_server = Server::new_async().await;
let mock_server_url = mock_server.url();
let config = Config::builder()
.jwk_url(&format!("{}/oauth/jwks", mock_server_url))
.jwk_refresh_backoff(Duration::from_millis(1))
.jwk_refresh_timeout(Duration::from_secs(1))
.build()
.expect("Failed to build Config");
let esi_client = Client::builder()
.user_agent("MyApp/1.0 (contact@example.com)")
.config(config)
.build()
.expect("Failed to build Client");
(esi_client, mock_server)
}
pub fn create_mock_jwt_claims() -> EveJwtClaims {
let expires_in_fifteen_minutes = Utc::now() + chrono::Duration::seconds(900);
let created_now = Utc::now();
EveJwtClaims {
iss: "https://login.eveonline.com".to_string(),
sub: "CHARACTER:EVE:123456789".to_string(),
aud: vec!["client_id".to_string(), "EVE Online".to_string()],
jti: "abc123def456".to_string(),
kid: "JWT-Signature-Key-1".to_string(),
tenant: "tranquility".to_string(),
region: "world".to_string(),
exp: expires_in_fifteen_minutes,
iat: created_now,
scp: vec![],
name: "Test Character".to_string(),
owner: "123456789".to_string(),
azp: "client_id".to_string(),
}
}