selfsign_test.go 731 B

1234567891011121314151617181920212223242526272829303132
  1. package selfsign
  2. import (
  3. "testing"
  4. "github.com/cloudflare/cfssl/cli"
  5. )
  6. func TestSelfSignMain(t *testing.T) {
  7. err := selfSignMain([]string{"cloudflare.com", "../../testdata/csr.json"}, cli.Config{Hostname: ""})
  8. if err != nil {
  9. t.Fatal(err)
  10. }
  11. }
  12. func TestBadSelfSignMain(t *testing.T) {
  13. err := selfSignMain([]string{"cloudflare.com"}, cli.Config{Hostname: ""})
  14. if err == nil {
  15. t.Fatal("No CSR, should report error")
  16. }
  17. err = selfSignMain([]string{}, cli.Config{Hostname: ""})
  18. if err == nil {
  19. t.Fatal("No server, should report error")
  20. }
  21. err = selfSignMain([]string{"cloudflare.com", "../../testdata/garbage.key"}, cli.Config{Hostname: ""})
  22. if err == nil {
  23. t.Fatal("Wrong CSR file, should report error")
  24. }
  25. }