feat(acp): replace raw config and secret methods (#9000)
Signed-off-by: Kalvin Chau <kalvin@block.xyz>
This commit is contained in:
@@ -79,6 +79,7 @@ fn acp_secret_mutations_and_inventory_refresh_invalidate_global_secret_cache() {
|
||||
("GOOSE_PATH_ROOT", Some(root_path.as_str())),
|
||||
("GOOSE_DISABLE_KEYRING", Some("1")),
|
||||
("ANTHROPIC_API_KEY", None),
|
||||
("GROQ_API_KEY", None),
|
||||
("OPENAI_API_KEY", None),
|
||||
("XAI_API_KEY", None),
|
||||
("XAI_HOST", None),
|
||||
@@ -87,12 +88,12 @@ fn acp_secret_mutations_and_inventory_refresh_invalidate_global_secret_cache() {
|
||||
let config_dir = Paths::config_dir();
|
||||
let data_dir = Paths::data_dir();
|
||||
write_config(&config_dir);
|
||||
write_secrets(&config_dir, "OPENAI_API_KEY: stale-key\n");
|
||||
write_secrets(&config_dir, "GROQ_API_KEY: stale-key\n");
|
||||
|
||||
run_test(async move {
|
||||
assert_eq!(
|
||||
Config::global()
|
||||
.get_secret::<String>("OPENAI_API_KEY")
|
||||
.get_secret::<String>("GROQ_API_KEY")
|
||||
.unwrap(),
|
||||
"stale-key"
|
||||
);
|
||||
@@ -109,43 +110,43 @@ fn acp_secret_mutations_and_inventory_refresh_invalidate_global_secret_cache() {
|
||||
};
|
||||
let conn = AcpServerConnection::new(config, openai).await;
|
||||
|
||||
write_secrets(&config_dir, "OPENAI_API_KEY: fresh-key\n");
|
||||
write_secrets(&config_dir, "GROQ_API_KEY: fresh-key\n");
|
||||
send_custom(
|
||||
conn.cx(),
|
||||
"_goose/secret/upsert",
|
||||
"_goose/dictation/secret/save",
|
||||
serde_json::json!({
|
||||
"key": "OPENAI_API_KEY",
|
||||
"provider": "groq",
|
||||
"value": "fresh-key",
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.expect("secret upsert should succeed");
|
||||
.expect("dictation secret save should succeed");
|
||||
|
||||
assert_eq!(
|
||||
Config::global()
|
||||
.get_secret::<String>("OPENAI_API_KEY")
|
||||
.get_secret::<String>("GROQ_API_KEY")
|
||||
.unwrap(),
|
||||
"fresh-key",
|
||||
"ACP secret upsert should invalidate the global secrets cache"
|
||||
"ACP dictation secret save should invalidate the global secrets cache"
|
||||
);
|
||||
|
||||
write_secrets(&config_dir, "{}\n");
|
||||
send_custom(
|
||||
conn.cx(),
|
||||
"_goose/secret/remove",
|
||||
"_goose/dictation/secret/delete",
|
||||
serde_json::json!({
|
||||
"key": "OPENAI_API_KEY",
|
||||
"provider": "groq",
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.expect("secret remove should succeed");
|
||||
.expect("dictation secret delete should succeed");
|
||||
|
||||
assert!(
|
||||
matches!(
|
||||
Config::global().get_secret::<String>("OPENAI_API_KEY"),
|
||||
Config::global().get_secret::<String>("GROQ_API_KEY"),
|
||||
Err(ConfigError::NotFound(_))
|
||||
),
|
||||
"ACP secret remove should invalidate the global secrets cache"
|
||||
"ACP dictation secret delete should invalidate the global secrets cache"
|
||||
);
|
||||
|
||||
let save_provider_config = send_custom(
|
||||
|
||||
Reference in New Issue
Block a user