mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-20 06:56:17 -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 struct Gateway {
|
||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
pub(crate) address: String,
|
pub(crate) address: String,
|
||||||
|
#[serde(default)]
|
||||||
pub(crate) kind: GatewayKind,
|
pub(crate) kind: GatewayKind,
|
||||||
pub(crate) priority: u32,
|
pub(crate) priority: u32,
|
||||||
pub(crate) priority_rules: Vec<PriorityRule>,
|
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)]
|
#[derive(Debug, Serialize, Deserialize, Type, Clone, Copy, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub enum GatewaySelection {
|
pub enum GatewaySelection {
|
||||||
@@ -60,6 +67,12 @@ impl GatewaySelection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for GatewaySelection {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Auto
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct GatewayLoginContext {
|
pub struct GatewayLoginContext {
|
||||||
host: String,
|
host: String,
|
||||||
@@ -163,3 +176,23 @@ impl Gateway {
|
|||||||
self.kind
|
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