From 157072a39f463b50262930baadeb056d5be46ebf Mon Sep 17 00:00:00 2001 From: = Date: Thu, 14 Apr 2016 21:47:17 +0100 Subject: [PATCH] Windows: win_regedit integration tests (following https://github.com/ansible/ansible-modules-extras/pull/2034 ) --- .../roles/test_win_regedit/meta/main.yml | 3 + .../roles/test_win_regedit/tasks/main.yml | 359 ++++++++++++++++++ test/integration/test_winrm.yml | 1 + 3 files changed, 363 insertions(+) create mode 100644 test/integration/roles/test_win_regedit/meta/main.yml create mode 100644 test/integration/roles/test_win_regedit/tasks/main.yml diff --git a/test/integration/roles/test_win_regedit/meta/main.yml b/test/integration/roles/test_win_regedit/meta/main.yml new file mode 100644 index 0000000000..55200b3fc6 --- /dev/null +++ b/test/integration/roles/test_win_regedit/meta/main.yml @@ -0,0 +1,3 @@ +dependencies: + - prepare_win_tests + diff --git a/test/integration/roles/test_win_regedit/tasks/main.yml b/test/integration/roles/test_win_regedit/tasks/main.yml new file mode 100644 index 0000000000..9b69a65af6 --- /dev/null +++ b/test/integration/roles/test_win_regedit/tasks/main.yml @@ -0,0 +1,359 @@ +# test code for the win_regedit module +# (c) 2014, Michael DeHaan + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see . + +# clear the area of the registry we are using for tests + +- name: remove setting + win_regedit: + key: 'HKCU:\SOFTWARE\Cow Corp' + state: absent + +- name: check basic set works + win_regedit: + key: HKCU:\Software\Cow Corp + value: hello + data: world + register: check01_result + +- assert: + that: + - "check01_result.changed == true" + +- name: check that setting the same again is not changed + win_regedit: + key: HKCU:\Software\Cow Corp + value: hello + data: world + register: check02_result + +- assert: + that: + - "check02_result.changed == false" + +# binary mode checks +# tests with 'hex:' prefix (as intended) + +- name: check binary with hex(colon) prefix + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:be,ef,be,ef,be,ef,be,ef,be,ef + datatype: binary + register: check03_result + +- assert: + that: + - "check03_result.changed == true" + +- name: check binary with hex(colon) prefix not modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:be,ef,be,ef,be,ef,be,ef,be,ef + datatype: binary + register: check04_result + +- assert: + that: + - "check04_result.changed == false" + +- name: check binary with hex(colon) prefix modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:de,ad,be,ef,de,ad,be,ef,de,ad,be,ef + datatype: binary + register: check05_result + +- assert: + that: + - "check05_result.changed == true" + +# reset +- name: reset test + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + state: absent + register: check06_result + +- assert: + that: + - "check06_result.changed == true" + +# check without hex(colon) prefix + +# tests without 'hex:' prefix (optional) +- name: check binary with hex(colon) prefix + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: be,ef,be,ef,be,ef,be,ef,be,ef + datatype: binary + register: check13_result + +- assert: + that: + - "check13_result.changed == true" + +- name: check binary without hex(colon) prefix not modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: be,ef,be,ef,be,ef,be,ef,be,ef + datatype: binary + register: check14_result + +- assert: + that: + - "check14_result.changed == false" + +- name: check binary without hex(colon) prefix modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: de,ad,be,ef,de,ad,be,ef,de,ad,be,ef + datatype: binary + register: check15_result + +- assert: + that: + - "check15_result.changed == true" + +# reset +- name: reset test + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + state: absent + register: check16_result + +- assert: + that: + - "check16_result.changed == true" + +# check mixed case hex values with hex: prefix + +- name: check mixed case binary with hex(colon) prefix + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:be,EF,be,EF,be,EF,be,EF,be,EF + datatype: binary + register: check23_result + +- assert: + that: + - "check23_result.changed == true" + +- name: check mixed case binary with hex(colon) prefix not modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:be,EF,be,EF,be,EF,be,EF,be,EF + datatype: binary + register: check24_result + +- assert: + that: + - "check24_result.changed == false" + +- name: check mixed case binary with hex(colon) prefix modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:DE,ad,be,EF,DE,ad,be,EF,DE,ad,be,EF + datatype: binary + register: check25_result + +- assert: + that: + - "check25_result.changed == true" + +# reset +- name: reset test + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + state: absent + register: check26_result + +- assert: + that: + - "check26_result.changed == true" + +# check mixed case without hex: prefix + +# tests without 'hex:' prefix (optional) +- name: check mixed case binary without hex(colon) prefix + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: be,EF,be,EF,be,EF,be,EF,be,EF + datatype: binary + register: check33_result + +- assert: + that: + - "check33_result.changed == true" + +- name: check mixed case binary without hex(colon) prefix not modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: be,EF,be,EF,be,EF,be,EF,be,EF + datatype: binary + register: check34_result + +- assert: + that: + - "check34_result.changed == false" + +- name: check mixed case binary without hex(colon) prefix modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: DE,ad,be,EF,DE,ad,be,EF,DE,ad,be,EF + datatype: binary + register: check35_result + +- assert: + that: + - "check35_result.changed == true" + +# reset +- name: reset test + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + state: absent + register: check36_result + +- assert: + that: + - "check36_result.changed == true" + +# check colon separated hex values with hex: prefix + +- name: check colon separated hex values with hex(colon) prefix + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:be:ef:be:ef:be:ef:be:ef:be:ef + datatype: binary + register: check43_result + +- assert: + that: + - "check43_result.changed == true" + +- name: check colon separated binary with hex(colon) prefix not modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:be:ef:be:ef:be:ef:be:ef:be:ef + datatype: binary + register: check44_result + +- assert: + that: + - "check44_result.changed == false" + +- name: check colon separated binary with hex(colon) prefix modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: hex:de:ad:be:ef:de:ad:be:ef:de:ad:be:ef + datatype: binary + register: check45_result + +- assert: + that: + - "check45_result.changed == true" + +# reset +- name: reset test + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + state: absent + register: check46_result + +- assert: + that: + - "check46_result.changed == true" + +# check colon separated hex values without hex(colon) prefix + +# tests without 'hex:' prefix (optional) +- name: check colon separated binary with hex(colon) prefix + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: be:ef:be:ef:be:ef:be:ef:be:ef + datatype: binary + register: check53_result + +- assert: + that: + - "check53_result.changed == true" + +- name: check colon separated binary without hex(colon) prefix not modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: be:ef:be:ef:be:ef:be:ef:be:ef + datatype: binary + register: check54_result + +- assert: + that: + - "check54_result.changed == false" + +- name: check colon separated binary without hex(colon) prefix modified + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + data: de:ad:be:ef:de:ad:be:ef:de:ad:be:ef + datatype: binary + register: check55_result + +- assert: + that: + - "check55_result.changed == true" + +# reset +- name: reset test + win_regedit: + key: HKCU:\Software\Cow Corp + value: hellobinary + state: absent + register: check56_result + +- assert: + that: + - "check56_result.changed == true" + +# tear down + +- name: remove registry key used for testing + win_regedit: + key: 'HKCU:\SOFTWARE\Cow Corp' + state: absent + +# END OF win_regedit tests diff --git a/test/integration/test_winrm.yml b/test/integration/test_winrm.yml index 51a5daa51f..3634d4606c 100644 --- a/test/integration/test_winrm.yml +++ b/test/integration/test_winrm.yml @@ -38,4 +38,5 @@ - { role: test_win_template, tags: test_win_template } - { role: test_win_lineinfile, tags: test_win_lineinfile } - { role: test_win_regmerge, tags: test_win_regmerge } + - { role: test_win_regedit, tags: test_win_regedit }