traefik/acme/localStore_test.go

33 lines
621 B
Go
Raw Normal View History

2018-01-15 15:04:05 +00:00
package acme
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
2018-03-05 19:54:04 +00:00
"github.com/stretchr/testify/assert"
2018-01-15 15:04:05 +00:00
)
2018-03-05 19:54:04 +00:00
func TestGet(t *testing.T) {
2018-01-15 15:04:05 +00:00
acmeFile := "./acme_example.json"
folder, prefix := filepath.Split(acmeFile)
tmpFile, err := ioutil.TempFile(folder, prefix)
defer os.Remove(tmpFile.Name())
2018-03-05 19:54:04 +00:00
assert.NoError(t, err)
2018-01-15 15:04:05 +00:00
fileContent, err := ioutil.ReadFile(acmeFile)
2018-03-05 19:54:04 +00:00
assert.NoError(t, err)
2018-01-15 15:04:05 +00:00
2019-03-04 15:40:05 +00:00
_, err = tmpFile.Write(fileContent)
assert.NoError(t, err)
2018-01-15 15:04:05 +00:00
localStore := NewLocalStore(tmpFile.Name())
2018-03-05 19:54:04 +00:00
account, err := localStore.Get()
assert.NoError(t, err)
assert.Len(t, account.DomainsCertificate.Certs, 1)
2018-01-15 15:04:05 +00:00
}