(t *testing.T)
| 8 | ) |
| 9 | |
| 10 | func TestSignX509Certs(t *testing.T) { |
| 11 | cah := new(x509CAHandler) |
| 12 | certh := new(x509CertsHandler) |
| 13 | |
| 14 | capkw, err := cah.GenPrivateKey() |
| 15 | if err != nil { |
| 16 | t.Fatal(err) |
| 17 | } |
| 18 | cablock, err := cah.NewSelfSigned(capkw) |
| 19 | if err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | |
| 23 | certpkw, err := certh.GenPrivateKey() |
| 24 | if err != nil { |
| 25 | t.Fatal(err) |
| 26 | } |
| 27 | csrblock, err := certh.CreateCSR(pkix.Name{ |
| 28 | Country: []string{"CN"}, |
| 29 | Organization: []string{"system:nodes"}, |
| 30 | Locality: []string{"Hangzhou"}, |
| 31 | Province: []string{"Zhejiang"}, |
| 32 | CommonName: "test-node", |
| 33 | }, certpkw, nil) |
| 34 | |
| 35 | opts := SignCertsOptionsWithCSR(csrblock.Bytes, cablock.Bytes, capkw.DER(), |
| 36 | []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, 24*time.Hour) |
| 37 | certblock, err := certh.SignCerts(opts) |
| 38 | if err != nil { |
| 39 | t.Fatal(err) |
| 40 | } |
| 41 | if len(certblock.Bytes) == 0 { |
| 42 | t.Fatal("cert bytes cannot be empty") |
| 43 | } |
| 44 | } |
nothing calls this directly
no test coverage detected