From: Piotrek Zadroga Date: Mon, 16 Jun 2025 18:21:06 +0000 (+0200) Subject: [#3940] add kea-shell tests X-Git-Tag: Kea-3.0.0~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c34bacf97a5f404667ab7a9f4a3841739a80a69;p=thirdparty%2Fkea.git [#3940] add kea-shell tests Tests cover --auth-password-file flag usage. --- 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 index 0000000000..ba0e162e1c --- /dev/null +++ b/src/bin/shell/tests/auth_bad_password_file.in @@ -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 index 0000000000..0a47d36591 --- /dev/null +++ b/src/bin/shell/tests/auth_password_file.in @@ -0,0 +1 @@ +meow \ No newline at end of file diff --git a/src/bin/shell/tests/ca_basic_auth_tests.sh.in b/src/bin/shell/tests/ca_basic_auth_tests.sh.in index 287a15c1a6..cc8245aa75 100755 --- a/src/bin/shell/tests/ca_basic_auth_tests.sh.in +++ b/src/bin/shell/tests/ca_basic_auth_tests.sh.in @@ -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 } ]" diff --git a/src/bin/shell/tests/d2_basic_auth_tests.sh.in b/src/bin/shell/tests/d2_basic_auth_tests.sh.in index aac0631dec..0702626a39 100755 --- a/src/bin/shell/tests/d2_basic_auth_tests.sh.in +++ b/src/bin/shell/tests/d2_basic_auth_tests.sh.in @@ -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 } ]" diff --git a/src/bin/shell/tests/dhcp4_basic_auth_tests.sh.in b/src/bin/shell/tests/dhcp4_basic_auth_tests.sh.in index 9e07744956..d11721d5b3 100755 --- a/src/bin/shell/tests/dhcp4_basic_auth_tests.sh.in +++ b/src/bin/shell/tests/dhcp4_basic_auth_tests.sh.in @@ -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 } ]" diff --git a/src/bin/shell/tests/dhcp6_basic_auth_tests.sh.in b/src/bin/shell/tests/dhcp6_basic_auth_tests.sh.in index 311ee365e2..9fea36dd8f 100755 --- a/src/bin/shell/tests/dhcp6_basic_auth_tests.sh.in +++ b/src/bin/shell/tests/dhcp6_basic_auth_tests.sh.in @@ -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 } ]" diff --git a/src/bin/shell/tests/meson.build b/src/bin/shell/tests/meson.build index 5b0b6d52ec..18a7bc3339 100644 --- a/src/bin/shell/tests/meson.build +++ b/src/bin/shell/tests/meson.build @@ -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, +)