diff options
| author | akbash <akbash@herdr.dev> | 2026-08-30 03:03:25 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-30 03:03:25 +0300 |
| commit | 4a3b04f59ba3b7d8a15cea187b23e1e80c343b0c (patch) | |
| tree | e1a38be588e702c39c434092f8b7a7a218e88f7c /src/integration/tests.rs | |
| parent | 3a3792622e59c7f2dc20f9c0236167161e4a5035 (diff) | |
fix: encode antigravity windows hook command (#3352)
refs #3348
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src/integration/tests.rs')
| -rw-r--r-- | src/integration/tests.rs | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/src/integration/tests.rs b/src/integration/tests.rs index 7cac9145..c2d94a6e 100644 --- a/src/integration/tests.rs +++ b/src/integration/tests.rs @@ -14,6 +14,40 @@ use std::path::{Path, PathBuf}; use serde_json::{json, Map, Value}; #[test] +fn windows_powershell_encoded_hook_command_preserves_script_invocation() { + use base64::Engine; + + let hook_path = Path::new(r"C:\Users\O'Neil λ\App Data\hooks\herdr-agent-state.ps1"); + let command = powershell_encoded_hook_command(hook_path, "session"); + let encoded = command + .strip_prefix("powershell -NoProfile -ExecutionPolicy Bypass -EncodedCommand ") + .expect("encoded PowerShell command"); + let bytes = base64::engine::general_purpose::STANDARD + .decode(encoded) + .expect("base64 payload"); + let mut chunks = bytes.chunks_exact(2); + let utf16 = chunks + .by_ref() + .map(|chunk| u16::from_le_bytes([chunk[0], chunk[1]])) + .collect::<Vec<_>>(); + assert!(chunks.remainder().is_empty(), "UTF-16LE payload"); + assert_eq!( + String::from_utf16(&utf16).expect("PowerShell script"), + r"& 'C:\Users\O''Neil λ\App Data\hooks\herdr-agent-state.ps1' session" + ); +} + +#[cfg(windows)] +#[test] +fn windows_antigravity_cli_hook_command_uses_encoded_powershell() { + let hook_path = Path::new(r"C:\Users\reporter\.gemini\config\hooks\herdr-agent-state.ps1"); + assert_eq!( + antigravity_cli_hook_command(hook_path, "session"), + powershell_encoded_hook_command(hook_path, "session") + ); +} + +#[test] fn extract_version_triple_parses_common_outputs() { assert_eq!(extract_version_triple("0.14.0"), Some((0, 14, 0))); assert_eq!(extract_version_triple("v1.2.3"), Some((1, 2, 3))); @@ -3889,8 +3923,10 @@ fn install_antigravity_cli_writes_hook_and_updates_hooks_json() { Some(ANTIGRAVITY_CLI_HOOK_TIMEOUT_SEC) ); let command = handler.get("command").and_then(Value::as_str).unwrap(); - assert!(command.contains("herdr-agent-state")); - assert!(command.ends_with(action)); + assert_eq!( + command, + antigravity_cli_hook_command(&installed.hook_path, action) + ); } // The integration is session-only. Antigravity CLI cannot express blocked @@ -3921,6 +3957,39 @@ fn install_antigravity_cli_writes_hook_and_updates_hooks_json() { } #[test] +fn antigravity_cli_v2_install_is_outdated_until_reinstalled() { + let _lock = integration_env_lock(); + let base = unique_base(); + let agy_dir = base.join(".gemini").join("config"); + let hook_dir = agy_dir.join("hooks"); + fs::create_dir_all(&hook_dir).unwrap(); + fs::write( + hook_dir.join(ANTIGRAVITY_CLI_HOOK_INSTALL_NAME), + ANTIGRAVITY_CLI_HOOK_ASSET + .replace("HERDR_INTEGRATION_VERSION=3", "HERDR_INTEGRATION_VERSION=2"), + ) + .unwrap(); + std::env::set_var(ANTIGRAVITY_CLI_CONFIG_DIR_ENV_VAR, &agy_dir); + + let status = || { + installed_integration_statuses() + .into_iter() + .find(|status| status.target == crate::api::schema::IntegrationTarget::AntigravityCli) + .expect("antigravity cli integration status") + }; + let outdated = status(); + assert_eq!(outdated.state, IntegrationStatusKind::Outdated); + assert_eq!(outdated.installed_version, Some(2)); + assert_eq!(outdated.expected_version, 3); + + install_antigravity_cli().unwrap(); + assert_eq!(status().state, IntegrationStatusKind::Current); + + std::env::remove_var(ANTIGRAVITY_CLI_CONFIG_DIR_ENV_VAR); + let _ = fs::remove_dir_all(base); +} + +#[test] fn install_antigravity_cli_rewrites_stale_herdr_block() { let _lock = integration_env_lock(); let base = unique_base(); |
