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-21 06:03:20 +00:00
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: CommandConnect}}); !ok {
2014-01-23 19:15:53 +00:00
t.Fatalf("expect connect")
}
2020-04-21 06:03:20 +00:00
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: CommandBind}}); ok {
2014-01-23 19:15:53 +00:00
t.Fatalf("do not expect bind")
}
2020-04-21 06:03:20 +00:00
if _, ok := r.Allow(ctx, &Request{Header: Header{Command: CommandAssociate}}); ok {
2014-01-23 19:15:53 +00:00
t.Fatalf("do not expect associate")
}
}