Skip to content

Commit

Permalink
mqtt: make tests run correctly even when a local MQTT server is in fa…
Browse files Browse the repository at this point in the history
…ct running

Signed-off-by: Ron Evans <[email protected]>
  • Loading branch information
deadprogram committed May 22, 2019
1 parent 9a9d580 commit 9b97c70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion platforms/mqtt/mqtt_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (a *Adaptor) newTLSConfig() *tls.Config {
ClientCAs: nil,
// InsecureSkipVerify = verify that cert contents
// match server. IP matches what is in cert etc.
InsecureSkipVerify: true,
InsecureSkipVerify: false,
// Certificates = list of certs client sends to server.
Certificates: certs,
}
Expand Down
6 changes: 3 additions & 3 deletions platforms/mqtt/mqtt_adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,21 @@ func TestMqttAdaptorUseClientKey(t *testing.T) {
}

func TestMqttAdaptorConnectError(t *testing.T) {
a := initTestMqttAdaptor()
a := NewAdaptor("tcp://localhost:1884", "client")

err := a.Connect()
gobottest.Assert(t, strings.Contains(err.Error(), "connection refused"), true)
}

func TestMqttAdaptorConnectSSLError(t *testing.T) {
a := initTestMqttAdaptor()
a := NewAdaptor("tcp://localhost:1884", "client")
a.SetUseSSL(true)
err := a.Connect()
gobottest.Assert(t, strings.Contains(err.Error(), "connection refused"), true)
}

func TestMqttAdaptorConnectWithAuthError(t *testing.T) {
a := NewAdaptorWithAuth("localhost:1883", "client", "user", "pass")
a := NewAdaptorWithAuth("xyz://localhost:1883", "client", "user", "pass")
var expected error
expected = multierror.Append(expected, errors.New("Network Error : Unknown protocol"))

Expand Down

0 comments on commit 9b97c70

Please sign in to comment.