diff --git a/proxmox-subscription/src/check.rs b/proxmox-subscription/src/check.rs index 40bd41ab..f65ee7f3 100644 --- a/proxmox-subscription/src/check.rs +++ b/proxmox-subscription/src/check.rs @@ -55,6 +55,7 @@ fn parse_status(value: &str) -> SubscriptionStatus { "notfound" => SubscriptionStatus::NotFound, "invalid" => SubscriptionStatus::Invalid, "expired" => SubscriptionStatus::Expired, + "suspended" => SubscriptionStatus::Suspended, _ => SubscriptionStatus::Invalid, } } @@ -149,7 +150,7 @@ fn test_parse_register_response() -> Result<(), Error> { info, SubscriptionInfo { key: Some(key), - serverid: Some(server_id), + serverid: Some(server_id.clone()), status: SubscriptionStatus::Active, checktime: Some(checktime), url: Some("https://www.proxmox.com/en/proxmox-backup-server/pricing".into()), @@ -160,6 +161,49 @@ fn test_parse_register_response() -> Result<(), Error> { signature: None, } ); + + let response = r#" +Suspended +Test 12345 +65977 +11 +Proxmox VE Test Subscription -1 year +2022-09-20 00:00:00 +2022-09-20 +Annually +proxmox.com,www.proxmox.com +830000000123456789ABCDEF00000042 +Notes=Test Key! + +969f4df84fe157ee4f5a2f71950ad154 +"#; + + let key = "pvet-123456789a".to_string(); + let info = parse_register_response( + response, + key.to_owned(), + server_id.to_owned(), + checktime, + salt, + "https://www.proxmox.com/en/proxmox-ve/pricing".to_string(), + )?; + + assert_eq!( + info, + SubscriptionInfo { + key: Some(key), + serverid: Some(server_id), + status: SubscriptionStatus::Suspended, + checktime: Some(checktime), + url: Some("https://www.proxmox.com/en/proxmox-ve/pricing".into()), + message: None, + nextduedate: Some("2022-09-20".into()), + regdate: Some("2022-09-20 00:00:00".into()), + productname: Some("Proxmox VE Test Subscription -1 year".into()), + signature: None, + } + ); + Ok(()) } diff --git a/proxmox-subscription/src/subscription_info.rs b/proxmox-subscription/src/subscription_info.rs index adeada95..a5c32b1e 100644 --- a/proxmox-subscription/src/subscription_info.rs +++ b/proxmox-subscription/src/subscription_info.rs @@ -40,6 +40,9 @@ pub enum SubscriptionStatus { /// subscription set but expired for this server #[serde(alias = "Expired")] Expired, + /// subscription got (recently) suspended + #[serde(alias = "Suspended")] + Suspended, } impl Default for SubscriptionStatus { fn default() -> Self { @@ -54,6 +57,7 @@ impl std::fmt::Display for SubscriptionStatus { SubscriptionStatus::Active => write!(f, "active"), SubscriptionStatus::Invalid => write!(f, "invalid"), SubscriptionStatus::Expired => write!(f, "expired"), + SubscriptionStatus::Suspended => write!(f, "suspended"), } } }