fleet/pkg/certificate/certificate_test.go
Martin Angers a3714d2ed9
Add fleetctl debug connection command (#1706)
Adds the `fleetctl debug connection` command to investigate
connection issues to the fleet server.

Closes #1579 .
2021-08-24 08:50:03 -04:00

32 lines
615 B
Go

package certificate
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestLoadPEM(t *testing.T) {
t.Parallel()
pool, err := LoadPEM(filepath.Join("testdata", "test.crt"))
require.NoError(t, err)
assert.True(t, len(pool.Subjects()) > 0)
}
func TestLoadErrorNoCertificates(t *testing.T) {
t.Parallel()
_, err := LoadPEM(filepath.Join("testdata", "empty.crt"))
require.Error(t, err)
}
func TestLoadErrorMissingFile(t *testing.T) {
t.Parallel()
_, err := LoadPEM(filepath.Join("testdata", "invalid_path"))
require.Error(t, err)
}