[OOM-K8S-CERT-EXTERNAL-PROVIDER] Add CMPv2IssuerController test
[oom/platform/cert-service.git] / certServiceK8sExternalProvider / src / testdata / provider.go
1 /*
2  * ============LICENSE_START=======================================================
3  * oom-certservice-k8s-external-provider
4  * ================================================================================
5  * Copyright (C) 2020 Nokia. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package testdata
22
23 import (
24         "k8s.io/api/core/v1"
25         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26
27         "onap.org/oom-certservice/k8s-external-provider/src/cmpv2api"
28 )
29
30 const (
31         SecretName       = "issuer-cert-secret"
32         Url              = "https://oom-cert-service:8443/v1/certificate/"
33         HealthEndpoint   = "actuator/health"
34         CertEndpoint     = "v1/certificate"
35         CaName           = "RA"
36         KeySecretKey     = "cmpv2Issuer-key.pem"
37         CertSecretKey    = "cmpv2Issuer-cert.pem"
38         CacertSecretKey  = "cacert.pem"
39         Namespace        = "default"
40         IssuerObjectName = "fakeIssuer"
41         Kind             = "CMPv2Issuer"
42         APIVersion       = "v1"
43 )
44
45 func GetValidIssuerWithSecret() (cmpv2api.CMPv2Issuer, v1.Secret) {
46         issuer := cmpv2api.CMPv2Issuer{
47
48                 TypeMeta: metav1.TypeMeta{
49                         APIVersion: APIVersion,
50                         Kind:       Kind,
51                 },
52                 ObjectMeta: metav1.ObjectMeta{
53                         Name:      IssuerObjectName,
54                         Namespace: Namespace,
55                 },
56                 Spec: GetValidCMPv2IssuerSpec(),
57         }
58         secret := v1.Secret{
59
60                 Data: map[string][]byte{
61                         KeySecretKey:    KeyBytes,
62                         CertSecretKey:   CertBytes,
63                         CacertSecretKey: CacertBytes,
64                 },
65                 ObjectMeta: metav1.ObjectMeta{
66                         Name:      SecretName,
67                         Namespace: Namespace,
68                 },
69         }
70         secret.Name = SecretName
71         return issuer, secret
72 }
73
74 func GetValidCMPv2IssuerSpec() cmpv2api.CMPv2IssuerSpec {
75         issuerSpec := cmpv2api.CMPv2IssuerSpec{
76                 URL:            Url,
77                 HealthEndpoint: HealthEndpoint,
78                 CertEndpoint:   CertEndpoint,
79                 CaName:         CaName,
80                 CertSecretRef: cmpv2api.SecretKeySelector{
81                         Name:      SecretName,
82                         KeyRef:    KeySecretKey,
83                         CertRef:   CertSecretKey,
84                         CacertRef: CacertSecretKey,
85                 },
86         }
87         return issuerSpec
88 }
89