From 29a0ea32c69df836bc3e5a5247810c55fd9bd775 Mon Sep 17 00:00:00 2001 From: "Mr.An" <42627702+SnowMoon-Dev@users.noreply.github.com> Date: Sat, 23 Apr 2022 18:41:03 +0800 Subject: [PATCH] [Fix] Support more generic tenant code when create tenant (#9634) --- .../apache/dolphinscheduler/api/utils/RegexUtils.java | 2 +- .../dolphinscheduler/api/utils/RegexUtilsTest.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/RegexUtils.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/RegexUtils.java index 3fd12d90ba..df94af687b 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/RegexUtils.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/utils/RegexUtils.java @@ -26,7 +26,7 @@ import java.util.regex.Pattern; */ public class RegexUtils { - private static final String LINUX_USERNAME_PATTERN = "[a-z_][a-z\\d_]{0,30}"; + private static final String LINUX_USERNAME_PATTERN = "^[a-zA-Z0-9_].{0,30}"; private RegexUtils() { } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/RegexUtilsTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/RegexUtilsTest.java index 2a339fdea8..f37b057fcf 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/RegexUtilsTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/RegexUtilsTest.java @@ -28,10 +28,10 @@ public class RegexUtilsTest { @Test public void testIsValidLinuxUserName() { String name1 = "10000"; - Assert.assertFalse(RegexUtils.isValidLinuxUserName(name1)); + Assert.assertTrue(RegexUtils.isValidLinuxUserName(name1)); String name2 = "00hayden"; - Assert.assertFalse(RegexUtils.isValidLinuxUserName(name2)); + Assert.assertTrue(RegexUtils.isValidLinuxUserName(name2)); String name3 = "hayde123456789123456789123456789"; Assert.assertFalse(RegexUtils.isValidLinuxUserName(name3)); @@ -44,6 +44,12 @@ public class RegexUtilsTest { String name6 = "hayden"; Assert.assertTrue(RegexUtils.isValidLinuxUserName(name6)); + + String name7 = "00hayden_0"; + Assert.assertTrue(RegexUtils.isValidLinuxUserName(name2)); + + String name8 = "00hayden.8"; + Assert.assertTrue(RegexUtils.isValidLinuxUserName(name2)); } @Test