mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
40 lines
650 B
Go
40 lines
650 B
Go
package selfsign
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/cloudflare/cfssl/config"
|
|
"github.com/cloudflare/cfssl/helpers"
|
|
)
|
|
|
|
const (
|
|
keyFile = "testdata/localhost.key"
|
|
csrFile = "testdata/localhost.csr"
|
|
)
|
|
|
|
func TestDefaultSign(t *testing.T) {
|
|
csrBytes, err := ioutil.ReadFile(csrFile)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
keyBytes, err := ioutil.ReadFile(keyFile)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
priv, err := helpers.ParsePrivateKeyPEM(keyBytes)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
profile := config.DefaultConfig()
|
|
profile.Expiry = 10 * time.Hour
|
|
|
|
_, err = Sign(priv, csrBytes, profile)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|