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