-
Notifications
You must be signed in to change notification settings - Fork 53
/
cert_manager.go
83 lines (67 loc) · 1.83 KB
/
cert_manager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package test
import (
"context"
"crypto/tls"
"crypto/x509"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
)
const (
MockCAName = "mock-ca-cert"
)
type TestCertManager struct{}
func (m *TestCertManager) PopulateK8sObjects(ctx context.Context, client ctrlclient.Client, namespace string) error {
secret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: MockCAName,
Namespace: namespace,
},
Data: map[string][]byte{
"ca.crt": TestData("root_ca.crt"),
"ca.key": TestData("root_ca.key"),
},
}
return client.Create(ctx, secret)
}
func (m *TestCertManager) GenerateRootCACert() error {
return nil
}
func (m *TestCertManager) GenerateTransportCA() error {
return nil
}
func (m *TestCertManager) GenerateHTTPCA() error {
return nil
}
func (m *TestCertManager) GenerateClientCert(user string) error {
return nil
}
func (m *TestCertManager) GenerateAdminClientCert() error {
return nil
}
func (m *TestCertManager) GetTransportRootCAs() (*x509.CertPool, error) {
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(TestData("root_ca.crt"))
return pool, nil
}
func (m *TestCertManager) GetHTTPRootCAs() (*x509.CertPool, error) {
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(TestData("root_ca.crt"))
return pool, nil
}
func (m *TestCertManager) GetClientCert(user string) (tls.Certificate, error) {
return tls.Certificate{}, nil
}
func (m *TestCertManager) GetAdminClientCert() (tls.Certificate, error) {
return tls.Certificate{}, nil
}
func (m *TestCertManager) GetTransportCARef() (corev1.LocalObjectReference, error) {
return corev1.LocalObjectReference{
Name: MockCAName,
}, nil
}
func (m *TestCertManager) GetHTTPCARef() (corev1.LocalObjectReference, error) {
return corev1.LocalObjectReference{
Name: MockCAName,
}, nil
}