(t *testing.T)
| 118 | } |
| 119 | |
| 120 | func TestOnConnectAuthenticate(t *testing.T) { |
| 121 | h := new(Hook) |
| 122 | h.SetOpts(logger, nil) |
| 123 | |
| 124 | ln := new(Ledger) |
| 125 | ln.Auth = checkLedger.Auth |
| 126 | ln.ACL = checkLedger.ACL |
| 127 | err := h.Init( |
| 128 | &Options{ |
| 129 | Ledger: ln, |
| 130 | }, |
| 131 | ) |
| 132 | |
| 133 | require.NoError(t, err) |
| 134 | |
| 135 | require.True(t, h.OnConnectAuthenticate( |
| 136 | &mqtt.Client{ |
| 137 | Properties: mqtt.ClientProperties{ |
| 138 | Username: []byte("mochi"), |
| 139 | }, |
| 140 | }, |
| 141 | packets.Packet{Connect: packets.ConnectParams{Password: []byte("melon")}}, |
| 142 | )) |
| 143 | |
| 144 | require.False(t, h.OnConnectAuthenticate( |
| 145 | &mqtt.Client{ |
| 146 | Properties: mqtt.ClientProperties{ |
| 147 | Username: []byte("mochi"), |
| 148 | }, |
| 149 | }, |
| 150 | packets.Packet{Connect: packets.ConnectParams{Password: []byte("bad-pass")}}, |
| 151 | )) |
| 152 | |
| 153 | require.False(t, h.OnConnectAuthenticate( |
| 154 | &mqtt.Client{}, |
| 155 | packets.Packet{}, |
| 156 | )) |
| 157 | } |
| 158 | |
| 159 | func TestOnACL(t *testing.T) { |
| 160 | h := new(Hook) |
nothing calls this directly
no test coverage detected