This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git
The following commit(s) were added to refs/heads/master by this push:
new e10f59e change regular expression of getkey (#255)
e10f59e is described below
commit e10f59effb90980441db32fbe2fa67a89790e3ba
Author: kkf1 <[email protected]>
AuthorDate: Mon Aug 15 15:33:33 2022 +0800
change regular expression of getkey (#255)
* change regular expression of getkey
* change regular expression of getkey
---
pkg/validator/rule.go | 2 +-
pkg/validator/rule_test.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/pkg/validator/rule.go b/pkg/validator/rule.go
index 612017a..2568741 100644
--- a/pkg/validator/rule.go
+++ b/pkg/validator/rule.go
@@ -25,7 +25,7 @@ const (
commonNameRegexString =
`^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$`
labelKeyRegexString =
`^[a-zA-Z0-9]{1,32}$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]{1,30}[a-zA-Z0-9]$`
labelValueRegexString =
`^[a-zA-Z0-9]{0,160}$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]{0,158}[a-zA-Z0-9]$`
- getKeyRegexString =
`^[a-zA-Z0-9]*$|^[a-zA-Z0-9][a-zA-Z0-9_\-.]*[a-zA-Z0-9]$|^beginWith\([a-zA-Z0-9][a-zA-Z0-9_\-.]*\)$|^wildcard\([a-zA-Z0-9*][a-zA-Z0-9_\-.*]*\)$`
+ getKeyRegexString =
`^[a-zA-Z0-9._:-]*$|^beginWith\([a-zA-Z0-9._:-]*\)$|^wildcard\([a-zA-Z0-9*._:-]*\)$`
asciiRegexString = `^[\x00-\x7F]*$`
allCharString = `.*`
)
diff --git a/pkg/validator/rule_test.go b/pkg/validator/rule_test.go
index db1a4ae..a76d3b9 100644
--- a/pkg/validator/rule_test.go
+++ b/pkg/validator/rule_test.go
@@ -238,3 +238,61 @@ func TestStatus(t *testing.T) {
}
assert.Error(t, validator.Validate(kvDoc))
}
+
+func TestGetKey(t *testing.T) {
+ listKvreq := model.ListKVRequest{
+ Project: "default",
+ Domain: "default",
+ Key: "beginWith(zZ12.-_:)",
+ Labels: map[string]string{
+ "service": "utService",
+ },
+ Offset: 0,
+ Limit: 10,
+ Status: "enabled",
+ Match: "exact",
+ }
+ assert.NoError(t, validator.Validate(listKvreq))
+
+ listKvreq = model.ListKVRequest{
+ Project: "default",
+ Domain: "default",
+ Key: "wildcard(*IME*)",
+ Labels: map[string]string{
+ "service": "utService",
+ },
+ Offset: 0,
+ Limit: 10,
+ Status: "enabled",
+ Match: "exact",
+ }
+ assert.NoError(t, validator.Validate(listKvreq))
+
+ listKvreq = model.ListKVRequest{
+ Project: "default",
+ Domain: "default",
+ Key: "zZ12.-_:",
+ Labels: map[string]string{
+ "service": "utService",
+ },
+ Offset: 0,
+ Limit: 10,
+ Status: "enabled",
+ Match: "exact",
+ }
+ assert.NoError(t, validator.Validate(listKvreq))
+
+ listKvreq = model.ListKVRequest{
+ Project: "default",
+ Domain: "default",
+ Key: "wildcard(*zZ12.-_:*)",
+ Labels: map[string]string{
+ "service": "utService",
+ },
+ Offset: 0,
+ Limit: 10,
+ Status: "enabled",
+ Match: "exact",
+ }
+ assert.NoError(t, validator.Validate(listKvreq))
+}