go-socks5/ruleset_test.go

24 lines
522 B
Go
Raw Normal View History

2014-01-23 19:15:53 +00:00
package socks5
import (
2020-04-19 09:08:22 +00:00
"context"
"testing"
)
2014-01-23 19:15:53 +00:00
func TestPermitCommand(t *testing.T) {
ctx := context.Background()
2014-01-23 19:15:53 +00:00
r := &PermitCommand{true, false, false}
2020-04-19 15:40:14 +00:00
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: ConnectCommand}}); !ok {
2014-01-23 19:15:53 +00:00
t.Fatalf("expect connect")
}
2020-04-19 15:40:14 +00:00
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: BindCommand}}); ok {
2014-01-23 19:15:53 +00:00
t.Fatalf("do not expect bind")
}
2020-04-19 15:40:14 +00:00
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: AssociateCommand}}); ok {
2014-01-23 19:15:53 +00:00
t.Fatalf("do not expect associate")
}
}