aboutsummaryrefslogtreecommitdiffstats
path: root/certServiceK8sExternalProvider/src/x509/x509_utils_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'certServiceK8sExternalProvider/src/x509/x509_utils_test.go')
-rw-r--r--certServiceK8sExternalProvider/src/x509/x509_utils_test.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/certServiceK8sExternalProvider/src/x509/x509_utils_test.go b/certServiceK8sExternalProvider/src/x509/x509_utils_test.go
index 2692bf4e..c867d2e8 100644
--- a/certServiceK8sExternalProvider/src/x509/x509_utils_test.go
+++ b/certServiceK8sExternalProvider/src/x509/x509_utils_test.go
@@ -28,15 +28,28 @@ import (
"onap.org/oom-certservice/k8s-external-provider/src/x509/testdata"
)
-func TestShouldDecodeCSR(t *testing.T) {
+func Test_DecodeCSR_ShouldDecodeValidCsr(t *testing.T) {
csr, err := DecodeCSR([]byte(testdata.ValidCertificateSignRequest))
assert.Nil(t, err)
assert.Equal(t, "ONAP", csr.Subject.Organization[0])
}
-func TestShouldReturnError(t *testing.T) {
+func Test_DecodeCSR_ShouldReturnErrorForInvalidCsr(t *testing.T) {
_, err := DecodeCSR([]byte(testdata.InvalidCertificateSignRequest))
- assert.NotNil(t, err)
+ assert.Error(t, err)
+}
+
+func Test_DecodePrivateKey_ShouldDecodeValidPrivateKey(t *testing.T) {
+ privateKey, err := DecodePrivateKey([]byte(testdata.ValidPrivateKey))
+
+ assert.Nil(t, err)
+ assert.NotNil(t, privateKey)
+}
+
+func Test_DecodePrivateKey_ShouldReturnErrorForInvalidPrivateKey(t *testing.T) {
+ _, err := DecodePrivateKey([]byte(testdata.InvalidPrivateKey))
+
+ assert.Error(t, err)
}