public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
To: pdm-devel@lists.proxmox.com
Cc: Thomas Ellmenreich <t.ellmenreich@proxmox.com>
Subject: [PATCH proxmox 1/4] api-types: reorganise unit tests
Date: Thu, 13 Aug 2026 17:05:48 +0200	[thread overview]
Message-ID: <20260813150551.415237-2-t.ellmenreich@proxmox.com> (raw)
In-Reply-To: <20260813150551.415237-1-t.ellmenreich@proxmox.com>

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 <t.ellmenreich@proxmox.com>
---
 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





  reply	other threads:[~2026-08-13 15:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 15:05 [PATCH datacenter-manager/proxmox 0/4] fix #7747: OpenID: allow non HTTP scheme in redirect URL Thomas Ellmenreich
2026-08-13 15:05 ` Thomas Ellmenreich [this message]
2026-08-13 15:05 ` [PATCH proxmox 2/4] api-types: refactor HTTP_URL_REGEX construction Thomas Ellmenreich
2026-08-13 15:05 ` [PATCH proxmox 3/4] api-types: add a scheme generic URL regex Thomas Ellmenreich
2026-08-13 15:05 ` [PATCH datacenter-manager 4/4] fix #7747: openid: allow non HTTP schemes in redirect URL Thomas Ellmenreich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260813150551.415237-2-t.ellmenreich@proxmox.com \
    --to=t.ellmenreich@proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal