34 lines
650 B
Go
34 lines
650 B
Go
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
|
|
|
|
package config
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
"crypto/x509"
|
|
)
|
|
|
|
func TestNewCertificateConfig(t *testing.T) {
|
|
c := NewCertificate()
|
|
assert.NotNil(t, c)
|
|
}
|
|
|
|
func TestNewCertificateConfigYAML(t *testing.T) {
|
|
c := NewCertificate()
|
|
assert.NotNil(t, c)
|
|
|
|
config := `
|
|
catemplate:
|
|
subject:
|
|
organization:
|
|
- RKH
|
|
notbefore: 2024-07-10
|
|
`
|
|
|
|
yamlErr := c.LoadYAML(config)
|
|
assert.Nil(t, yamlErr)
|
|
crt, err := c.GetValue("catemplate")
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, []string{"RKH"}, crt.(*x509.Certificate).Subject.Organization)
|
|
}
|