1
0

ruleset_test.go 492 B

123456789101112131415161718192021222324
  1. package socks5
  2. import (
  3. "testing"
  4. "golang.org/x/net/context"
  5. )
  6. func TestPermitCommand(t *testing.T) {
  7. ctx := context.Background()
  8. r := &PermitCommand{true, false, false}
  9. if _, ok := r.Allow(ctx, &Request{Command: ConnectCommand}); !ok {
  10. t.Fatalf("expect connect")
  11. }
  12. if _, ok := r.Allow(ctx, &Request{Command: BindCommand}); ok {
  13. t.Fatalf("do not expect bind")
  14. }
  15. if _, ok := r.Allow(ctx, &Request{Command: AssociateCommand}); ok {
  16. t.Fatalf("do not expect associate")
  17. }
  18. }