From 10c43ab5641a857ec08e7375f6f2527280d269de Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Mon, 17 Apr 2023 15:22:56 +0200 Subject: [PATCH] Add test to add ports to a set Signed-off-by: Stefan Schantl --- t/IPSet.t | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/t/IPSet.t b/t/IPSet.t index 82657e4..8705c01 100644 --- a/t/IPSet.t +++ b/t/IPSet.t @@ -8,7 +8,7 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 24; BEGIN { use_ok('IPSet') }; ######################### @@ -32,6 +32,9 @@ my %portset = ( # Array with addresses to be added to the testset. my @addresses = ("1.1.1.1", "2.2.2.2"); +# Array with ports to be added to the portset. +my @ports = ("22", "53", "80", "443"); + # Name of the renamed set. my $setname_renamed = "TEST_RENAMED"; @@ -117,6 +120,15 @@ ok($create_port_set, "Sucessfully created set: $portset{'name'}"); $exists = &IPSet::setname_exists($session, $portset{'name'}); ok($exists, "The portset exists."); +# Add all ports from the array to the portset. +foreach my $port (@ports) { + &IPSet::add_port($session, $portset{'name'}, $port); +} + +# Grab set data from portset. +$data = &IPSet::get_set_data($session, $portset{'name'}); +ok($data->{entries} eq scalar(@ports), "All ports added successfully to the set"); + # Destroy the port set. &IPSet::delete_set($session, $portset{'name'}); -- 2.47.3