aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
36
akode-rs/core/tests/common/oauth.rs
Normal file
36
akode-rs/core/tests/common/oauth.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
//! 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
|
||||
}
|
||||
Reference in New Issue
Block a user