selfsign_test.go 650 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package selfsign
  2. import (
  3. "io/ioutil"
  4. "testing"
  5. "time"
  6. "github.com/cloudflare/cfssl/config"
  7. "github.com/cloudflare/cfssl/helpers"
  8. )
  9. const (
  10. keyFile = "testdata/localhost.key"
  11. csrFile = "testdata/localhost.csr"
  12. )
  13. func TestDefaultSign(t *testing.T) {
  14. csrBytes, err := ioutil.ReadFile(csrFile)
  15. if err != nil {
  16. t.Fatal(err)
  17. }
  18. keyBytes, err := ioutil.ReadFile(keyFile)
  19. if err != nil {
  20. t.Fatal(err)
  21. }
  22. priv, err := helpers.ParsePrivateKeyPEM(keyBytes)
  23. if err != nil {
  24. t.Fatal(err)
  25. }
  26. profile := config.DefaultConfig()
  27. profile.Expiry = 10 * time.Hour
  28. _, err = Sign(priv, csrBytes, profile)
  29. if err != nil {
  30. t.Fatal(err)
  31. }
  32. }