diff options
author | psi / Ryo Hirafuji <ryo.hirafuji@link-u.co.jp> | 2020-07-23 10:26:10 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-22 18:26:10 -0700 |
commit | 61f8f8ce7f701a1d9d248679152bdcc98e2dddd5 (patch) | |
tree | ab08d469377165e14a0a4777ddbb493426cd6793 /test | |
parent | 7eb5f532946686c7173c0d95946aa4b49c010cf1 (diff) | |
download | ansible-61f8f8ce7f701a1d9d248679152bdcc98e2dddd5.tar.gz |
cron - Allow non-ascii (UTF-8) chars in cron file paths and jobs (#70426) (#70794)
* Encode/Decode files in UTF-8
* Use helper function in ansible
* Add an integration test
* Use emoji in test data.
* add changelog
* Also support non-ascii chars in filepath and add tests about this.
* Also use non-ascii chars in replaced text and ensure not to break cron syntax.
* rename self.existing to self.n_existing
* rename crontab.existing to crontab.n_existing
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/targets/cron/tasks/main.yml | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/integration/targets/cron/tasks/main.yml b/test/integration/targets/cron/tasks/main.yml index 155fc2d580..950d52dc4f 100644 --- a/test/integration/targets/cron/tasks/main.yml +++ b/test/integration/targets/cron/tasks/main.yml @@ -122,3 +122,65 @@ - assert: that: not cron_file_stats.stat.exists + +- name: Allow non-ascii chars in job (#69492) + block: + - name: Cron file creation + cron: + cron_file: cron_filename + name: "cron job that contain non-ascii chars in job (これは日本語です; This is Japanese)" + job: 'echo "うどんは好きだがお化け👻は苦手である。"' + user: root + + - name: "Ensure cron_file contains job string" + replace: + path: /etc/cron.d/cron_filename + regexp: "うどんは好きだがお化け👻は苦手である。" + replace: "それは機密情報🔓です。" + register: find_chars + failed_when: (find_chars is not changed) or (find_chars is failed) + + - name: Cron file deletion + cron: + cron_file: cron_filename + name: "cron job that contain non-ascii chars in job (これは日本語です; This is Japanese)" + state: absent + + - name: Check file succesfull deletion + stat: + path: /etc/cron.d/cron_filename + register: cron_file_stats + + - assert: + that: not cron_file_stats.stat.exists + +- name: Allow non-ascii chars in cron_file (#69492) + block: + - name: Cron file creation with non-ascii filename (これは日本語です; This is Japanese) + cron: + cron_file: 'なせば大抵なんとかなる👊' + name: "integration test cron" + job: 'echo "Hello, ansible!"' + user: root + + - name: Check file exists + stat: + path: "/etc/cron.d/なせば大抵なんとかなる👊" + register: cron_file_stats + + - assert: + that: cron_file_stats.stat.exists + + - name: Cron file deletion + cron: + cron_file: 'なせば大抵なんとかなる👊' + name: "integration test cron" + state: absent + + - name: Check file succesfull deletion + stat: + path: "/etc/cron.d/なせば大抵なんとかなる👊" + register: cron_file_stats + + - assert: + that: not cron_file_stats.stat.exists |