func AuthenticationTest(t *testing.T, config *Config) {
	deniedClient := client.New()
	deniedClient.Callback = func(msg *packet.Message, err error) error {
		assert.Equal(t, client.ErrClientConnectionDenied, err)
		return nil
	}
	cf, err := deniedClient.Connect(client.NewConfig(config.DenyURL))
	assert.NoError(t, err)
	assert.Error(t, cf.Wait(10*time.Second))
	assert.Equal(t, packet.NotAuthorized, cf.ReturnCode())
	assert.False(t, cf.SessionPresent())
	allowedClient := client.New()
	cf, err = allowedClient.Connect(client.NewConfig(config.URL))
	assert.NoError(t, err)
	assert.NoError(t, cf.Wait(10*time.Second))
	assert.Equal(t, packet.ConnectionAccepted, cf.ReturnCode())
	assert.False(t, cf.SessionPresent())
	err = allowedClient.Disconnect()
	assert.NoError(t, err)
}
AuthenticationTest tests the broker for valid and invalid authentication.
package spec
import (
	"testing"
	"time"
	"github.com/256dpi/gomqtt/client"
	"github.com/256dpi/gomqtt/packet"
	"github.com/stretchr/testify/assert"
)