Skip to content

Commit a729193

Browse files
committed
[envtest] additional tlsetests
Extendend envtest for following scenarios: * TLSe OpenStackControlplane * TLSe OpenStackControlplane with custom public issuer * public TLS OpenStackControlplane with custom keystone public certificate Depends-On: openstack-k8s-operators/lib-common#498
1 parent 47fcf16 commit a729193

3 files changed

Lines changed: 677 additions & 81 deletions

File tree

‎pkg/openstack/common.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,10 @@ func (ed *EndpointDetail) CreateRoute(
483483
if err != nil {
484484
return ctrl.Result{}, err
485485
}
486-
enptRoute.OwnerReferences = append(enptRoute.OwnerReferences, owner)
486+
// in EnvTest the UID of the created service CRs are empty
487+
if owner.GetUID() != "" {
488+
enptRoute.OwnerReferences = append(enptRoute.OwnerReferences, owner)
489+
}
487490

488491
// if route TLS is disabled -> create the route
489492
// if TLS is enabled and the route does not yet exist -> create the route

‎tests/functional/base_test.go‎

Lines changed: 153 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,39 @@ import (
3131
)
3232

3333
type Names struct {
34-
Namespace string
35-
OpenStackControlplaneName types.NamespacedName
36-
OpenStackVersionName types.NamespacedName
37-
KeystoneAPIName types.NamespacedName
38-
MemcachedName types.NamespacedName
39-
CinderName types.NamespacedName
40-
ManilaName types.NamespacedName
41-
DBName types.NamespacedName
42-
DBCertName types.NamespacedName
43-
DBCell1Name types.NamespacedName
44-
DBCell1CertName types.NamespacedName
45-
RabbitMQName types.NamespacedName
46-
RabbitMQCell1Name types.NamespacedName
47-
ServiceAccountName types.NamespacedName
48-
RoleName types.NamespacedName
49-
RoleBindingName types.NamespacedName
50-
RootCAPublicName types.NamespacedName
51-
RootCAInternalName types.NamespacedName
52-
RootCAOvnName types.NamespacedName
53-
SelfSignedIssuerName types.NamespacedName
54-
CABundleName types.NamespacedName
55-
OpenStackClientName types.NamespacedName
56-
OVNNorthdName types.NamespacedName
57-
OVNControllerName types.NamespacedName
58-
OVNDbServerNBName types.NamespacedName
59-
OVNDbServerSBName types.NamespacedName
34+
Namespace string
35+
OpenStackControlplaneName types.NamespacedName
36+
OpenStackVersionName types.NamespacedName
37+
KeystoneAPIName types.NamespacedName
38+
MemcachedName types.NamespacedName
39+
MemcachedCertName types.NamespacedName
40+
CinderName types.NamespacedName
41+
ManilaName types.NamespacedName
42+
DBName types.NamespacedName
43+
DBCertName types.NamespacedName
44+
DBCell1Name types.NamespacedName
45+
DBCell1CertName types.NamespacedName
46+
RabbitMQName types.NamespacedName
47+
RabbitMQCertName types.NamespacedName
48+
RabbitMQCell1Name types.NamespacedName
49+
RabbitMQCell1CertName types.NamespacedName
50+
ServiceAccountName types.NamespacedName
51+
RoleName types.NamespacedName
52+
RoleBindingName types.NamespacedName
53+
RootCAPublicName types.NamespacedName
54+
RootCAInternalName types.NamespacedName
55+
RootCAOvnName types.NamespacedName
56+
SelfSignedIssuerName types.NamespacedName
57+
CustomIssuerName types.NamespacedName
58+
CustomServiceCertSecretName types.NamespacedName
59+
CABundleName types.NamespacedName
60+
OpenStackClientName types.NamespacedName
61+
OVNNorthdName types.NamespacedName
62+
OVNNorthdCertName types.NamespacedName
63+
OVNControllerName types.NamespacedName
64+
OVNControllerCertName types.NamespacedName
65+
OVNDbServerNBName types.NamespacedName
66+
OVNDbServerSBName types.NamespacedName
6067
}
6168

6269
func CreateNames(openstackControlplaneName types.NamespacedName) Names {
@@ -79,9 +86,15 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
7986
SelfSignedIssuerName: types.NamespacedName{
8087
Namespace: openstackControlplaneName.Namespace,
8188
Name: "selfsigned-issuer"},
89+
CustomIssuerName: types.NamespacedName{
90+
Namespace: openstackControlplaneName.Namespace,
91+
Name: "custom-issuer"},
8292
CABundleName: types.NamespacedName{
8393
Namespace: openstackControlplaneName.Namespace,
8494
Name: "combined-ca-bundle"},
95+
CustomServiceCertSecretName: types.NamespacedName{
96+
Namespace: openstackControlplaneName.Namespace,
97+
Name: "custom-service-cert"},
8598
ServiceAccountName: types.NamespacedName{
8699
Namespace: openstackControlplaneName.Namespace,
87100
Name: openstackControlplaneName.Name},
@@ -99,6 +112,10 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
99112
Namespace: openstackControlplaneName.Namespace,
100113
Name: "memcached",
101114
},
115+
MemcachedCertName: types.NamespacedName{
116+
Namespace: openstackControlplaneName.Namespace,
117+
Name: "cert-memcached-svc",
118+
},
102119
CinderName: types.NamespacedName{
103120
Namespace: openstackControlplaneName.Namespace,
104121
Name: "cinder",
@@ -127,10 +144,18 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
127144
Namespace: openstackControlplaneName.Namespace,
128145
Name: "rabbitmq",
129146
},
147+
RabbitMQCertName: types.NamespacedName{
148+
Namespace: openstackControlplaneName.Namespace,
149+
Name: "cert-rabbitmq-svc",
150+
},
130151
RabbitMQCell1Name: types.NamespacedName{
131152
Namespace: openstackControlplaneName.Namespace,
132153
Name: "rabbitmq-cell1",
133154
},
155+
RabbitMQCell1CertName: types.NamespacedName{
156+
Namespace: openstackControlplaneName.Namespace,
157+
Name: "cert-rabbitmq-cell1-svc",
158+
},
134159
OpenStackClientName: types.NamespacedName{
135160
Namespace: openstackControlplaneName.Namespace,
136161
Name: "openstackclient",
@@ -139,6 +164,10 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
139164
Namespace: openstackControlplaneName.Namespace,
140165
Name: "ovnnorthd",
141166
},
167+
OVNNorthdCertName: types.NamespacedName{
168+
Namespace: openstackControlplaneName.Namespace,
169+
Name: "cert-ovnnorthd-ovndbs",
170+
},
142171
OVNDbServerNBName: types.NamespacedName{
143172
Namespace: openstackControlplaneName.Namespace,
144173
Name: "ovndbcluster-nb",
@@ -151,6 +180,10 @@ func CreateNames(openstackControlplaneName types.NamespacedName) Names {
151180
Namespace: openstackControlplaneName.Namespace,
152181
Name: "ovncontroller",
153182
},
183+
OVNControllerCertName: types.NamespacedName{
184+
Namespace: openstackControlplaneName.Namespace,
185+
Name: "cert-ovncontroller-ovndbs",
186+
},
154187
}
155188
}
156189

