Skip to content

Commit 7cacdb7

Browse files
author
Matt Pryor
committed
Add new fields to unit tests
1 parent 321c88e commit 7cacdb7

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

pkg/cloud/services/networking/securitygroups_test.go

+25-4
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func TestGenerateDesiredSecGroups(t *testing.T) {
317317
wantErr: false,
318318
},
319319
{
320-
name: "Valid openStackCluster with securityGroups",
320+
name: "Valid openStackCluster with default securityGroups",
321321
openStackCluster: &infrav1.OpenStackCluster{
322322
Spec: infrav1.OpenStackClusterSpec{
323323
ManagedSecurityGroups: &infrav1.ManagedSecurityGroups{},
@@ -327,10 +327,11 @@ func TestGenerateDesiredSecGroups(t *testing.T) {
327327
wantErr: false,
328328
},
329329
{
330-
name: "Valid openStackCluster with securityGroups and allNodesSecurityGroupRules",
330+
name: "Valid openStackCluster with default + additional security groups",
331331
openStackCluster: &infrav1.OpenStackCluster{
332332
Spec: infrav1.OpenStackClusterSpec{
333333
ManagedSecurityGroups: &infrav1.ManagedSecurityGroups{
334+
// This should add 4 rules (two for the control plane group and two for the worker group)
334335
AllNodesSecurityGroupRules: []infrav1.SecurityGroupRuleSpec{
335336
{
336337
Protocol: ptr.To("tcp"),
@@ -339,14 +340,34 @@ func TestGenerateDesiredSecGroups(t *testing.T) {
339340
RemoteManagedGroups: []infrav1.ManagedSecurityGroupName{"controlplane", "worker"},
340341
},
341342
},
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+
},
342363
},
343364
},
344365
},
345-
expectedNumberSecurityGroupRules: 18,
366+
expectedNumberSecurityGroupRules: 20,
346367
wantErr: false,
347368
},
348369
{
349-
name: "Valid openStackCluster with securityGroups with invalid allNodesSecurityGroupRules",
370+
name: "Valid openStackCluster with invalid allNodesSecurityGroupRules",
350371
openStackCluster: &infrav1.OpenStackCluster{
351372
Spec: infrav1.OpenStackClusterSpec{
352373
ManagedSecurityGroups: &infrav1.ManagedSecurityGroups{

0 commit comments

Comments
 (0)