mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
refactor: centralize test credential constants into testing::credentials (#829)
* refactor: centralize test credential constants into testing::credentials Scattered test credential strings (API keys, OAuth tokens, crypto keys, Telegram tokens, session tokens) across ~25 files made security auditing harder and created unnecessary duplication. Centralize all test-only fake credentials into a new `src/testing/credentials.rs` module with named constants and a shared `test_secrets_store()` helper. - Convert `src/testing.rs` to directory module (`src/testing/mod.rs`) - Add `src/testing/credentials.rs` with ~30 named constants - Replace hardcoded literals in 24 source files - Deduplicate `test_store()` helper (was copy-pasted in 3 files) - Leave leak_detector/shell/signature tests as-is (inline values aid readability for pattern detection tests) [skip-regression-check] Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * refactor: replace real Telegram bot token with obviously fake test stub Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Update src/testing/credentials.rs Co-authored-by: Copilot <[email protected]> * Update src/testing/credentials.rs Co-authored-by: Copilot <[email protected]> * refactor: address PR review feedback on test credentials - Fix TEST_CRYPTO_KEY doc comment ("32-byte hex" → "32-character key string") - Rename confusing "real"/"fake" Anthropic constant names and values - Change TEST_STRIPE_KEY from "sk-live" to "sk_test_fake123" to avoid scanners - Use test_secrets_store() helper in orchestrator and http tool tests - Clarify config_round_trip.rs doc comment about integration test visibility Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: Copilot <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
Copilot
parent
24d4fbb8a7
commit
76375f2eaa
@@ -12,6 +12,11 @@ use tempfile::tempdir;
|
||||
|
||||
use ironclaw::bootstrap::{save_bootstrap_env_to, upsert_bootstrap_var_to};
|
||||
|
||||
/// Fake OpenAI API key for test use only. Mirrors the internal
|
||||
/// `TEST_OPENAI_API_KEY_LONG` constant from the main crate, which is not
|
||||
/// directly available to integration tests due to `#[cfg(test)]`.
|
||||
const TEST_OPENAI_API_KEY_LONG: &str = "sk-test-key-1234567890";
|
||||
|
||||
/// Parse a .env file into a HashMap using dotenvy.
|
||||
fn read_env_map(path: &std::path::Path) -> HashMap<String, String> {
|
||||
dotenvy::from_path_iter(path)
|
||||
@@ -77,7 +82,7 @@ fn bootstrap_env_round_trips_embedding_disabled() {
|
||||
&[
|
||||
("DATABASE_BACKEND", "libsql"),
|
||||
("EMBEDDING_ENABLED", "false"),
|
||||
("OPENAI_API_KEY", "sk-test-key-1234567890"),
|
||||
("OPENAI_API_KEY", TEST_OPENAI_API_KEY_LONG),
|
||||
("ONBOARD_COMPLETED", "true"),
|
||||
],
|
||||
)
|
||||
@@ -92,7 +97,7 @@ fn bootstrap_env_round_trips_embedding_disabled() {
|
||||
);
|
||||
assert_eq!(
|
||||
map.get("OPENAI_API_KEY").map(String::as_str),
|
||||
Some("sk-test-key-1234567890"),
|
||||
Some(TEST_OPENAI_API_KEY_LONG),
|
||||
"OPENAI_API_KEY must be preserved alongside EMBEDDING_ENABLED"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user