mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
refactor: align GP profile and packaging flow
Main changes: - Refactor connect/auth flows around a single OS profile and host identity model, including gateway fallback and cookie-on-stdin handling. - Align request parameters, HIP host-id propagation, SAML webview user-agent behavior, and portal default-browser handling with observed official client behavior. - Add opt-in cookie cache support and Microsoft Defender HIP reporting while keeping host-id validation explicit. - Add BSD build, packaging, release artifact, and provenance support with FreeBSD/OpenBSD path and dependency cleanup. - Update NixOS install documentation and dependency compatibility fixes.
This commit is contained in:
92 files changed
+9847
-2868
No files matched your search
@@ -0,0 +1,62 @@
|
||||
use crate::{credential::Credential, gp_params::GpParams};
|
||||
|
||||
const EMPTY_PORTAL_COOKIE: &str = "empty";
|
||||
|
||||
fn portal_cookie_param(value: Option<&str>) -> String {
|
||||
match value {
|
||||
Some(value) if !value.is_empty() => value.to_string(),
|
||||
_ => EMPTY_PORTAL_COOKIE.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn build(cred: &Credential, gp_params: &GpParams) -> Vec<(String, String)> {
|
||||
let mut params = Vec::new();
|
||||
params.push(("user".to_string(), cred.username().to_string()));
|
||||
|
||||
let (passwd, prelogin_cookie, portal_userauthcookie, portal_prelogonuserauthcookie, token) = match cred {
|
||||
Credential::Password(cred) => (Some(cred.password()), None, None, None, None),
|
||||
Credential::Prelogin(cred) => (
|
||||
Some(gp_params.os_profile().saml_password()),
|
||||
cred.prelogin_cookie(),
|
||||
cred.portal_userauthcookie(),
|
||||
None,
|
||||
cred.token(),
|
||||
),
|
||||
Credential::AuthCookie(cred) => (
|
||||
Some(
|
||||
cred
|
||||
.password()
|
||||
.unwrap_or_else(|| gp_params.os_profile().saml_password()),
|
||||
),
|
||||
None,
|
||||
Some(cred.user_auth_cookie()),
|
||||
Some(cred.prelogon_user_auth_cookie()),
|
||||
None,
|
||||
),
|
||||
Credential::Cached(cred) => (
|
||||
cred.password(),
|
||||
None,
|
||||
cred.auth_cookie().map(|cred| cred.user_auth_cookie()),
|
||||
cred.auth_cookie().map(|cred| cred.prelogon_user_auth_cookie()),
|
||||
None,
|
||||
),
|
||||
};
|
||||
|
||||
params.push(("passwd".to_string(), passwd.unwrap_or_default().to_string()));
|
||||
params.push((
|
||||
"prelogin-cookie".to_string(),
|
||||
prelogin_cookie.unwrap_or_default().to_string(),
|
||||
));
|
||||
params.push((
|
||||
"portal-userauthcookie".to_string(),
|
||||
portal_cookie_param(portal_userauthcookie),
|
||||
));
|
||||
params.push((
|
||||
"portal-prelogonuserauthcookie".to_string(),
|
||||
portal_cookie_param(portal_prelogonuserauthcookie),
|
||||
));
|
||||
|
||||
params.push(("token".to_string(), token.unwrap_or_default().to_string()));
|
||||
|
||||
params
|
||||
}
|
||||
@@ -0,0 +1,487 @@
|
||||
use std::net::ToSocketAddrs;
|
||||
|
||||
use super::{RequestParams, credential as credential_params};
|
||||
use crate::{credential::Credential, gateway::GatewayLoginContext, gp_params::GpParams};
|
||||
|
||||
/// Inputs required to build gateway login request parameters.
|
||||
pub(crate) struct GatewayLoginInput<'a> {
|
||||
pub gp_params: &'a GpParams,
|
||||
pub cred: &'a Credential,
|
||||
pub gateway_host: &'a str,
|
||||
pub context: Option<&'a GatewayLoginContext>,
|
||||
pub client_ip: Option<&'a str>,
|
||||
pub extend_lifetime: bool,
|
||||
}
|
||||
|
||||
/// Build request parameters for the gateway login endpoint.
|
||||
///
|
||||
/// Resolves the `server` parameter to an IPv4 address when
|
||||
/// `profile.gateway_server_uses_resolved_ipv4()` is true.
|
||||
/// Sets `gw` and `gateway-name` to the gateway FQDN.
|
||||
pub(crate) fn build(input: &GatewayLoginInput) -> RequestParams {
|
||||
let profile = input.gp_params.os_profile();
|
||||
let mut body: Vec<(String, String)> = Vec::new();
|
||||
|
||||
// Credential params (user, passwd, prelogin-cookie, portal-userauthcookie, etc.)
|
||||
body.extend(credential_params::build(input.cred, input.gp_params));
|
||||
|
||||
// Common login params
|
||||
body.push(("prot".into(), "https:".into()));
|
||||
body.push(("jnlpReady".into(), "jnlpReady".into()));
|
||||
body.push(("ok".into(), "Login".into()));
|
||||
body.push(("direct".into(), "yes".into()));
|
||||
body.push(("ipv6-support".into(), "yes".into()));
|
||||
body.push(("clientVer".into(), "4100".into()));
|
||||
body.push(("clientos".into(), profile.client_os().as_str().into()));
|
||||
body.push(("computer".into(), profile.computer().into()));
|
||||
body.push((
|
||||
"inputStr".into(),
|
||||
input.gp_params.input_str().unwrap_or_default().into(),
|
||||
));
|
||||
if let Some(otp) = input.gp_params.otp() {
|
||||
body.push(("passwd".into(), otp.into()));
|
||||
}
|
||||
if let Some(os_version) = input.gp_params.os_version() {
|
||||
body.push(("os-version".into(), os_version.into()));
|
||||
}
|
||||
|
||||
// Server — resolve to IPv4 when profile requires it
|
||||
let server = resolve_server(input);
|
||||
body.push(("server".into(), server));
|
||||
|
||||
// Identity fields
|
||||
body.push(("host-id".into(), profile.host_id().into()));
|
||||
body.push(("serialno".into(), profile.serialno().into()));
|
||||
body.push(("preferred-ip".into(), String::new()));
|
||||
body.push(("preferred-ipv6".into(), String::new()));
|
||||
|
||||
// Client version
|
||||
if let Some(client_version) = input.gp_params.client_version() {
|
||||
body.push(("clientgpversion".into(), client_version.to_string()));
|
||||
}
|
||||
|
||||
// Context-dependent fields
|
||||
if let Some(context) = input.context {
|
||||
let gateway_host = context.host().to_string();
|
||||
body.push(("host".into(), gateway_host.clone()));
|
||||
body.push(("gw".into(), gateway_host.clone()));
|
||||
body.push(("gateway-name".into(), gateway_host));
|
||||
body.push(("internal".into(), context.kind().as_login_param().to_string()));
|
||||
body.push((
|
||||
"selection-type".into(),
|
||||
context.selection().as_login_param().to_string(),
|
||||
));
|
||||
body.push(("client-ipv6".into(), String::new()));
|
||||
|
||||
if let Some(connect_method) = context.connect_method() {
|
||||
body.push(("connect-method".into(), connect_method.to_string()));
|
||||
}
|
||||
|
||||
if let Some(client_version) = input.gp_params.client_version() {
|
||||
// Ensure clientgpversion is set in the context block (override earlier value if present)
|
||||
if let Some(pos) = body.iter().position(|(k, _)| k == "clientgpversion") {
|
||||
body[pos].1 = client_version.to_string();
|
||||
} else {
|
||||
body.push(("clientgpversion".into(), client_version.to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(client_ip) = input.client_ip {
|
||||
body.push(("client-ip".into(), client_ip.to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
// Extend lifetime
|
||||
if input.extend_lifetime {
|
||||
body.push(("extend-lifetime".into(), "true".into()));
|
||||
}
|
||||
|
||||
RequestParams { body, query: vec![] }
|
||||
}
|
||||
|
||||
/// Resolve the gateway server to an IPv4 address if the profile requires it.
|
||||
///
|
||||
/// Falls back to the original gateway host if resolution fails.
|
||||
fn resolve_server(input: &GatewayLoginInput) -> String {
|
||||
if !input.gp_params.os_profile().gateway_server_uses_resolved_ipv4() {
|
||||
return input.gateway_host.to_string();
|
||||
}
|
||||
|
||||
if let Some(context) = input.context {
|
||||
resolve_to_ipv4(context.host()).unwrap_or_else(|| input.gateway_host.to_string())
|
||||
} else {
|
||||
input.gateway_host.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
/// Attempt DNS resolution of a hostname to its first IPv4 address.
|
||||
fn resolve_to_ipv4(host: &str) -> Option<String> {
|
||||
(host, 443)
|
||||
.to_socket_addrs()
|
||||
.ok()?
|
||||
.find(|addr| addr.ip().is_ipv4())
|
||||
.map(|addr| addr.ip().to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
credential::{AuthCookieCredential, PasswordCredential},
|
||||
gateway::{Gateway, GatewayKind, GatewaySelection},
|
||||
os_profile::{ClientOs, HostIdentity, OsProfile},
|
||||
};
|
||||
|
||||
fn test_identity() -> HostIdentity {
|
||||
HostIdentity::new(
|
||||
"test-computer".to_string(),
|
||||
"host-id-123".to_string(),
|
||||
"serial-456".to_string(),
|
||||
"aa-bb-cc-dd-ee-ff".to_string(),
|
||||
)
|
||||
}
|
||||
|
||||
fn test_profile(os: ClientOs) -> OsProfile {
|
||||
OsProfile::builder(os).host_identity(test_identity()).build()
|
||||
}
|
||||
|
||||
fn make_gp_params() -> GpParams {
|
||||
GpParams::builder(test_profile(ClientOs::Linux)).build()
|
||||
}
|
||||
|
||||
fn make_credential() -> Credential {
|
||||
Credential::Password(PasswordCredential::new("alice", "secret"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_without_context_includes_identity_fields() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("host-id"), Some(profile.host_id()));
|
||||
assert_eq!(find("serialno"), Some(profile.serialno()));
|
||||
assert_eq!(find("preferred-ip"), Some(""));
|
||||
assert_eq!(find("preferred-ipv6"), Some(""));
|
||||
assert_eq!(find("token"), Some(""));
|
||||
assert_eq!(find("server"), Some("vpn.example.com"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_without_context_excludes_context_fields() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let has_key = |key: &str| result.body.iter().any(|(k, _)| k == key);
|
||||
|
||||
assert!(!has_key("host"));
|
||||
assert!(!has_key("gw"));
|
||||
assert!(!has_key("gateway-name"));
|
||||
assert!(!has_key("internal"));
|
||||
assert!(!has_key("selection-type"));
|
||||
assert!(!has_key("connect-method"));
|
||||
assert!(!has_key("client-ip"));
|
||||
assert!(!has_key("client-ipv6"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn build_with_context_includes_gateway_fqdn() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
let gateway = Gateway {
|
||||
name: "US_East".to_string(),
|
||||
address: "us1.vpn.example.com".to_string(),
|
||||
kind: GatewayKind::External,
|
||||
priority: 1,
|
||||
priority_rules: vec![],
|
||||
};
|
||||
let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto);
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "us1.vpn.example.com",
|
||||
context: Some(&context),
|
||||
client_ip: Some("192.168.0.10"),
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("gw"), Some("us1.vpn.example.com"));
|
||||
assert_eq!(find("gateway-name"), Some("us1.vpn.example.com"));
|
||||
assert_eq!(find("host"), Some("us1.vpn.example.com"));
|
||||
assert_eq!(find("internal"), Some("no"));
|
||||
assert_eq!(find("selection-type"), Some("auto"));
|
||||
assert_eq!(find("client-ip"), Some("192.168.0.10"));
|
||||
assert_eq!(find("client-ipv6"), Some(""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mac_profile_uses_fqdn_for_gateway_display() {
|
||||
let gp_params = GpParams::builder(test_profile(ClientOs::Mac)).build();
|
||||
let cred = make_credential();
|
||||
let gateway = Gateway {
|
||||
name: "US_East".to_string(),
|
||||
address: "us1.vpn.example.com".to_string(),
|
||||
kind: GatewayKind::External,
|
||||
priority: 1,
|
||||
priority_rules: vec![],
|
||||
};
|
||||
let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto);
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "us1.vpn.example.com",
|
||||
context: Some(&context),
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("gw"), Some("us1.vpn.example.com"));
|
||||
assert_eq!(find("gateway-name"), Some("us1.vpn.example.com"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linux_prelogin_credential_uses_profile_saml_password() {
|
||||
let gp_params = GpParams::builder(test_profile(ClientOs::Linux)).build();
|
||||
let cred = Credential::Prelogin(crate::credential::PreloginCredential::new(
|
||||
"alice",
|
||||
Some("prelogin-cookie"),
|
||||
None,
|
||||
None,
|
||||
));
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str());
|
||||
assert_eq!(passwd, Some("SAMLPASS"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn portal_auth_cookie_login_leaves_gateway_prelogin_cookie_empty() {
|
||||
let gp_params = GpParams::builder(test_profile(ClientOs::Linux)).build();
|
||||
let cred = Credential::AuthCookie(AuthCookieCredential::new("alice", "empty", "empty"));
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("passwd"), Some("SAMLPASS"));
|
||||
assert_eq!(find("prelogin-cookie"), Some(""));
|
||||
assert_eq!(find("portal-userauthcookie"), Some("empty"));
|
||||
assert_eq!(find("portal-prelogonuserauthcookie"), Some("empty"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn portal_auth_cookie_login_reuses_portal_password_when_available() {
|
||||
let gp_params = GpParams::builder(test_profile(ClientOs::Linux)).build();
|
||||
let cred = Credential::AuthCookie(
|
||||
AuthCookieCredential::new("alice", "portal-user-cookie", "portal-prelogon-cookie").with_password("secret"),
|
||||
);
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("passwd"), Some("secret"));
|
||||
assert_eq!(find("prelogin-cookie"), Some(""));
|
||||
assert_eq!(find("portal-userauthcookie"), Some("portal-user-cookie"));
|
||||
assert_eq!(find("portal-prelogonuserauthcookie"), Some("portal-prelogon-cookie"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extend_lifetime_adds_param() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: true,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
assert_eq!(find("extend-lifetime"), Some("true"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_extend_lifetime_omits_param() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let has_key = |key: &str| result.body.iter().any(|(k, _)| k == key);
|
||||
assert!(!has_key("extend-lifetime"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn context_connect_method_included_when_present() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
let gateway = Gateway::new("GW".to_string(), "vpn.example.com".to_string());
|
||||
let context = GatewayLoginContext::new(&gateway, GatewaySelection::Manual).with_connect_method(Some("on-demand"));
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: Some(&context),
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
assert_eq!(find("connect-method"), Some("on-demand"));
|
||||
assert_eq!(find("selection-type"), Some("manual"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_params_in_body_not_query() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "vpn.example.com",
|
||||
context: None,
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
assert!(result.query.is_empty());
|
||||
assert!(!result.body.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn server_resolves_to_ipv4_with_context_using_localhost() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
let gateway = Gateway::new("Local".to_string(), "localhost".to_string());
|
||||
let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto);
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "localhost",
|
||||
context: Some(&context),
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let server = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "server")
|
||||
.map(|(_, v)| v.as_str())
|
||||
.expect("server param should exist");
|
||||
// localhost resolves to 127.0.0.1 (IPv4)
|
||||
assert_eq!(server, "127.0.0.1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn server_falls_back_to_host_when_resolution_fails() {
|
||||
let gp_params = make_gp_params();
|
||||
let cred = make_credential();
|
||||
let gateway = Gateway::new("GW".to_string(), "nonexistent.invalid.test".to_string());
|
||||
let context = GatewayLoginContext::new(&gateway, GatewaySelection::Auto);
|
||||
|
||||
let input = GatewayLoginInput {
|
||||
gp_params: &gp_params,
|
||||
cred: &cred,
|
||||
gateway_host: "nonexistent.invalid.test",
|
||||
context: Some(&context),
|
||||
client_ip: None,
|
||||
extend_lifetime: false,
|
||||
};
|
||||
|
||||
let result = build(&input);
|
||||
|
||||
let server = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "server")
|
||||
.map(|(_, v)| v.as_str())
|
||||
.expect("server param should exist");
|
||||
// Falls back to the original gateway host when DNS resolution fails
|
||||
assert_eq!(server, "nonexistent.invalid.test");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
use super::RequestParams;
|
||||
use crate::os_profile::{OsProfile, PreloginBrowserMode, PreloginParamLocation};
|
||||
|
||||
/// Build request parameters for the gateway prelogin endpoint.
|
||||
///
|
||||
/// Same as portal prelogin but uses the gateway-specific embedded browser value.
|
||||
pub(crate) fn build(profile: &OsProfile, browser_mode: PreloginBrowserMode) -> RequestParams {
|
||||
let default_browser = profile.gateway_default_browser(browser_mode);
|
||||
|
||||
let params: Vec<(String, String)> = vec![
|
||||
("tmp".into(), "tmp".into()),
|
||||
("clientVer".into(), "4100".into()),
|
||||
("clientos".into(), profile.client_os().as_str().into()),
|
||||
("os-version".into(), profile.os_version().into()),
|
||||
("host-id".into(), profile.host_id().into()),
|
||||
("ipv6-support".into(), "yes".into()),
|
||||
("default-browser".into(), default_browser.into()),
|
||||
("cas-support".into(), "yes".into()),
|
||||
("data".into(), "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9".into()),
|
||||
];
|
||||
|
||||
let mut query: Vec<(String, String)> = vec![];
|
||||
if profile.kerberos_support_in_query() {
|
||||
query.push(("kerberos-support".into(), "yes".into()));
|
||||
}
|
||||
|
||||
match profile.prelogin_param_location() {
|
||||
PreloginParamLocation::Body => RequestParams { body: params, query },
|
||||
PreloginParamLocation::Query => RequestParams {
|
||||
body: vec![],
|
||||
query: params.into_iter().chain(query).collect(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::os_profile::ClientOs;
|
||||
|
||||
#[test]
|
||||
fn linux_places_params_in_body() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
assert!(!result.body.is_empty());
|
||||
assert!(result.query.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mac_places_params_in_body_with_kerberos_query() {
|
||||
let profile = OsProfile::builder(ClientOs::Mac).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
assert!(!result.body.is_empty());
|
||||
assert_eq!(result.query.len(), 1);
|
||||
assert_eq!(result.query[0], ("kerberos-support".into(), "yes".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_places_all_params_in_query() {
|
||||
let profile = OsProfile::builder(ClientOs::Windows).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
assert!(result.body.is_empty());
|
||||
// 9 base params + 1 kerberos-support
|
||||
assert_eq!(result.query.len(), 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uses_embedded_gateway_default_browser_value() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let browser_param = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "default-browser")
|
||||
.expect("default-browser param should exist");
|
||||
assert_eq!(browser_param.1, "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uses_target_value_when_external_browser_is_requested() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::External);
|
||||
|
||||
let browser_param = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "default-browser")
|
||||
.expect("default-browser param should exist");
|
||||
assert_eq!(browser_param.1, "4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn includes_all_required_params() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect();
|
||||
assert!(keys.contains(&"tmp"));
|
||||
assert!(keys.contains(&"clientVer"));
|
||||
assert!(keys.contains(&"clientos"));
|
||||
assert!(keys.contains(&"os-version"));
|
||||
assert!(keys.contains(&"host-id"));
|
||||
assert!(keys.contains(&"ipv6-support"));
|
||||
assert!(keys.contains(&"default-browser"));
|
||||
assert!(keys.contains(&"cas-support"));
|
||||
assert!(keys.contains(&"data"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_param_is_cas_embedded_browser_base64() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let data_param = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "data")
|
||||
.expect("data param should exist");
|
||||
assert_eq!(data_param.1, "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
pub(crate) mod credential;
|
||||
pub mod gateway_login;
|
||||
pub mod gateway_prelogin;
|
||||
pub mod portal_getconfig;
|
||||
pub mod portal_prelogin;
|
||||
|
||||
/// Ordered request parameters split into body (form data) and query string.
|
||||
///
|
||||
/// Uses `Vec<(String, String)>` instead of `HashMap` to preserve parameter
|
||||
/// ordering, as some servers may be sensitive to order.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct RequestParams {
|
||||
pub body: Vec<(String, String)>,
|
||||
pub query: Vec<(String, String)>,
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
use super::{RequestParams, credential as credential_params};
|
||||
use crate::{credential::Credential, gp_params::GpParams, os_profile::ClientOs, portal::csc::swg_nonce};
|
||||
|
||||
/// Build request parameters for the portal getconfig endpoint.
|
||||
///
|
||||
/// This builder produces the form body for `getconfig.esp`. It deliberately
|
||||
/// excludes `server`, `prot`, `direct`, and `jnlpReady` which are not sent
|
||||
/// by the official client for this endpoint.
|
||||
///
|
||||
/// For SAML (prelogin) credentials the password is set to `SAMLPASS` on Linux
|
||||
/// and left empty on macOS/Windows, matching official client behavior.
|
||||
pub(crate) fn build(cred: &Credential, gp_params: &GpParams, server: &str) -> RequestParams {
|
||||
let profile = gp_params.os_profile();
|
||||
let nonce = if profile.client_os() == ClientOs::Linux {
|
||||
"0".to_string()
|
||||
} else {
|
||||
swg_nonce()
|
||||
};
|
||||
|
||||
let mut body = credential_params::build(cred, gp_params);
|
||||
body.push(("inputStr".into(), gp_params.input_str().unwrap_or_default().into()));
|
||||
|
||||
// Fixed params
|
||||
body.push(("ok".into(), "Login".into()));
|
||||
body.push(("clientVer".into(), "4100".into()));
|
||||
|
||||
// OS params
|
||||
body.push(("clientos".into(), profile.client_os().as_str().into()));
|
||||
body.push(("clientgpversion".into(), profile.client_version().into()));
|
||||
body.push(("computer".into(), profile.computer().into()));
|
||||
body.push(("os-version".into(), profile.os_version().into()));
|
||||
body.push(("host-id".into(), profile.host_id().into()));
|
||||
body.push(("ipv6-support".into(), "yes".into()));
|
||||
body.push(("serialno".into(), profile.serialno().into()));
|
||||
|
||||
// CSC fields
|
||||
body.push(("csc-digest".into(), String::new()));
|
||||
body.push(("config-digest".into(), String::new()));
|
||||
body.push((
|
||||
"csc-support".into(),
|
||||
if gp_params.effective_csc_support() { "yes" } else { "no" }.into(),
|
||||
));
|
||||
|
||||
// Host and SWG
|
||||
body.push(("host".into(), server.into()));
|
||||
body.push(("swg-auth-token".into(), "0".into()));
|
||||
body.push(("swg-nonce".into(), nonce));
|
||||
|
||||
RequestParams { body, query: vec![] }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
credential::{PasswordCredential, PreloginCredential},
|
||||
gp_params::CscMode,
|
||||
os_profile::{ClientOs, HostIdentity, OsProfile},
|
||||
};
|
||||
|
||||
fn test_profile(os: ClientOs) -> OsProfile {
|
||||
OsProfile::builder(os)
|
||||
.computer_name_override("test-computer")
|
||||
.client_version("6.3.3-100")
|
||||
.host_identity(HostIdentity::new(
|
||||
"test-computer".into(),
|
||||
"test-host-id".into(),
|
||||
"test-serial".into(),
|
||||
"aa:bb:cc:dd:ee:ff".into(),
|
||||
))
|
||||
.build()
|
||||
}
|
||||
|
||||
fn password_cred() -> Credential {
|
||||
Credential::from(PasswordCredential::new("alice", "secret"))
|
||||
}
|
||||
|
||||
fn prelogin_cred() -> Credential {
|
||||
Credential::Prelogin(PreloginCredential::new(
|
||||
"alice",
|
||||
Some("my-prelogin-cookie"),
|
||||
Some("my-userauthcookie"),
|
||||
None,
|
||||
))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn excludes_forbidden_params() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect();
|
||||
assert!(!keys.contains(&"server"));
|
||||
assert!(!keys.contains(&"prot"));
|
||||
assert!(!keys.contains(&"direct"));
|
||||
assert!(!keys.contains(&"jnlpReady"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn includes_required_params() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect();
|
||||
assert!(keys.contains(&"clientgpversion"));
|
||||
assert!(keys.contains(&"host-id"));
|
||||
assert!(keys.contains(&"serialno"));
|
||||
assert!(keys.contains(&"token"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn includes_identity_from_profile() {
|
||||
let profile = test_profile(ClientOs::Mac);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("host-id"), Some(profile.host_id()));
|
||||
assert_eq!(find("serialno"), Some(profile.serialno()));
|
||||
assert_eq!(find("clientgpversion"), Some("6.3.3-100"));
|
||||
assert_eq!(find("computer"), Some("test-computer"));
|
||||
assert_eq!(find("os-version"), Some(profile.os_version()));
|
||||
assert_eq!(find("clientos"), Some("Mac"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linux_saml_sets_passwd_to_samlpass() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = prelogin_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str());
|
||||
assert_eq!(passwd, Some("SAMLPASS"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mac_saml_sets_passwd_to_empty() {
|
||||
let profile = test_profile(ClientOs::Mac);
|
||||
let cred = prelogin_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str());
|
||||
assert_eq!(passwd, Some(""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn saml_without_portal_auth_cookies_uses_empty_sentinel() {
|
||||
let profile = test_profile(ClientOs::Mac);
|
||||
let cred = Credential::Prelogin(PreloginCredential::new("alice", Some("my-prelogin-cookie"), None, None));
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("portal-userauthcookie"), Some("empty"));
|
||||
assert_eq!(find("portal-prelogonuserauthcookie"), Some("empty"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn saml_blank_portal_auth_cookie_uses_empty_sentinel() {
|
||||
let profile = test_profile(ClientOs::Mac);
|
||||
let cred = Credential::Prelogin(PreloginCredential::new(
|
||||
"alice",
|
||||
Some("my-prelogin-cookie"),
|
||||
Some(""),
|
||||
None,
|
||||
));
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let portal_cookie = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "portal-userauthcookie")
|
||||
.map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(portal_cookie, Some("empty"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_saml_sets_passwd_to_empty() {
|
||||
let profile = test_profile(ClientOs::Windows);
|
||||
let cred = prelogin_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str());
|
||||
assert_eq!(passwd, Some(""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn password_cred_sends_actual_password() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let passwd = result.body.iter().find(|(k, _)| k == "passwd").map(|(_, v)| v.as_str());
|
||||
assert_eq!(passwd, Some("secret"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn includes_csc_support_fields() {
|
||||
let profile = test_profile(ClientOs::Mac);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let find = |key: &str| result.body.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str());
|
||||
|
||||
assert_eq!(find("csc-support"), Some("yes"));
|
||||
assert_eq!(find("csc-digest"), Some(""));
|
||||
assert_eq!(find("config-digest"), Some(""));
|
||||
assert_eq!(find("swg-auth-token"), Some("0"));
|
||||
assert!(find("swg-nonce").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linux_uses_zero_swg_nonce() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = prelogin_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let nonce = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "swg-nonce")
|
||||
.map(|(_, v)| v.as_str());
|
||||
assert_eq!(nonce, Some("0"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn linux_defaults_csc_support_to_no() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let csc = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "csc-support")
|
||||
.map(|(_, v)| v.as_str());
|
||||
assert_eq!(csc, Some("no"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn csc_mode_override_works() {
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(test_profile(ClientOs::Linux))
|
||||
.csc_mode(CscMode::Yes)
|
||||
.build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let csc = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "csc-support")
|
||||
.map(|(_, v)| v.as_str());
|
||||
assert_eq!(csc, Some("yes"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn host_param_is_server_value() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let host = result.body.iter().find(|(k, _)| k == "host").map(|(_, v)| v.as_str());
|
||||
assert_eq!(host, Some("vpn.example.com"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn token_is_empty_for_password_cred() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
let token = result.body.iter().find(|(k, _)| k == "token").map(|(_, v)| v.as_str());
|
||||
assert_eq!(token, Some(""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn all_params_in_body_not_query() {
|
||||
let profile = test_profile(ClientOs::Linux);
|
||||
let cred = password_cred();
|
||||
let gp_params = GpParams::builder(profile.clone()).build();
|
||||
let result = build(&cred, &gp_params, "vpn.example.com");
|
||||
|
||||
assert!(!result.body.is_empty());
|
||||
assert!(result.query.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
use super::RequestParams;
|
||||
use crate::os_profile::{OsProfile, PreloginBrowserMode, PreloginParamLocation};
|
||||
|
||||
/// Build request parameters for the portal prelogin endpoint.
|
||||
///
|
||||
/// Parameters are placed in the request body for Linux/macOS and in the query
|
||||
/// string for Windows, based on `profile.prelogin_param_location()`.
|
||||
///
|
||||
/// When `profile.kerberos_support_in_query()` is true (macOS/Windows),
|
||||
/// `kerberos-support=yes` is added as a query parameter.
|
||||
pub(crate) fn build(profile: &OsProfile, browser_mode: PreloginBrowserMode) -> RequestParams {
|
||||
let default_browser = profile.portal_default_browser(browser_mode);
|
||||
|
||||
let params: Vec<(String, String)> = vec![
|
||||
("tmp".into(), "tmp".into()),
|
||||
("clientVer".into(), "4100".into()),
|
||||
("clientos".into(), profile.client_os().as_str().into()),
|
||||
("os-version".into(), profile.os_version().into()),
|
||||
("host-id".into(), profile.host_id().into()),
|
||||
("ipv6-support".into(), "yes".into()),
|
||||
("default-browser".into(), default_browser.into()),
|
||||
("cas-support".into(), "yes".into()),
|
||||
("data".into(), "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9".into()),
|
||||
];
|
||||
|
||||
let mut query: Vec<(String, String)> = vec![];
|
||||
if profile.kerberos_support_in_query() {
|
||||
query.push(("kerberos-support".into(), "yes".into()));
|
||||
}
|
||||
|
||||
match profile.prelogin_param_location() {
|
||||
PreloginParamLocation::Body => RequestParams { body: params, query },
|
||||
PreloginParamLocation::Query => RequestParams {
|
||||
body: vec![],
|
||||
query: params.into_iter().chain(query).collect(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::os_profile::ClientOs;
|
||||
|
||||
#[test]
|
||||
fn linux_places_params_in_body() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
assert!(!result.body.is_empty());
|
||||
assert!(result.query.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mac_places_params_in_body_with_kerberos_query() {
|
||||
let profile = OsProfile::builder(ClientOs::Mac).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
assert!(!result.body.is_empty());
|
||||
assert_eq!(result.query.len(), 1);
|
||||
assert_eq!(result.query[0], ("kerberos-support".into(), "yes".into()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_places_all_params_in_query() {
|
||||
let profile = OsProfile::builder(ClientOs::Windows).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
assert!(result.body.is_empty());
|
||||
// 9 base params + 1 kerberos-support
|
||||
assert_eq!(result.query.len(), 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uses_embedded_portal_default_browser_value() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let browser_param = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "default-browser")
|
||||
.expect("default-browser param should exist");
|
||||
assert_eq!(browser_param.1, "-10");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uses_target_value_when_external_browser_is_requested() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::External);
|
||||
|
||||
let browser_param = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "default-browser")
|
||||
.expect("default-browser param should exist");
|
||||
assert_eq!(browser_param.1, "4");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn includes_all_required_params() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let keys: Vec<&str> = result.body.iter().map(|(k, _)| k.as_str()).collect();
|
||||
assert!(keys.contains(&"tmp"));
|
||||
assert!(keys.contains(&"clientVer"));
|
||||
assert!(keys.contains(&"clientos"));
|
||||
assert!(keys.contains(&"os-version"));
|
||||
assert!(keys.contains(&"host-id"));
|
||||
assert!(keys.contains(&"ipv6-support"));
|
||||
assert!(keys.contains(&"default-browser"));
|
||||
assert!(keys.contains(&"cas-support"));
|
||||
assert!(keys.contains(&"data"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn data_param_is_cas_embedded_browser_base64() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let data_param = result
|
||||
.body
|
||||
.iter()
|
||||
.find(|(k, _)| k == "data")
|
||||
.expect("data param should exist");
|
||||
assert_eq!(data_param.1, "eyJjYXNfZW1iZWRkZWRfYnJvd3NlciI6InllcyJ9");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kerberos_not_in_query_for_linux() {
|
||||
let profile = OsProfile::builder(ClientOs::Linux).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let has_kerberos = result.query.iter().any(|(k, _)| k == "kerberos-support");
|
||||
assert!(!has_kerberos);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn kerberos_in_query_for_windows() {
|
||||
let profile = OsProfile::builder(ClientOs::Windows).build();
|
||||
let result = build(&profile, PreloginBrowserMode::Embedded);
|
||||
|
||||
let has_kerberos = result.query.iter().any(|(k, _)| k == "kerberos-support");
|
||||
assert!(has_kerberos);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user