mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-21 07:36:40 +00:00
feat: wire up asn and geoip checkers
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
|
||||
"github.com/TecharoHQ/anubis"
|
||||
"github.com/TecharoHQ/anubis/data"
|
||||
"github.com/TecharoHQ/anubis/internal/thoth"
|
||||
"github.com/TecharoHQ/anubis/internal/thoth/thothmock"
|
||||
)
|
||||
|
||||
func TestDefaultPolicyMustParse(t *testing.T) {
|
||||
@@ -16,7 +18,11 @@ func TestDefaultPolicyMustParse(t *testing.T) {
|
||||
}
|
||||
defer fin.Close()
|
||||
|
||||
if _, err := ParseConfig(t.Context(), fin, "botPolicies.json", anubis.DefaultDifficulty); err != nil {
|
||||
thothCli := &thoth.Client{}
|
||||
thothCli.WithIPToASNService(thothmock.MockIpToASNService())
|
||||
ctx := thoth.With(t.Context(), thothCli)
|
||||
|
||||
if _, err := ParseConfig(ctx, fin, "botPolicies.json", anubis.DefaultDifficulty); err != nil {
|
||||
t.Fatalf("can't parse config: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -36,7 +42,11 @@ func TestGoodConfigs(t *testing.T) {
|
||||
}
|
||||
defer fin.Close()
|
||||
|
||||
if _, err := ParseConfig(t.Context(), fin, fin.Name(), anubis.DefaultDifficulty); err != nil {
|
||||
thothCli := &thoth.Client{}
|
||||
thothCli.WithIPToASNService(thothmock.MockIpToASNService())
|
||||
ctx := thoth.With(t.Context(), thothCli)
|
||||
|
||||
if _, err := ParseConfig(ctx, fin, fin.Name(), anubis.DefaultDifficulty); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
})
|
||||
@@ -58,7 +68,11 @@ func TestBadConfigs(t *testing.T) {
|
||||
}
|
||||
defer fin.Close()
|
||||
|
||||
if _, err := ParseConfig(t.Context(), fin, fin.Name(), anubis.DefaultDifficulty); err == nil {
|
||||
thothCli := &thoth.Client{}
|
||||
thothCli.WithIPToASNService(thothmock.MockIpToASNService())
|
||||
ctx := thoth.With(t.Context(), thothCli)
|
||||
|
||||
if _, err := ParseConfig(ctx, fin, fin.Name(), anubis.DefaultDifficulty); err == nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
t.Log(err)
|
||||
|
||||
Reference in New Issue
Block a user