2016-11-04 20:44:38 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-02-01 17:20:50 +00:00
|
|
|
"github.com/kolide/kolide/server/config"
|
|
|
|
"github.com/kolide/kolide/server/datastore/inmem"
|
|
|
|
"github.com/kolide/kolide/server/kolide"
|
2016-11-04 20:44:38 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2016-11-09 17:19:07 +00:00
|
|
|
func TestCreateAppConfig(t *testing.T) {
|
2016-11-25 18:08:22 +00:00
|
|
|
ds, err := inmem.New(config.TestConfig())
|
2016-11-04 20:44:38 +00:00
|
|
|
require.Nil(t, err)
|
2017-01-05 17:27:56 +00:00
|
|
|
require.Nil(t, ds.MigrateData())
|
|
|
|
|
2016-11-14 18:22:54 +00:00
|
|
|
svc, err := newTestService(ds, nil)
|
2016-11-04 20:44:38 +00:00
|
|
|
require.Nil(t, err)
|
2016-11-09 17:19:07 +00:00
|
|
|
var appConfigTests = []struct {
|
|
|
|
configPayload kolide.AppConfigPayload
|
2016-11-04 20:44:38 +00:00
|
|
|
}{
|
|
|
|
{
|
2016-11-09 17:19:07 +00:00
|
|
|
configPayload: kolide.AppConfigPayload{
|
2016-11-04 20:44:38 +00:00
|
|
|
OrgInfo: &kolide.OrgInfo{
|
|
|
|
OrgLogoURL: stringPtr("acme.co/images/logo.png"),
|
|
|
|
OrgName: stringPtr("Acme"),
|
|
|
|
},
|
|
|
|
ServerSettings: &kolide.ServerSettings{
|
|
|
|
KolideServerURL: stringPtr("https://acme.co:8080/"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2016-11-09 17:19:07 +00:00
|
|
|
for _, tt := range appConfigTests {
|
|
|
|
result, err := svc.NewAppConfig(context.Background(), tt.configPayload)
|
2016-11-04 20:44:38 +00:00
|
|
|
require.Nil(t, err)
|
|
|
|
|
2016-11-09 17:19:07 +00:00
|
|
|
payload := tt.configPayload
|
2016-11-04 20:44:38 +00:00
|
|
|
assert.NotEmpty(t, result.ID)
|
|
|
|
assert.Equal(t, *payload.OrgInfo.OrgLogoURL, result.OrgLogoURL)
|
|
|
|
assert.Equal(t, *payload.OrgInfo.OrgName, result.OrgName)
|
|
|
|
assert.Equal(t, *payload.ServerSettings.KolideServerURL, result.KolideServerURL)
|
|
|
|
}
|
|
|
|
}
|