@@ -317,7 +317,7 @@ func TestGenerateDesiredSecGroups(t *testing.T) {
317
317
wantErr : false ,
318
318
},
319
319
{
320
- name : "Valid openStackCluster with securityGroups" ,
320
+ name : "Valid openStackCluster with default securityGroups" ,
321
321
openStackCluster : & infrav1.OpenStackCluster {
322
322
Spec : infrav1.OpenStackClusterSpec {
323
323
ManagedSecurityGroups : & infrav1.ManagedSecurityGroups {},
@@ -327,10 +327,11 @@ func TestGenerateDesiredSecGroups(t *testing.T) {
327
327
wantErr : false ,
328
328
},
329
329
{
330
- name : "Valid openStackCluster with securityGroups and allNodesSecurityGroupRules " ,
330
+ name : "Valid openStackCluster with default + additional security groups " ,
331
331
openStackCluster : & infrav1.OpenStackCluster {
332
332
Spec : infrav1.OpenStackClusterSpec {
333
333
ManagedSecurityGroups : & infrav1.ManagedSecurityGroups {
334
+ // This should add 4 rules (two for the control plane group and two for the worker group)
334
335
AllNodesSecurityGroupRules : []infrav1.SecurityGroupRuleSpec {
335
336
{
336
337
Protocol : ptr .To ("tcp" ),
@@ -339,14 +340,34 @@ func TestGenerateDesiredSecGroups(t *testing.T) {
339
340
RemoteManagedGroups : []infrav1.ManagedSecurityGroupName {"controlplane" , "worker" },
340
341
},
341
342
},
343
+ // This should add one rule
344
+ ControlPlaneNodesSecurityGroupRules : []infrav1.SecurityGroupRuleSpec {
345
+ {
346
+ Protocol : ptr .To ("tcp" ),
347
+ PortRangeMin : ptr .To (9000 ),
348
+ PortRangeMax : ptr .To (9000 ),
349
+ RemoteManagedGroups : []infrav1.ManagedSecurityGroupName {"controlplane" },
350
+ },
351
+ },
352
+ // This should also add one rule
353
+ WorkerNodesSecurityGroupRules : []infrav1.SecurityGroupRuleSpec {
354
+ {
355
+ Protocol : ptr .To ("tcp" ),
356
+ Direction : "ingress" ,
357
+ EtherType : ptr .To ("IPv4" ),
358
+ PortRangeMin : ptr .To (30000 ),
359
+ PortRangeMax : ptr .To (32767 ),
360
+ RemoteIPPrefix : ptr .To ("0.0.0.0/0" ),
361
+ },
362
+ },
342
363
},
343
364
},
344
365
},
345
- expectedNumberSecurityGroupRules : 18 ,
366
+ expectedNumberSecurityGroupRules : 20 ,
346
367
wantErr : false ,
347
368
},
348
369
{
349
- name : "Valid openStackCluster with securityGroups with invalid allNodesSecurityGroupRules" ,
370
+ name : "Valid openStackCluster with invalid allNodesSecurityGroupRules" ,
350
371
openStackCluster : & infrav1.OpenStackCluster {
351
372
Spec : infrav1.OpenStackClusterSpec {
352
373
ManagedSecurityGroups : & infrav1.ManagedSecurityGroups {
0 commit comments