mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-17 13:54:59 +00:00
fix(thoth): minor testing fixups, ensure ASNChecker is Checker
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -5,16 +5,19 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/TecharoHQ/anubis/lib/policy"
|
||||||
iptoasnv1 "github.com/TecharoHQ/thoth-proto/gen/techaro/thoth/iptoasn/v1"
|
iptoasnv1 "github.com/TecharoHQ/thoth-proto/gen/techaro/thoth/iptoasn/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ policy.Checker = &ASNChecker{}
|
||||||
|
|
||||||
func TestASNChecker(t *testing.T) {
|
func TestASNChecker(t *testing.T) {
|
||||||
cli := loadSecrets(t)
|
cli := loadSecrets(t)
|
||||||
|
|
||||||
asnc := &ASNChecker{
|
asnc := &ASNChecker{
|
||||||
iptoasn: cli.iptoasn,
|
iptoasn: cli.iptoasn,
|
||||||
asns: map[int]struct{}{
|
asns: map[int]struct{}{
|
||||||
13335: struct{}{},
|
13335: {},
|
||||||
},
|
},
|
||||||
hash: "foobar",
|
hash: "foobar",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
iptoasnv1 "github.com/TecharoHQ/thoth-proto/gen/techaro/thoth/iptoasn/v1"
|
iptoasnv1 "github.com/TecharoHQ/thoth-proto/gen/techaro/thoth/iptoasn/v1"
|
||||||
grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
|
grpcprom "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
|
||||||
|
"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/timeout"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
@@ -34,6 +36,7 @@ func New(ctx context.Context, thothURL, apiToken string) (*Client, error) {
|
|||||||
thothURL,
|
thothURL,
|
||||||
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
|
grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
|
||||||
grpc.WithChainUnaryInterceptor(
|
grpc.WithChainUnaryInterceptor(
|
||||||
|
timeout.UnaryClientInterceptor(500*time.Millisecond),
|
||||||
clMetrics.UnaryClientInterceptor(),
|
clMetrics.UnaryClientInterceptor(),
|
||||||
authUnaryClientInterceptor(apiToken),
|
authUnaryClientInterceptor(apiToken),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user