summaryrefslogtreecommitdiff
path: root/test/integration/targets/module_utils
diff options
context:
space:
mode:
authorRick Elrod <rick@elrod.me>2020-07-01 09:28:48 -0500
committerGitHub <noreply@github.com>2020-07-01 09:28:48 -0500
commitf7078c1f8f7deb71676840a8b370ea240402c6a9 (patch)
tree93f4f35f8ada4829c1811869bba2f17a2de3965f /test/integration/targets/module_utils
parenta1ac595d426f61001a718698c89b3b0e65ff56e2 (diff)
downloadansible-f7078c1f8f7deb71676840a8b370ea240402c6a9.tar.gz
Throw a prettier error in m_u.basic syslog (#70312)
Change: - In certain situations, such as when the input string contains null bytes (\0), syslog.syslog will throw a TypeError. Handle that and fail_json instead. Test Plan: - New test - ansible-test --docker centos[68] (for py2 and py3 respectively) Tickets: - Refs #70269 Signed-off-by: Rick Elrod <rick@elrod.me>
Diffstat (limited to 'test/integration/targets/module_utils')
-rw-r--r--test/integration/targets/module_utils/module_utils_test.yml37
-rwxr-xr-xtest/integration/targets/module_utils/runme.sh2
2 files changed, 38 insertions, 1 deletions
diff --git a/test/integration/targets/module_utils/module_utils_test.yml b/test/integration/targets/module_utils/module_utils_test.yml
index e29039f901..81302c5ec8 100644
--- a/test/integration/targets/module_utils/module_utils_test.yml
+++ b/test/integration/targets/module_utils/module_utils_test.yml
@@ -60,3 +60,40 @@
that:
- result.deprecations[0].msg == "Alias 'baz' is deprecated. See the module docs for more information"
- result.deprecations[0].version == '9.99'
+
+ - block:
+ - name: Get a string with a \0 in it
+ command: echo -e 'hi\0foo'
+ register: string_with_null
+
+ - name: Use the null string as a module parameter
+ lineinfile:
+ path: "{{ output_dir }}/nulltest"
+ line: "{{ string_with_null.stdout }}"
+ create: yes
+ ignore_errors: yes
+ register: nulltest
+
+ - name: See if the file exists
+ stat:
+ path: "{{ output_dir }}/nulltest"
+ register: nullstat
+
+ - assert:
+ that:
+ - nulltest is failed
+ - nulltest.msg_to_log.startswith('Invoked ')
+ - nulltest.msg.startswith('Failed to log to syslog')
+ # Conditionalize this, because when we log with something other than
+ # syslog, it's probably successful and these assertions will fail.
+ when: nulltest is failed
+
+ # Ensure we fail out early and don't actually run the module if logging
+ # failed.
+ - assert:
+ that:
+ - nullstat.stat.exists == nulltest is successful
+ always:
+ - file:
+ path: "{{ output_dir }}/nulltest"
+ state: absent
diff --git a/test/integration/targets/module_utils/runme.sh b/test/integration/targets/module_utils/runme.sh
index e1a0e7c953..8ae2e9cca2 100755
--- a/test/integration/targets/module_utils/runme.sh
+++ b/test/integration/targets/module_utils/runme.sh
@@ -8,6 +8,6 @@ ANSIBLE_ROLES_PATH=../ ansible-playbook module_utils_basic_setcwd.yml -i ../../i
# doesn't traceback with unicode in the custom module_utils directory path.
ansible-playbook module_utils_vvvvv.yml -i ../../inventory -vvvvv "$@"
-ansible-playbook module_utils_test.yml -i ../../inventory -v "$@"
+ansible-playbook module_utils_test.yml -i ../../inventory -e output_dir="$OUTPUT_DIR" -v "$@"
ANSIBLE_MODULE_UTILS=other_mu_dir ansible-playbook module_utils_envvar.yml -i ../../inventory -v "$@"