func TestAuthorizerBypassLocal(t *testing.T) {
	config := &Config{
		RealmConfigs: []*RealmConfig{
			{
				URI:        testRealm,
				Authorizer: &testAuthzMod{},
			},
		},
		Debug: debug,
	}
	r, err := NewRouter(config, logger)
	if err != nil {
		t.Fatal(err)
	}
	defer r.Close()
	sub, err := testClient(r)
	if err != nil {
		t.Fatal(err)
	}
	subscribeID := wamp.GlobalID()
	sub.Send(&wamp.Subscribe{Request: subscribeID, Topic: denyTopic})
	msg := <-sub.Recv()
	if _, ok := msg.(*wamp.Subscribed); !ok {
		t.Fatal("Expected SUBSCRIBED, got:", msg.MessageType())
	}
}
Test that authorizer is not called with a local session and config does not
specify RequireLocalAuthz=true.
package router
import (
	"testing"
	"time"
	"github.com/gammazero/nexus/v3/wamp"
)
const (
	denyTopic  = wamp.URI("forbidden.topic")
	allowTopic = wamp.URI("allowed.topic")
)
type testAuthz struct{}
func (a *testAuthz) Authorize(session *wamp.Session, msg wamp.Message) (bool, error) {
	m, ok := msg.(*wamp.Subscribe)
	if ok {
		if m.Topic == denyTopic {
			return false, nil
		}
	}
	return true, nil
}
type testAuthzMod struct{}
func (a *testAuthzMod) Authorize(sess *wamp.Session, msg wamp.Message) (bool, error) {
	count, _ := wamp.AsInt64(sess.Details["count"])
	count++
	sess.Details["count"] = count
	sess.Details["foo"] = "bar"
	delete(sess.Details, "xyzzy")
	return true, nil
}
func TestAuthorizer(t *testing.T) {
	config := &Config{
		RealmConfigs: []*RealmConfig{
			{
				URI:               testRealm,
				Authorizer:        &testAuthz{},
				RequireLocalAuthz: true,
			},
		},
		Debug: debug,
	}
	r, err := NewRouter(config, logger)
	if err != nil {
		t.Fatal(err)
	}
	defer r.Close()
	sub, err := testClient(r)
	if err != nil {
		t.Fatal(err)
	}
	subscribeID := wamp.GlobalID()
	sub.Send(&wamp.Subscribe{Request: subscribeID, Topic: denyTopic})
	msg := <-sub.Recv()
	_, ok := msg.(*wamp.Error)
	if !ok {
		t.Fatal("Expected ERROR, got:", msg.MessageType())
	}
	sub.Send(&wamp.Subscribe{Request: subscribeID, Topic: allowTopic})
	msg = <-sub.Recv()
	if _, ok = msg.(*wamp.Subscribed); !ok {
		t.Fatal("Expected SUBSCRIBED, got:", msg.MessageType())
	}
}