Files
imeai-aKode/akode-rs/core/tests/common/oauth.rs
andrea.difonzo 7c1c6dfa8d Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
  nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 12:37:52 +01:00

37 lines
1.2 KiB
Rust

//! Mock OAuth endpoints for device sign-in tests.
use serde_json::json;
use wiremock::Mock;
use wiremock::MockGuard;
use wiremock::MockServer;
use wiremock::ResponseTemplate;
use wiremock::matchers::body_string_contains;
use wiremock::matchers::method;
use wiremock::matchers::path;
/// Issues a challenge and answers one token poll. The guard lets a test wait for that poll.
pub async fn mount_device_code_grant(
server: &MockServer,
token_response: ResponseTemplate,
) -> MockGuard {
Mock::given(method("POST"))
.and(path("/devicecode"))
.respond_with(ResponseTemplate::new(200).set_body_json(json!({
"device_code": "secret-device-code", "user_code": "ABCD-EFGH",
"verification_uri": "https://login.example/device", "expires_in": 60, "interval": 1,
})))
.expect(1)
.mount(server)
.await;
Mock::given(method("POST"))
.and(path("/token"))
.and(body_string_contains(
"grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Adevice_code",
))
.and(body_string_contains("device_code=secret-device-code"))
.respond_with(token_response)
.expect(1)
.mount_as_scoped(server)
.await
}