]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: add 139-nts test
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 12 Sep 2019 14:42:53 +0000 (16:42 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 5 Mar 2020 15:02:15 +0000 (16:02 +0100)
test/simulation/139-nts [new file with mode: 0755]

diff --git a/test/simulation/139-nts b/test/simulation/139-nts
new file mode 100755 (executable)
index 0000000..aa5b0bd
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+. ./test.common
+
+test_start "NTP authentication with NTS"
+
+check_config_h 'FEAT_NTS 1' || test_skip
+certtool --help &> /dev/null || test_skip
+
+export CLKNETSIM_START_DATE=$(date -d 'Jan  1 00:00:00 UTC 2010' +'%s')
+
+cat > tmp/cert.cfg <<EOF
+cn = "node1.net1.clk"
+serial = 001
+activation_date = "2010-01-01 00:00:00 UTC"
+expiration_date = "2010-01-02 00:00:00 UTC"
+#dns_name = "node1.net1.clk"
+signing_key
+encryption_key
+EOF
+
+certtool --generate-privkey --key-type=ed25519 --outfile tmp/server.key &> tmp/log.certtool
+certtool --generate-self-signed --load-privkey tmp/server.key \
+       --template tmp/cert.cfg --outfile tmp/server.crt &>> tmp/log.certtool
+
+max_sync_time=400
+dns=1
+server_conf="
+ntsserverkey tmp/server.key
+ntsservercert tmp/server.crt
+ntsprocesses 0
+ntsrotate 64
+"
+client_server_options="minpoll 6 maxpoll 6 nts"
+client_conf="
+nosystemcert
+ntstrustedcerts tmp/server.crt
+logdir tmp
+log rawmeasurements"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+check_file_messages "20.*123\.1.* 111 111 1111" 91 93 measurements.log || test_fail
+check_file_messages "20.*123\.1.* 111 001 0000" 30 32 measurements.log || test_fail
+rm -f tmp/measurements.log
+
+client_conf+="
+ntsrefresh 120"
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection || test_fail
+check_sync || test_fail
+
+check_file_messages "20.*123\.1.* 111 111 1111" 101 103 measurements.log || test_fail
+check_file_messages "20.*123\.1.* 111 001 0000" 0 0 measurements.log || test_fail
+rm -f tmp/measurements.log
+
+client_conf=""
+
+run_test || test_fail
+check_chronyd_exit || test_fail
+check_source_selection && test_fail
+check_sync && test_fail
+
+test_pass