@@ -230,6 +263,88 @@ func CreateOpenStackControlPlane(name types.NamespacedName, spec map[string]inte
230263
return th.CreateUnstructured(raw)
231264
}
232265

266+
func GetTLSPublicSpec() map[string]interface{} {
267+
return map[string]interface{}{
268+
"ingress": map[string]interface{}{
269+
"enabled": true,
270+
"ca": map[string]interface{}{
271+
"duration": "100h",
272+
},
273+
"cert": map[string]interface{}{
274+
"duration": "10h",
275+
},
276+
},
277+
}
278+
}
279+
280+
func GetTLSeSpec() map[string]interface{} {
281+
return map[string]interface{}{
282+
"ingress": map[string]interface{}{
283+
"enabled": true,
284+
"ca": map[string]interface{}{
285+
"duration": "100h",
286+
},
287+
"cert": map[string]interface{}{
288+
"duration": "10h",
289+
},
290+
},
291+
"podLevel": map[string]interface{}{
292+
"enabled": true,
293+
"internal": map[string]interface{}{
294+
"ca": map[string]interface{}{
295+
"duration": "100h",
296+
},
297+
"cert": map[string]interface{}{
298+
"duration": "10h",
299+
},
300+
},
301+
"ovn": map[string]interface{}{
302+
"ca": map[string]interface{}{
303+
"duration": "100h",
304+
},
305+
"cert": map[string]interface{}{
306+
"duration": "10h",
307+
},
308+
},
309+
},
310+
}
311+
}
312+
313+
func GetTLSeCustomIssuerSpec() map[string]interface{} {
314+
return map[string]interface{}{
315+
"ingress": map[string]interface{}{
316+
"enabled": true,
317+
318+
"ca": map[string]interface{}{
319+
"customIssuer": names.CustomIssuerName.Name,
320+
"duration": "100h",
321+
},
322+
"cert": map[string]interface{}{
323+
"duration": "10h",
324+
},
325+
},
326+
"podLevel": map[string]interface{}{
327+
"enabled": true,
328+
"internal": map[string]interface{}{
329+
"ca": map[string]interface{}{
330+
"duration": "100h",
331+
},
332+
"cert": map[string]interface{}{
333+
"duration": "10h",
334+
},
335+
},
336+
"ovn": map[string]interface{}{
337+
"ca": map[string]interface{}{
338+
"duration": "100h",
339+
},
340+
"cert": map[string]interface{}{
341+
"duration": "10h",
342+
},
343+
},
344+
},
345+
}
346+
}
347+
233348
func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
234349
memcachedTemplate := map[string]interface{}{
235350
"memcached": map[string]interface{}{
@@ -260,22 +375,10 @@ func GetDefaultOpenStackControlPlaneSpec() map[string]interface{} {
260375
"ironicConductors": []interface{}{},
261376
}
262377

263-
tlsTemplate := map[string]interface{}{
264-
"ingress": map[string]interface{}{
265-
"enabled": true,
266-
"ca": map[string]interface{}{
267-
"duration": "100h",
268-
},
269-
"cert": map[string]interface{}{
270-
"duration": "10h",
271-
},
272-
},
273-
}
274-
275378
return map[string]interface{}{
276379
"secret": "osp-secret",
277380
"storageClass": "local-storage",
278-
"tls": tlsTemplate,
381+
"tls": GetTLSeSpec(),
279382
"galera": map[string]interface{}{
280383
"enabled": true,
281384
"templates": galeraTemplate,
@@ -339,7 +442,7 @@ func OpenStackControlPlaneConditionGetter(name types.NamespacedName) condition.C
339442
return instance.Status.Conditions
340443
}
341444

342-
func CreatePublicCACertSecret(name types.NamespacedName) *k8s_corev1.Secret {
445+
func CreateCertSecret(name types.NamespacedName) *k8s_corev1.Secret {
343446
certBase64 := "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJlekNDQVNLZ0F3SUJBZ0lRTkhER1lzQnM3OThpYkREN3EvbzJsakFLQmdncWhrak9QUVFEQWpBZU1Sd3cKR2dZRFZRUURFeE55YjI5MFkyRXRhM1YwZEd3dGNIVmliR2xqTUI0WERUSTBNREV4TlRFd01UVXpObG9YRFRNMApNREV4TWpFd01UVXpObG93SGpFY01Cb0dBMVVFQXhNVGNtOXZkR05oTFd0MWRIUnNMWEIxWW14cFl6QlpNQk1HCkJ5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEEwSUFCRDc4YXZYcWhyaEM1dzhzOVdrZDRJcGJlRXUwM0NSK1hYVWQKa0R6T1J5eGE5d2NjSWREaXZiR0pqSkZaVFRjVm1ianExQk1Zc2pyMTJVSUU1RVQzVmxxalFqQkFNQTRHQTFVZApEd0VCL3dRRUF3SUNwREFQQmdOVkhSTUJBZjhFQlRBREFRSC9NQjBHQTFVZERnUVdCQlRLSml6V1VKOWVVS2kxCmRzMGxyNmM2c0Q3RUJEQUtCZ2dxaGtqT1BRUURBZ05IQURCRUFpQklad1lxNjFCcU1KYUI2VWNGb1JzeGVjd0gKNXovek1PZHJPeWUwbU5pOEpnSWdRTEI0d0RLcnBmOXRYMmxvTSswdVRvcEFEU1lJbnJjZlZ1NEZCdVlVM0lnPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
344447
keyBase64 := "LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUptbGNLUEl1RitFc3RhYkxnVmowZkNhdzFTK09xNnJPU3M0U3pMQkJGYVFvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFUHZ4cTllcUd1RUxuRHl6MWFSM2dpbHQ0UzdUY0pINWRkUjJRUE01SExGcjNCeHdoME9LOQpzWW1Na1ZsTk54V1p1T3JVRXhpeU92WFpRZ1RrUlBkV1dnPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=="
345448

@@ -360,44 +463,19 @@ func CreatePublicCACertSecret(name types.NamespacedName) *k8s_corev1.Secret {
360463
return s
361464
}
362465

363-
func CreateInternalCACertSecret(name types.NamespacedName) *k8s_corev1.Secret {
364-
certBase64 := "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUJmekNDQVNhZ0F3SUJBZ0lRUWxlcTNZcDBtU2kwVDNiTm03Q29UVEFLQmdncWhrak9QUVFEQWpBZ01SNHcKSEFZRFZRUURFeFZ5YjI5MFkyRXRhM1YwZEd3dGFXNTBaWEp1WVd3d0hoY05NalF3TVRFMU1URTBOelUwV2hjTgpNelF3TVRFeU1URTBOelUwV2pBZ01SNHdIQVlEVlFRREV4VnliMjkwWTJFdGEzVjBkR3d0YVc1MFpYSnVZV3d3CldUQVRCZ2NxaGtqT1BRSUJCZ2dxaGtqT1BRTUJCd05DQUFTRk9rNHJPUldVUGhoTjUrK09EN1I2MW5Gb1lBY0QKenpvUS91SW93NktjeGhwRWNQTDFxb3ZZUGxUYUJabEh3c2FpNE50VHA4aDA1RHVRSGZKOE9JNXFvMEl3UURBTwpCZ05WSFE4QkFmOEVCQU1DQXFRd0R3WURWUjBUQVFIL0JBVXdBd0VCL3pBZEJnTlZIUTRFRmdRVXE3TGtFSk1TCm1MOVpKWjBSOUluKzZkclhycEl3Q2dZSUtvWkl6ajBFQXdJRFJ3QXdSQUlnVlN1K00ydnZ3QlF3eTJHMVlhdkkKQld2RGtSNlRla0I5U0VqdzJIblRSMWtDSUZSNFNkWGFPQkFGWjVHa2RLWCtSY2IzaDFIZm52eFJEVW96bTl2agphenp3Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K=="
365-
keyBase64 := "LS0tLS1CRUdJTiBFQyBQUklWQVRFIEtFWS0tLS0tCk1IY0NBUUVFSUV3dlQ2dFZMUWRrVnlXUDV1VnJ3RWRyZ0VLK3drdmttRjFKa0xNYzJCUVFvQW9HQ0NxR1NNNDkKQXdFSG9VUURRZ0FFaFRwT0t6a1ZsRDRZVGVmdmpnKzBldFp4YUdBSEE4ODZFUDdpS01PaW5NWWFSSER5OWFxTAoyRDVVMmdXWlI4TEdvdURiVTZmSWRPUTdrQjN5ZkRpT2FnPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=="
366-
367-
cert, _ := base64.StdEncoding.DecodeString(certBase64)
368-
key, _ := base64.StdEncoding.DecodeString(keyBase64)
369-
370-
s := &k8s_corev1.Secret{}
371-
Eventually(func(g Gomega) {
372-
s = th.CreateSecret(
373-
name,
374-
map[string][]byte{
375-
"ca.crt": []byte(cert),
376-
"tls.crt": []byte(cert),
377-
"tls.key": []byte(key),
378-
})
379-
}, timeout, interval).Should(Succeed())
380-
381-
return s
382-
}
383-
384-
func CreateOvnCACertSecret(name types.Namespaced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PUTdrQjN5ZkRpT2FnPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=="
466+
func CreateClusterConfigCM() client.Object {
467+
var cm client.Object
387468

388-
cert, _ := base64.StdEncoding.DecodeString(certBase64)
389-
key, _ := base64.StdEncoding.DecodeString(keyBase64)
390-
391-
s := &k8s_corev1.Secret{}
392469
Eventually(func(g Gomega) {
393-
s = th.CreateSecret(
394-
name,
395-
map[string][]byte{
396-
"ca.crt": []byte(cert),
397-
"tls.crt": []byte(cert),
398-
"tls.key": []byte(key),
470+
cm = th.CreateConfigMap(
471+
types.NamespacedName{
472+
Name: "cluster-config-v1",
473+
Namespace: "kube-system",
474+
},
475+
map[string]interface{}{
476+
"install-config": "",
399477
})
400478
}, timeout, interval).Should(Succeed())
401479

402-
return s
480+
return cm
403481
}

0 commit comments

Comments
 (0)