mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
30 lines
991 B
Rust
30 lines
991 B
Rust
#![cfg(windows)]
|
|
|
|
use auth::AuthCallbackReceiver;
|
|
use std::{process::Stdio, time::Duration};
|
|
|
|
#[tokio::test]
|
|
async fn callback_command_forwards_between_processes() {
|
|
let receiver = AuthCallbackReceiver::bind().unwrap();
|
|
let child = tokio::process::Command::new(env!("CARGO_BIN_EXE_gpauth"))
|
|
.args([
|
|
"auth-callback",
|
|
"globalprotectcallback:cas-as=1&un=windows-fixture&token=callback-command-test",
|
|
])
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped())
|
|
.kill_on_drop(true)
|
|
.spawn()
|
|
.unwrap();
|
|
let (data, output) = tokio::time::timeout(Duration::from_secs(10), async {
|
|
tokio::join!(receiver.receive(), child.wait_with_output())
|
|
})
|
|
.await
|
|
.expect("callback executable did not complete");
|
|
let output = output.unwrap();
|
|
assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr));
|
|
let data = data.unwrap();
|
|
assert_eq!(data.username(), "windows-fixture");
|
|
assert_eq!(data.token(), Some("callback-command-test"));
|
|
}
|