feat: test coverage more than 80%
This commit is contained in:
parent
72ffe8456d
commit
89136cae59
|
@ -83,6 +83,12 @@ func Test_newRootCA(t *testing.T) {
|
||||||
require.Greater(t, len(keyPEM), 0)
|
require.Greater(t, len(keyPEM), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_newRootCAError(t *testing.T) {
|
||||||
|
_, _, err := newRootCA(&ca.CaConfig{})
|
||||||
|
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func Test_parseCertificate(t *testing.T) {
|
func Test_parseCertificate(t *testing.T) {
|
||||||
caPEM, _, err := newRootCA(&rootTestConfig)
|
caPEM, _, err := newRootCA(&rootTestConfig)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -126,3 +132,12 @@ func Test_rootCA_WithClientCert(t *testing.T) {
|
||||||
require.NotNil(t, clientSrv.PEM())
|
require.NotNil(t, clientSrv.PEM())
|
||||||
require.Greater(t, len(clientSrv.PEM()), 0)
|
require.Greater(t, len(clientSrv.PEM()), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_rootCA_WithClientCertEror(t *testing.T) {
|
||||||
|
rootCert := rootCA{
|
||||||
|
caPEM: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := rootCert.WithClientCert(&clientTestConfig)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
|
@ -34,21 +34,3 @@ var (
|
||||||
extKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth}
|
extKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth}
|
||||||
keyUsage = x509.KeyUsageDigitalSignature
|
keyUsage = x509.KeyUsageDigitalSignature
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDefaultConfig() *ClientCertConfig {
|
|
||||||
return &ClientCertConfig{
|
|
||||||
Serial: big.NewInt(12321),
|
|
||||||
Subject: Subject{
|
|
||||||
Organization: "",
|
|
||||||
Country: "",
|
|
||||||
Province: "",
|
|
||||||
Locality: "",
|
|
||||||
StreetAddress: "",
|
|
||||||
PostalCode: "",
|
|
||||||
},
|
|
||||||
Duration: time.Duration(time.Hour * 24 * 365),
|
|
||||||
SubjectKeyId: subjectKeyId,
|
|
||||||
ExtKeyUsage: extKeyUsage,
|
|
||||||
KeyUsage: keyUsage,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue