You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
610 B
Go
43 lines
610 B
Go
4 years ago
|
package cert
|
||
4 years ago
|
|
||
|
import (
|
||
4 years ago
|
"bytes"
|
||
|
"io/ioutil"
|
||
|
"reflect"
|
||
4 years ago
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestGetStorePath(t *testing.T) {
|
||
|
path, err := getStorePath("")
|
||
|
if err != nil {
|
||
4 years ago
|
t.Fatal(err)
|
||
4 years ago
|
}
|
||
|
if path == "" {
|
||
4 years ago
|
t.Fatal("should have path")
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
|
func TestNewCA(t *testing.T) {
|
||
|
ca, err := NewCA("")
|
||
|
if err != nil {
|
||
4 years ago
|
t.Fatal(err)
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
4 years ago
|
data := make([]byte, 0)
|
||
|
buf := bytes.NewBuffer(data)
|
||
|
|
||
|
err = ca.saveTo(buf)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
fileContent, err := ioutil.ReadFile(ca.caFile())
|
||
4 years ago
|
if err != nil {
|
||
4 years ago
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if !reflect.DeepEqual(fileContent, buf.Bytes()) {
|
||
|
t.Fatal("pem content should equal")
|
||
4 years ago
|
}
|
||
4 years ago
|
}
|