mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-05 00:47:48 +08:00
test(oauth): make antigravity fixtures deterministic
This commit is contained in:
@@ -19,6 +19,24 @@ impl Default for AntigravityProviderOAuthAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AntigravityProviderOAuthAdapter {
|
||||||
|
/// Supply deterministic OAuth client credentials for tests without
|
||||||
|
/// requiring a process-wide environment variable. Production callers
|
||||||
|
/// continue to resolve the secret from the configured environment.
|
||||||
|
#[cfg(test)]
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn with_oauth_credentials_for_tests(
|
||||||
|
mut self,
|
||||||
|
client_id: impl Into<String>,
|
||||||
|
client_secret: impl Into<String>,
|
||||||
|
) -> Self {
|
||||||
|
self.inner = self
|
||||||
|
.inner
|
||||||
|
.with_oauth_credentials_for_tests(client_id, client_secret);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
impl ProviderOAuthAdapter for AntigravityProviderOAuthAdapter {
|
impl ProviderOAuthAdapter for AntigravityProviderOAuthAdapter {
|
||||||
fn provider_type(&self) -> &'static str {
|
fn provider_type(&self) -> &'static str {
|
||||||
@@ -150,7 +168,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn antigravity_authorize_requests_offline_refresh_token() {
|
fn antigravity_authorize_requests_offline_refresh_token() {
|
||||||
let adapter = AntigravityProviderOAuthAdapter::default();
|
let adapter = AntigravityProviderOAuthAdapter::default()
|
||||||
|
.with_oauth_credentials_for_tests("test-client-id", "test-client-secret");
|
||||||
let response = adapter
|
let response = adapter
|
||||||
.build_authorize_url(&transport_context(), "state-1", Some("challenge-1"))
|
.build_authorize_url(&transport_context(), "state-1", Some("challenge-1"))
|
||||||
.expect("authorize url should build");
|
.expect("authorize url should build");
|
||||||
|
|||||||
@@ -947,7 +947,12 @@ mod tests {
|
|||||||
hits: Arc::clone(&hits),
|
hits: Arc::clone(&hits),
|
||||||
};
|
};
|
||||||
let adapter = GenericOAuthRefreshAdapter::default()
|
let adapter = GenericOAuthRefreshAdapter::default()
|
||||||
.with_token_url_for_tests("antigravity", "https://oauth.example/token");
|
.with_token_url_for_tests("antigravity", "https://oauth.example/token")
|
||||||
|
.with_oauth_credentials_for_tests(
|
||||||
|
"antigravity",
|
||||||
|
"test-client-id",
|
||||||
|
"test-client-secret",
|
||||||
|
);
|
||||||
|
|
||||||
assert!(adapter.supports(&transport));
|
assert!(adapter.supports(&transport));
|
||||||
assert!(adapter.should_refresh(&transport, None));
|
assert!(adapter.should_refresh(&transport, None));
|
||||||
|
|||||||
Reference in New Issue
Block a user