From 4c7fa12a2aa1967329c29aafe1341e01460ed032 Mon Sep 17 00:00:00 2001 From: khanova <32508607+khanova@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:26:15 +0100 Subject: [PATCH] Proxy introduce allowed ips (#5729) ## Problem Proxy doesn't accept wake_compute responses with the allowed IPs. ## Summary of changes Extend wake_compute api to be able to return allowed_ips. --- proxy/src/console/messages.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/proxy/src/console/messages.rs b/proxy/src/console/messages.rs index 0d321c077a..e5f1615b14 100644 --- a/proxy/src/console/messages.rs +++ b/proxy/src/console/messages.rs @@ -13,6 +13,7 @@ pub struct ConsoleError { #[derive(Deserialize)] pub struct GetRoleSecret { pub role_secret: Box, + pub allowed_ips: Option>>, } // Manually implement debug to omit sensitive info. @@ -187,4 +188,31 @@ mod tests { Ok(()) } + + #[test] + fn parse_wake_compute() -> anyhow::Result<()> { + let json = json!({ + "address": "0.0.0.0", + "aux": dummy_aux(), + }); + let _: WakeCompute = serde_json::from_str(&json.to_string())?; + Ok(()) + } + + #[test] + fn parse_get_role_secret() -> anyhow::Result<()> { + // Empty `allowed_ips` field. + let json = json!({ + "role_secret": "secret", + }); + let _: GetRoleSecret = serde_json::from_str(&json.to_string())?; + // Empty `allowed_ips` field. + let json = json!({ + "role_secret": "secret", + "allowed_ips": ["8.8.8.8"], + }); + let _: GetRoleSecret = serde_json::from_str(&json.to_string())?; + + Ok(()) + } }