Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(credentials): add tests for credential and session operations

Steven Enamakelc07880bbf015
diff --git a/crates/openhuman-core/src/security/credentials/ops_session_tests.rs b/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs
similarity index 50%
rename from crates/openhuman-core/src/security/credentials/ops_session_tests.rs
rename to crates/openhuman-core/src/security/credentials/ops_credential_tests.rs
index d6e357b3bb..fd5ee74b78 100644
--- a/crates/openhuman-core/src/security/credentials/ops_session_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs
@@ -38,10 +38,10 @@ async fn decrypt_secret_round_trips_noise_through_migrate_path() {
);
}
-// ── store_session (input validation) ──────────────────────────
+// ── set_credential (input validation) ─────────────────────────
#[tokio::test]
-async fn store_session_rejects_empty_or_whitespace_token() {
+async fn set_credential_rejects_empty_or_whitespace_token() {
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
let err = store_session(&config, "", None, None).await.unwrap_err();
@@ -50,70 +50,55 @@ async fn store_session_rejects_empty_or_whitespace_token() {
assert!(err.contains("token is required"));
}
-#[test]
-fn sanitize_stored_session_user_discards_empty_objects() {
- assert_eq!(sanitize_stored_session_user(Some(json!({}))), None);
- assert_eq!(
- sanitize_stored_session_user(Some(serde_json::Value::Null)),
- None
- );
- assert_eq!(
- sanitize_stored_session_user(Some(json!({ "firstName": "steven" }))),
- Some(json!({ "firstName": "steven" }))
- );
+#[tokio::test]
+async fn set_credential_rejects_unknown_kind() {
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp);
+ let err = set_credential(
+ &config,
+ SetCredentialRequest {
+ token: "x".into(),
+ kind: Some("jwt".into()),
+ ..Default::default()
+ },
+ )
+ .await
+ .unwrap_err();
+ assert!(err.contains("unknown credential kind"), "{err}");
}
-#[test]
-fn auth_me_store_failure_classifier_only_accepts_transient_shapes() {
- assert!(auth_me_store_failure_is_transient(
- "GET /auth/me failed (503 Service Unavailable): overloaded"
- ));
- assert!(auth_me_store_failure_is_transient(
- "GET /auth/me failed (503 Service Unavailable): session timeout"
- ));
- assert!(auth_me_store_failure_is_transient(
- "GET /auth/me: error sending request for url"
- ));
- assert!(!auth_me_store_failure_is_transient(
- "GET /auth/me failed (401 Unauthorized): bad token"
- ));
- assert!(!auth_me_store_failure_is_transient(
- "GET /auth/me failed (401 Unauthorized): session timeout"
- ));
- assert!(!auth_me_store_failure_is_transient(
- "GET /auth/me failed (403 Forbidden): connection reset"
- ));
+#[tokio::test]
+async fn set_credential_rejects_an_expired_jwt_without_storing() {
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp);
+ let token = jwt_with_payload(json!({
+ "sub": "user-1",
+ "exp": (chrono::Utc::now() - chrono::Duration::hours(1)).timestamp()
+ }));
+ let err = store_session(&config, &token, None, None).await.unwrap_err();
+ assert!(err.starts_with("CREDENTIAL_EXPIRED:"), "{err}");
+ assert!(auth_get_state(&config).await.unwrap().value.user_id.is_none());
}
#[tokio::test]
-async fn store_session_rejects_live_jwt_when_auth_me_transient() {
- let _env_guard = crate::config::TEST_ENV_LOCK
- .lock()
- .unwrap_or_else(|e| e.into_inner());
+async fn set_credential_requires_a_user_id_for_a_session() {
let tmp = TempDir::new().unwrap();
- std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();
- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());
- let mut config = test_config(&tmp);
- config.api_url = Some(spawn_auth_me_status(StatusCode::SERVICE_UNAVAILABLE).await);
+ let config = test_config(&tmp);
let token = jwt_with_payload(json!({
"exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
}));
-
- let err = store_session(&config, &token, None, Some(json!({})))
+ let err = store_session(&config, &token, None, None).await.unwrap_err();
+ assert!(err.contains("userId required"), "{err}");
+ let err = store_session(&config, "opaque-token", None, Some(json!({ "name": "no id" })))
.await
.unwrap_err();
-
- assert!(
- err.contains("Session validation failed (GET /auth/me)"),
- "expected auth/me validation error, got: {err}"
- );
- let state = auth_get_state(&config).await.unwrap().value;
- assert!(!state.is_authenticated);
- assert!(state.user.is_none());
+ assert!(err.contains("userId required"), "{err}");
}
+// ── set_credential (session) ──────────────────────────────────
+
#[tokio::test]
-async fn store_session_rejects_supplied_user_when_auth_me_transient() {
+async fn set_credential_installs_a_session_without_touching_the_backend() {
let _env_guard = crate::config::TEST_ENV_LOCK
.lock()
.unwrap_or_else(|e| e.into_inner());
@@ -121,270 +106,198 @@ async fn store_session_rejects_supplied_user_when_auth_me_transient() {
std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();
let _home = EnvVarGuard::set_to_path("HOME", tmp.path());
let mut config = test_config(&tmp);
- config.api_url = Some(spawn_auth_me_status(StatusCode::SERVICE_UNAVAILABLE).await);
- let token = jwt_with_payload(json!({
- "exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
- }));
+ // A backend that would reject everything: it must never be consulted.
+ config.api_url = Some(spawn_auth_me_status(StatusCode::UNAUTHORIZED).await);
+ let exp = chrono::Utc::now() + chrono::Duration::hours(1);
+ let token = jwt_with_payload(json!({ "sub": "user-42", "exp": exp.timestamp() }));
- let err = store_session(
+ let result = store_session(
&config,
&token,
None,
- Some(json!({
- "name": "Callback User",
- "email": "[email protected]"
- })),
+ Some(json!({ "id": "user-42", "email": "[email protected]" })),
)
.await
- .unwrap_err();
+ .unwrap();
- assert!(
- err.contains("Session validation failed (GET /auth/me)"),
- "expected auth/me validation error, got: {err}"
+ let state = result.value;
+ assert!(state.is_authenticated);
+ assert_eq!(state.user_id.as_deref(), Some("user-42"));
+ assert_eq!(state.credential.as_deref(), Some("session"));
+ assert_eq!(state.user.unwrap()["email"], "[email protected]");
+ assert!(state.expires_at.is_some(), "JWT exp is recorded for the local precheck");
+ let logs = result.logs.join(" ");
+ assert!(logs.contains("user directory activated for user-42"), "{logs}");
+ assert!(logs.contains("session credential stored"), "{logs}");
+ assert_eq!(
+ crate::config::read_active_user_id(&default_root_openhuman_dir().unwrap()).as_deref(),
+ Some("user-42")
+ );
+ assert_eq!(
+ identity::peek_credential_user_identity().and_then(|i| i.email).as_deref(),
);
- let state = auth_get_state(&config).await.unwrap().value;
- assert!(!state.is_authenticated);
- assert!(state.user.is_none());
}
#[tokio::test]
-async fn store_session_rejects_non_object_user_when_auth_me_transient() {
+async fn set_credential_derives_the_user_id_from_the_jwt_subject() {
let _env_guard = crate::config::TEST_ENV_LOCK
.lock()
.unwrap_or_else(|e| e.into_inner());
let tmp = TempDir::new().unwrap();
std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();
let _home = EnvVarGuard::set_to_path("HOME", tmp.path());
- let mut config = test_config(&tmp);
- config.api_url = Some(spawn_auth_me_status(StatusCode::SERVICE_UNAVAILABLE).await);
+ let config = test_config(&tmp);
let token = jwt_with_payload(json!({
+ "sub": "from-claims",
"exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
}));
-
- let err = store_session(&config, &token, None, Some(json!("callback-user")))
+ let state = store_session(&config, &token, None, None).await.unwrap().value;
+ assert_eq!(state.user_id.as_deref(), Some("from-claims"));
+ // Explicit userId wins over the claim; the user payload's id wins over
+ // the claim too.
+ let state = store_session(&config, &token, Some("explicit".into()), None)
.await
- .unwrap_err();
-
- assert!(
- err.contains("Session validation failed (GET /auth/me)"),
- "expected auth/me validation error, got: {err}"
- );
- let state = auth_get_state(&config).await.unwrap().value;
- assert!(!state.is_authenticated);
- assert!(state.user.is_none());
+ .unwrap()
+ .value;
+ assert_eq!(state.user_id.as_deref(), Some("explicit"));
}
#[tokio::test]
-async fn store_session_defers_minimal_live_jwt_when_auth_me_transient_and_allowed() {
+async fn set_credential_with_the_same_token_and_user_is_a_cheap_refresh() {
let _env_guard = crate::config::TEST_ENV_LOCK
.lock()
.unwrap_or_else(|e| e.into_inner());
let tmp = TempDir::new().unwrap();
std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();
let _home = EnvVarGuard::set_to_path("HOME", tmp.path());
- let mut config = test_config(&tmp);
- config.api_url = Some(spawn_auth_me_status(StatusCode::SERVICE_UNAVAILABLE).await);
+ let config = test_config(&tmp);
let token = jwt_with_payload(json!({
- "sub": "unverified-jwt-user",
- "email": "[email protected]",
- "name": "Unverified JWT User",
+ "sub": "user-7",
"exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
}));
-
- let result = store_session_with_deferred_validation(
+ let first = store_session(
&config,
&token,
None,
- Some(json!({
- "id": "supplied-callback-user",
- "name": "Supplied Callback User"
- })),
+ Some(json!({ "id": "user-7", "pendingBackendValidation": true })),
)
.await
.unwrap();
+ assert!(first.logs.join(" ").contains("user directory activated"));
- assert!(result.value.has_token);
- let log_text = result.logs.join(" ");
- assert!(
- log_text.contains("session JWT accepted with deferred GET /auth/me validation"),
- "expected deferred validation log, got: {log_text}"
- );
- let state = auth_get_state(&config).await.unwrap().value;
- assert!(state.is_authenticated);
- assert_eq!(
- state.user,
- Some(json!({ "pendingBackendValidation": true })),
- "deferred fallback must not copy identity claims from an unverified JWT or callback payload"
- );
+ // The host's `/auth/me` answer arrives: same token, same user.
+ let user_config = crate::config::load_config_with_timeout().await.unwrap();
+ let second = store_session(
+ &user_config,
+ &token,
+ None,
+ Some(json!({ "id": "user-7", "name": "Confirmed" })),
+ )
+ .await
+ .unwrap();
+ let logs = second.logs.join(" ");
+ assert!(logs.contains("credential refreshed"), "{logs}");
+ assert!(!logs.contains("user directory activated"), "{logs}");
+ assert!(!logs.contains("credential-gated services started"), "{logs}");
+ let user = second.value.user.unwrap();
+ assert_eq!(user["name"], "Confirmed");
+ assert!(user.get("pendingBackendValidation").is_none());
}
#[tokio::test]
-async fn store_session_defers_live_jwt_when_auth_me_hangs_past_budget() {
- // Issue #5166: a reachable-but-slow backend must not hang store-time
- // validation until the desktop sign-in RPC times out. Capping the budget
- // makes the hang fail fast (as transient) into the deferred-validation path
- // so a live-`exp` JWT still persists instead of bouncing the user.
+async fn set_credential_for_a_different_user_signs_the_previous_one_out_first() {
let _env_guard = crate::config::TEST_ENV_LOCK
.lock()
.unwrap_or_else(|e| e.into_inner());
- let _budget = EnvVarGuard::set(AUTH_ME_STORE_VALIDATION_BUDGET_ENV, "200");
let tmp = TempDir::new().unwrap();
std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();
let _home = EnvVarGuard::set_to_path("HOME", tmp.path());
- let mut config = test_config(&tmp);
- config.api_url = Some(spawn_auth_me_hang().await);
- let token = jwt_with_payload(json!({
- "sub": "unverified-jwt-user",
- "email": "[email protected]",
- "name": "Unverified JWT User",
- "exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
- }));
-
- let started = std::time::Instant::now();
- let result = store_session_with_deferred_validation(&config, &token, None, Some(json!({})))
+ let config = test_config(&tmp);
+ let exp = (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp();
+ store_session(&config, &jwt_with_payload(json!({ "sub": "alice", "exp": exp })), None, None)
.await
.unwrap();
- // The 200ms budget must cap the 60s hang — proves the timeout fired rather
- // than the store awaiting the backend. Bound safely above the 200ms budget
- // but below the 12s default so a multi-second regression still fails.
- assert!(
- started.elapsed() < std::time::Duration::from_secs(2),
- "store-time validation should be capped by the budget, took {:?}",
- started.elapsed()
- );
-
- assert!(result.value.has_token);
- let log_text = result.logs.join(" ");
- assert!(
- log_text.contains("session JWT accepted with deferred GET /auth/me validation"),
- "expected deferred validation log after budget timeout, got: {log_text}"
- );
- let state = auth_get_state(&config).await.unwrap().value;
- assert!(state.is_authenticated);
+ let alice_config = crate::config::load_config_with_timeout().await.unwrap();
+ let result = store_session(
+ &alice_config,
+ &jwt_with_payload(json!({ "sub": "bob", "exp": exp })),
+ None,
+ None,
+ )
+ .await
+ .unwrap();
+ let logs = result.logs.join(" ");
+ assert!(logs.contains("session cleared"), "{logs}");
+ assert!(logs.contains("user directory activated for bob"), "{logs}");
+ assert_eq!(result.value.user_id.as_deref(), Some("bob"));
assert_eq!(
- state.user,
- Some(json!({ "pendingBackendValidation": true })),
- "budget-timeout fallback must not copy identity claims from an unverified JWT"
+ crate::config::read_active_user_id(&default_root_openhuman_dir().unwrap()).as_deref(),
+ Some("bob")
);
+ // Alice's profile is gone from her scope.
+ assert!(auth_get_state(&alice_config).await.unwrap().value.user_id.is_none());
}
-#[test]
-fn auth_me_store_validation_budget_reads_env_override() {
- let _env_guard = crate::config::TEST_ENV_LOCK
- .lock()
- .unwrap_or_else(|e| e.into_inner());
- {
- let _guard = EnvVarGuard::set(AUTH_ME_STORE_VALIDATION_BUDGET_ENV, "750");
- assert_eq!(
- auth_me_store_validation_budget(),
- std::time::Duration::from_millis(750)
- );
- }
- // Invalid / non-positive overrides fall back to the compiled default.
- {
- let _guard = EnvVarGuard::set(AUTH_ME_STORE_VALIDATION_BUDGET_ENV, "0");
- assert_eq!(
- auth_me_store_validation_budget(),
- AUTH_ME_STORE_VALIDATION_BUDGET
- );
- }
- {
- let _guard = EnvVarGuard::set(AUTH_ME_STORE_VALIDATION_BUDGET_ENV, "not-a-number");
- assert_eq!(
- auth_me_store_validation_budget(),
- AUTH_ME_STORE_VALIDATION_BUDGET
- );
- }
-}
+// ── set_credential (api key) ──────────────────────────────────
#[tokio::test]
-async fn deferred_session_without_user_id_does_not_replace_active_user_profile() {
- let _env_guard = crate::config::TEST_ENV_LOCK
- .lock()
- .unwrap_or_else(|e| e.into_inner());
+async fn set_and_clear_api_key_credential() {
let tmp = TempDir::new().unwrap();
- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());
- let root_dir = default_root_openhuman_dir().unwrap();
- let active_user_id = "existing-active-user";
- write_active_user_id(&root_dir, active_user_id).unwrap();
- let active_user_dir = user_openhuman_dir(&root_dir, active_user_id);
- std::fs::create_dir_all(active_user_dir.join("workspace")).unwrap();
- let mut config = Config {
- config_path: active_user_dir.join("config.toml"),
- workspace_dir: active_user_dir.join("workspace"),
- action_dir: active_user_dir.join("workspace"),
- ..Config::default()
- };
- config.api_url = Some(spawn_auth_me_status(StatusCode::SERVICE_UNAVAILABLE).await);
- let mut metadata = std::collections::HashMap::new();
- metadata.insert("user_id".to_string(), active_user_id.to_string());
- metadata.insert(
- "user_json".to_string(),
- json!({
- "id": active_user_id,
- "name": "Existing Active User"
- })
- .to_string(),
- );
- AuthService::from_config(&config)
- .store_provider_token(
- APP_SESSION_PROVIDER,
- DEFAULT_AUTH_PROFILE_NAME,
- "existing.active.session",
- metadata,
- true,
- )
- .unwrap();
- let pending_token = jwt_with_payload(json!({
- "exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
- }));
-
- let err =
- store_session_with_deferred_validation(&config, &pending_token, None, Some(json!({})))
- .await
- .unwrap_err();
-
- assert!(
- err.contains("backend user id required before replacing the active session"),
- "expected active-session protection error, got: {err}"
- );
- let state = auth_get_state(&config).await.unwrap().value;
+ let config = test_config(&tmp);
+ let state = set_credential(
+ &config,
+ SetCredentialRequest {
+ token: "sk-live".into(),
+ kind: Some("api-key".into()),
+ ..Default::default()
+ },
+ )
+ .await
+ .unwrap()
+ .value;
assert!(state.is_authenticated);
- let token = auth_get_session_token_json(&config).await.unwrap().value;
- assert_eq!(token.get("token"), Some(&json!("existing.active.session")));
- assert_eq!(state.user_id.as_deref(), Some(active_user_id));
- assert_eq!(
- state.user.as_ref().and_then(|value| value.get("id")),
- Some(&json!(active_user_id))
- );
+ assert_eq!(state.credential.as_deref(), Some("api-key"));
+ assert!(state.user_id.is_none());
+ assert!(!crate::cron::scheduler_gate::is_signed_out());
+
+ let cleared = clear_credential(&config, Some(session_support::CredentialKind::ApiKey))
+ .await
+ .unwrap()
+ .value;
+ assert_eq!(cleared["removedApiKey"], true);
+ assert_eq!(cleared["removedSession"], false);
+ assert!(!auth_get_state(&config).await.unwrap().value.is_authenticated);
+ assert!(crate::cron::scheduler_gate::is_signed_out());
}
#[tokio::test]
-async fn store_session_rejects_live_jwt_when_auth_me_unauthorized() {
+async fn clear_credential_without_a_kind_removes_everything() {
let _env_guard = crate::config::TEST_ENV_LOCK
.lock()
.unwrap_or_else(|e| e.into_inner());
let tmp = TempDir::new().unwrap();
std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();
let _home = EnvVarGuard::set_to_path("HOME", tmp.path());
- let mut config = test_config(&tmp);
- config.api_url = Some(spawn_auth_me_status(StatusCode::UNAUTHORIZED).await);
- let token = jwt_with_payload(json!({
- "exp": (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp()
- }));
-
- let err = store_session(&config, &token, None, None)
- .await
- .unwrap_err();
-
- assert!(
- err.contains("Session validation failed (GET /auth/me)"),
- "expected auth/me validation error, got: {err}"
- );
- let state = auth_get_state(&config).await.unwrap().value;
- assert!(!state.is_authenticated);
+ let config = test_config(&tmp);
+ set_credential(
+ &config,
+ SetCredentialRequest {
+ token: "sk-live".into(),
+ kind: Some("api-key".into()),
+ ..Default::default()
+ },
+ )
+ .await
+ .unwrap();
+ let cleared = clear_credential(&config, None).await.unwrap().value;
+ assert_eq!(cleared["removed"], true);
+ assert_eq!(cleared["removedApiKey"], true);
+ assert!(!auth_get_state(&config).await.unwrap().value.is_authenticated);
}
+// ── authed routes keep the SESSION_EXPIRED sentinel ───────────
+
/// #5307 — a lapsed session on `GET /auth/me` must stay classifiable as
/// session expiry all the way out of `auth_get_me`.
///
@@ -464,7 +377,7 @@ async fn auth_create_channel_link_token_401_stays_classifiable_as_session_expiry
);
}
-// ── store_session (local session) ─────────────────────────────
+// ── set_credential (local session) ─────────────────────────────
/// A local session token requires a non-empty user payload — the backend
/// fetch path is bypassed entirely, so there is no fallback to derive the
@@ -516,11 +429,9 @@ async fn store_session_local_token_succeeds_without_network_and_forces_local_use
)
.await
.unwrap();
- // Profile must be stored (no network call was required).
- assert!(
- result.value.has_token,
- "local session should result in a stored token"
- );
+ // The credential is installed (no network call was required).
+ assert!(result.value.is_authenticated);
+ assert_eq!(result.value.credential.as_deref(), Some("local"));
// Logs must mention that backend validation was skipped.
let log_text = result.logs.join(" ");
assert!(
@@ -538,12 +449,11 @@ async fn store_session_local_token_succeeds_without_network_and_forces_local_use
log_text.contains("onboarding left incomplete for local session setup"),
"expected local session to remain in onboarding, got: {log_text}"
);
- // The profile_id or metadata must reflect the forced user_id.
- // Because store_session re-activates the user directory and reloads
- // config (so it picks up the user-scoped workspace path), we verify
- // via the returned profile summary rather than a secondary profile lookup.
- assert_eq!(
- result.value.provider, "app-session",
- "profile must be stored under the app-session provider"
- );
+ // The forced local user id wins over the caller's hint, and the user
+ // payload's id fields are rewritten to match.
+ assert_eq!(result.value.user_id.as_deref(), Some(expected_local_user_id.as_str()));
+ let user = result.value.user.unwrap();
+ assert_eq!(user["id"], expected_local_user_id);
+ assert_eq!(user["_id"], expected_local_user_id);
+ assert_eq!(user["name"], "Local User");
}
diff --git a/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs b/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs
index bb9547f9e5..793bc7373e 100644
--- a/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs
@@ -1,21 +1,5 @@
use super::*;
-#[test]
-fn normalize_local_session_user_overwrites_id_fields() {
- let out = normalize_local_session_user(
- json!({
- "id": "old",
- "_id": "old",
- "name": "Local User"
- }),
- "local-device-123",
- );
-
- assert_eq!(out["id"], "local-device-123");
- assert_eq!(out["_id"], "local-device-123");
- assert_eq!(out["name"], "Local User");
-}
-
// ── clear_session ──────────────────────────────────────────────
#[tokio::test]
diff --git a/crates/openhuman-core/src/security/credentials/ops_tests.rs b/crates/openhuman-core/src/security/credentials/ops_tests.rs
index b5d54e0d05..e7b1023027 100644
--- a/crates/openhuman-core/src/security/credentials/ops_tests.rs
+++ b/crates/openhuman-core/src/security/credentials/ops_tests.rs
@@ -1,7 +1,9 @@
use super::*;
use crate::config::{default_root_openhuman_dir, user_openhuman_dir, write_active_user_id, Config};
use crate::security::credentials::session_support::local_session_user_id;
-use crate::security::credentials::{AuthService, APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME};
+use crate::security::credentials::{
+ identity, session_support, AuthService, APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME,
+};
use axum::http::StatusCode;
use axum::routing::get;
use axum::Router;
@@ -77,25 +79,6 @@ async fn spawn_auth_me_status(status: StatusCode) -> String {
format!("http://{addr}")
}
-/// A backend that accepts the connection but never answers `/auth/me`, modelling
-/// a reachable-but-slow backend whose request hangs far past the store-time
-/// validation budget (issue #5166).
-async fn spawn_auth_me_hang() -> String {
- let app = Router::new().route(
- "/auth/me",
- get(|| async {
- tokio::time::sleep(std::time::Duration::from_secs(60)).await;
- StatusCode::OK
- }),
- );
- let listener = TcpListener::bind("127.0.0.1:0").await.unwrap();
- let addr = listener.local_addr().unwrap();
- tokio::spawn(async move {
- axum::serve(listener, app).await.unwrap();
- });
- format!("http://{addr}")
-}
-
/// Persist a live (unexpired) app-session profile for `user_id` and return the
/// user-scoped `Config` that reads it back, mirroring the on-disk state of an
/// already-signed-in install.
@@ -138,5 +121,5 @@ fn store_live_session(user_id: &str) -> Config {
#[path = "ops_provider_oauth_tests.rs"]
mod provider_oauth_tests;
-#[path = "ops_session_tests.rs"]
-mod session_tests;
+#[path = "ops_credential_tests.rs"]
+mod credential_tests;