Onboarding: select bundled Telegram channel and auto-install (#3)

Co-authored-by: Firat Sertgoz <[email protected]>
This commit is contained in:
firat.sertgoz
2026-02-07 06:56:01 +00:00
committed by GitHub
co-authored by Firat Sertgoz
parent 6bcc168ec5
commit 6831a54793
6 changed files with 314 additions and 40 deletions
+35
View File
@@ -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#"{
+4
View File
@@ -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.
}
}
}