func UniqueClientIDUncleanTest(t *testing.T, config *Config) {
	id := config.clientID()
	options := client.NewConfigWithClientID(config.URL, id)
	options.CleanSession = false
	assert.NoError(t, client.ClearSession(options, 10*time.Second))
	wait := make(chan struct{})
	firstClient := client.New()
	firstClient.Callback = func(msg *packet.Message, err error) error {
		close(wait)
		return nil
	}
	cf, err := firstClient.Connect(options)
	assert.NoError(t, err)
	assert.NoError(t, cf.Wait(10*time.Second))
	assert.Equal(t, packet.ConnectionAccepted, cf.ReturnCode())
	assert.False(t, cf.SessionPresent())
	secondClient := client.New()
	cf, err = secondClient.Connect(options)
	assert.NoError(t, err)
	assert.NoError(t, cf.Wait(10*time.Second))
	assert.Equal(t, packet.ConnectionAccepted, cf.ReturnCode())
	assert.True(t, cf.SessionPresent())
	safeReceive(wait)
	err = secondClient.Disconnect()
	assert.NoError(t, err)
}
UniqueClientIDUncleanTest tests the broker for enforcing unique client ids.
package spec
import (
	"testing"
	"time"
	"github.com/256dpi/gomqtt/client"
	"github.com/256dpi/gomqtt/packet"
	"github.com/stretchr/testify/assert"
)
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)
}