diff options
Diffstat (limited to 'certServiceK8sExternalProvider/src')
10 files changed, 21 insertions, 25 deletions
diff --git a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_factory.go b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_factory.go index 2c04b908..0fa1d165 100644 --- a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_factory.go +++ b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_factory.go @@ -54,7 +54,7 @@ func CreateCertServiceClient(baseUrl string, healthEndpoint string, certEndpoint return nil, err } client := CertServiceClientImpl{ - healthUrl: healthUrl, + healthUrl: healthUrl, certificationUrl: certificationUrl, httpClient: httpClient, } diff --git a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go index f2b5032f..5e80f7f7 100644 --- a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go +++ b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go @@ -37,7 +37,6 @@ const ( certificationUrl = "https://oom-cert-service:8443/v1/certificate/RA" ) - func Test_GetCertificates_shouldParseCertificateResponseCorrectly(t *testing.T) { responseJson := `{"certificateChain": ["cert-0", "cert-1"], "trustedCertificates": ["trusted-cert-0", "trusted-cert-1"]}` responseJsonReader := ioutil.NopCloser(bytes.NewReader([]byte(responseJson))) @@ -55,7 +54,7 @@ func Test_GetCertificates_shouldReturnError_whenResponseIsNotJson(t *testing.T) responseJsonReader := ioutil.NopCloser(bytes.NewReader([]byte(responseJson))) client := CertServiceClientImpl{ certificationUrl: certificationUrl, - httpClient: &httpClientMock{ + httpClient: &httpClientMock{ DoFunc: func(req *http.Request) (response *http.Response, e error) { mockedResponse := &http.Response{ Body: responseJsonReader, @@ -73,7 +72,7 @@ func Test_GetCertificates_shouldReturnError_whenResponseIsNotJson(t *testing.T) func Test_GetCertificates_shouldReturnError_whenHttpClientReturnsError(t *testing.T) { client := CertServiceClientImpl{ certificationUrl: certificationUrl, - httpClient: &httpClientMock{ + httpClient: &httpClientMock{ DoFunc: func(req *http.Request) (response *http.Response, err error) { return nil, fmt.Errorf("mock error") }, @@ -101,10 +100,10 @@ func Test_GetCertificates_shouldReturnError_whenResponseOtherThan200(t *testing. func Test_CheckHealth_shouldReturnNil_whenHttpClientReturnsStatusCode200(t *testing.T) { client := CertServiceClientImpl{ certificationUrl: certificationUrl, - httpClient: &httpClientMock{ + httpClient: &httpClientMock{ DoFunc: func(req *http.Request) (response *http.Response, e error) { mockedResponse := &http.Response{ - Body: nil, + Body: nil, StatusCode: 200, } return mockedResponse, nil @@ -120,10 +119,10 @@ func Test_CheckHealth_shouldReturnNil_whenHttpClientReturnsStatusCode200(t *test func Test_CheckHealth_shouldReturnError_whenHttpClientReturnsStatusCode404(t *testing.T) { client := CertServiceClientImpl{ certificationUrl: certificationUrl, - httpClient: &httpClientMock{ + httpClient: &httpClientMock{ DoFunc: func(req *http.Request) (response *http.Response, e error) { mockedResponse := &http.Response{ - Body: nil, + Body: nil, StatusCode: 404, } return mockedResponse, nil @@ -139,7 +138,7 @@ func Test_CheckHealth_shouldReturnError_whenHttpClientReturnsStatusCode404(t *te func Test_CheckHealth_shouldReturnError_whenHttpClientReturnsError(t *testing.T) { client := CertServiceClientImpl{ certificationUrl: certificationUrl, - httpClient: &httpClientMock{ + httpClient: &httpClientMock{ DoFunc: func(req *http.Request) (response *http.Response, err error) { return nil, fmt.Errorf("mock error") }, diff --git a/certServiceK8sExternalProvider/src/cmpv2controller/logger/certificate_request_logger_test.go b/certServiceK8sExternalProvider/src/cmpv2controller/logger/certificate_request_logger_test.go index 0b50980b..05909f1d 100644 --- a/certServiceK8sExternalProvider/src/cmpv2controller/logger/certificate_request_logger_test.go +++ b/certServiceK8sExternalProvider/src/cmpv2controller/logger/certificate_request_logger_test.go @@ -56,7 +56,7 @@ var supportedProperties = []string{ "+ property 'ipAddresses'", "+ property 'uris'", "+ property 'email addresses'", - } +} const RESULT_LOG = "testdata/test_result.log" diff --git a/certServiceK8sExternalProvider/src/cmpv2controller/updater/k8s_resource_updater_test.go b/certServiceK8sExternalProvider/src/cmpv2controller/updater/k8s_resource_updater_test.go index 553c419f..b4f336fc 100644 --- a/certServiceK8sExternalProvider/src/cmpv2controller/updater/k8s_resource_updater_test.go +++ b/certServiceK8sExternalProvider/src/cmpv2controller/updater/k8s_resource_updater_test.go @@ -31,10 +31,9 @@ import ( ) const ( - recorderBufferSize = 3 + recorderBufferSize = 3 ) - func Test_shouldFireWarningEvent_forCmpv2Issuer(t *testing.T) { fakeRecorder := record.NewFakeRecorder(recorderBufferSize) diff --git a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go index be15e832..ee65b3cb 100644 --- a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go +++ b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go @@ -32,10 +32,10 @@ import ( certmanager "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1" "k8s.io/apimachinery/pkg/types" - "onap.org/oom-certservice/k8s-external-provider/src/leveledlogger" "onap.org/oom-certservice/k8s-external-provider/src/certserviceclient" "onap.org/oom-certservice/k8s-external-provider/src/cmpv2api" "onap.org/oom-certservice/k8s-external-provider/src/cmpv2provisioner/csr" + "onap.org/oom-certservice/k8s-external-provider/src/leveledlogger" ) var collection = new(sync.Map) diff --git a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory.go b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory.go index 00abd2ea..cf55266c 100644 --- a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory.go +++ b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory.go @@ -29,7 +29,6 @@ import ( "onap.org/oom-certservice/k8s-external-provider/src/cmpv2api" ) - type ProvisionerFactory interface { CreateProvisioner(issuer *cmpv2api.CMPv2Issuer, secret v1.Secret) (*CertServiceCA, error) } diff --git a/certServiceK8sExternalProvider/src/cmpv2provisioner/csr/csr.go b/certServiceK8sExternalProvider/src/cmpv2provisioner/csr/csr.go index 583d533e..0d0902fc 100644 --- a/certServiceK8sExternalProvider/src/cmpv2provisioner/csr/csr.go +++ b/certServiceK8sExternalProvider/src/cmpv2provisioner/csr/csr.go @@ -43,10 +43,10 @@ func FilterFieldsFromCSR(csrBytes []byte, privateKeyBytes []byte) ([]byte, error filteredSubject := filterFieldsFromSubject(csr.Subject) filteredCsr, err := x509.CreateCertificateRequest(rand.Reader, &x509.CertificateRequest{ - Subject: filteredSubject, - DNSNames: csr.DNSNames, - IPAddresses: csr.IPAddresses, - URIs: csr.URIs, + Subject: filteredSubject, + DNSNames: csr.DNSNames, + IPAddresses: csr.IPAddresses, + URIs: csr.URIs, EmailAddresses: csr.EmailAddresses, }, key) if err != nil { diff --git a/certServiceK8sExternalProvider/src/leveledlogger/logger.go b/certServiceK8sExternalProvider/src/leveledlogger/logger.go index ee839cbc..01f3c3b8 100644 --- a/certServiceK8sExternalProvider/src/leveledlogger/logger.go +++ b/certServiceK8sExternalProvider/src/leveledlogger/logger.go @@ -27,9 +27,9 @@ import ( "log" "github.com/go-logr/logr" - "go.uber.org/zap/zapcore" "github.com/go-logr/zapr" "go.uber.org/zap" + "go.uber.org/zap/zapcore" ) const ( @@ -39,7 +39,7 @@ const ( ) type Logger struct { - Log logr.Logger + Log logr.Logger ConfigFile string } diff --git a/certServiceK8sExternalProvider/src/leveledlogger/logger_test.go b/certServiceK8sExternalProvider/src/leveledlogger/logger_test.go index 84aa5907..2f958fd9 100644 --- a/certServiceK8sExternalProvider/src/leveledlogger/logger_test.go +++ b/certServiceK8sExternalProvider/src/leveledlogger/logger_test.go @@ -50,7 +50,7 @@ func TestLoggerOnDebugLevel(t *testing.T) { SetConfigFileName("testdata/test_logger_config_debug.json") logger := GetLoggerWithName("loggername") - logOnAllLevels(logger) + logOnAllLevels(logger) resultLogBytes := readFile(resultLogName) expectedLogBytes := readFile(expectedLogName) diff --git a/certServiceK8sExternalProvider/src/x509/x509_utils.go b/certServiceK8sExternalProvider/src/x509/x509_utils.go index e1e887f0..308a24eb 100644 --- a/certServiceK8sExternalProvider/src/x509/x509_utils.go +++ b/certServiceK8sExternalProvider/src/x509/x509_utils.go @@ -36,7 +36,7 @@ const ( func DecodeCSR(data []byte) (*x509.CertificateRequest, error) { block, err := decodePemBlock(data, PemCsrType) if err != nil { - return nil, fmt.Errorf("error decoding CSR PEM: %v", err) + return nil, fmt.Errorf("error decoding CSR PEM: %v", err) } csr, err := x509.ParseCertificateRequest(block.Bytes) if err != nil { @@ -51,11 +51,11 @@ func DecodeCSR(data []byte) (*x509.CertificateRequest, error) { func DecodePrivateKey(data []byte) (interface{}, error) { block, err := decodePemBlock(data, pemPrivateKeyType) if err != nil { - return nil, fmt.Errorf("error decoding Private Key PEM: %v", err) + return nil, fmt.Errorf("error decoding Private Key PEM: %v", err) } key, err := x509.ParsePKCS8PrivateKey(block.Bytes) if err != nil { - return nil, fmt.Errorf("error parsing Private Key: %v", err) + return nil, fmt.Errorf("error parsing Private Key: %v", err) } return key, nil } @@ -71,7 +71,6 @@ func decodePemBlock(data []byte, pemType string) (*pem.Block, error) { return block, nil } - func ParseCertificateArrayToBytes(certificateArray []string) ([]byte, error) { buffer := bytes.NewBuffer([]byte{}) for _, cert := range certificateArray { |