mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
fix: default gateway context fields
This commit is contained in:
1 file changed
+33
@@ -23,6 +23,7 @@ pub(crate) struct PriorityRule {
|
||||
pub struct Gateway {
|
||||
pub(crate) name: String,
|
||||
pub(crate) address: String,
|
||||
#[serde(default)]
|
||||
pub(crate) kind: GatewayKind,
|
||||
pub(crate) priority: u32,
|
||||
pub(crate) priority_rules: Vec<PriorityRule>,
|
||||
@@ -44,6 +45,12 @@ impl GatewayKind {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for GatewayKind {
|
||||
fn default() -> Self {
|
||||
Self::External
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Type, Clone, Copy, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum GatewaySelection {
|
||||
@@ -60,6 +67,12 @@ impl GatewaySelection {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for GatewaySelection {
|
||||
fn default() -> Self {
|
||||
Self::Auto
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct GatewayLoginContext {
|
||||
host: String,
|
||||
@@ -163,3 +176,23 @@ impl Gateway {
|
||||
self.kind
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn deserializes_gateway_without_kind_as_external() {
|
||||
let gateway: Gateway = serde_json::from_str(
|
||||
r#"{
|
||||
"name": "US East",
|
||||
"address": "us-east.example.com",
|
||||
"priority": 1,
|
||||
"priorityRules": []
|
||||
}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(gateway.kind(), GatewayKind::External);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user