From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id CF5561FF0EA for ; Thu, 13 Aug 2026 17:06:06 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 516DD218FA; Thu, 13 Aug 2026 17:06:02 +0200 (CEST) From: Thomas Ellmenreich To: pdm-devel@lists.proxmox.com Subject: [PATCH proxmox 1/4] api-types: reorganise unit tests Date: Thu, 13 Aug 2026 17:05:48 +0200 Message-ID: <20260813150551.415237-2-t.ellmenreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260813150551.415237-1-t.ellmenreich@proxmox.com> References: <20260813150551.415237-1-t.ellmenreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1786633539770 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.110 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: VB6UKOHME47DWH4BZFOWVF6KYBTNJJV2 X-Message-ID-Hash: VB6UKOHME47DWH4BZFOWVF6KYBTNJJV2 X-MailFrom: t.ellmenreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Thomas Ellmenreich X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: In preparation for extending the api_types tests, reorganzie them into their own module. Also, split the large test into several smaller ones to make them clearer. Signed-off-by: Thomas Ellmenreich --- proxmox-schema/src/api_types.rs | 76 +++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/proxmox-schema/src/api_types.rs b/proxmox-schema/src/api_types.rs index d6a0608c..553eb054 100644 --- a/proxmox-schema/src/api_types.rs +++ b/proxmox-schema/src/api_types.rs @@ -270,35 +270,49 @@ pub const DISK_LIST_SCHEMA: Schema = StringSchema::new("A list of disk names, co .format(&ApiStringFormat::PropertyString(&DISK_ARRAY_SCHEMA)) .schema(); -#[test] -fn test_regexes() { - assert!(IP_REGEX.is_match("127.0.0.1")); - assert!(IP_V4_REGEX.is_match("127.0.0.1")); - assert!(!IP_V6_REGEX.is_match("127.0.0.1")); - - assert!(CIDR_V4_REGEX.is_match("127.0.0.1/24")); - assert!(CIDR_REGEX.is_match("127.0.0.1/24")); - - assert!(IP_REGEX.is_match("::1")); - assert!(IP_REGEX.is_match("2014:b3a::27")); - assert!(IP_REGEX.is_match("2014:b3a::192.168.0.1")); - assert!(IP_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF")); - assert!(!IP_V4_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF")); - assert!(IP_V6_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF")); - - assert!(CIDR_V6_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF/60")); - assert!(CIDR_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF/60")); - - assert!(IP_BRACKET_REGEX.is_match("127.0.0.1")); - assert!(IP_BRACKET_REGEX.is_match("[::1]")); - assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::27]")); - assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::192.168.0.1]")); - assert!(IP_BRACKET_REGEX.is_match("[2014:b3a:0102:adf1:1234:4321:4afA:BCDF]")); - - assert!(ED25519_BASE64_KEY_REGEX.is_match("KNpc7alqlLTaWE6RzuzHGioKs7Nqh/z3YxMJojpSelA=")); - assert!(!ED25519_BASE64_KEY_REGEX.is_match("")); - // 31 bytes of data - assert!(!ED25519_BASE64_KEY_REGEX.is_match("6zroXbjGs9sdOpr1n/M5hh+UklBxtQ90tGQDnYzJfw==")); - // 33 bytes of data - assert!(!ED25519_BASE64_KEY_REGEX.is_match("IiC3Nkh4Fn2ukUZUNmdK5K5CWO53Zmk/eGlKO4m6aCD/")); +#[cfg(test)] +mod tests { + use super::{ + CIDR_REGEX, CIDR_V4_REGEX, CIDR_V6_REGEX, ED25519_BASE64_KEY_REGEX, IP_BRACKET_REGEX, + IP_REGEX, IP_V4_REGEX, IP_V6_REGEX, + }; + + #[test] + fn test_ip_regexes() { + assert!(IP_REGEX.is_match("127.0.0.1")); + assert!(IP_V4_REGEX.is_match("127.0.0.1")); + assert!(!IP_V6_REGEX.is_match("127.0.0.1")); + + assert!(IP_REGEX.is_match("::1")); + assert!(IP_REGEX.is_match("2014:b3a::27")); + assert!(IP_REGEX.is_match("2014:b3a::192.168.0.1")); + assert!(IP_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF")); + assert!(!IP_V4_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF")); + assert!(IP_V6_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF")); + + assert!(IP_BRACKET_REGEX.is_match("127.0.0.1")); + assert!(IP_BRACKET_REGEX.is_match("[::1]")); + assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::27]")); + assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::192.168.0.1]")); + assert!(IP_BRACKET_REGEX.is_match("[2014:b3a:0102:adf1:1234:4321:4afA:BCDF]")); + } + + #[test] + fn test_cidr_regexes() { + assert!(CIDR_V4_REGEX.is_match("127.0.0.1/24")); + assert!(CIDR_REGEX.is_match("127.0.0.1/24")); + + assert!(CIDR_V6_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF/60")); + assert!(CIDR_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF/60")); + } + + #[test] + fn test_ed25519_regex() { + assert!(ED25519_BASE64_KEY_REGEX.is_match("KNpc7alqlLTaWE6RzuzHGioKs7Nqh/z3YxMJojpSelA=")); + assert!(!ED25519_BASE64_KEY_REGEX.is_match("")); + // 31 bytes of data + assert!(!ED25519_BASE64_KEY_REGEX.is_match("6zroXbjGs9sdOpr1n/M5hh+UklBxtQ90tGQDnYzJfw==")); + // 33 bytes of data + assert!(!ED25519_BASE64_KEY_REGEX.is_match("IiC3Nkh4Fn2ukUZUNmdK5K5CWO53Zmk/eGlKO4m6aCD/")); + } } -- 2.47.3