|
| 1 | +/* |
| 2 | +Copyright 2023 Red Hat |
| 3 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +you may not use this file except in compliance with the License. |
| 5 | +You may obtain a copy of the License at |
| 6 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | +Unless required by applicable law or agreed to in writing, software |
| 8 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +See the License for the specific language governing permissions and |
| 11 | +limitations under the License. |
| 12 | +*/ |
| 13 | + |
| 14 | +package helpers |
| 15 | + |
| 16 | +import ( |
| 17 | + "k8s.io/apimachinery/pkg/types" |
| 18 | + |
| 19 | + corev1 "k8s.io/api/core/v1" |
| 20 | +) |
| 21 | + |
| 22 | +// CreateCABundleSecret creates a new secret holding the tls-ca-bundle.pem with fake data. |
| 23 | +// |
| 24 | +// Example usage: |
| 25 | +// |
| 26 | +// caBundleSecretName = types.NamespacedName{Name: "bundlename", Namespace: namespace} |
| 27 | +// s := th.CreateCABundleSecret(caBundleSecretName) |
| 28 | +func (tc *TestHelper) CreateCABundleSecret(name types.NamespacedName) *corev1.Secret { |
| 29 | + data := map[string][]byte{ |
| 30 | + "tls-ca-bundle.pem": []byte("Zm9v"), |
| 31 | + } |
| 32 | + |
| 33 | + return tc.CreateSecret(name, data) |
| 34 | +} |
| 35 | + |
| 36 | +// CreateCertSecret creates a new secret with entries for the cert, key and a ca using fake data. |
| 37 | +// |
| 38 | +// Example usage: |
| 39 | +// |
| 40 | +// certSecretName = types.NamespacedName{Name: "secretname", Namespace: namespace} |
| 41 | +// s := th.CreateCertSecret(certSecretName) |
| 42 | +func (tc *TestHelper) CreateCertSecret(name types.NamespacedName) *corev1.Secret { |
| 43 | + data := map[string][]byte{ |
| 44 | + "ca.crt": []byte("Zm9v"), |
| 45 | + "tls.crt": []byte("Zm9v"), |
| 46 | + "tls.key": []byte("Zm9v"), |
| 47 | + } |
| 48 | + |
| 49 | + return tc.CreateSecret(name, data) |
| 50 | +} |
0 commit comments