Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
sharedlimit "git.sendico.io/tech/sxchnge/bff/edge/shared/interface/ratelimit"
|
||||
"git.sendico.io/tech/sxchnge/bff/pkg/merrors"
|
||||
)
|
||||
|
||||
func TestVerificationRateLimitsDefaults(t *testing.T) {
|
||||
got, err := (*VerificationConfig)(nil).ResolveRateLimits()
|
||||
if err != nil {
|
||||
t.Fatalf("resolve defaults: %v", err)
|
||||
}
|
||||
if got.PerDestination.Limit != 5 || got.PerDestination.Window != time.Hour ||
|
||||
got.PerIP.Limit != 20 || got.PerIP.Window != time.Hour {
|
||||
t.Fatalf("unexpected defaults: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVerificationRateLimitsRejectInvalidPolicy(t *testing.T) {
|
||||
cfg := &VerificationConfig{RateLimits: &VerificationRateLimitsConfig{
|
||||
PerDestination: sharedlimit.WindowConfig{Limit: 5, Window: "1h"},
|
||||
PerIP: sharedlimit.WindowConfig{Limit: 0, Window: "1h"},
|
||||
}}
|
||||
_, err := cfg.ResolveRateLimits()
|
||||
if !errors.Is(err, merrors.ErrInvalidArg) {
|
||||
t.Fatalf("expected invalid argument, got %v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user