Import Anubis v1.28.2

Replace the tree with upstream TecharoHQ/anubis v1.28.2 (a1384fbf42e3).
Masyunis customizations are re-applied in the following commits.
This commit is contained in:
sol_bot Bot committed 2026-11-28 14:52:26 +03:00
1 parent eb3e46d8d0
commit e07de898cd
573 files changed
+35846 -6807

No files matched your search

+87
View File
@@ -0,0 +1,87 @@
package config
import (
"errors"
"testing"
)
func TestHoneypotValid(t *testing.T) {
for _, cs := range []struct {
err error
name string
inp Honeypot
}{
{
name: "naive enabled",
inp: Honeypot{
Enabled: true,
Implementation: "naive",
},
err: nil,
},
{
name: "naive disabled",
inp: Honeypot{
Enabled: false,
Implementation: "naive",
},
err: nil,
},
{
name: "empty implementation",
inp: Honeypot{
Enabled: true,
Implementation: "",
},
err: ErrInvalidHoneypotMethod,
},
{
name: "unknown implementation",
inp: Honeypot{
Enabled: true,
Implementation: "sophisticated",
},
err: ErrInvalidHoneypotMethod,
},
{
name: "wrong case implementation",
inp: Honeypot{
Enabled: true,
Implementation: "Naive",
},
err: ErrInvalidHoneypotMethod,
},
{
name: "zero value",
inp: Honeypot{},
err: nil,
},
} {
t.Run(cs.name, func(t *testing.T) {
if err := cs.inp.Valid(); !errors.Is(err, cs.err) {
t.Logf("want: %v", cs.err)
t.Logf("got: %v", err)
t.Error("validation returned an unexpected error")
}
})
}
}
func TestHoneypotDefault(t *testing.T) {
want := Honeypot{
Enabled: true,
Implementation: "naive",
}
got := (Honeypot{}).Default()
if got != want {
t.Errorf("Default() = %+v, want %+v", got, want)
}
}
func TestHoneypotDefaultIsValid(t *testing.T) {
h := (Honeypot{}).Default()
if err := h.Valid(); err != nil {
t.Fatal(err)
}
}