Cap sync_interval at 30 days (#174)
sync_interval has no upper bound, so a value above MaxInt32 passes validation and then fails the INTEGER column insert as a 500, and very large values overflow time.Duration. - add MaxSyncInterval (30 days in seconds) - reject sync_interval above it with a 400 via ValidateSyncInterval - cover the boundary in TestValidateSyncInterval and over-limit values in TestSyncIntervalAPI Reviewed-on: #174 Co-authored-by: unkin-agent <unkin-agent@unkin.net> Co-committed-by: unkin-agent <unkin-agent@unkin.net>
This commit was merged in pull request #174.
This commit is contained in:
@@ -57,7 +57,7 @@ func TestMutableTTLOmittedVsZero(t *testing.T) {
|
||||
}
|
||||
|
||||
// sync_interval round-trips through the API and DB on github_* remotes and is
|
||||
// rejected when negative or on a type without a background syncer.
|
||||
// rejected when negative, over the maximum, or on a type without a background syncer.
|
||||
func TestSyncIntervalAPI(t *testing.T) {
|
||||
if testDSN == "" {
|
||||
t.Skip("Docker unavailable")
|
||||
@@ -93,6 +93,8 @@ func TestSyncIntervalAPI(t *testing.T) {
|
||||
|
||||
for _, body := range []string{
|
||||
`{"name":"si-neg",` + gh + `,"sync_interval":-1}`,
|
||||
`{"name":"si-max",` + gh + `,"sync_interval":2592001}`,
|
||||
`{"name":"si-int32",` + gh + `,"sync_interval":2147483648}`,
|
||||
`{"name":"si-rpm","package_type":"rpm","base_url":"https://example.com/repo","sync_interval":60}`,
|
||||
} {
|
||||
if c := do(t, h, "POST", "/", body); c != 400 {
|
||||
|
||||
Reference in New Issue
Block a user