mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/kolide/fleet/server/kolide"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSSONotPresent(t *testing.T) {
|
|
invalid := &invalidArgumentError{}
|
|
var p kolide.AppConfigPayload
|
|
validateSSOSettings(p, &kolide.AppConfig{}, invalid)
|
|
assert.False(t, invalid.HasErrors())
|
|
|
|
}
|
|
|
|
func TestNeedFieldsPresent(t *testing.T) {
|
|
invalid := &invalidArgumentError{}
|
|
config := kolide.AppConfig{
|
|
EnableSSO: true,
|
|
EntityID: "kolide",
|
|
IssuerURI: "http://issuer.idp.com",
|
|
MetadataURL: "http://isser.metadata.com",
|
|
IDPName: "onelogin",
|
|
}
|
|
p := appConfigPayloadFromAppConfig(&config)
|
|
validateSSOSettings(*p, &kolide.AppConfig{}, invalid)
|
|
assert.False(t, invalid.HasErrors())
|
|
}
|
|
|
|
func TestMissingMetadata(t *testing.T) {
|
|
invalid := invalidArgumentError{}
|
|
config := kolide.AppConfig{
|
|
EnableSSO: true,
|
|
EntityID: "kolide",
|
|
IssuerURI: "http://issuer.idp.com",
|
|
IDPName: "onelogin",
|
|
}
|
|
p := appConfigPayloadFromAppConfig(&config)
|
|
validateSSOSettings(*p, &kolide.AppConfig{}, &invalid)
|
|
require.True(t, invalid.HasErrors())
|
|
require.Len(t, invalid, 1)
|
|
assert.Equal(t, "metadata", invalid[0].name)
|
|
assert.Equal(t, "either metadata or metadata_url must be defined", invalid[0].reason)
|
|
}
|