aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--certServiceK8sExternalProvider/src/certserviceclient/cert_service_client.go21
-rw-r--r--certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_mock.go12
-rw-r--r--certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go21
-rw-r--r--certServiceK8sExternalProvider/src/cmpv2controller/certificate_request_controller.go27
-rw-r--r--certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util.go21
-rw-r--r--certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util_test.go68
-rw-r--r--certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go33
-rw-r--r--certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory_mock.go4
-rw-r--r--certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_test.go25
-rw-r--r--certServiceK8sExternalProvider/src/model/sign_certificate_model.go10
-rw-r--r--certServiceK8sExternalProvider/src/model/sign_certificate_model_factory.go56
-rw-r--r--certServiceK8sExternalProvider/src/model/sign_certificate_model_factory_test.go59
-rw-r--r--certServiceK8sExternalProvider/src/testdata/constants.go4
-rw-r--r--certServiceK8sExternalProvider/src/testdata/provider.go46
14 files changed, 245 insertions, 162 deletions
diff --git a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client.go b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client.go
index f4cc9991..ad0bdbb9 100644
--- a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client.go
+++ b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client.go
@@ -37,9 +37,9 @@ const (
)
type CertServiceClient interface {
- GetCertificates(csr []byte, key []byte) (*CertificatesResponse, error)
+ GetCertificates(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error)
+ UpdateCertificate(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error)
CheckHealth() error
- UpdateCertificate(csr []byte, key []byte, signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error)
}
type CertServiceClientImpl struct {
@@ -80,29 +80,28 @@ func (client *CertServiceClientImpl) CheckHealth() error {
return nil
}
-func (client *CertServiceClientImpl) GetCertificates(csr []byte, key []byte) (*CertificatesResponse, error) {
-
+func (client *CertServiceClientImpl) GetCertificates(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error) {
request, err := http.NewRequest("GET", client.certificationUrl, nil)
if err != nil {
return nil, err
}
- request.Header.Add(CsrHeaderName, base64.StdEncoding.EncodeToString(csr))
- request.Header.Add(PkHeaderName, base64.StdEncoding.EncodeToString(key))
+ request.Header.Add(CsrHeaderName, base64.StdEncoding.EncodeToString(signCertificateModel.FilteredCsr))
+ request.Header.Add(PkHeaderName, base64.StdEncoding.EncodeToString(signCertificateModel.PrivateKeyBytes))
return client.executeRequest(request)
}
-func (client *CertServiceClientImpl) UpdateCertificate(csr []byte, key []byte, signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error) {
+func (client *CertServiceClientImpl) UpdateCertificate(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error) {
request, err := http.NewRequest("GET", client.updateUrl, nil)
if err != nil {
return nil, err
}
- request.Header.Add(CsrHeaderName, base64.StdEncoding.EncodeToString(csr))
- request.Header.Add(PkHeaderName, base64.StdEncoding.EncodeToString(key))
- request.Header.Add(OldPkHeaderName, signCertificateModel.OldPrivateKey)
- request.Header.Add(OldCertificateHeaderName, signCertificateModel.OldCertificate)
+ request.Header.Add(CsrHeaderName, base64.StdEncoding.EncodeToString(signCertificateModel.FilteredCsr))
+ request.Header.Add(PkHeaderName, base64.StdEncoding.EncodeToString(signCertificateModel.PrivateKeyBytes))
+ request.Header.Add(OldPkHeaderName, base64.StdEncoding.EncodeToString(signCertificateModel.OldPrivateKeyBytes))
+ request.Header.Add(OldCertificateHeaderName, base64.StdEncoding.EncodeToString(signCertificateModel.OldCertificateBytes))
return client.executeRequest(request)
}
diff --git a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_mock.go b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_mock.go
index a6fec1fd..0550c8fa 100644
--- a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_mock.go
+++ b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_mock.go
@@ -23,16 +23,16 @@ package certserviceclient
import "onap.org/oom-certservice/k8s-external-provider/src/model"
type CertServiceClientMock struct {
- GetCertificatesFunc func(csr []byte, key []byte) (*CertificatesResponse, error)
- UpdateCertificateFunc func(csr []byte, key []byte, signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error)
+ GetCertificatesFunc func(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error)
+ UpdateCertificateFunc func(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error)
}
-func (client *CertServiceClientMock) UpdateCertificate(csr []byte, key []byte, signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error) {
- return client.UpdateCertificateFunc(csr, key, signCertificateModel)
+func (client *CertServiceClientMock) UpdateCertificate(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error) {
+ return client.UpdateCertificateFunc(signCertificateModel)
}
-func (client *CertServiceClientMock) GetCertificates(csr []byte, key []byte) (*CertificatesResponse, error) {
- return client.GetCertificatesFunc(csr, key)
+func (client *CertServiceClientMock) GetCertificates(signCertificateModel model.SignCertificateModel) (*CertificatesResponse, error) {
+ return client.GetCertificatesFunc(signCertificateModel)
}
func (client *CertServiceClientMock) CheckHealth() error {
diff --git a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go
index e1c6bb91..86562c01 100644
--- a/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go
+++ b/certServiceK8sExternalProvider/src/certserviceclient/cert_service_client_test.go
@@ -46,7 +46,7 @@ func Test_GetCertificates_shouldParseCertificateResponseCorrectly(t *testing.T)
certificationUrl: certificationUrl,
httpClient: getMockedClient(responseJsonReader, http.StatusOK),
}
- response, _ := client.GetCertificates(testdata.CsrBytes, testdata.PkBytes)
+ response, _ := client.GetCertificates(getTestSignCertificateModel())
assert.ElementsMatch(t, []string{"cert-0", "cert-1"}, response.CertificateChain)
assert.ElementsMatch(t, []string{"trusted-cert-0", "trusted-cert-1"}, response.TrustedCertificates)
}
@@ -65,7 +65,7 @@ func Test_GetCertificates_shouldReturnError_whenResponseIsNotJson(t *testing.T)
},
},
}
- response, err := client.GetCertificates(testdata.CsrBytes, testdata.PkBytes)
+ response, err := client.GetCertificates(getTestSignCertificateModel())
assert.Nil(t, response)
assert.Error(t, err)
@@ -80,7 +80,7 @@ func Test_GetCertificates_shouldReturnError_whenHttpClientReturnsError(t *testin
},
},
}
- response, err := client.GetCertificates(testdata.CsrBytes, testdata.PkBytes)
+ response, err := client.GetCertificates(getTestSignCertificateModel())
assert.Nil(t, response)
assert.Error(t, err)
@@ -93,7 +93,7 @@ func Test_GetCertificates_shouldReturnError_whenResponseOtherThan200(t *testing.
certificationUrl: certificationUrl,
httpClient: getMockedClient(responseJsonReader, http.StatusNotFound),
}
- response, err := client.GetCertificates(testdata.CsrBytes, testdata.PkBytes)
+ response, err := client.GetCertificates(getTestSignCertificateModel())
assert.Nil(t, response)
assert.Error(t, err)
@@ -107,12 +107,11 @@ func Test_UpdateCertificates_shouldParseCertificateResponseCorrectly(t *testing.
httpClient: getMockedClient(responseJsonReader, http.StatusOK),
}
- response, _ := client.UpdateCertificate(testdata.CsrBytes, testdata.PkBytes, getTestSignCertificateModel())
+ response, _ := client.UpdateCertificate(getTestSignCertificateModel())
assert.ElementsMatch(t, []string{"cert-0", "cert-1"}, response.CertificateChain)
assert.ElementsMatch(t, []string{"trusted-cert-0", "trusted-cert-1"}, response.TrustedCertificates)
}
-
func Test_UpdateCertificates_shouldReturnError_whenHttpClientReturnsError(t *testing.T) {
client := CertServiceClientImpl{
updateUrl: certificateUpdateUrl,
@@ -122,7 +121,7 @@ func Test_UpdateCertificates_shouldReturnError_whenHttpClientReturnsError(t *tes
},
},
}
- response, err := client.UpdateCertificate(testdata.CsrBytes, testdata.PkBytes, getTestSignCertificateModel())
+ response, err := client.UpdateCertificate(getTestSignCertificateModel())
assert.Nil(t, response)
assert.Error(t, err)
@@ -135,7 +134,7 @@ func Test_UpdateCertificates_shouldReturnError_whenResponseOtherThan200(t *testi
updateUrl: updateEndpoint,
httpClient: getMockedClient(responseJsonReader, http.StatusNotFound),
}
- response, err := client.UpdateCertificate(testdata.CsrBytes, testdata.PkBytes, getTestSignCertificateModel())
+ response, err := client.UpdateCertificate(getTestSignCertificateModel())
assert.Nil(t, response)
assert.Error(t, err)
@@ -215,8 +214,10 @@ func (client httpClientMock) Do(req *http.Request) (*http.Response, error) {
func getTestSignCertificateModel() model.SignCertificateModel {
testSignCertificateModel := model.SignCertificateModel{
- OldCertificate: testdata.OldCertificateEncoded,
- OldPrivateKey: testdata.OldPrivateKeyEncoded,
+ FilteredCsr: testdata.CsrBytes,
+ PrivateKeyBytes: testdata.PkBytes,
+ OldCertificateBytes: testdata.OldCertificateBytes,
+ OldPrivateKeyBytes: testdata.OldPrivateKeyBytes,
}
return testSignCertificateModel
}
diff --git a/certServiceK8sExternalProvider/src/cmpv2controller/certificate_request_controller.go b/certServiceK8sExternalProvider/src/cmpv2controller/certificate_request_controller.go
index 9d266854..5f8b1964 100644
--- a/certServiceK8sExternalProvider/src/cmpv2controller/certificate_request_controller.go
+++ b/certServiceK8sExternalProvider/src/cmpv2controller/certificate_request_controller.go
@@ -40,7 +40,6 @@ import (
"onap.org/oom-certservice/k8s-external-provider/src/cmpv2api"
"onap.org/oom-certservice/k8s-external-provider/src/cmpv2controller/logger"
"onap.org/oom-certservice/k8s-external-provider/src/cmpv2controller/updater"
- "onap.org/oom-certservice/k8s-external-provider/src/cmpv2controller/util"
provisioners "onap.org/oom-certservice/k8s-external-provider/src/cmpv2provisioner"
"onap.org/oom-certservice/k8s-external-provider/src/leveledlogger"
"onap.org/oom-certservice/k8s-external-provider/src/model"
@@ -139,25 +138,18 @@ func (controller *CertificateRequestController) Reconcile(k8sRequest ctrl.Reques
// 9. Log Certificate Request properties not supported or overridden by CertService API
logger.LogCertRequestProperties(leveledlogger.GetLoggerWithName("CSR details:"), certificateRequest, csr)
- // 10. Check if CertificateRequest is an update request
- isUpdateRevision, oldCertificate, oldPrivateKey := util.CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk(
- controller.Client, certificateRequest, ctx)
- if isUpdateRevision {
- log.Info("Update revision detected")
- }
- signCertificateModel := model.SignCertificateModel{
- CertificateRequest: certificateRequest,
- PrivateKeyBytes: privateKeyBytes,
- IsUpdateRevision: isUpdateRevision,
- OldCertificate: oldCertificate,
- OldPrivateKey: oldPrivateKey,
+ //10. Create sign certificate object with filtered CSR
+ signCertificateModel, err := model.CreateSignCertificateModel(controller.Client, certificateRequest, ctx, privateKeyBytes)
+ if err != nil {
+ controller.handleErrorFailedToFilterCSR(certUpdater, log, err)
+ return ctrl.Result{}, err
}
// 11. Sign CertificateRequest
- signedPEM, trustedCAs, err := provisioner.Sign(ctx, signCertificateModel)
+ signedPEM, trustedCAs, err := provisioner.Sign(signCertificateModel)
if err != nil {
controller.handleErrorFailedToSignCertificate(certUpdater, log, err)
- return ctrl.Result{}, nil
+ return ctrl.Result{}, err
}
// 12. Store signed certificates in CertificateRequest
@@ -234,6 +226,11 @@ func (controller *CertificateRequestController) handleErrorFailedToDecodeCSR(upd
_ = updater.UpdateStatusWithEventTypeWarning(cmapi.CertificateRequestReasonFailed, "Failed to decode CSR: %v", err)
}
+func (controller *CertificateRequestController) handleErrorFailedToFilterCSR(updater *updater.CertificateRequestStatusUpdater, log leveledlogger.Logger, err error) {
+ log.Error(err, "Failed to filter certificate sign request fields")
+ _ = updater.UpdateStatusWithEventTypeWarning(cmapi.CertificateRequestReasonFailed, "Failed to filter CSR: %v", err)
+}
+
func handleErrorResourceNotFound(log leveledlogger.Logger, err error) error {
if apierrors.IsNotFound(err) {
log.Error(err, "CertificateRequest resource not found")
diff --git a/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util.go b/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util.go
index 93746b82..86cca3e0 100644
--- a/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util.go
+++ b/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util.go
@@ -26,7 +26,6 @@ package util
import (
"context"
- "encoding/base64"
"encoding/json"
"strconv"
@@ -43,17 +42,15 @@ const (
oldPrivateKeySecretKey = "tls.key"
)
-func CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk(
+func RetrieveOldCertificateAndPkForCertificateUpdate(
k8sClient client.Client,
certificateRequest *cmapi.CertificateRequest,
ctx context.Context,
-) (bool, string, string) {
+) ([]byte, []byte) {
if !IsUpdateCertificateRevision(certificateRequest) {
- return false, "", ""
+ return []byte{}, []byte{}
}
- certificate, privateKey := RetrieveOldCertificateAndPk(k8sClient, certificateRequest, ctx)
- areCertAndPkPresent := certificate != "" && privateKey != ""
- return areCertAndPkPresent, certificate, privateKey
+ return RetrieveOldCertificateAndPk(k8sClient, certificateRequest, ctx)
}
func IsUpdateCertificateRevision(certificateRequest *cmapi.CertificateRequest) bool {
@@ -68,11 +65,11 @@ func RetrieveOldCertificateAndPk(
k8sClient client.Client,
certificateRequest *cmapi.CertificateRequest,
ctx context.Context,
-) (string, string) {
+) ([]byte, []byte) {
certificateConfigString := certificateRequest.ObjectMeta.Annotations[certificateConfigurationAnnotation]
var certificateConfig cmapi.Certificate
if err := json.Unmarshal([]byte(certificateConfigString), &certificateConfig); err != nil {
- return "", ""
+ return []byte{}, []byte{}
}
oldCertificateSecretName := certificateConfig.Spec.SecretName
oldCertificateSecretNamespacedName := types.NamespacedName{
@@ -81,9 +78,7 @@ func RetrieveOldCertificateAndPk(
}
var oldCertificateSecret core.Secret
if err := k8sClient.Get(ctx, oldCertificateSecretNamespacedName, &oldCertificateSecret); err != nil {
- return "", ""
+ return []byte{}, []byte{}
}
- oldCertificateString := base64.StdEncoding.EncodeToString(oldCertificateSecret.Data[oldCertificateSecretKey])
- oldPrivateKeyString := base64.StdEncoding.EncodeToString(oldCertificateSecret.Data[oldPrivateKeySecretKey])
- return oldCertificateString, oldPrivateKeyString
+ return oldCertificateSecret.Data[oldCertificateSecretKey], oldCertificateSecret.Data[oldPrivateKeySecretKey]
}
diff --git a/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util_test.go b/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util_test.go
index 7dbbbe7a..f9005277 100644
--- a/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util_test.go
+++ b/certServiceK8sExternalProvider/src/cmpv2controller/util/certificate_update_util_test.go
@@ -25,20 +25,16 @@
package util
import (
- "encoding/base64"
"fmt"
"testing"
cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
"github.com/stretchr/testify/assert"
- v1 "k8s.io/api/core/v1"
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"onap.org/oom-certservice/k8s-external-provider/src/testdata"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
)
const (
- oldCertificateConfig = "{\"apiVersion\":\"cert-manager.io/v1\",\"kind\":\"Certificate\",\"metadata\":{\"annotations\":{},\"name\":\"cert-test\",\"namespace\":\"onap\"},\"spec\":{\"commonName\":\"certissuer.onap.org\",\"dnsNames\":[\"localhost\",\"certissuer.onap.org\"],\"emailAddresses\":[\"onap@onap.org\"],\"ipAddresses\":[\"127.0.0.1\"],\"issuerRef\":{\"group\":\"certmanager.onap.org\",\"kind\":\"CMPv2Issuer\",\"name\":\"cmpv2-issuer-onap\"},\"secretName\":\"cert-test-secret-name\",\"subject\":{\"countries\":[\"US\"],\"localities\":[\"San-Francisco\"],\"organizationalUnits\":[\"ONAP\"],\"organizations\":[\"Linux-Foundation\"],\"provinces\":[\"California\"]},\"uris\":[\"onap://cluster.local/\"]}}\n"
testPrivateKeyData = "test-private-key"
testCertificateData = "test-certificate"
)
@@ -48,36 +44,33 @@ func Test_CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk_revisionOne(t *
request.ObjectMeta.Annotations = map[string]string{
revisionAnnotation: "2",
}
- isUpdate, certificate, privateKey := CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk(nil, request, nil)
- assert.False(t, isUpdate)
- assert.Equal(t, "", certificate)
- assert.Equal(t, "", privateKey)
+ certificate, privateKey := RetrieveOldCertificateAndPkForCertificateUpdate(nil, request, nil)
+ assert.Equal(t, []byte{}, certificate)
+ assert.Equal(t, []byte{}, privateKey)
}
func Test_CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk_revisionTwoSecretPresent(t *testing.T) {
request := new(cmapi.CertificateRequest)
request.ObjectMeta.Annotations = map[string]string{
revisionAnnotation: "2",
- certificateConfigurationAnnotation: oldCertificateConfig,
+ certificateConfigurationAnnotation: testdata.OldCertificateConfig,
}
- fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme(), getValidCertificateSecret())
- isUpdate, certificate, privateKey := CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk(fakeClient, request, nil)
- assert.True(t, isUpdate)
- assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(testCertificateData)), certificate)
- assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(testPrivateKeyData)), privateKey)
+ fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme(), testdata.GetValidCertificateSecret())
+ certificate, privateKey := RetrieveOldCertificateAndPkForCertificateUpdate(fakeClient, request, nil)
+ assert.Equal(t, []byte(testCertificateData), certificate)
+ assert.Equal(t, []byte(testPrivateKeyData), privateKey)
}
func Test_CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk_revisionTwoSecretNotPresent(t *testing.T) {
request := new(cmapi.CertificateRequest)
request.ObjectMeta.Annotations = map[string]string{
revisionAnnotation: "2",
- certificateConfigurationAnnotation: oldCertificateConfig,
+ certificateConfigurationAnnotation: testdata.OldCertificateConfig,
}
fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme())
- isUpdate, certificate, privateKey := CheckIfCertificateUpdateAndRetrieveOldCertificateAndPk(fakeClient, request, nil)
- assert.False(t, isUpdate)
- assert.Equal(t, "", certificate)
- assert.Equal(t, "", privateKey)
+ certificate, privateKey := RetrieveOldCertificateAndPkForCertificateUpdate(fakeClient, request, nil)
+ assert.Equal(t, []byte{}, certificate)
+ assert.Equal(t, []byte{}, privateKey)
}
func Test_IsUpdateCertificateRevision(t *testing.T) {
@@ -109,45 +102,30 @@ func testIsUpdateCertificateRevision(t *testing.T, revision string, expected boo
func Test_RetrieveOldCertificateAndPk_shouldSucceedWhenSecretPresent(t *testing.T) {
request := new(cmapi.CertificateRequest)
request.ObjectMeta.Annotations = map[string]string{
- certificateConfigurationAnnotation: oldCertificateConfig,
+ certificateConfigurationAnnotation: testdata.OldCertificateConfig,
}
- fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme(), getValidCertificateSecret())
+ fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme(), testdata.GetValidCertificateSecret())
certificate, privateKey := RetrieveOldCertificateAndPk(fakeClient, request, nil)
- assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(testCertificateData)), certificate)
- assert.Equal(t, base64.StdEncoding.EncodeToString([]byte(testPrivateKeyData)), privateKey)
+ assert.Equal(t, []byte(testCertificateData), certificate)
+ assert.Equal(t, []byte(testPrivateKeyData), privateKey)
}
-func Test_RetrieveOldCertificateAndPk_shouldReturnEmptyStringsWhenSecretNotPresent(t *testing.T) {
+func Test_RetrieveOldCertificateAndPk_shouldBeEmptyWhenSecretNotPresent(t *testing.T) {
request := new(cmapi.CertificateRequest)
request.ObjectMeta.Annotations = map[string]string{
- certificateConfigurationAnnotation: oldCertificateConfig,
+ certificateConfigurationAnnotation: testdata.OldCertificateConfig,
}
fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme())
certificate, privateKey := RetrieveOldCertificateAndPk(fakeClient, request, nil)
- assert.Equal(t, "", certificate)
- assert.Equal(t, "", privateKey)
+ assert.Equal(t, []byte{}, certificate)
+ assert.Equal(t, []byte{}, privateKey)
}
-func Test_RetrieveOldCertificateAndPk_shouldReturnEmptyStringsWhenOldCertificateCannotBeUnmarshalled(t *testing.T) {
+func Test_RetrieveOldCertificateAndPk_shouldBeEmptyWhenOldCertificateCannotBeUnmarshalled(t *testing.T) {
request := new(cmapi.CertificateRequest)
fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme())
certificate, privateKey := RetrieveOldCertificateAndPk(fakeClient, request, nil)
- assert.Equal(t, "", certificate)
- assert.Equal(t, "", privateKey)
+ assert.Equal(t, []byte{}, certificate)
+ assert.Equal(t, []byte{}, privateKey)
}
-func getValidCertificateSecret() *v1.Secret {
- const privateKeySecretKey = "tls.key"
- const certificateSecretKey = "tls.crt"
-
- return &v1.Secret{
- Data: map[string][]byte{
- privateKeySecretKey: []byte("test-private-key"),
- certificateSecretKey: []byte("test-certificate"),
- },
- ObjectMeta: metav1.ObjectMeta{
- Name: "cert-test-secret-name",
- Namespace: "onap",
- },
- }
-}
diff --git a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go
index dc2824ce..53932494 100644
--- a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go
+++ b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner.go
@@ -26,14 +26,12 @@
package cmpv2provisioner
import (
- "context"
"sync"
"k8s.io/apimachinery/pkg/types"
"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"
"onap.org/oom-certservice/k8s-external-provider/src/model"
)
@@ -85,40 +83,24 @@ func Store(namespacedName types.NamespacedName, provisioner *CertServiceCA) {
}
func (ca *CertServiceCA) Sign(
- ctx context.Context,
signCertificateModel model.SignCertificateModel,
) (signedCertificateChain []byte, trustedCertificates []byte, err error) {
log := leveledlogger.GetLoggerWithName("certservice-provisioner")
- if signCertificateModel.IsUpdateRevision {
- log.Debug("Certificate will be updated.", "old-certificate", signCertificateModel.OldCertificate,
- "old-private-key", signCertificateModel.OldPrivateKey)
- }
-
certificateRequest := signCertificateModel.CertificateRequest
- privateKeyBytes := signCertificateModel.PrivateKeyBytes
log.Info("Signing certificate: ", "cert-name", certificateRequest.Name)
-
log.Info("CA: ", "name", ca.name, "url", ca.url)
- csrBytes := certificateRequest.Spec.Request
- log.Debug("Original CSR PEM: ", "bytes", csrBytes)
-
- filteredCsrBytes, err := csr.FilterFieldsFromCSR(csrBytes, privateKeyBytes)
- if err != nil {
- return nil, nil, err
- }
- log.Debug("Filtered out CSR PEM: ", "bytes", filteredCsrBytes)
-
var response *certserviceclient.CertificatesResponse
var errAPI error
- if signCertificateModel.IsUpdateRevision {
+ if ca.isCertificateUpdate(signCertificateModel) {
+ log.Debug("Certificate will be updated.", "old-certificate", signCertificateModel.OldCertificateBytes)
log.Info("Attempt to send certificate update request")
- response, errAPI = ca.certServiceClient.UpdateCertificate(filteredCsrBytes, privateKeyBytes, signCertificateModel)
+ response, errAPI = ca.certServiceClient.UpdateCertificate(signCertificateModel)
} else {
log.Info("Attempt to send certificate request")
- response, errAPI = ca.certServiceClient.GetCertificates(filteredCsrBytes, privateKeyBytes)
+ response, errAPI = ca.certServiceClient.GetCertificates(signCertificateModel)
}
if errAPI != nil {
@@ -135,11 +117,14 @@ func (ca *CertServiceCA) Sign(
log.Error(signErr, "Cannot parse response from CertService API")
return nil, nil, signErr
}
-
log.Info("Successfully signed: ", "cert-name", certificateRequest.Name)
-
log.Debug("Signed cert PEM: ", "bytes", signedCertificateChain)
log.Debug("Trusted CA PEM: ", "bytes", trustedCertificates)
return signedCertificateChain, trustedCertificates, nil
}
+
+
+func (ca *CertServiceCA) isCertificateUpdate(signCertificateModel model.SignCertificateModel) bool {
+ return len(signCertificateModel.OldCertificateBytes) > 0 && len(signCertificateModel.OldPrivateKeyBytes) > 0
+}
diff --git a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory_mock.go b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory_mock.go
index cb3b8c63..0e543610 100644
--- a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory_mock.go
+++ b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_factory_mock.go
@@ -35,10 +35,10 @@ type ProvisionerFactoryMock struct {
func (f *ProvisionerFactoryMock) CreateProvisioner(issuer *cmpv2api.CMPv2Issuer, secret v1.Secret) (*CertServiceCA, error) {
provisioner, err := New(issuer, &certserviceclient.CertServiceClientMock{
- GetCertificatesFunc: func(csr []byte, pk []byte) (response *certserviceclient.CertificatesResponse, e error) {
+ GetCertificatesFunc: func(signCertificateModel model.SignCertificateModel) (response *certserviceclient.CertificatesResponse, e error) {
return &testdata.SampleCertServiceResponse, nil
},
- UpdateCertificateFunc: func(csr []byte, key []byte, signCertificateModel model.SignCertificateModel) (*certserviceclient.CertificatesResponse, error) {
+ UpdateCertificateFunc: func(signCertificateModel model.SignCertificateModel) (*certserviceclient.CertificatesResponse, error) {
return &testdata.SampleCertServiceResponse, nil
},
})
diff --git a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_test.go b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_test.go
index 1a066657..e0b0c2e9 100644
--- a/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_test.go
+++ b/certServiceK8sExternalProvider/src/cmpv2provisioner/cmpv2_provisioner_test.go
@@ -21,7 +21,6 @@
package cmpv2provisioner
import (
- "context"
"testing"
"time"
@@ -77,19 +76,17 @@ func Test_shouldReturnCorrectSignedPemsWhenParametersAreCorrectForCertificateReq
testdata.VerifyThatConditionIsTrue(ok, "Provisioner could not be loaded", t)
- ctx := context.Background()
request := createCertificateRequest()
privateKeyBytes := getPrivateKeyBytes()
signCertificateModel := model.SignCertificateModel{
- CertificateRequest: request,
- PrivateKeyBytes: privateKeyBytes,
- IsUpdateRevision: false,
- OldCertificate: "",
- OldPrivateKey: "",
+ CertificateRequest: request,
+ PrivateKeyBytes: privateKeyBytes,
+ OldCertificateBytes: []byte{},
+ OldPrivateKeyBytes: []byte{},
}
- signedPEM, trustedCAs, err := provisioner.Sign(ctx, signCertificateModel)
+ signedPEM, trustedCAs, err := provisioner.Sign(signCertificateModel)
assert.Nil(t, err)
@@ -108,19 +105,17 @@ func Test_shouldReturnCorrectSignedPemsWhenParametersAreCorrectForUpdateCertific
testdata.VerifyThatConditionIsTrue(ok, "Provisioner could not be loaded", t)
- ctx := context.Background()
request := createCertificateRequest()
privateKeyBytes := getPrivateKeyBytes()
signCertificateModel := model.SignCertificateModel{
- CertificateRequest: request,
- PrivateKeyBytes: privateKeyBytes,
- IsUpdateRevision: true,
- OldCertificate: testdata.OldCertificateEncoded,
- OldPrivateKey: testdata.OldPrivateKeyEncoded,
+ CertificateRequest: request,
+ PrivateKeyBytes: privateKeyBytes,
+ OldCertificateBytes: testdata.OldCertificateBytes,
+ OldPrivateKeyBytes: testdata.OldPrivateKeyBytes,
}
- signedPEM, trustedCAs, err := provisioner.Sign(ctx, signCertificateModel)
+ signedPEM, trustedCAs, err := provisioner.Sign(signCertificateModel)
assert.Nil(t, err)
diff --git a/certServiceK8sExternalProvider/src/model/sign_certificate_model.go b/certServiceK8sExternalProvider/src/model/sign_certificate_model.go
index 40dca1ae..6fcf0cff 100644
--- a/certServiceK8sExternalProvider/src/model/sign_certificate_model.go
+++ b/certServiceK8sExternalProvider/src/model/sign_certificate_model.go
@@ -23,9 +23,9 @@ package model
import cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
type SignCertificateModel struct {
- CertificateRequest *cmapi.CertificateRequest
- PrivateKeyBytes []byte
- IsUpdateRevision bool
- OldCertificate string
- OldPrivateKey string
+ CertificateRequest *cmapi.CertificateRequest
+ FilteredCsr []byte
+ PrivateKeyBytes []byte
+ OldCertificateBytes []byte
+ OldPrivateKeyBytes []byte
}
diff --git a/certServiceK8sExternalProvider/src/model/sign_certificate_model_factory.go b/certServiceK8sExternalProvider/src/model/sign_certificate_model_factory.go
new file mode 100644
index 00000000..297201be
--- /dev/null
+++ b/certServiceK8sExternalProvider/src/model/sign_certificate_model_factory.go
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START=======================================================
+ * oom-certservice-k8s-external-provider
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package model
+
+import (
+ "context"
+
+ "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
+ "sigs.k8s.io/controller-runtime/pkg/client"
+
+ "onap.org/oom-certservice/k8s-external-provider/src/cmpv2controller/util"
+ "onap.org/oom-certservice/k8s-external-provider/src/cmpv2provisioner/csr"
+ "onap.org/oom-certservice/k8s-external-provider/src/leveledlogger"
+)
+
+func CreateSignCertificateModel(client client.Client, certificateRequest *v1.CertificateRequest, ctx context.Context, privateKeyBytes []byte) (SignCertificateModel, error) {
+ log := leveledlogger.GetLoggerWithName("certservice-certificate-model")
+ oldCertificateBytes, oldPrivateKeyBytes := util.RetrieveOldCertificateAndPkForCertificateUpdate(
+ client, certificateRequest, ctx)
+
+ csrBytes := certificateRequest.Spec.Request
+ log.Debug("Original CSR PEM: ", "bytes", csrBytes)
+
+ filteredCsrBytes, err := csr.FilterFieldsFromCSR(csrBytes, privateKeyBytes)
+ if err != nil {
+ return SignCertificateModel{}, err
+ }
+ log.Debug("Filtered out CSR PEM: ", "bytes", filteredCsrBytes)
+
+ signCertificateModel := SignCertificateModel{
+ CertificateRequest: certificateRequest,
+ FilteredCsr: filteredCsrBytes,
+ PrivateKeyBytes: privateKeyBytes,
+ OldCertificateBytes: oldCertificateBytes,
+ OldPrivateKeyBytes: oldPrivateKeyBytes,
+ }
+ return signCertificateModel, nil
+}
diff --git a/certServiceK8sExternalProvider/src/model/sign_certificate_model_factory_test.go b/certServiceK8sExternalProvider/src/model/sign_certificate_model_factory_test.go
new file mode 100644
index 00000000..def9a377
--- /dev/null
+++ b/certServiceK8sExternalProvider/src/model/sign_certificate_model_factory_test.go
@@ -0,0 +1,59 @@
+/*
+ * ============LICENSE_START=======================================================
+ * oom-certservice-k8s-external-provider
+ * ================================================================================
+ * Copyright (C) 2021 Nokia. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package model
+
+import (
+ "context"
+ "testing"
+
+ cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
+ "github.com/stretchr/testify/assert"
+ "sigs.k8s.io/controller-runtime/pkg/client/fake"
+
+ "onap.org/oom-certservice/k8s-external-provider/src/testdata"
+)
+
+const (
+ revisionAnnotation = "cert-manager.io/certificate-revision"
+ certificateConfigurationAnnotation = "kubectl.kubernetes.io/last-applied-configuration"
+ testPrivateKeyData = "test-private-key"
+ testCertificateData = "test-certificate"
+)
+
+func Test_shouldCreateCertificateModelWithCorrectParameters(t *testing.T) {
+ request := new(cmapi.CertificateRequest)
+ request.ObjectMeta.Annotations = map[string]string{
+ revisionAnnotation: "2",
+ certificateConfigurationAnnotation: testdata.OldCertificateConfig,
+ }
+ request.Spec.Request = testdata.CsrBytes
+ fakeClient := fake.NewFakeClientWithScheme(testdata.GetScheme(), testdata.GetValidCertificateSecret())
+
+ signCertModel, err := CreateSignCertificateModel(fakeClient, request, *new(context.Context), testdata.PkBytes)
+
+ assert.Nil(t, err)
+ assert.NotNil(t, signCertModel)
+ assert.NotNil(t, signCertModel.FilteredCsr)
+ assert.Equal(t, testdata.PkBytes, signCertModel.PrivateKeyBytes)
+ assert.Equal(t, request, signCertModel.CertificateRequest)
+ assert.Equal(t, []byte(testCertificateData), signCertModel.OldCertificateBytes)
+ assert.Equal(t, []byte(testPrivateKeyData), signCertModel.OldPrivateKeyBytes)
+}
diff --git a/certServiceK8sExternalProvider/src/testdata/constants.go b/certServiceK8sExternalProvider/src/testdata/constants.go
index c1e86146..062fdd24 100644
--- a/certServiceK8sExternalProvider/src/testdata/constants.go
+++ b/certServiceK8sExternalProvider/src/testdata/constants.go
@@ -29,7 +29,7 @@ var (
CacertBytes, _ = base64.StdEncoding.DecodeString("QmFnIEF0dHJpYnV0ZXMKICAgIGZyaWVuZGx5TmFtZTogcm9vdAogICAgMi4xNi44NDAuMS4xMTM4OTQuNzQ2ODc1LjEuMTogPFVuc3VwcG9ydGVkIHRhZyA2PgpzdWJqZWN0PUMgPSBVUywgU1QgPSBDYWxpZm9ybmlhLCBMID0gU2FuLUZyYW5jaXNjbywgTyA9IExpbnV4LUZvdW5kYXRpb24sIE9VID0gT05BUCwgQ04gPSBvbmFwLm9yZwoKaXNzdWVyPUMgPSBVUywgU1QgPSBDYWxpZm9ybmlhLCBMID0gU2FuLUZyYW5jaXNjbywgTyA9IExpbnV4LUZvdW5kYXRpb24sIE9VID0gT05BUCwgQ04gPSBvbmFwLm9yZwoKLS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk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STlzcFIrYlExWGdVVlBSSE1BNEdBMVVkRHdFQi93UUVBd0lGNERBTkJna3Foa2lHOXcwQkFRc0ZBQU9DQVlFQQpoWE9HWU1OUjJzcTNreUVhWG9KL3BYWlJiRW1jWlNYZ2p1dXVES0U4bjh3WlArY2Izd0FDZWU3MmFtZ2dJODR6CmtJeGlkU2ZNZWgvdURZTVBGR2pBQUFyQ1kydTdxcnZsMzBmaVU1OG9qZmhsbUwzbHYyalZBSnRyWksvVnVrWnUKajB6ZG5TU2d6ZyszN0NhL1BHeE1nY3pDaHdhZVEvU0ZpZHhuYWczdHhmUFZjYUdXa25pTkljVER5ZlRUQ3J0YQpjU0JPQ3B1S1doOWRCZk15dTg3VjhNc2N2dGh0WDNIWFhEQStVSXN4VzJlekxOS25UYmM1SURHL3NqOGVteXNmCnA1aDE3alQxblZ1eEY3QWluWC96Um84YzBBK20zVUdLQVdxM1NKU3k1RDdDRkVzTWtRRUhiNWQ3WGtZR3pRNWkKNmZPZURuZlpZZjV0R2tYSTdaZmZXZjduRkprVEhmU25xNkxUaE9SbDAyRWliMXJoZXFCR2xSR0hhTFNIWTh4OApZb0trK2dZbkI3a2MzSzRuV3NMNGpTWW5oUlBaMmpJMTM1RWxwckFtaGlBQ2E3Zk5wMThLbitsQzZvWGZ6b1FqCmJPMlFhUENCdU1NMFFhLzZzb2NwN1lnZkRXZjdUR3llYi9rV2pIWEpXaUUzSk5FcjBhN28ycGVFUHQvSEY4WTAKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQoK"
diff --git a/certServiceK8sExternalProvider/src/testdata/provider.go b/certServiceK8sExternalProvider/src/testdata/provider.go
index 6bb420c3..ce09f4a7 100644
--- a/certServiceK8sExternalProvider/src/testdata/provider.go
+++ b/certServiceK8sExternalProvider/src/testdata/provider.go
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* oom-certservice-k8s-external-provider
* ================================================================================
- * Copyright (C) 2020 Nokia. All rights reserved.
+ * Copyright (C) 2020-2021 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,19 +33,20 @@ import (
)
const (
- SecretName = "issuer-cert-secret"
- Url = "https://oom-cert-service:8443/v1/certificate/"
- HealthEndpoint = "actuator/health"
- CertEndpoint = "v1/certificate"
- CaName = "RA"
- KeySecretKey = "cmpv2Issuer-key.pem"
- CertSecretKey = "cmpv2Issuer-cert.pem"
- CacertSecretKey = "cacert.pem"
- Namespace = "onap"
- IssuerObjectName = "cmpv2-issuer"
- Kind = "CMPv2Issuer"
- APIVersion = "v1"
- PrivateKeySecret = "privateKeySecretName"
+ SecretName = "issuer-cert-secret"
+ Url = "https://oom-cert-service:8443/v1/certificate/"
+ HealthEndpoint = "actuator/health"
+ CertEndpoint = "v1/certificate"
+ CaName = "RA"
+ KeySecretKey = "cmpv2Issuer-key.pem"
+ CertSecretKey = "cmpv2Issuer-cert.pem"
+ CacertSecretKey = "cacert.pem"
+ Namespace = "onap"
+ IssuerObjectName = "cmpv2-issuer"
+ Kind = "CMPv2Issuer"
+ APIVersion = "v1"
+ PrivateKeySecret = "privateKeySecretName"
+ OldCertificateConfig = "{\"apiVersion\":\"cert-manager.io/v1\",\"kind\":\"Certificate\",\"metadata\":{\"annotations\":{},\"name\":\"cert-test\",\"namespace\":\"onap\"},\"spec\":{\"commonName\":\"certissuer.onap.org\",\"dnsNames\":[\"localhost\",\"certissuer.onap.org\"],\"emailAddresses\":[\"onap@onap.org\"],\"ipAddresses\":[\"127.0.0.1\"],\"issuerRef\":{\"group\":\"certmanager.onap.org\",\"kind\":\"CMPv2Issuer\",\"name\":\"cmpv2-issuer-onap\"},\"secretName\":\"cert-test-secret-name\",\"subject\":{\"countries\":[\"US\"],\"localities\":[\"San-Francisco\"],\"organizationalUnits\":[\"ONAP\"],\"organizations\":[\"Linux-Foundation\"],\"provinces\":[\"California\"]},\"uris\":[\"onap://cluster.local/\"]}}\n"
)
func GetValidIssuerWithSecret() (cmpv2api.CMPv2Issuer, v1.Secret) {
@@ -117,3 +118,20 @@ func CreateIssuerNamespaceName(namespace string, name string) types.NamespacedNa
Name: name,
}
}
+
+func GetValidCertificateSecret() *v1.Secret {
+ const privateKeySecretKey = "tls.key"
+ const certificateSecretKey = "tls.crt"
+
+ return &v1.Secret{
+ Data: map[string][]byte{
+ privateKeySecretKey: []byte("test-private-key"),
+ certificateSecretKey: []byte("test-certificate"),
+ },
+ ObjectMeta: metav1.ObjectMeta{
+ Name: "cert-test-secret-name",
+ Namespace: "onap",
+ },
+ }
+}
+