mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-31 08:39:24 +00:00
Onboarding: select bundled Telegram channel and auto-install (#3)
Co-authored-by: Firat Sertgoz <[email protected]>
This commit is contained in:
co-authored by
Firat Sertgoz
parent
6bcc168ec5
commit
6831a54793
@@ -241,6 +241,9 @@ pub enum CredentialLocationSchema {
|
||||
|
||||
/// Query parameter.
|
||||
QueryParam { name: String },
|
||||
|
||||
/// URL/path placeholder replacement.
|
||||
UrlPath { placeholder: String },
|
||||
}
|
||||
|
||||
impl CredentialLocationSchema {
|
||||
@@ -259,6 +262,9 @@ impl CredentialLocationSchema {
|
||||
CredentialLocationSchema::QueryParam { name } => {
|
||||
CredentialLocation::QueryParam { name: name.clone() }
|
||||
}
|
||||
CredentialLocationSchema::UrlPath { placeholder } => CredentialLocation::UrlPath {
|
||||
placeholder: placeholder.clone(),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -565,6 +571,35 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_url_path_credential() {
|
||||
let json = r#"{
|
||||
"http": {
|
||||
"allowlist": [{ "host": "api.telegram.org" }],
|
||||
"credentials": {
|
||||
"telegram_bot": {
|
||||
"secret_name": "telegram_bot_token",
|
||||
"location": {
|
||||
"type": "url_path",
|
||||
"placeholder": "{TELEGRAM_BOT_TOKEN}"
|
||||
},
|
||||
"host_patterns": ["api.telegram.org"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}"#;
|
||||
|
||||
let caps = CapabilitiesFile::from_json(json).unwrap();
|
||||
let http = caps.http.unwrap();
|
||||
let cred = http.credentials.get("telegram_bot").unwrap();
|
||||
match &cred.location {
|
||||
CredentialLocationSchema::UrlPath { placeholder } => {
|
||||
assert_eq!(placeholder, "{TELEGRAM_BOT_TOKEN}");
|
||||
}
|
||||
_ => panic!("Expected UrlPath location"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_secrets_capability() {
|
||||
let json = r#"{
|
||||
|
||||
@@ -200,6 +200,10 @@ fn inject_credential(
|
||||
.query_params
|
||||
.insert(name.clone(), secret.expose().to_string());
|
||||
}
|
||||
CredentialLocation::UrlPath { .. } => {
|
||||
// URL placeholder replacement is handled by channel/tool wrappers
|
||||
// that substitute {PLACEHOLDER} values in templated strings.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user