]> git.ipfire.org Git - network.git/commitdiff
test: Add some test data
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 31 May 2017 12:59:01 +0000 (14:59 +0200)
committerJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 31 May 2017 12:59:01 +0000 (14:59 +0200)
The file test/constants.sh contains valid and invalid
IPv4 and IPV6 networks, adresses, etc.
If we need some addresses to test a function we use this data because:
1. it prevent code duplication
2. every data that is added here, can be tested in several tests without touching the test,
thats make maintaining easier

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Makefile.am
test/constants.sh [new file with mode: 0644]

index ecc6ed7cbd009505f0592af8d523b8212825413c..63b75edaaabc96fb2398fe90b3726d51750c6df9 100644 (file)
@@ -432,7 +432,8 @@ uninstall-hook: $(UNINSTALL_EXEC_HOOKS)
 
 TESTS_ENVIRONMENT = \
        topdir="$(shell pwd)" \
-       networkdir="$(top_srcdir)/src/functions"
+       networkdir="$(top_srcdir)/src/functions" \
+       testdir="$(top_srcdir)/test"
 
 dist_check_SCRIPTS = \
        test/load-library
diff --git a/test/constants.sh b/test/constants.sh
new file mode 100644 (file)
index 0000000..95af032
--- /dev/null
@@ -0,0 +1,129 @@
+#!/bin/bash
+
+INVALID_IPv4_NETWORKS=(
+        2001:470:1f09:1249::
+        2001:470:1f09:1249::/256
+        2001:470:1f09:1249::/-20
+        2001:470:6ef3::
+        192.168.101.0/224
+        192.168.190.0/-23
+        1.2.3.X/abc
+        1.2.3.4/33
+        a.b.c.d/24
+        a.b.c.d/e
+        1.2.3.4/e
+)
+
+INVALID_IPv6_NETWORKS=(
+        192.168.101.0/24
+       192.168.190.0/23
+       1.2.3.X/abc
+        1.2.3.4/33
+        a.b.c.d/24
+        a.b.c.d/e
+        1.2.3.4/e
+        2001:470:1f09:1249::
+        2001:470:1f09:1249::/256
+        2001:470:1f09:1249::/-20
+       2001:470:6ef3::
+)
+
+
+INVALID_NETWORKS=(
+       1.2.3.X/abc
+       1.2.3.4/33
+       a.b.c.d/24
+       a.b.c.d/e
+       1.2.3.4/e
+       2001:470:6ef3::
+       2001:470:1f09:1249::
+       2001:470:1f09:1249::/256
+       2001:470:1f09:1249::/-20
+       1.2.3.4/33
+       1.2.3.4/-33
+       192.168.106.1
+       8.8.8.8
+)
+
+
+VALID_IPv4_NETWORKS=(
+        1.2.3.4/24
+        192.168.101.0/24
+        1.2.3.4/32
+)
+
+VALID_IPv6_NETWORKS=(
+        2001:470:1f09:1249::/64
+        2001:470:6ef3::/48
+)
+
+VALID_NETWORKS=( "${VALID_IPv4_NETWORKS[@]}" "${VALID_IPv6_NETWORKS[@]}")
+
+
+
+VALID_IPv4_ADDRESSES=(
+       12.3.4.5/32
+       192.168.101.254
+       127.0.0.1
+)
+
+VALID_IPv6_ADDRESSES=(
+       2001:470:1f08:1249::2
+       2001:470:1f08:1249::1
+       ::1
+
+)
+
+# We can merge these two array because bot of them conatin only vaild IP adresses
+VALID_ADDRESSES=("${VALID_IPv4_ADDRESSES[@]}" "${VALID_IPv6_ADDRESSES[@]}")
+
+
+
+INVALID_IPv4_ADDRESSES=(
+       1.2.3.X/abc
+       a.b.c.d/24
+       a.b.c.d/e
+       1.2.3.500
+       1.2.3.4/33
+       1.2.3.4/e
+       ::1
+       2001:470:1f08:1249::2
+       2001:470:1f08:1249::1
+)
+
+
+INVALID_IPv6_ADDRESSES=(
+       1200::AB00:1234::2552:7777:1313
+       1200:0000:AB00:1234:O000:2552:7777:1313
+       127.0.0.0.1
+       "::1/256"
+       
+)
+
+# we cannot just merge the 2 array above because 127.0.0.0.1 is a valid IPv4 addresse but an invalid IPv6 address
+INVALID_ADDRESSES=(
+        1200::AB00:1234::2552:7777:1313
+        1200:0000:AB00:1234:O000:2552:7777:1313
+        "::1/256"
+        1.2.3.X/abc
+        a.b.c.d/24
+        a.b.c.d/e
+        1.2.3.500
+        1.2.3.4/33
+        1.2.3.4/e
+)
+
+IP_TEST_SUPPORTED_PROTOCOLS=(
+       ipv4
+       ipv6
+)
+
+IP_TEST_UNSUPPORTED_PROTOCOLS=(
+       ""
+       ipb6
+       ipc6
+       upv6
+       ipb4
+        ipc4
+        upv4
+)