go-socks5/ruleset_test.go
ymmt2005 385bbe4759 Add golang.org/x/net/context support.
Read http://blog.golang.org/context for its benefits.

This PR has not utilized contexts yet; just passing them
to every customization points to help them add/retrieve
request context values.
2016-03-08 23:29:11 +09:00

25 lines
492 B
Go

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