VoiceWake: add SSH forwarder tests

This commit is contained in:
Peter Steinberger
2025-12-07 01:55:30 +01:00
parent cf0f44823a
commit 141d2b5626
3 changed files with 41 additions and 14 deletions

View File

@@ -60,7 +60,7 @@ enum VoiceWakeForwarder {
await self.wait(process, timeout: config.timeout)
}
private static func renderedCommand(template: String, transcript: String) -> String {
static func renderedCommand(template: String, transcript: String) -> String {
let escaped = Self.shellEscape(transcript)
if template.contains("${text}") {
return template.replacingOccurrences(of: "${text}", with: escaped)
@@ -68,7 +68,7 @@ enum VoiceWakeForwarder {
return template
}
private static func shellEscape(_ text: String) -> String {
static func shellEscape(_ text: String) -> String {
// Single-quote based shell escaping.
let replaced = text.replacingOccurrences(of: "'", with: "'\\''")
return "'\(replaced)'"
@@ -95,7 +95,7 @@ enum VoiceWakeForwarder {
}
}
private static func parse(target: String) -> (user: String?, host: String, port: Int)? {
static func parse(target: String) -> (user: String?, host: String, port: Int)? {
guard !target.isEmpty else { return nil }
var remainder = target
var user: String?