forked from cloudfoundry/bosh-bootloader
-
Notifications
You must be signed in to change notification settings - Fork 2
/
certificate_validator.go
87 lines (78 loc) · 2.39 KB
/
certificate_validator.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
84
85
86
87
package fakes
import "github.com/cloudfoundry/bosh-bootloader/certs"
type CertificateValidator struct {
ReadAndValidateCall struct {
CallCount int
Returns struct {
CertData certs.CertData
Error error
}
Receives struct {
Command string
CertificatePath string
KeyPath string
ChainPath string
}
}
ReadCall struct {
CallCount int
Returns struct {
CertData certs.CertData
Error error
}
Receives struct {
Command string
CertificatePath string
KeyPath string
ChainPath string
}
}
ReadAndValidatePKCS12Call struct {
CallCount int
Returns struct {
CertData certs.CertData
Error error
}
Receives struct {
CertificatePath string
PasswordPath string
}
}
ReadPKCS12Call struct {
CallCount int
Returns struct {
CertData certs.CertData
Error error
}
Receives struct {
CertificatePath string
PasswordPath string
}
}
}
func (c *CertificateValidator) ReadAndValidate(certificatePath, keyPath, chainPath string) (certs.CertData, error) {
c.ReadAndValidateCall.CallCount++
c.ReadAndValidateCall.Receives.CertificatePath = certificatePath
c.ReadAndValidateCall.Receives.KeyPath = keyPath
c.ReadAndValidateCall.Receives.ChainPath = chainPath
return c.ReadAndValidateCall.Returns.CertData, c.ReadAndValidateCall.Returns.Error
}
func (c *CertificateValidator) Read(certificatePath, keyPath, chainPath string) (certs.CertData, error) {
c.ReadCall.CallCount++
c.ReadCall.Receives.CertificatePath = certificatePath
c.ReadCall.Receives.KeyPath = keyPath
c.ReadCall.Receives.ChainPath = chainPath
return c.ReadCall.Returns.CertData, c.ReadCall.Returns.Error
}
func (c *CertificateValidator) ReadPKCS12(certificatePath, passwordPath string) (certs.CertData, error) {
c.ReadPKCS12Call.CallCount++
c.ReadPKCS12Call.Receives.CertificatePath = certificatePath
c.ReadPKCS12Call.Receives.PasswordPath = passwordPath
return c.ReadPKCS12Call.Returns.CertData, c.ReadPKCS12Call.Returns.Error
}
func (c *CertificateValidator) ReadAndValidatePKCS12(certificatePath, passwordPath string) (certs.CertData, error) {
c.ReadAndValidatePKCS12Call.CallCount++
c.ReadAndValidatePKCS12Call.Receives.CertificatePath = certificatePath
c.ReadAndValidatePKCS12Call.Receives.PasswordPath = passwordPath
return c.ReadAndValidatePKCS12Call.Returns.CertData, c.ReadAndValidatePKCS12Call.Returns.Error
}