Skip to content

Commit dea4f44

Browse files
authored
Add more tests for isHostAndPort (#347)
1 parent f07f281 commit dea4f44

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tools/protovalidate-conformance/internal/cases/cases_is_host_and_port.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,38 @@ func isHostAndPortSuite() suites.Suite {
120120
Message: &cases.IsHostAndPort{Val: "example.com:0", PortRequired: true},
121121
Expected: results.Success(true),
122122
},
123+
"port_required/true/invalid/port_double_zero": {
124+
Message: &cases.IsHostAndPort{Val: "example.com:00", PortRequired: true},
125+
Expected: results.Violations(
126+
&validate.Violation{
127+
ConstraintId: proto.String("library.is_host_and_port"),
128+
},
129+
),
130+
},
131+
"port_required/true/invalid/port_leading_zero": {
132+
Message: &cases.IsHostAndPort{Val: "example.com:080", PortRequired: true},
133+
Expected: results.Violations(
134+
&validate.Violation{
135+
ConstraintId: proto.String("library.is_host_and_port"),
136+
},
137+
),
138+
},
139+
"port_required/false/invalid/port_double_zero": {
140+
Message: &cases.IsHostAndPort{Val: "example.com:00"},
141+
Expected: results.Violations(
142+
&validate.Violation{
143+
ConstraintId: proto.String("library.is_host_and_port"),
144+
},
145+
),
146+
},
147+
"port_required/false/invalid/port_leading_zero": {
148+
Message: &cases.IsHostAndPort{Val: "example.com:080"},
149+
Expected: results.Violations(
150+
&validate.Violation{
151+
ConstraintId: proto.String("library.is_host_and_port"),
152+
},
153+
),
154+
},
123155
"port_required/true/invalid/port_number_sign": {
124156
Message: &cases.IsHostAndPort{Val: "example.com:+0", PortRequired: true},
125157
Expected: results.Violations(
@@ -300,6 +332,10 @@ func isHostAndPortSuite() suites.Suite {
300332
Message: &cases.IsHostAndPort{Val: "[::1%% :x\x1F]"},
301333
Expected: results.Success(true),
302334
},
335+
"port_required/false/valid/ipv6_zone-id_any_non_null_character_2": {
336+
Message: &cases.IsHostAndPort{Val: "[::0%00]]"},
337+
Expected: results.Success(true),
338+
},
303339
"port_required/false/invalid/ipv4_in_brackets": {
304340
Message: &cases.IsHostAndPort{Val: "[127.0.0.1]"},
305341
Expected: results.Violations(

0 commit comments

Comments
 (0)