Skip to content

Change validation in Duration type in CRDs and NGF #2525

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Update validation tests
  • Loading branch information
bjee19 committed Sep 11, 2024
commit 54d0e298c6ef793eb21e903603a6ffe7facb41b4
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,19 @@ func TestValidator_Validate(t *testing.T) {
return p
}),
expConditions: []conditions.Condition{
staticConds.NewPolicyInvalid("[spec.body.timeout: Invalid value: \"invalid\": \\d{1,4}(ms|s)? " +
"(e.g. '5ms', or '10s', regex used for validation is 'must contain a number followed by 'ms' or 's''), " +
"spec.keepAlive.time: Invalid value: \"invalid\": \\d{1,4}(ms|s)? (e.g. '5ms', or '10s', regex used for " +
"validation is 'must contain a number followed by 'ms' or 's''), spec.keepAlive.timeout.server: Invalid value: " +
"\"invalid\": \\d{1,4}(ms|s)? (e.g. '5ms', or '10s', regex used for validation is 'must contain a number " +
"followed by 'ms' or 's''), spec.keepAlive.timeout.header: Invalid value: \"invalid\": \\d{1,4}(ms|s)? " +
"(e.g. '5ms', or '10s', regex used for validation is 'must contain a number followed by 'ms' or 's'')]"),
staticConds.NewPolicyInvalid(
"[spec.body.timeout: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
"spec.keepAlive.time: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
"spec.keepAlive.timeout.server: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h''), " +
"spec.keepAlive.timeout.header: Invalid value: \"invalid\": ^[0-9]{1,4}(ms|s|m|h)? " +
"(e.g. '5ms', or '10s', or '500m', or '1000h', regex used for validation is " +
"'must contain an, at most, four digit number followed by 'ms', 's', 'm', or 'h'')]"),
},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ func TestValidateNginxDuration(t *testing.T) {
`5ms`,
`10s`,
`123ms`,
`5m`,
`2h`,
)

testInvalidValuesForSimpleValidator(
t,
validator.ValidateNginxDuration,
`test`,
`12345`,
`5m`,
`5k`,
)
}

Expand Down
Loading