...
1
16
17 package clustertrustbundles
18
19 import (
20 "crypto/ed25519"
21 "crypto/x509"
22 "encoding/pem"
23 mathrand "math/rand"
24 "testing"
25
26 "k8s.io/kubernetes/test/integration/framework"
27 )
28
29 func TestMain(m *testing.M) {
30 framework.EtcdMain(m.Run)
31 }
32
33 func mustMakeCertificate(t *testing.T, template *x509.Certificate) []byte {
34 gen := mathrand.New(mathrand.NewSource(12345))
35
36 pub, priv, err := ed25519.GenerateKey(gen)
37 if err != nil {
38 t.Fatalf("Error while generating key: %v", err)
39 }
40
41 cert, err := x509.CreateCertificate(gen, template, template, pub, priv)
42 if err != nil {
43 t.Fatalf("Error while making certificate: %v", err)
44 }
45
46 return cert
47 }
48
49 func mustMakePEMBlock(blockType string, headers map[string]string, data []byte) string {
50 return string(pem.EncodeToMemory(&pem.Block{
51 Type: blockType,
52 Headers: headers,
53 Bytes: data,
54 }))
55 }
56
View as plain text