Skip to content

Commit

Permalink
Add new test cases for URI encoding (#302)
Browse files Browse the repository at this point in the history
This adds some additional conformance tests for validating the encoding
of a query string in a URI.
  • Loading branch information
smaye81 authored Feb 3, 2025
1 parent 0390a45 commit 7d7000d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tools/protovalidate-conformance/internal/cases/cases_strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,16 @@ func stringSuite() suites.Suite {
},
),
},
"uri/invalid/encoding": {
Message: &cases.StringURI{Val: "http://example.com/foo/bar?baz=%x"},
Expected: results.Violations(
&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("string.uri"),
ConstraintId: proto.String("string.uri"),
},
),
},
"uri/invalid/not_checked/empty": {
Message: &cases.StringNotURI{Val: ""},
Expected: results.Success(true),
Expand Down Expand Up @@ -1076,6 +1086,26 @@ func stringSuite() suites.Suite {
},
),
},
"uri/invalid/absolute/encoding": {
Message: &cases.StringURI{Val: "https://example.com/foo/bar?baz=%x"},
Expected: results.Violations(
&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("string.uri"),
ConstraintId: proto.String("string.uri"),
},
),
},
"uri/invalid/relative/encoding": {
Message: &cases.StringURI{Val: "/foo/bar?baz=%x"},
Expected: results.Violations(
&validate.Violation{
Field: results.FieldPath("val"),
Rule: results.FieldPath("string.uri"),
ConstraintId: proto.String("string.uri"),
},
),
},
"uri_ref/valid/absolute": {
Message: &cases.StringURIRef{Val: "https://example.com/foo/bar?baz=quux"},
Expected: results.Success(true),
Expand Down

0 comments on commit 7d7000d

Please sign in to comment.