]> git.ipfire.org Git - people/stevee/perl-ipset.git/commitdiff
Add test to add ports to a set
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 17 Apr 2023 13:22:56 +0000 (15:22 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Mon, 17 Apr 2023 13:22:56 +0000 (15:22 +0200)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
t/IPSet.t

index 82657e4be02c87af842b24b41146160abfe07b74..8705c013c457d1fda6dc3dce46e403343a39e68c 100644 (file)
--- 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'});