1
0
Fork 0
bypass/ruleset_test.go

25 lines
492 B
Go
Raw Normal View History

2014-01-24 03:15:53 +08:00
package socks5
import (
"testing"
"golang.org/x/net/context"
)
2014-01-24 03:15:53 +08:00
func TestPermitCommand(t *testing.T) {
ctx := context.Background()
2014-01-24 03:15:53 +08:00
r := &PermitCommand{true, false, false}
if _, ok := r.Allow(ctx, &Request{Command: ConnectCommand}); !ok {
2014-01-24 03:15:53 +08:00
t.Fatalf("expect connect")
}
if _, ok := r.Allow(ctx, &Request{Command: BindCommand}); ok {
2014-01-24 03:15:53 +08:00
t.Fatalf("do not expect bind")
}
if _, ok := r.Allow(ctx, &Request{Command: AssociateCommand}); ok {
2014-01-24 03:15:53 +08:00
t.Fatalf("do not expect associate")
}
}