|
|
|
internal/policy/file_limits_test.go raw
| 1 | package policy | | 2 | | | 3 | import ( | | 4 | "encoding/json" | | 5 | "testing" | | 6 | ) | | 7 | | | 8 | func TestFileLimitsPatchAndValidation(t *testing.T) { | | 9 | p := Defaults("owner" ) | | 10 | p.FileLimits = FileLimits{MaxFileBytes: 1024, UserStorageBytes: 4096} | | 11 | updated, err := Patch(p, map[string]json.RawMessage{"fileLimits" : json.RawMessage(`{"maxFileBytes":2048}` )}) | | 12 | if err != nil { | | 13 | t.Fatal(err) | | 14 | } | | 15 | if updated.FileLimits.MaxFileBytes != 2048 || updated.FileLimits.UserStorageBytes != 4096 { | | 16 | t.Fatalf("partial limit patch lost settings: %+v" , updated.FileLimits) | | 17 | } | | 18 | for _, patch := range []string{`{"maxFileBytes":-1}` , `{"userStorageBytes":-1}` } { | | 19 | if _, err := Patch(p, map[string]json.RawMessage{"fileLimits" : json.RawMessage(patch)}); err == nil { | | 20 | t.Fatalf("accepted negative limit: %s" , patch) | | 21 | } | | 22 | } | | 23 | updated, err = Patch(p, map[string]json.RawMessage{"fileLimits" : json.RawMessage(`{"maxFileBytes":0,"userStorageBytes":0}` )}) | | 24 | if err != nil || updated.FileLimits != (FileLimits{}) { | | 25 | t.Fatalf("zero should disable limits: %+v, %v" , updated.FileLimits, err) | | 26 | } | | 27 | } |
|
|
About| owner | c01503e8035f |
|---|
| visibility | public |
|---|
| head | d730679639bf |
|---|
Maintainers- c01503e8035f owner
- ba1b5beed5b5 agent hermes
Clonehttps://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git
|