-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish ConnState message on gateway (un)subscribe.
This introduces a new topic hierarchy gateway/ID/state/STATE for publishing state messages. State messages are published with the retained flag. The ConnState message is published to gateway/ID/state/conn and contains the state ONLINE or OFFLINE.
- Loading branch information
Showing
15 changed files
with
342 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package auth | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/brocaar/chirpstack-gateway-bridge/internal/config" | ||
"github.com/brocaar/lorawan" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGenericAuthentication(t *testing.T) { | ||
gatewayID := lorawan.EUI64{1, 2, 3, 4, 5, 6, 7, 8} | ||
|
||
var conf config.Config | ||
conf.Integration.Marshaler = "json" | ||
conf.Integration.MQTT.EventTopicTemplate = "gateway/{{ .GatewayID }}/event/{{ .EventType }}" | ||
conf.Integration.MQTT.StateTopicTemplate = "gateway/{{ .GatewayID }}/state/{{ .StateType }}" | ||
conf.Integration.MQTT.CommandTopicTemplate = "gateway/{{ .GatewayID }}/command/#" | ||
conf.Integration.MQTT.Auth.Type = "generic" | ||
conf.Integration.MQTT.Auth.Generic.Servers = []string{"tcp://localhost:1883"} | ||
conf.Integration.MQTT.Auth.Generic.Username = "foo" | ||
conf.Integration.MQTT.Auth.Generic.Password = "bar" | ||
conf.Integration.MQTT.Auth.Generic.CleanSession = true | ||
conf.Integration.MQTT.Auth.Generic.ClientID = gatewayID.String() | ||
|
||
t.Run("New", func(t *testing.T) { | ||
assert := require.New(t) | ||
|
||
auth, err := NewGenericAuthentication(conf) | ||
assert.NoError(err) | ||
|
||
t.Run("GetGatewayID", func(t *testing.T) { | ||
assert := require.New(t) | ||
assert.Equal(&gatewayID, auth.GetGatewayID()) | ||
}) | ||
}) | ||
} |
Oops, something went wrong.