代码整理
This commit is contained in:
35
hooks/auth/allow_all_test.go
Normal file
35
hooks/auth/allow_all_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-FileCopyrightText: 2022 mochi-mqtt, mochi-co
|
||||
// SPDX-FileContributor: mochi-co
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"testmqtt/mqtt"
|
||||
"testmqtt/packets"
|
||||
)
|
||||
|
||||
func TestAllowAllID(t *testing.T) {
|
||||
h := new(AllowHook)
|
||||
require.Equal(t, "allow-all-auth", h.ID())
|
||||
}
|
||||
|
||||
func TestAllowAllProvides(t *testing.T) {
|
||||
h := new(AllowHook)
|
||||
require.True(t, h.Provides(mqtt.OnACLCheck))
|
||||
require.True(t, h.Provides(mqtt.OnConnectAuthenticate))
|
||||
require.False(t, h.Provides(mqtt.OnPublished))
|
||||
}
|
||||
|
||||
func TestAllowAllOnConnectAuthenticate(t *testing.T) {
|
||||
h := new(AllowHook)
|
||||
require.True(t, h.OnConnectAuthenticate(new(mqtt.Client), packets.Packet{}))
|
||||
}
|
||||
|
||||
func TestAllowAllOnACLCheck(t *testing.T) {
|
||||
h := new(AllowHook)
|
||||
require.True(t, h.OnACLCheck(new(mqtt.Client), "any", true))
|
||||
}
|
||||
Reference in New Issue
Block a user