]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3940] add kea-shell tests
authorPiotrek Zadroga <piotrek@isc.org>
Mon, 16 Jun 2025 18:21:06 +0000 (20:21 +0200)
committerPiotrek Zadroga <piotrek@isc.org>
Tue, 17 Jun 2025 18:55:08 +0000 (18:55 +0000)
Tests cover --auth-password-file flag usage.

src/bin/shell/tests/auth_bad_password_file.in [new file with mode: 0644]
src/bin/shell/tests/auth_password_file.in [new file with mode: 0644]
src/bin/shell/tests/ca_basic_auth_tests.sh.in
src/bin/shell/tests/d2_basic_auth_tests.sh.in
src/bin/shell/tests/dhcp4_basic_auth_tests.sh.in
src/bin/shell/tests/dhcp6_basic_auth_tests.sh.in
src/bin/shell/tests/meson.build

diff --git a/src/bin/shell/tests/auth_bad_password_file.in b/src/bin/shell/tests/auth_bad_password_file.in
new file mode 100644 (file)
index 0000000..ba0e162
--- /dev/null
@@ -0,0 +1 @@
+bar
\ No newline at end of file
diff --git a/src/bin/shell/tests/auth_password_file.in b/src/bin/shell/tests/auth_password_file.in
new file mode 100644 (file)
index 0000000..0a47d36
--- /dev/null
@@ -0,0 +1 @@
+meow
\ No newline at end of file
index 287a15c1a6fd8b5c215a36726ebfb83a2f98ca72..cc8245aa75d1eba336068840d44c64d65d6c49b1 100755 (executable)
@@ -198,3 +198,12 @@ shell_command_test "shell.bad-auth" \
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
     "[ { \"arguments\": [ \"build-report\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"list-commands\", \"shutdown\", \"status-get\", \"version-get\" ], \"result\": 0 } ]"
+shell_command_test "shell.bad-auth-password-file" \
+    "--auth-user foo --auth-password-file test" "list-commands" "fail" \
+    "Failed to run: [Errno 2] No such file or directory: 'test'"
+shell_command_test "shell.bad-auth-password-file-content" \
+    "--auth-user foo --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
+    "Failed to run: HTTP Error 401: Unauthorized"
+shell_command_test "shell.good-auth-password-file-content" \
+    "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
+    "[ { \"arguments\": [ \"build-report\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"list-commands\", \"shutdown\", \"status-get\", \"version-get\" ], \"result\": 0 } ]"
index aac0631dec046506971e981f3319243d4f574521..0702626a39ed18cb81aeec258781a8c5a90e17b9 100755 (executable)
@@ -203,3 +203,12 @@ shell_command_test "shell.bad-auth" \
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
     "[ { \"arguments\": [ \"build-report\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"list-commands\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-reset\", \"statistic-reset-all\", \"status-get\", \"version-get\" ], \"result\": 0 } ]"
+shell_command_test "shell.bad-auth-password-file" \
+    "--auth-user foo --auth-password-file test" "list-commands" "fail" \
+    "Failed to run: [Errno 2] No such file or directory: 'test'"
+shell_command_test "shell.bad-auth-password-file-content" \
+    "--auth-user foo --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
+    "Failed to run: HTTP Error 401: Unauthorized"
+shell_command_test "shell.good-auth-password-file-content" \
+    "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
+    "[ { \"arguments\": [ \"build-report\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"list-commands\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-reset\", \"statistic-reset-all\", \"status-get\", \"version-get\" ], \"result\": 0 } ]"
index 9e07744956caf4e10444a4ef00aac8b4a5154a97..d11721d5b3ca5afb52d2a2d44b74e8905946613e 100755 (executable)
@@ -230,3 +230,12 @@ shell_command_test "shell.bad-auth" \
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
     "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+shell_command_test "shell.bad-auth-password-file" \
+    "--auth-user foo --auth-password-file test" "list-commands" "fail" \
+    "Failed to run: [Errno 2] No such file or directory: 'test'"
+shell_command_test "shell.bad-auth-password-file-content" \
+    "--auth-user foo --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
+    "Failed to run: HTTP Error 401: Unauthorized"
+shell_command_test "shell.good-auth-password-file-content" \
+    "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet4-select-test\", \"subnet4o6-select-test\", \"version-get\" ], \"result\": 0 } ]"
index 311ee365e261bfa2042d58ce6fd3c5dcca0aeac0..9fea36dd8f8c740940198b020446a72a4bae4149 100755 (executable)
@@ -235,3 +235,12 @@ shell_command_test "shell.bad-auth" \
 shell_command_test "shell.authorized" \
     "--auth-user pet --auth-password meow" "list-commands" "" \
     "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
+shell_command_test "shell.bad-auth-password-file" \
+    "--auth-user foo --auth-password-file test" "list-commands" "fail" \
+    "Failed to run: [Errno 2] No such file or directory: 'test'"
+shell_command_test "shell.bad-auth-password-file-content" \
+    "--auth-user foo --auth-password-file ${tmpfile_path}/auth_bad_password_file" "list-commands" "fail" \
+    "Failed to run: HTTP Error 401: Unauthorized"
+shell_command_test "shell.good-auth-password-file-content" \
+    "--auth-user pet --auth-password-file ${tmpfile_path}/auth_password_file" "list-commands" "" \
+    "[ { \"arguments\": [ \"build-report\", \"config-backend-pull\", \"config-get\", \"config-hash-get\", \"config-reload\", \"config-set\", \"config-test\", \"config-write\", \"dhcp-disable\", \"dhcp-enable\", \"leases-reclaim\", \"list-commands\", \"server-tag-get\", \"shutdown\", \"statistic-get\", \"statistic-get-all\", \"statistic-remove\", \"statistic-remove-all\", \"statistic-reset\", \"statistic-reset-all\", \"statistic-sample-age-set\", \"statistic-sample-age-set-all\", \"statistic-sample-count-set\", \"statistic-sample-count-set-all\", \"status-get\", \"subnet6-select-test\", \"version-get\" ], \"result\": 0 } ]"
index 5b0b6d52ec8d6ba607b50db6f5ed3d403013996e..18a7bc3339be7e514ec2de28b1dfdf051b70740d 100644 (file)
@@ -165,3 +165,13 @@ test(
     priority: -1,
     suite: 'shell-tests',
 )
+auth_bad_password_file = configure_file(
+    input: 'auth_bad_password_file.in',
+    output: 'auth_bad_password_file',
+    configuration: shell_tests_conf_data,
+)
+auth_password_file = configure_file(
+    input: 'auth_password_file.in',
+    output: 'auth_password_file',
+    configuration: shell_tests_conf_data,
+)