MCPcopy
hub / github.com/kubeedge/kubeedge / TestSignX509Certs

Function TestSignX509Certs

pkg/security/certs/x509_ca_certs_test.go:10–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func 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}

Callers

nothing calls this directly

Calls 6

SignCertsOptionsWithCSRFunction · 0.85
GenPrivateKeyMethod · 0.65
NewSelfSignedMethod · 0.65
CreateCSRMethod · 0.65
DERMethod · 0.65
SignCertsMethod · 0.65

Tested by

no test coverage detected