2016-09-22 00:45:57 +00:00
|
|
|
package datastore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-06-22 19:50:45 +00:00
|
|
|
"github.com/kolide/fleet/server/kolide"
|
2016-09-22 00:45:57 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2016-12-20 21:54:30 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2016-09-22 00:45:57 +00:00
|
|
|
)
|
|
|
|
|
2016-10-17 19:30:47 +00:00
|
|
|
func testOrgInfo(t *testing.T, ds kolide.Datastore) {
|
2016-11-04 20:44:38 +00:00
|
|
|
info := &kolide.AppConfig{
|
2016-09-22 00:45:57 +00:00
|
|
|
OrgName: "Kolide",
|
|
|
|
OrgLogoURL: "localhost:8080/logo.png",
|
|
|
|
}
|
|
|
|
|
2016-11-04 20:44:38 +00:00
|
|
|
info, err := ds.NewAppConfig(info)
|
2016-09-22 00:45:57 +00:00
|
|
|
assert.Nil(t, err)
|
2017-01-11 04:41:58 +00:00
|
|
|
require.NotNil(t, info)
|
2016-09-22 00:45:57 +00:00
|
|
|
|
2016-11-04 20:44:38 +00:00
|
|
|
info2, err := ds.AppConfig()
|
2016-12-20 21:54:30 +00:00
|
|
|
require.Nil(t, err)
|
2016-09-22 00:45:57 +00:00
|
|
|
assert.Equal(t, info2.OrgName, info.OrgName)
|
2016-12-20 21:54:30 +00:00
|
|
|
assert.False(t, info2.SMTPConfigured)
|
2016-09-22 00:45:57 +00:00
|
|
|
|
|
|
|
info2.OrgName = "koolide"
|
2016-12-20 21:54:30 +00:00
|
|
|
info2.SMTPDomain = "foo"
|
|
|
|
info2.SMTPConfigured = true
|
|
|
|
info2.SMTPSenderAddress = "123"
|
|
|
|
info2.SMTPServer = "server"
|
|
|
|
info2.SMTPPort = 100
|
|
|
|
info2.SMTPAuthenticationType = kolide.AuthTypeUserNamePassword
|
|
|
|
info2.SMTPUserName = "username"
|
|
|
|
info2.SMTPPassword = "password"
|
|
|
|
info2.SMTPEnableTLS = false
|
|
|
|
info2.SMTPAuthenticationMethod = kolide.AuthMethodCramMD5
|
|
|
|
info2.SMTPVerifySSLCerts = true
|
|
|
|
info2.SMTPEnableStartTLS = true
|
2017-05-17 15:58:40 +00:00
|
|
|
info2.EnableSSO = true
|
|
|
|
info2.EntityID = "kolide"
|
|
|
|
info2.MetadataURL = "https://idp.com/metadata.xml"
|
|
|
|
info2.IssuerURI = "https://idp.issuer.com"
|
|
|
|
info2.IDPName = "My IDP"
|
|
|
|
|
2016-11-04 20:44:38 +00:00
|
|
|
err = ds.SaveAppConfig(info2)
|
2016-12-20 21:54:30 +00:00
|
|
|
require.Nil(t, err)
|
2016-09-22 00:45:57 +00:00
|
|
|
|
2016-11-04 20:44:38 +00:00
|
|
|
info3, err := ds.AppConfig()
|
2016-12-20 21:54:30 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
assert.Equal(t, info2, info3)
|
2016-09-22 00:45:57 +00:00
|
|
|
|
2016-11-04 20:44:38 +00:00
|
|
|
info4, err := ds.NewAppConfig(info3)
|
2016-09-22 00:45:57 +00:00
|
|
|
assert.Nil(t, err)
|
2016-12-20 21:54:30 +00:00
|
|
|
assert.Equal(t, info3, info4)
|
2016-09-22 00:45:57 +00:00
|
|
|
}
|