fabro/test/twin/github/src/test_support.rs
Bryan Helmkamp 3b2cffceaf refactor(http): centralize reqwest behind fabro-http
Add the shared fabro-http transport crate and route hand-written HTTP client construction through it.

Use FABRO_HTTP_PROXY_POLICY for test no-proxy defaults, remove direct reqwest deps from ordinary crates, and add clippy bans for raw reqwest entrypoints.
2026-04-12 11:48:54 -04:00

36 lines
919 B
Rust

#[cfg(test)]
pub fn test_http_client() -> fabro_http::HttpClient {
fabro_http::test_http_client().unwrap()
}
#[cfg(test)]
pub fn test_rsa_private_key() -> &'static str {
include_str!("testdata/rsa_private.pem")
}
#[cfg(test)]
pub fn test_rsa_public_key() -> &'static str {
include_str!("testdata/rsa_public.pem")
}
#[cfg(test)]
pub fn sign_test_jwt(app_id: &str, private_key_pem: &str) -> String {
use jsonwebtoken::{Algorithm, EncodingKey, Header, encode};
use serde::Serialize;
#[derive(Serialize)]
struct Claims {
iss: String,
iat: i64,
exp: i64,
}
let now = chrono::Utc::now().timestamp();
let claims = Claims {
iss: app_id.to_string(),
iat: now - 60,
exp: now + 600,
};
let key = EncodingKey::from_rsa_pem(private_key_pem.as_bytes()).unwrap();
encode(&Header::new(Algorithm::RS256), &claims, &key).unwrap()
}