Skip to content

Commit

Permalink
add InputValidatorTest
Browse files Browse the repository at this point in the history
  • Loading branch information
AbnerHuang2 committed Sep 15, 2022
1 parent f07a3f3 commit 6448534
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
public class InputValidator {
public static final String INVALID_CLUSTER_NAMESPACE_MESSAGE = "Only digits, alphabets and symbol - _ . (except single .) are allowed";
public static final String INVALID_NAMESPACE_NAMESPACE_MESSAGE = "not allowed to end with .json, .yml, .yaml, .xml, .properties";
public static final String CLUSTER_NAMESPACE_VALIDATOR = "[0-9a-zA-Z-]+[0-9a-zA-Z._-]*";
private static final String APP_NAMESPACE_VALIDATOR = "[a-zA-Z0-9._-]+(?<!\\.(json|yml|yaml|xml|properties))$";
public static final String CLUSTER_NAMESPACE_VALIDATOR = "[0-9a-zA-Z_-]+[0-9a-zA-Z_.-]*";
private static final String APP_NAMESPACE_VALIDATOR = "[a-zA-Z0-9_-]+[a-zA-Z0-9._-]*(?<!\\.(json|yml|yaml|xml|properties))$";
private static final Pattern CLUSTER_NAMESPACE_PATTERN = Pattern.compile(CLUSTER_NAMESPACE_VALIDATOR);
private static final Pattern APP_NAMESPACE_PATTERN = Pattern.compile(APP_NAMESPACE_VALIDATOR);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void testValidClusterName() throws Exception {
checkClusterName("some.&.name", false);
checkClusterName("", false);
checkClusterName(null, false);
checkClusterName(".",false);
}

@Test
Expand All @@ -42,6 +43,7 @@ public void testValidAppNamespaceName() throws Exception {
checkAppNamespaceName("some.name.yaml", false);
checkAppNamespaceName("some.name.xml", false);
checkAppNamespaceName("some.name.properties", false);
checkAppNamespaceName("..xml", false);
}

private void checkClusterName(String name, boolean valid) {
Expand Down

0 comments on commit 6448534

Please sign in to comment.