Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE-20756: Added regex for Property Key/Value #1668

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ private RbacKeys() {
private static final String ALLOWED_USER_URL_CHARS = "[-._a-zA-Z0-9]";
public static final String USER_URL_REGEX = ALLOWED_USER_URL_CHARS + "{3,200}[%40]{0,3}" + ALLOWED_USER_URL_CHARS + "{0,50}";

/**
* User property key and value regex.
*/
public static final String PROPERTY_KEY_VALUE_REGEX = "[-._a-zA-Z0-9]{1,255}";

/**
* CPI file checksum.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import net.corda.rbac.schema.RbacKeys.HSM_CATEGORY_REGEX
import net.corda.rbac.schema.RbacKeys.KEY_ID_REGEX
import net.corda.rbac.schema.RbacKeys.KEY_SCHEME_REGEX
import net.corda.rbac.schema.RbacKeys.OPTIONAL_QUERY_PARAMETER
import net.corda.rbac.schema.RbacKeys.PROPERTY_KEY_VALUE_REGEX
import net.corda.rbac.schema.RbacKeys.TENANT_ID_REGEX
import net.corda.rbac.schema.RbacKeys.USER_REGEX
import net.corda.rbac.schema.RbacKeys.USER_URL_REGEX
Expand Down Expand Up @@ -81,6 +82,14 @@ class TestPatternsMatch {
assertFalse(wildcardMatch("0", USER_URL_REGEX))
}

@Test
fun testPropertyKeyValue() {
val validPropertyKey = "My_Property-key.1"

assertTrue(wildcardMatch(validPropertyKey, PROPERTY_KEY_VALUE_REGEX))
assertFalse(wildcardMatch("Invalid@", PROPERTY_KEY_VALUE_REGEX))
}

@Test
fun testCPIFileChecksum() {
val validChecksum = "ABCDEF123456"
Expand Down