go-socks5/ruleset_test.go
2020-04-19 23:40:14 +08:00

24 lines
522 B
Go

package socks5
import (
"context"
"testing"
)
func TestPermitCommand(t *testing.T) {
ctx := context.Background()
r := &PermitCommand{true, false, false}
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: ConnectCommand}}); !ok {
t.Fatalf("expect connect")
}
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: BindCommand}}); ok {
t.Fatalf("do not expect bind")
}
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: AssociateCommand}}); ok {
t.Fatalf("do not expect associate")
}
}