summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/check_ipaddrcheck.c10
-rwxr-xr-xtests/integration_tests.sh25
2 files changed, 33 insertions, 2 deletions
diff --git a/tests/check_ipaddrcheck.c b/tests/check_ipaddrcheck.c
index feb5a41..3b260c2 100644
--- a/tests/check_ipaddrcheck.c
+++ b/tests/check_ipaddrcheck.c
@@ -2,7 +2,7 @@
* check_ipaddrcheck.c: ipaddrcheck unit tests
*
* Copyright (C) 2013 Daniil Baturin
- * Copyright (C) 2018 VyOS maintainers and contributors
+ * Copyright (C) 2018-2024 VyOS maintainers and contributors
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 or later as
@@ -411,6 +411,14 @@ START_TEST (test_is_ipv4_range)
}
END_TEST
+START_TEST (test_is_ipv6_range)
+{
+ ck_assert_int_eq(is_ipv6_range("2001:db8::1-2001:db8::20", 0), RESULT_SUCCESS);
+ ck_assert_int_eq(is_ipv6_range("2001:-", 0), RESULT_FAILURE);
+ ck_assert_int_eq(is_ipv6_range("2001:db8::99-2001:db8:1", 0), RESULT_FAILURE);
+}
+END_TEST
+
Suite *ipaddrcheck_suite(void)
{
diff --git a/tests/integration_tests.sh b/tests/integration_tests.sh
index a679ea0..8264960 100755
--- a/tests/integration_tests.sh
+++ b/tests/integration_tests.sh
@@ -3,7 +3,7 @@
# integration_tests.sh: ipaddrcheck integration tests
#
# Copyright (C) 2013 Daniil Baturin
-# Copyright (C) 2018 VyOS maintainers and contributors
+# Copyright (C) 2018-2024 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -58,6 +58,16 @@ ipv4_range_negative=(
192.0.2.200-192.0.2.100
)
+ipv6_range_positive=(
+ 2001:db8::1-2001:db8::99
+)
+
+ipv6_range_negative=(
+ 2001:db8:xx-2001:db8::99
+ 2001:db:-
+ 2001:db8::99-2001:db8::1
+)
+
ipv6_single_positive=(
2001:0db8:0000:0000:0000:ff00:0042:8329
2001:db8:0:0:0:ff00:42:8329
@@ -274,4 +284,17 @@ do
assert_raises "$IPADDRCHECK --is-ipv4-range $range" 1
done
+# --is-ipv6-range
+for range in \
+ ${ipv6_range_positive[*]}
+do
+ assert_raises "$IPADDRCHECK --is-ipv6-range $range" 0
+done
+
+for range in \
+ ${ipv6_range_negative[*]}
+do
+ assert_raises "$IPADDRCHECK --is-ipv6-range $range" 1
+done
+
assert_end ipaddrcheck_integration