]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: extend 105-ntpauth
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 17 May 2016 10:55:54 +0000 (12:55 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 17 May 2016 11:03:53 +0000 (13:03 +0200)
test/simulation/105-ntpauth

index 2ebcec33e7142312fc8110e245527f8284c9e000..5cfdf324ed513ba9543bd908e9dc5d0200c12ef4 100755 (executable)
@@ -4,17 +4,40 @@
 
 test_start "NTP authentication"
 
-server_conf="keyfile tmp/keys"
-client_conf="keyfile tmp/keys"
-
-cat > tmp/keys <<-EOF
-1 $(tr -c -d 'a-zA-Z0-9' < /dev/urandom 2> /dev/null | head -c 24)
-2 ASCII:$(tr -c -d 'a-zA-Z0-9' < /dev/urandom 2> /dev/null | head -c 24)
-3 MD5 ASCII:$(tr -c -d 'a-zA-Z' < /dev/urandom 2> /dev/null | head -c 24)
-4 MD5 HEX:$(tr -c -d '0-9A-F' < /dev/urandom 2> /dev/null | head -c 32)
+server_conf="keyfile tmp/server.keys"
+client_conf="keyfile tmp/client.keys"
+
+cat > tmp/server.keys <<-EOF
+1 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
+2 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
+3 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
+4 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
+EOF
+
+cat > tmp/client.keys <<-EOF
+1 k]<j.Jtw^Oo;z5E>n\_0-x=)yP\f<)Z^
+2 ASCII:k]<j.Jtw^Oo;z5E>n\_0-x=)yP\f<)Z^
+3 MD5 ASCII:k]<j.Jtw^Oo;z5E>n\_0-x=)yP\f<)Z^
+4 MD5 HEX:6B5D3C6A2E4A74775E4F6F3B7A35453E6E5C5F302D783D2979505C663C295A5E
 EOF
 
-for key in 1 2 3 4; do
+keys=4
+
+if grep -q 'FEAT_SECHASH 1' ../../config.h; then
+       hashes="MD5 SHA1 SHA256 SHA384 SHA512"
+else
+       hashes="MD5"
+fi
+
+for hash in $hashes; do
+       keys=$[$keys + 1]
+       key=$(echo $keys $hash HEX:$(tr -c -d '0-9A-F' < /dev/urandom 2> /dev/null | \
+               head -c $[$RANDOM % 64 * 2 + 2]))
+       echo "$key" >> tmp/server.keys
+       echo "$key" >> tmp/client.keys
+done
+
+for key in $(seq $keys); do
        client_server_options="key $key"
        run_test || test_fail
        check_chronyd_exit || test_fail
@@ -31,7 +54,7 @@ check_chronyd_exit || test_fail
 check_sync && test_fail
 check_packet_interval || test_fail
 
-server_conf="keyfile tmp/keys"
+server_conf="keyfile tmp/server.keys"
 client_conf=""
 
 run_test || test_fail
@@ -40,7 +63,7 @@ check_chronyd_exit || test_fail
 check_sync && test_fail
 check_packet_interval || test_fail
 
-client_conf="keyfile tmp/keys"
+client_conf="keyfile tmp/client.keys"
 clients=2
 peers=2
 max_sync_time=500