diff options
author | Ansible Core Team <info@ansible.com> | 2020-03-09 10:40:31 +0100 |
---|---|---|
committer | Matt Martz <matt@sivel.net> | 2020-03-23 17:14:21 +0100 |
commit | bb3494356aecbf0b37183da04eaf322996273771 (patch) | |
tree | 97aeae3b636084a601991495f73bc2edd80189db /test | |
parent | Migrated to community.vmware (diff) | |
download | ansible-bb3494356aecbf0b37183da04eaf322996273771.tar.xz ansible-bb3494356aecbf0b37183da04eaf322996273771.zip |
Migrated to community.windows
Diffstat (limited to 'test')
310 files changed, 0 insertions, 23480 deletions
diff --git a/test/integration/targets/psexec/aliases b/test/integration/targets/psexec/aliases deleted file mode 100644 index 8642fd8fd4..0000000000 --- a/test/integration/targets/psexec/aliases +++ /dev/null @@ -1,3 +0,0 @@ -windows -shippable/windows/group1 - diff --git a/test/integration/targets/psexec/tasks/main.yml b/test/integration/targets/psexec/tasks/main.yml deleted file mode 100644 index c785d87175..0000000000 --- a/test/integration/targets/psexec/tasks/main.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -- name: check whether the host supports encryption - win_shell: | - if ([System.Environment]::OSVersion.Version -lt [Version]"6.2") { - "false" - } else { - "true" - } - register: encryption_supported_raw - -- name: install pypsexec Python library for tests - pip: - name: pypsexec - state: latest - delegate_to: localhost - -- name: define psexec variables - set_fact: - psexec_hostname: '{{ansible_host}}' - psexec_username: '{{ansible_user}}' - psexec_password: '{{ansible_password}}' - psexec_encrypt: '{{encryption_supported_raw.stdout_lines[0]|bool}}' - -- name: create test rule to allow SMB traffic inbound - win_firewall_rule: - name: File and Printer Sharing (SMB-In) Test - direction: in - action: allow - localport: 445 - enabled: yes - protocol: tcp - program: System - profiles: - - domain - - private - - public - state: present - -- name: run tests - block: - - include_tasks: tests.yml - - always: - - name: remove test rule that allows SMB traffic inbound - win_firewall_rule: - name: File and Printer Sharing (SMB-In) Test - direction: in - action: allow - state: absent diff --git a/test/integration/targets/psexec/tasks/tests.yml b/test/integration/targets/psexec/tasks/tests.yml deleted file mode 100644 index e87c79a1e0..0000000000 --- a/test/integration/targets/psexec/tasks/tests.yml +++ /dev/null @@ -1,231 +0,0 @@ ---- -- name: fail when process_password is not set with process_username - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: hostname.exe - process_username: '{{psexec_username}}' - delegate_to: localhost - register: fail_no_process_pass - failed_when: 'fail_no_process_pass.msg != "parameters are required together when not running as System: process_username, process_password"' - -- name: get current host - win_command: hostname.exe - register: actual_hostname - -- name: run basic psexec command - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: hostname.exe - delegate_to: localhost - register: psexec_hostname_actual - -- name: assert basic psexec command matches expected output - assert: - that: - - psexec_hostname_actual is changed - - psexec_hostname_actual.rc == 0 - - psexec_hostname_actual.stderr == '' - - psexec_hostname_actual.stdout == actual_hostname.stdout - -- name: get output for executable with arguments - win_command: hostname.exe /? - register: actual_hostname_help - failed_when: actual_hostname_help.rc != 1 - -- name: run psexec command with arguments - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: hostname.exe - arguments: /? - delegate_to: localhost - register: psexec_hostname_help - failed_when: psexec_hostname_help.rc != 1 - -- name: assert basic pesexec command with arguments matches expected output - assert: - that: - - psexec_hostname_help is changed - - psexec_hostname_help.rc == 1 - - psexec_hostname_help.stderr == actual_hostname_help.stderr - - psexec_hostname_help.stdout == actual_hostname_help.stdout - -- name: run psexec command and send data through stdin - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: powershell.exe - arguments: '-' - stdin: | - Write-Host hello world - Write-Host this is another message - exit 0 - delegate_to: localhost - register: psexec_stdin - -- name: assert psexec ommand and send data through stdin - assert: - that: - - psexec_stdin is changed - - psexec_stdin.rc == 0 - - psexec_stdin.stderr == '' - - psexec_stdin.stdout == 'hello world\nthis is another message\n' - -- name: run psexec command with specific process username - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - load_profile: no # on Azure, the profile does not exist yet so we don't load it for this task - executable: powershell.exe - arguments: '-' - stdin: | - ((Get-CimInstance Win32_Process -filter "processid = $pid") | Get-CimAssociatedInstance -Association Win32_SessionProcess).LogonType - exit 0 - process_username: '{{psexec_username}}' - process_password: '{{psexec_password}}' - delegate_to: localhost - register: psexec_process_username - -- name: assert psexec command with specific process username - assert: - that: - - psexec_process_username is changed - - psexec_process_username.rc == 0 - - psexec_process_username.stderr == '' - - psexec_process_username.stdout_lines[0] != '3' # 3 is Network Logon Type, we assert we are not a network logon with process credentials - -- name: run psexec command with both stderr and stdout - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: cmd.exe - arguments: /c echo first && echo second 1>&2 && echo third - delegate_to: localhost - register: psexec_process_stderr - -- name: assert psexec command with both stderr and stdout - assert: - that: - - psexec_process_stderr is changed - - psexec_process_stderr.rc == 0 - - psexec_process_stderr.stderr == 'second \r\n' - - psexec_process_stderr.stdout == 'first \r\nthird\r\n' - -- name: run process asynchronously - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: powershell.exe - arguments: Start-Sleep -Seconds 30 - asynchronous: yes - delegate_to: localhost - register: psexec_process_async - -- name: check if process is still running - win_shell: (Get-Process -ID {{psexec_process_async.pid}}).ProcessName - register: psexec_process_async_actual - -- name: assert run process asynchronously - assert: - that: - - psexec_process_async is changed - - psexec_process_async.rc is not defined - - psexec_process_async.pid is defined - - psexec_process_async.stdout is not defined - - psexec_process_async.stderr is not defined - - psexec_process_async_actual.stdout_lines[0] == 'powershell' - -- name: run process interactively - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: powershell.exe - arguments: Write-Host hi - interactive: yes - delegate_to: localhost - register: psexec_process_interactive - -- name: assert run process interactively - assert: - that: - - psexec_process_interactive is changed - - psexec_process_interactive.rc == 0 - - psexec_process_interactive.stdout is not defined - - psexec_process_interactive.stderr is not defined - -- name: run process with timeout - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: powershell.exe - arguments: Start-Sleep -Seconds 30 - process_timeout: 5 - delegate_to: localhost - register: psexec_process_timeout - failed_when: psexec_process_timeout.rc == 0 - -- name: assert psexec process with timeout - assert: - that: - - psexec_process_timeout.rc != 0 - - psexec_process_timeout.stdout == '' - - psexec_process_timeout.stderr == '' - -- name: run process as system - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: whoami.exe - process_username: System - delegate_to: localhost - register: psexec_process_system - -- name: assert run process as system - assert: - that: - - psexec_process_system is changed - - psexec_process_system.rc == 0 - - psexec_process_system.stderr == '' - - psexec_process_system.stdout == 'nt authority\system\r\n' - -- name: run process with different chdir - psexec: - hostname: '{{psexec_hostname}}' - connection_username: '{{psexec_username}}' - connection_password: '{{psexec_password}}' - encrypt: '{{psexec_encrypt}}' - executable: powershell.exe - arguments: (pwd).Path - working_directory: C:\Windows - delegate_to: localhost - register: psexec_process_working_dir - -- name: assert run process with different chdir - assert: - that: - - psexec_process_working_dir is changed - - psexec_process_working_dir.rc == 0 - - psexec_process_working_dir.stderr == '' - - psexec_process_working_dir.stdout == 'C:\Windows\r\n' diff --git a/test/integration/targets/win_audit_policy_system/aliases b/test/integration/targets/win_audit_policy_system/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_audit_policy_system/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_audit_policy_system/defaults/main.yml b/test/integration/targets/win_audit_policy_system/defaults/main.yml deleted file mode 100644 index 9e0d35c777..0000000000 --- a/test/integration/targets/win_audit_policy_system/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -#important that the subcategory is from a different category -category_name: detailed tracking -subcategory_name: file system diff --git a/test/integration/targets/win_audit_policy_system/tasks/add.yml b/test/integration/targets/win_audit_policy_system/tasks/add.yml deleted file mode 100644 index 75ea23045b..0000000000 --- a/test/integration/targets/win_audit_policy_system/tasks/add.yml +++ /dev/null @@ -1,108 +0,0 @@ -######################## -### check mode apply ### -######################## -- name: check mode enable category - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: success - check_mode: yes - register: category - -- name: check mode enable subcategory - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: success, failure - check_mode: yes - register: subcategory - -- name: check mode assert that changed is true - assert: - that: - - category is changed - - subcategory is changed - -- name: check mode assert that audit_type is "no auditing" - assert: - that: - - item == "no auditing" - with_items: - - "{{ subcategory.current_audit_policy.values() | list }}" - - "{{ category.current_audit_policy.values() | list | unique }}" - -#alternative check for category...pretty noise and requires more lines -# - name: assert that audit_type is no auditing -# assert: -# that: item.value == "no auditing" -# with_dict: "{{ category.current_audit_policy }}" - -#################### -### apply change ### -#################### - -- name: enable category - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: success - register: category - -- name: enable subcategory - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: success, failure - register: subcategory - -- name: enable assert that changed is true - assert: - that: - - category is changed - - subcategory is changed - -- name: enable assert that audit_type is "success" for category - assert: - that: - - item == "success" - with_items: - - "{{ category.current_audit_policy.values() | list | unique }}" - -- name: enable assert that audit_type is "success and failure" for subcategory - assert: - that: - - item == "success and failure" - with_items: - - "{{ subcategory.current_audit_policy.values() | list }}" - -############################### -### idempotent apply change ### -############################### - -- name: idem enable category - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: success - register: category - -- name: idem enable subcategory - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: success, failure - register: subcategory - -- name: idem assert that changed is false - assert: - that: - - category is not changed - - subcategory is not changed - -- name: idem assert that audit_type is "success" for category - assert: - that: - - item == "success" - with_items: - - "{{ category.current_audit_policy.values() | list | unique }}" - -- name: idem assert that audit_type is "success and failure" for subcategory - assert: - that: - - item == "success and failure" - with_items: - - "{{ subcategory.current_audit_policy.values() | list }}" diff --git a/test/integration/targets/win_audit_policy_system/tasks/main.yml b/test/integration/targets/win_audit_policy_system/tasks/main.yml deleted file mode 100644 index c2e55accf5..0000000000 --- a/test/integration/targets/win_audit_policy_system/tasks/main.yml +++ /dev/null @@ -1,25 +0,0 @@ -#turn off so then we can test changes occur on enable. Turning off for object access also -#covers our subcategory test for file system -- name: turn off auditing for category - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: none - -- name: turn off auditing for subcategory - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: none - -- block: - - include_tasks: add.yml - - include_tasks: remove.yml - always: - - name: CLEANUP turn "{{ category_name }}" back to no auditing - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: none - - - name: CLEANUP turn "{{ subcategory_name }}" back to no auditing - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: none diff --git a/test/integration/targets/win_audit_policy_system/tasks/remove.yml b/test/integration/targets/win_audit_policy_system/tasks/remove.yml deleted file mode 100644 index 1cd60b0ab4..0000000000 --- a/test/integration/targets/win_audit_policy_system/tasks/remove.yml +++ /dev/null @@ -1,96 +0,0 @@ -######################### -### check mode remove ### -######################### -- name: check mode disable category - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: none - check_mode: yes - register: category - -- name: check mode disable subcategory - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: none - check_mode: yes - register: subcategory - -- name: check mode assert that changed is true - assert: - that: - - category is changed - - subcategory is changed - -- name: check mode assert that audit_type is still "success" (old value) for category - assert: - that: - - item == "success" - with_items: - - "{{ category.current_audit_policy.values() | list | unique }}" - -- name: check mode assert that audit_type is still "success and failure" (old value) for subcategory - assert: - that: - - item == "success and failure" - with_items: - - "{{ subcategory.current_audit_policy.values() | list }}" - -###################### -### disable policy ### -###################### - -- name: disable category - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: none - register: category - -- name: disable subcategory - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: none - register: subcategory - -- name: assert that changed is true - assert: - that: - - category is changed - - subcategory is changed - -- name: assert that audit_type is "no auditing" - assert: - that: - - item == "no auditing" - with_items: - - "{{ subcategory.current_audit_policy.values() | list }}" - - "{{ category.current_audit_policy.values() | list | unique }}" - -########################## -### idempotent disable ### -########################## - -- name: idem disable category - win_audit_policy_system: - category: "{{ category_name }}" - audit_type: none - register: category - -- name: idem disable subcategory - win_audit_policy_system: - subcategory: "{{ subcategory_name }}" - audit_type: none - register: subcategory - -- name: idem assert that changed is false - assert: - that: - - category is not changed - - subcategory is not changed - -- name: assert that audit_type is "no auditing" - assert: - that: - - item == "no auditing" - with_items: - - "{{ subcategory.current_audit_policy.values() | list }}" - - "{{ category.current_audit_policy.values() | list | unique }}" diff --git a/test/integration/targets/win_audit_rule/aliases b/test/integration/targets/win_audit_rule/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_audit_rule/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_audit_rule/defaults/main.yml b/test/integration/targets/win_audit_rule/defaults/main.yml deleted file mode 100644 index f0faa9a56c..0000000000 --- a/test/integration/targets/win_audit_rule/defaults/main.yml +++ /dev/null @@ -1,7 +0,0 @@ -test_audit_rule_folder: c:\windows\temp\{{ 'ansible test win_audit_policy' | to_uuid }} -test_audit_rule_file: c:\windows\temp\{{ 'ansible test win_audit_policy' | to_uuid }}.txt -test_audit_rule_registry: HKCU:\{{ 'ansible test win_audit_policy' | to_uuid }} -test_audit_rule_rights: 'delete' -test_audit_rule_new_rights: 'delete,changepermissions' -test_audit_rule_user: 'everyone' -test_audit_rule_audit_flags: success diff --git a/test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 b/test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 deleted file mode 100644 index a2a5105f89..0000000000 --- a/test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 +++ /dev/null @@ -1,98 +0,0 @@ -#!powershell - -# Copyright (c) 2017 Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -#Requires -Module Ansible.ModuleUtils.Legacy -#Requires -Module Ansible.ModuleUtils.SID - -$params = Parse-Args -arguments $args -supports_check_mode $true - -# these are your module parameters -$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true -aliases "destination","dest" -$user = Get-AnsibleParam -obj $params -name "user" -type "str" -failifempty $true -$rights = Get-AnsibleParam -obj $params -name "rights" -type "list" -$inheritance_flags = Get-AnsibleParam -obj $params -name "inheritance_flags" -type "list" -default 'ContainerInherit','ObjectInherit' # -validateset 'None','ContainerInherit','ObjectInherit' -$propagation_flags = Get-AnsibleParam -obj $params -name "propagation_flags" -type "str" -default "none" -ValidateSet 'InheritOnly','None','NoPropagateInherit' -$audit_flags = Get-AnsibleParam -obj $params -name "audit_flags" -type "list" -default "success" #-ValidateSet 'Success','Failure' -#$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset 'present','absent' - - -If (! (Test-Path $path) ) -{ - Fail-Json $result "Path not found ($path)" -} - -Function Get-CurrentAuditRules ($path) { - $ACL = Get-Acl -Path $path -Audit - - $HT = Foreach ($Obj in $ACL.Audit) - { - @{ - user = $Obj.IdentityReference.ToString() - rights = ($Obj | Select-Object -expand "*rights").ToString() - audit_flags = $Obj.AuditFlags.ToString() - is_inherited = $Obj.InheritanceFlags.ToString() - inheritance_flags = $Obj.IsInherited.ToString() - propagation_flags = $Obj.PropagationFlags.ToString() - } - } - - If (-Not $HT) - { - "No audit rules defined on $path" - } - Else {$HT} -} - - -$result = @{ - changed = $false - matching_rule_found = $false - current_audit_rules = Get-CurrentAuditRules $path -} - -$ACL = Get-ACL $Path -Audit -$SID = Convert-ToSid $user - -$ItemType = (Get-Item $path).GetType() -switch ($ItemType) -{ - ([Microsoft.Win32.RegistryKey]) { - $rights = [System.Security.AccessControl.RegistryRights]$rights - $result.path_type = 'registry' - } - ([System.IO.FileInfo]) { - $rights = [System.Security.AccessControl.FileSystemRights]$rights - $result.path_type = 'file' - } - ([System.IO.DirectoryInfo]) { - $rights = [System.Security.AccessControl.FileSystemRights]$rights - $result.path_type = 'directory' - } -} - -$flags = [System.Security.AccessControl.AuditFlags]$audit_flags -$inherit = [System.Security.AccessControl.InheritanceFlags]$inheritance_flags -$prop = [System.Security.AccessControl.PropagationFlags]$propagation_flags - -Foreach ($group in $ACL.Audit) -{ - #exit here if any existing rule matches defined rule, otherwise exit below - #with no matches - If ( - ($group | Select-Object -expand "*Rights") -eq $rights -and - $group.AuditFlags -eq $flags -and - $group.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]) -eq $SID -and - $group.InheritanceFlags -eq $inherit -and - $group.PropagationFlags -eq $prop - ) - { - $result.matching_rule_found = $true - $result.current_audit_rules = Get-CurrentAuditRules $path - Exit-Json $result - } -} - -$result.current_audit_rules = Get-CurrentAuditRules $path -Exit-Json $result diff --git a/test/integration/targets/win_audit_rule/tasks/add.yml b/test/integration/targets/win_audit_rule/tasks/add.yml deleted file mode 100644 index 2a059a88c9..0000000000 --- a/test/integration/targets/win_audit_rule/tasks/add.yml +++ /dev/null @@ -1,172 +0,0 @@ -###################### -### check mode add ### -###################### -- name: check mode ADD audit policy directory - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory - check_mode: yes - -- name: check mode ADD audit policy file - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file - check_mode: yes - -- name: check mode ADD audit policy registry - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry - check_mode: yes - -- name: check mode ADD get directory results - test_get_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory_results - -- name: check mode ADD get file results - test_get_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file_results - -- name: check mode ADD get REGISTRY results - test_get_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry_results - -- name: check mode ADD assert that a change is needed, but no change occurred to the audit rules - assert: - that: - - directory is changed - - file is changed - - registry is changed - - not directory_results.matching_rule_found and directory_results.path_type == 'directory' - - not file_results.matching_rule_found and file_results.path_type == 'file' - - not registry_results.matching_rule_found and registry_results.path_type == 'registry' - -################## -### add a rule ### -################## -- name: ADD audit policy directory - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory - -- name: ADD audit policy file - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file - -- name: ADD audit policy registry - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry - -- name: ADD get directory results - test_get_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory_results - -- name: ADD get file results - test_get_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file_results - -- name: ADD get REGISTRY results - test_get_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry_results - -- name: ADD assert that the rules were added and a change is detected - assert: - that: - - directory is changed - - file is changed - - registry is changed - - directory_results.matching_rule_found and directory_results.path_type == 'directory' - - file_results.matching_rule_found and file_results.path_type == 'file' - - registry_results.matching_rule_found and registry_results.path_type == 'registry' - -############################# -### idempotent add a rule ### -############################# -- name: idempotent ADD audit policy directory - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory - -- name: idempotent ADD audit policy file - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file - -- name: idempotent ADD audit policy registry idempotent - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry - -- name: idempotent ADD assert that a change did not occur - assert: - that: - - directory is not changed and directory.path_type == 'directory' - - file is not changed and file.path_type == 'file' - - registry is not changed and registry.path_type == 'registry' diff --git a/test/integration/targets/win_audit_rule/tasks/main.yml b/test/integration/targets/win_audit_rule/tasks/main.yml deleted file mode 100644 index 68fbca768a..0000000000 --- a/test/integration/targets/win_audit_rule/tasks/main.yml +++ /dev/null @@ -1,33 +0,0 @@ -- name: create temporary folder to test with - win_file: - path: "{{ test_audit_rule_folder }}" - state: directory - -- name: create temporary file to test with - win_file: - path: "{{ test_audit_rule_file }}" - state: touch - -- name: create temporary registry key to test with - win_regedit: - path: "{{ test_audit_rule_registry }}" - -- block: - - include_tasks: add.yml - - include_tasks: modify.yml - - include_tasks: remove.yml - always: - - name: remove testing folder - win_file: - path: "{{ test_audit_rule_folder }}" - state: absent - - - name: remove testing file - win_file: - path: "{{ test_audit_rule_file }}" - state: absent - - - name: remove registry key - win_regedit: - path: "{{ test_audit_rule_registry }}" - state: absent diff --git a/test/integration/targets/win_audit_rule/tasks/modify.yml b/test/integration/targets/win_audit_rule/tasks/modify.yml deleted file mode 100644 index 1db07e2b4a..0000000000 --- a/test/integration/targets/win_audit_rule/tasks/modify.yml +++ /dev/null @@ -1,172 +0,0 @@ -######################### -### modify check mode ### -######################### -- name: check mode modify audit policy directory - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory - check_mode: yes - -- name: check mode modify audit policy file - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file - check_mode: yes - -- name: check mode modify audit policy registry - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry - check_mode: yes - -- name: check mode modify get directory rule results - test_get_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory_results - -- name: check mode modify get file rule results - test_get_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file_results - -- name: check mode modify get REGISTRY rule results - test_get_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry_results - -- name: check mode modify assert that change is needed but rights still equal the original rights and not test_audit_rule_new_rights - assert: - that: - - directory is changed - - file is changed - - registry is changed - - not directory_results.matching_rule_found and directory_results.path_type == 'directory' - - not file_results.matching_rule_found and file_results.path_type == 'file' - - not registry_results.matching_rule_found and registry_results.path_type == 'registry' - -############## -### modify ### -############## -- name: modify audit policy directory - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory - -- name: modify audit policy file - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file - -- name: modify audit policy registry - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry - -- name: modify get directory rule results - test_get_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory_results - -- name: modify get file rule results - test_get_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file_results - -- name: modify get REGISTRY rule results - test_get_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry_results - -- name: modify assert that the rules were modified and a change is detected - assert: - that: - - directory is changed - - file is changed - - registry is changed - - directory_results.matching_rule_found and directory_results.path_type == 'directory' - - file_results.matching_rule_found and file_results.path_type == 'file' - - registry_results.matching_rule_found and registry_results.path_type == 'registry' - -##################################### -### idempotent test modify a rule ### -##################################### -- name: idempotent modify audit policy directory - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory - -- name: idempotent modify audit policy file - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file - -- name: idempotent modify audit policy registry - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - state: present - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry - -- name: idempotent modify assert that and a change is not detected - assert: - that: - - directory is not changed and directory.path_type == 'directory' - - file is not changed and file.path_type == 'file' - - registry is not changed and registry.path_type == 'registry' diff --git a/test/integration/targets/win_audit_rule/tasks/remove.yml b/test/integration/targets/win_audit_rule/tasks/remove.yml deleted file mode 100644 index 3102bc7487..0000000000 --- a/test/integration/targets/win_audit_rule/tasks/remove.yml +++ /dev/null @@ -1,151 +0,0 @@ -################################ -### check mode remove a rule ### -################################ -- name: check mode remove directory rule - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: directory - check_mode: yes - -- name: check mode remove file rule - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: file - check_mode: yes - -- name: check mode remove registry rule - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: registry - check_mode: yes - -- name: check mode remove get directory rule results - test_get_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory_results - -- name: check mode remove get file rule results - test_get_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file_results - -- name: check mode remove get REGISTRY rule results - test_get_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry_results - -- name: check mode remove assert that change detected, but rule is still present - assert: - that: - - directory is changed - - file is changed - - registry is changed - - directory_results.matching_rule_found and directory_results.path_type == 'directory' - - file_results.matching_rule_found and file_results.path_type == 'file' - - registry_results.matching_rule_found and registry_results.path_type == 'registry' - -##################### -### remove a rule ### -##################### -- name: remove directory rule - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: directory - -- name: remove file rule - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: file - -- name: remove registry rule - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: registry - -- name: remove get directory rule results - test_get_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: directory_results - -- name: remove get file rule results - test_get_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - inheritance_flags: none - register: file_results - -- name: remove get REGISTRY rule results - test_get_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - rights: "{{ test_audit_rule_new_rights }}" - audit_flags: "{{ test_audit_rule_audit_flags }}" - register: registry_results - -- name: remove assert that change detected and rule is gone - assert: - that: - - directory is changed - - file is changed - - registry is changed - - not directory_results.matching_rule_found and directory_results.path_type == 'directory' - - not file_results.matching_rule_found and file_results.path_type == 'file' - - not registry_results.matching_rule_found and registry_results.path_type == 'registry' - -################################ -### idempotent remove a rule ### -################################ -- name: idempotent remove directory rule - win_audit_rule: - path: "{{ test_audit_rule_folder }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: directory - -- name: idempotent remove file rule - win_audit_rule: - path: "{{ test_audit_rule_file }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: file - -- name: idempotent remove registry rule - win_audit_rule: - path: "{{ test_audit_rule_registry }}" - user: "{{ test_audit_rule_user }}" - state: absent - register: registry - -- name: idempotent remove assert that no change detected - assert: - that: - - directory is not changed and directory.path_type == 'directory' - - file is not changed and file.path_type == 'file' - - registry is not changed and registry.path_type == 'registry' diff --git a/test/integration/targets/win_auto_logon/aliases b/test/integration/targets/win_auto_logon/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_auto_logon/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_auto_logon/defaults/main.yml b/test/integration/targets/win_auto_logon/defaults/main.yml deleted file mode 100644 index d5462bb6a3..0000000000 --- a/test/integration/targets/win_auto_logon/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -# This doesn't have to be valid, just testing weird chars in the pass -test_logon_password: 'café - 💩' -test_logon_password2: '.ÅÑŚÌβŁÈ [$!@^&test(;)]' diff --git a/test/integration/targets/win_auto_logon/library/test_autologon_info.ps1 b/test/integration/targets/win_auto_logon/library/test_autologon_info.ps1 deleted file mode 100644 index ef4cf2d0f3..0000000000 --- a/test/integration/targets/win_auto_logon/library/test_autologon_info.ps1 +++ /dev/null @@ -1,214 +0,0 @@ -#!powershell - -#AnsibleRequires -CSharpUtil Ansible.Basic -#Requires -Module Ansible.ModuleUtils.AddType - -$module = [Ansible.Basic.AnsibleModule]::Create($args, @{}) - -Add-CSharpType -AnsibleModule $module -References @' -using Microsoft.Win32.SafeHandles; -using System; -using System.Runtime.ConstrainedExecution; -using System.Runtime.InteropServices; -using System.Text; - -namespace Ansible.TestAutoLogonInfo -{ - internal class NativeHelpers - { - [StructLayout(LayoutKind.Sequential)] - public class LSA_OBJECT_ATTRIBUTES - { - public UInt32 Length = 0; - public IntPtr RootDirectory = IntPtr.Zero; - public IntPtr ObjectName = IntPtr.Zero; - public UInt32 Attributes = 0; - public IntPtr SecurityDescriptor = IntPtr.Zero; - public IntPtr SecurityQualityOfService = IntPtr.Zero; - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct LSA_UNICODE_STRING - { - public UInt16 Length; - public UInt16 MaximumLength; - public IntPtr Buffer; - - public static explicit operator string(LSA_UNICODE_STRING s) - { - byte[] strBytes = new byte[s.Length]; - Marshal.Copy(s.Buffer, strBytes, 0, s.Length); - return Encoding.Unicode.GetString(strBytes); - } - - public static SafeMemoryBuffer CreateSafeBuffer(string s) - { - if (s == null) - return new SafeMemoryBuffer(IntPtr.Zero); - - byte[] stringBytes = Encoding.Unicode.GetBytes(s); - int structSize = Marshal.SizeOf(typeof(LSA_UNICODE_STRING)); - IntPtr buffer = Marshal.AllocHGlobal(structSize + stringBytes.Length); - try - { - LSA_UNICODE_STRING lsaString = new LSA_UNICODE_STRING() - { - Length = (UInt16)(stringBytes.Length), - MaximumLength = (UInt16)(stringBytes.Length), - Buffer = IntPtr.Add(buffer, structSize), - }; - Marshal.StructureToPtr(lsaString, buffer, false); - Marshal.Copy(stringBytes, 0, lsaString.Buffer, stringBytes.Length); - return new SafeMemoryBuffer(buffer); - } - catch - { - // Make sure we free the pointer before raising the exception. - Marshal.FreeHGlobal(buffer); - throw; - } - } - } - } - - internal class NativeMethods - { - [DllImport("Advapi32.dll")] - public static extern UInt32 LsaClose( - IntPtr ObjectHandle); - - [DllImport("Advapi32.dll")] - public static extern UInt32 LsaFreeMemory( - IntPtr Buffer); - - [DllImport("Advapi32.dll")] - internal static extern Int32 LsaNtStatusToWinError( - UInt32 Status); - - [DllImport("Advapi32.dll")] - public static extern UInt32 LsaOpenPolicy( - IntPtr SystemName, - NativeHelpers.LSA_OBJECT_ATTRIBUTES ObjectAttributes, - UInt32 AccessMask, - out SafeLsaHandle PolicyHandle); - - [DllImport("Advapi32.dll")] - public static extern UInt32 LsaRetrievePrivateData( - SafeLsaHandle PolicyHandle, - SafeMemoryBuffer KeyName, - out SafeLsaMemory PrivateData); - } - - internal class SafeLsaMemory : SafeBuffer - { - internal SafeLsaMemory() : base(true) { } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - - protected override bool ReleaseHandle() - { - return NativeMethods.LsaFreeMemory(handle) == 0; - } - } - - internal class SafeMemoryBuffer : SafeBuffer - { - internal SafeMemoryBuffer() : base(true) { } - - internal SafeMemoryBuffer(IntPtr ptr) : base(true) - { - base.SetHandle(ptr); - } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - - protected override bool ReleaseHandle() - { - if (handle != IntPtr.Zero) - Marshal.FreeHGlobal(handle); - return true; - } - } - - public class SafeLsaHandle : SafeHandleZeroOrMinusOneIsInvalid - { - internal SafeLsaHandle() : base(true) { } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - - protected override bool ReleaseHandle() - { - return NativeMethods.LsaClose(handle) == 0; - } - } - - public class Win32Exception : System.ComponentModel.Win32Exception - { - private string _exception_msg; - public Win32Exception(string message) : this(Marshal.GetLastWin32Error(), message) { } - public Win32Exception(int errorCode, string message) : base(errorCode) - { - _exception_msg = String.Format("{0} - {1} (Win32 Error Code {2}: 0x{3})", message, base.Message, errorCode, errorCode.ToString("X8")); - } - public override string Message { get { return _exception_msg; } } - public static explicit operator Win32Exception(string message) { return new Win32Exception(message); } - } - - public class LsaUtil - { - public static SafeLsaHandle OpenPolicy(UInt32 access) - { - NativeHelpers.LSA_OBJECT_ATTRIBUTES oa = new NativeHelpers.LSA_OBJECT_ATTRIBUTES(); - SafeLsaHandle lsaHandle; - UInt32 res = NativeMethods.LsaOpenPolicy(IntPtr.Zero, oa, access, out lsaHandle); - if (res != 0) - throw new Win32Exception(NativeMethods.LsaNtStatusToWinError(res), - String.Format("LsaOpenPolicy({0}) failed", access.ToString())); - return lsaHandle; - } - - public static string RetrievePrivateData(SafeLsaHandle handle, string key) - { - using (SafeMemoryBuffer keyBuffer = NativeHelpers.LSA_UNICODE_STRING.CreateSafeBuffer(key)) - { - SafeLsaMemory buffer; - UInt32 res = NativeMethods.LsaRetrievePrivateData(handle, keyBuffer, out buffer); - using (buffer) - { - if (res != 0) - { - // If the data object was not found we return null to indicate it isn't set. - if (res == 0xC0000034) // STATUS_OBJECT_NAME_NOT_FOUND - return null; - - throw new Win32Exception(NativeMethods.LsaNtStatusToWinError(res), - String.Format("LsaRetrievePrivateData({0}) failed", key)); - } - - NativeHelpers.LSA_UNICODE_STRING lsaString = (NativeHelpers.LSA_UNICODE_STRING) - Marshal.PtrToStructure(buffer.DangerousGetHandle(), - typeof(NativeHelpers.LSA_UNICODE_STRING)); - return (string)lsaString; - } - } - } - } -} -'@ - -$details = Get-ItemProperty -LiteralPath 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon' -$module.Result.AutoAdminLogon = $details.AutoAdminLogon -$module.Result.DefaultUserName = $details.DefaultUserName -$module.Result.DefaultDomainName = $details.DefaultDomainName -$module.Result.DefaultPassword = $details.DefaultPassword -$module.Result.AutoLogonCount = $details.AutoLogonCount - -$handle = [Ansible.TestAutoLogonInfo.LsaUtil]::OpenPolicy(0x00000004) -try { - $password = [Ansible.TestAutoLogonInfo.LsaUtil]::RetrievePrivateData($handle, 'DefaultPassword') - $module.Result.LsaPassword = $password -} finally { - $handle.Dispose() -} - -$module.ExitJson() diff --git a/test/integration/targets/win_auto_logon/tasks/main.yml b/test/integration/targets/win_auto_logon/tasks/main.yml deleted file mode 100644 index f8a8d01624..0000000000 --- a/test/integration/targets/win_auto_logon/tasks/main.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- name: get user domain split for ansible_user - win_shell: | - $account = New-Object -TypeName System.Security.Principal.NTAccount -ArgumentList '{{ ansible_user }}' - $sid = $account.Translate([System.Security.Principal.SecurityIdentifier]) - $sid.Translate([System.Security.Principal.NTAccount]).Value -split '{{ "\\" }}' - changed_when: False - register: test_user_split - -- set_fact: - test_domain: '{{ test_user_split.stdout_lines[0] }}' - test_user: '{{ test_user_split.stdout_lines[1] }}' - -- name: ensure auto logon is cleared before test - win_auto_logon: - state: absent - -- name: ensure defaults are set - win_regedit: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon - name: '{{ item.name }}' - data: '{{ item.value }}' - type: '{{ item.type }}' - state: present - loop: - # We set the DefaultPassword to ensure win_auto_logon clears this out - - name: DefaultPassword - value: abc - type: string - # Ensures the host we test on has a baseline key to check against - - name: AutoAdminLogon - value: 0 - type: dword - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: make sure the auto logon is cleared - win_auto_logon: - state: absent diff --git a/test/integration/targets/win_auto_logon/tasks/tests.yml b/test/integration/targets/win_auto_logon/tasks/tests.yml deleted file mode 100644 index c25e07709b..0000000000 --- a/test/integration/targets/win_auto_logon/tasks/tests.yml +++ /dev/null @@ -1,178 +0,0 @@ -# Copyright: (c) 2019, Prasoon Karunan V (@prasoonkarunan) <kvprasoon@Live.in> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: set autologon registry keys (check mode) - win_auto_logon: - username: '{{ ansible_user }}' - password: '{{ test_logon_password }}' - state: present - register: set_check - check_mode: yes - -- name: get acutal of set autologon registry keys (check mode) - test_autologon_info: - register: set_actual_check - -- name: assert set autologon registry keys (check mode) - assert: - that: - - set_check is changed - - set_actual_check.AutoAdminLogon == 0 - - set_actual_check.AutoLogonCount == None - - set_actual_check.DefaultDomainName == None - - set_actual_check.DefaultPassword == 'abc' - - set_actual_check.DefaultUserName == None - - set_actual_check.LsaPassword == None - -- name: set autologon registry keys - win_auto_logon: - username: '{{ ansible_user }}' - password: '{{ test_logon_password }}' - state: present - register: set - -- name: get acutal of set autologon registry keys - test_autologon_info: - register: set_actual - -- name: assert set autologon registry keys - assert: - that: - - set is changed - - set_actual.AutoAdminLogon == 1 - - set_actual.AutoLogonCount == None - - set_actual.DefaultDomainName == test_domain - - set_actual.DefaultPassword == None - - set_actual.DefaultUserName == test_user - - set_actual.LsaPassword == test_logon_password - -- name: set autologon registry keys (idempotent) - win_auto_logon: - username: '{{ ansible_user }}' - password: '{{ test_logon_password }}' - state: present - register: set_again - -- name: assert set autologon registry keys (idempotent) - assert: - that: - - not set_again is changed - -- name: add logon count (check mode) - win_auto_logon: - username: '{{ ansible_user }}' - password: '{{ test_logon_password }}' - logon_count: 2 - state: present - register: logon_count_check - check_mode: yes - -- name: get result of add logon count (check mode) - test_autologon_info: - register: logon_count_actual_check - -- name: assert add logon count (check mode) - assert: - that: - - logon_count_check is changed - - logon_count_actual_check.AutoLogonCount == None - -- name: add logon count - win_auto_logon: - username: '{{ ansible_user }}' - password: '{{ test_logon_password }}' - logon_count: 2 - state: present - register: logon_count - -- name: get result of add logon count - test_autologon_info: - register: logon_count_actual - -- name: assert add logon count - assert: - that: - - logon_count is changed - - logon_count_actual.AutoLogonCount == 2 - -- name: change auto logon (check mode) - win_auto_logon: - username: '{{ ansible_user }}' - password: '{{ test_logon_password2 }}' - state: present - register: change_check - check_mode: yes - -- name: get reuslt of change auto logon (check mode) - test_autologon_info: - register: change_actual_check - -- name: assert change auto logon (check mode) - assert: - that: - - change_check is changed - - change_actual_check == logon_count_actual - -- name: change auto logon - win_auto_logon: - username: '{{ ansible_user }}' - password: '{{ test_logon_password2 }}' - state: present - register: change - -- name: get reuslt of change auto logon - test_autologon_info: - register: change_actual - -- name: assert change auto logon - assert: - that: - - change is changed - - change_actual.AutoLogonCount == None - - change_actual.LsaPassword == test_logon_password2 - -- name: remove autologon registry keys (check mode) - win_auto_logon: - state: absent - register: remove_check - check_mode: yes - -- name: get result of remove autologon registry keys (check mode) - test_autologon_info: - register: remove_actual_check - -- name: assert remove autologon registry keys (check mode) - assert: - that: - - remove_check is changed - - remove_actual_check == change_actual - -- name: remove autologon registry keys - win_auto_logon: - state: absent - register: remove - -- name: get result of remove autologon registry keys - test_autologon_info: - register: remove_actual - -- name: assert remove autologon registry keys - assert: - that: - - remove is changed - - remove_actual.AutoAdminLogon == 0 - - remove_actual.AutoLogonCount == None - - remove_actual.DefaultDomainName == None - - remove_actual.DefaultPassword == None - - remove_actual.DefaultUserName == None - - remove_actual.LsaPassword == None - -- name: remove autologon registry keys (idempotent) - win_auto_logon: - state: absent - register: remove_again - -- name: assert remove autologon registry keys (idempotent) - assert: - that: - - not remove_again is changed diff --git a/test/integration/targets/win_certificate_info/aliases b/test/integration/targets/win_certificate_info/aliases deleted file mode 100644 index 6036e173f1..0000000000 --- a/test/integration/targets/win_certificate_info/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group7 diff --git a/test/integration/targets/win_certificate_info/defaults/main.yml b/test/integration/targets/win_certificate_info/defaults/main.yml deleted file mode 100644 index b8d5a0f90f..0000000000 --- a/test/integration/targets/win_certificate_info/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -win_cert_dir: '{{win_output_dir}}\win_certificate .ÅÑŚÌβŁÈ [$!@^&test(;)]' -subj_thumbprint: 'BD7AF104CF1872BDB518D95C9534EA941665FD27' -root_thumbprint: 'BC05633694E675449136679A658281F17A191087' diff --git a/test/integration/targets/win_certificate_info/files/root-cert.pem b/test/integration/targets/win_certificate_info/files/root-cert.pem deleted file mode 100644 index edbe6b8684..0000000000 --- a/test/integration/targets/win_certificate_info/files/root-cert.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDKDCCAhCgAwIBAgIJAP1vIdGgMJv/MA0GCSqGSIb3DQEBCwUAMCgxGTAXBgNV -BAMMEHJvb3QuYW5zaWJsZS5jb20xCzAJBgNVBAYTAlVTMCAXDTE3MTIxNTA4Mzkz -MloYDzIwODYwMTAyMDgzOTMyWjAoMRkwFwYDVQQDDBByb290LmFuc2libGUuY29t -MQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMmq -YT8eZY6rFQKnmScUGnnUH1tLQ+3WQpfKiWygCUSb1CNqO3J1u3pGMEqYM58LK4Kr -Mpskv7K1tCV/EMZqGTqXAIfSLy9umlb/9C3AhL9thBPn5I9dam/EmrIZktI9/w5Y -wBXn4toe+OopA3QkMQh9BUjUCPb9fdOI+ir7OGFZMmxXmiM64+BEeywM2oSGsdZ9 -5hU378UBu2IX4+OAV8Fbr2l6VW+Fxg/tKIOo6Bs46Pa4EZgtemOqs3kxYBOltBTb -vFcLsLa4KYVu5Ge5YfB0Axfaem7PoP8IlMs8gxyojZ/r0o5hzxUcYlL/h8GeeoLW -PFFdiAS+UgxWINOqNXMCAwEAAaNTMFEwHQYDVR0OBBYEFLp9k4LmOnAR4ROrqhb+ -CFdbk2+oMB8GA1UdIwQYMBaAFLp9k4LmOnAR4ROrqhb+CFdbk2+oMA8GA1UdEwEB -/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAGksycHsjGbXfWfuhQh+CvXk/A2v -MoNgiHtNMTGliVNgoVp1B1rj4x9xyZ8YrO8GAmv8jaCwCShd0B5Ul4aZVk1wglVv -lFAwb4IAZN9jv9+fw5BRzQ2tLhkVWIEwx6pZkhGhhjBvMaplLN5JwBtsdZorFbm7 -wuKiUKcFAM28acoOhCmOhgyNNBZpZn5wXaQDY43AthJOhitAV7vph4MPUkwIJnOh -MA5GJXEqS58TE9z9pkhQnn9598G8tmOXyA2erAoM9JAXM3EYHxVpoHBb9QRj6WAw -XVBo6qRXkwjNEM5CbnD4hVIBsdkOGsDrgd4Q5izQZ3x+jFNkdL/zPsXjJFw= ------END CERTIFICATE----- - diff --git a/test/integration/targets/win_certificate_info/files/subj-cert.pem b/test/integration/targets/win_certificate_info/files/subj-cert.pem deleted file mode 100644 index 6d9ec39c73..0000000000 --- a/test/integration/targets/win_certificate_info/files/subj-cert.pem +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIC0TCCAbkCCQC/MtOBa1UDpzANBgkqhkiG9w0BAQsFADAoMRkwFwYDVQQDDBBy -b290LmFuc2libGUuY29tMQswCQYDVQQGEwJVUzAgFw0xNzEyMTUwODU2MzBaGA8y -MDg2MDEwMjA4NTYzMFowKzEcMBoGA1UEAwwTc3ViamVjdC5hbnNpYmxlLmNvbTEL -MAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDszqdF -So3GlVP1xUnN4bSPrFRFiOl/Mqup0Zn5UJJUR9wLnRD+OLcq7kKin6hYqozSu7cC -+BnWQoq7vGSSNVqv7BqFMwzGJt9IBUQv0UqIQkA/duUdKdAiMn2PQRsNDnkWEbTj -4xsitItVNv84cDG0lkZBYyTgfyZlZLZWplkpUQkrZhoFCekZRJ+ODrqNW3W560rr -OUIh+HiQeBqocat6OdxgICBqpUh8EVo1iha3DXjGN08q5utg6gmbIl2VBaVJjfyd -wnUSqHylJwh6WCIEh+HXsn4ndfNWSN/fDqvi5I10V1j6Zos7yqQf8qAezUAm6eSq -hLgZz0odq9DsO4HHAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAFK5mVIJ2D+kI0kk -sxnW4ibWFjzlYFYPYrZg+2JFIVTbKBg1YzyhuIKm0uztqRxQq5iLn/C/uponHoqF -7KDQI37KAJIQdgSva+mEuO9bZAXg/eegail2hN6np7HjOKlPu23s40dAbFrbcOWP -VbsBEPDP0HLv6OgbQWzNlE9HO1b7pX6ozk3q4ULO7IR85P6OHYsBBThL+qsOTzg/ -gVknuB9+n9hgNqZcAcXBLDetOM9aEmYJCGk0enYP5UGLYpseE+rTXFbRuHTPr1o6 -e8BetiSWS/wcrV4ZF5qr9NiYt5eD6JzTB5Rn5awxxj0FwMtrBu003lLQUWxsuTzz -35/RLY4= ------END CERTIFICATE----- - diff --git a/test/integration/targets/win_certificate_info/meta/main.yml b/test/integration/targets/win_certificate_info/meta/main.yml deleted file mode 100644 index bdea853d75..0000000000 --- a/test/integration/targets/win_certificate_info/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- prepare_win_tests diff --git a/test/integration/targets/win_certificate_info/tasks/main.yml b/test/integration/targets/win_certificate_info/tasks/main.yml deleted file mode 100644 index 06bd6802c6..0000000000 --- a/test/integration/targets/win_certificate_info/tasks/main.yml +++ /dev/null @@ -1,88 +0,0 @@ -### keys in files/ have been generated with -# generate root private key -# openssl genrsa -aes256 -out enckey.pem 2048 -# openssl rsa -in envkey.pem -out root-key.pem -# -# generate root certificate -# openssl req -x509 -key root-key.pem -days 24855 -out root-vert.pem -subj "/CN=root.ansible.com/C=US" -# -# generate subject private key -# openssl genrsa -aes256 -out enckey.pem 2048 -# openssl rsa -in enckey.pem -out subj-key.pem -# -# generate subject certificate -# openssl req -new -key subj-key.pem -out cert.csr -subj "/CN=subject.ansible.com/C=US" -# openssl x509 -req -in cert.csr -CA root-cert.pem -CAkey root-key.pem -CAcreateserial -out subj-cert.pem -days 24855 -### ---- -- name: ensure test dir is present - win_file: - path: '{{win_cert_dir}}\exported' - state: directory - -- name: copy across test cert files - win_copy: - src: files/ - dest: '{{win_cert_dir}}' - -- name: subject cert imported to personal store - win_certificate_store: - path: '{{win_cert_dir}}\subj-cert.pem' - state: present - store_name: My - -- name: root certificate imported to trusted root - win_certificate_store: - path: '{{win_cert_dir}}\root-cert.pem' - store_name: Root - state: present - -- name: get raw root certificate - shell: 'cat root-cert.pem | grep "^[^-]"' - args: - chdir: '{{ role_path }}/files' - register: root_raw - delegate_to: localhost - -- name: get public key of root certificate - shell: 'openssl x509 -pubkey -noout -in root-cert.pem | grep "^[^-]"' - args: - chdir: '{{ role_path }}/files' - register: root_pub - delegate_to: localhost - -- name: get subject certificate - shell: 'cat subj-cert.pem | grep "^[^-]"' - args: - chdir: '{{ role_path }}/files' - register: subj_raw - delegate_to: localhost - -- name: get public key of subject certificate - shell: 'openssl x509 -pubkey -noout -in subj-cert.pem | grep "^[^-]"' - args: - chdir: '{{ role_path }}/files' - register: subj_pub - delegate_to: localhost - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: ensure subject cert removed from personal store - win_certificate_store: - thumbprint: '{{subj_thumbprint}}' - state: absent - store_name: My - - - name: ensure root cert removed from trusted root - win_certificate_store: - thumbprint: '{{root_thumbprint}}' - state: absent - store_name: Root - - - name: ensure test dir is deleted - win_file: - path: '{{win_cert_dir}}' - state: absent diff --git a/test/integration/targets/win_certificate_info/tasks/tests.yml b/test/integration/targets/win_certificate_info/tasks/tests.yml deleted file mode 100644 index 90eb0870bf..0000000000 --- a/test/integration/targets/win_certificate_info/tasks/tests.yml +++ /dev/null @@ -1,90 +0,0 @@ ---- - -- name: get stats on a store that doesn't exist - win_certificate_info: - store_name: teststore - register: test_store - -- name: ensure exists is false - assert: - that: - - test_store.exists == false - -- name: get stats on the root certificate store - win_certificate_info: - store_name: Root - register: root_store - -- name: at least one certificate is returned - assert: - that: - - "root_store.exists" - - "root_store.certificates | length > 0" - -- name: get stats on a certificate that doesn't exist - win_certificate_info: - thumbprint: ABC - register: actual - -- name: ensure exists is false - assert: - that: actual.exists == false - -- name: get stats on root certificate - win_certificate_info: - thumbprint: '{{ root_thumbprint }}' - store_name: Root - register: root_stats - -- name: root certificate stats returned are expected values - assert: - that: - - root_stats.exists - - root_stats.certificates[0].archived == false - - root_stats.certificates[0].dns_names == [ 'root.ansible.com' ] - - root_stats.certificates[0].extensions|count == 3 - - root_stats.certificates[0].has_private_key == false - - root_stats.certificates[0].issued_by == 'root.ansible.com' - - root_stats.certificates[0].issued_to == 'root.ansible.com' - - root_stats.certificates[0].issuer == 'C=US, CN=root.ansible.com' - - root_stats.certificates[0].path_length_constraint == 0 -# - root_stats.certificates[0].public_key == (root_pub.stdout_lines|join()) - - root_stats.certificates[0].raw == root_raw.stdout_lines|join() - - root_stats.certificates[0].serial_number == '00FD6F21D1A0309BFF' - - root_stats.certificates[0].signature_algorithm == 'sha256RSA' - - root_stats.certificates[0].ski == 'BA7D9382E63A7011E113ABAA16FE08575B936FA8' - - root_stats.certificates[0].subject == 'C=US, CN=root.ansible.com' - - root_stats.certificates[0].valid_from == 1513327172 - - root_stats.certificates[0].valid_from_iso8601 == '2017-12-15T08:39:32Z' - - root_stats.certificates[0].valid_to == 3660799172 - - root_stats.certificates[0].valid_to_iso8601 == '2086-01-02T08:39:32Z' - - root_stats.certificates[0].version == 3 - -- name: get stats on subject certificate - win_certificate_info: - thumbprint: '{{ subj_thumbprint }}' - register: subj_stats - -- name: subject certificate stats returned are expected values - assert: - that: - - subj_stats.exists - - subj_stats.certificates[0].archived == false - - subj_stats.certificates[0].dns_names == [ 'subject.ansible.com' ] - - subj_stats.certificates[0].extensions|count == 0 - - subj_stats.certificates[0].has_private_key == false - - subj_stats.certificates[0].issued_by == 'root.ansible.com' - - subj_stats.certificates[0].issued_to == 'subject.ansible.com' - - subj_stats.certificates[0].issuer == 'C=US, CN=root.ansible.com' - - subj_stats.certificates[0].path_length_constraint is undefined -# - subj_stats.certificates[0].public_key == subj_pub.stdout_lines|join() - - subj_stats.certificates[0].raw == subj_raw.stdout_lines|join() - - subj_stats.certificates[0].serial_number == '00BF32D3816B5503A7' - - subj_stats.certificates[0].signature_algorithm == 'sha256RSA' - - subj_stats.certificates[0].ski is undefined - - subj_stats.certificates[0].subject == 'C=US, CN=subject.ansible.com' - - subj_stats.certificates[0].valid_from == 1513328190 - - subj_stats.certificates[0].valid_from_iso8601 == '2017-12-15T08:56:30Z' - - subj_stats.certificates[0].valid_to == 3660800190 - - subj_stats.certificates[0].valid_to_iso8601 == '2086-01-02T08:56:30Z' - - subj_stats.certificates[0].version == 1 diff --git a/test/integration/targets/win_chocolatey/aliases b/test/integration/targets/win_chocolatey/aliases deleted file mode 100644 index 4f4664b685..0000000000 --- a/test/integration/targets/win_chocolatey/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group5 diff --git a/test/integration/targets/win_chocolatey/defaults/main.yml b/test/integration/targets/win_chocolatey/defaults/main.yml deleted file mode 100644 index eb5289d35f..0000000000 --- a/test/integration/targets/win_chocolatey/defaults/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -test_choco_path: '{{ win_output_dir }}\win_chocolatey' -test_choco_source: '{{ test_choco_path }}\packages' -test_choco_source2: '{{ test_choco_path }}\packages2' # used to verify source works with the source name and not just the path -test_choco_package1: ansible -test_choco_package2: ansible-test -test_choco_packages: -- '{{ test_choco_package1 }}' -- '{{ test_choco_package2 }}' diff --git a/test/integration/targets/win_chocolatey/files/package.nuspec b/test/integration/targets/win_chocolatey/files/package.nuspec deleted file mode 100644 index b5a3e409fe..0000000000 --- a/test/integration/targets/win_chocolatey/files/package.nuspec +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> - <metadata> - <id>--- NAME ---</id> - <version>--- VERSION ---</version> - <title>--- NAME ---</title> - <authors>Jordan Borean</authors> - <description>Test for win_chocolatey module</description> - </metadata> - <files> - <file src="tools\**" target="tools" /> - </files> -</package> diff --git a/test/integration/targets/win_chocolatey/files/tools/chocolateyUninstall.ps1 b/test/integration/targets/win_chocolatey/files/tools/chocolateyUninstall.ps1 deleted file mode 100644 index 8c49c11fb0..0000000000 --- a/test/integration/targets/win_chocolatey/files/tools/chocolateyUninstall.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -$ErrorActionPreference = 'Stop' - -$package_name = $env:ChocolateyPackageName -$package_version = $env:ChocolateyPackageVersion -$install_path = "--- PATH ---\$package_name-$package_version.txt" - -if (Test-Path -Path $install_path) { - Remove-Item -Path $install_path -Force > $null -} diff --git a/test/integration/targets/win_chocolatey/files/tools/chocolateyinstall.ps1 b/test/integration/targets/win_chocolatey/files/tools/chocolateyinstall.ps1 deleted file mode 100644 index ee2c47f6c8..0000000000 --- a/test/integration/targets/win_chocolatey/files/tools/chocolateyinstall.ps1 +++ /dev/null @@ -1,55 +0,0 @@ -$ErrorActionPreference = 'Stop' - -$package_name = $env:ChocolateyPackageName -$package_version = $env:ChocolateyPackageVersion -$install_path = "--- PATH ---\$package_name-$package_version.txt" -$source = "--- SOURCE ---" # used by the test to determine which source it was installed from - -if ($env:ChocolateyAllowEmptyChecksums) { - $allow_empty_checksums = $true -} else { - $allow_empty_checksums = $false -} -if ($env:ChocolateyIgnoreChecksums) { - $ignore_checksums = $true -} else { - $ignore_checksums = $false -} -if ($env:ChocolateyForce) { - $force = $true -} else { - $force = $false -} -if ($env:ChocolateyForceX86) { - $force_x86 = $true -} else { - $force_x86 = $false -} -if ($env:ChocolateyInstallOverride) { - $override_args = $true -} else { - $override_args = $false -} -#$process_env = Get-EnvironmentVariableNames -Scope Process -#$env_vars = @{} -#foreach ($name in $process_env) { -# $env_vars.$name = Get-EnvironmentVariable -Name $name -Scope Process -#} -$timeout = $env:chocolateyResponseTimeout - -$package_info = @{ - allow_empty_checksums = $allow_empty_checksums - #env_vars = $env_vars - force = $force - force_x86 = $force_x86 - ignore_checksums = $ignore_checksums - install_args = $env:ChocolateyInstallArguments - override_args = $override_args - package_params = Get-PackageParameters - proxy_url = $env:ChocolateyProxyLocation - source = $source - timeout = $timeout -} -$package_json = ConvertTo-Json -InputObject $package_info - -[System.IO.File]::WriteAllText($install_path, $package_json) diff --git a/test/integration/targets/win_chocolatey/tasks/main.yml b/test/integration/targets/win_chocolatey/tasks/main.yml deleted file mode 100644 index b50335a08b..0000000000 --- a/test/integration/targets/win_chocolatey/tasks/main.yml +++ /dev/null @@ -1,110 +0,0 @@ ---- -- name: ensure test package is uninstalled - win_chocolatey: - name: '{{ test_choco_packages }}' - state: absent - -- name: ensure testing dir is cleaned - win_file: - path: '{{ test_choco_path }}' - state: '{{ item }}' - with_items: - - absent - - directory - -- name: copy template package files - win_copy: - src: files/ - dest: '{{ test_choco_path }}' - -# run the setup in 1 shell script to save on test time -- name: set up packages - win_shell: | - $ErrorActionPreference = "Stop" - $root_path = '{{ test_choco_path }}' - $packages_path = '{{ test_choco_source }}' - $packages_path_override = '{{ test_choco_source2 }}' - $packages = @( - @{ name = "ansible"; version = "0.0.1"; override = $false }, - @{ name = "ansible"; version = "0.1.0"; override = $false }, - @{ name = "ansible"; version = "0.1.0"; override = $true }, - @{ name = "ansible-test"; version = "1.0.0"; override = $false }, - @{ name = "ansible-test"; version = "1.0.1-beta1"; override = $false } - ) - $nuspec_src = "$root_path\package.nuspec" - $install_src = "$root_path\tools\chocolateyinstall.ps1" - $uninstall_src = "$root_path\tools\chocolateyUninstall.ps1" - - New-Item -Path $packages_path -ItemType Directory > $null - New-Item -Path $packages_path_override -ItemType Directory > $null - - foreach ($package in $packages) { - $package_dir = "$root_path\$($package.name)-$($package.version)" - New-Item -Path $package_dir -ItemType Directory > $null - New-Item -Path "$package_dir\tools" -ItemType Directory > $null - - if ($package.override) { - $out_path = $packages_path_override - $source_value = "override" - } else { - $out_path = $packages_path - $source_value = "normal" - } - - $nuspec_text = ([System.IO.File]::ReadAllLines($nuspec_src) -join "`r`n") - $nuspec_text = $nuspec_text.Replace('--- NAME ---', $package.name).Replace('--- VERSION ---', $package.version) - - $install_text = ([System.IO.File]::ReadAllLines($install_src) -join "`r`n") - $install_text = $install_text.Replace('--- PATH ---', $root_path).Replace('--- SOURCE ---', $source_value) - - $uninstall_text = ([System.IO.File]::ReadAllLines($uninstall_src) -join "`r`n") - $uninstall_text = $uninstall_text.Replace('--- PATH ---', $root_path) - - $utf8 = New-Object -TypeName System.Text.UTF8Encoding -ArgumentList $false - $utf8_bom = New-Object -TypeName System.Text.UTF8Encoding -ArgumentList $true - [System.IO.File]::WriteAllText("$package_dir\$($package.name).nuspec", $nuspec_text, $utf8) - [System.IO.File]::WriteAllText("$package_dir\tools\chocolateyinstall.ps1", $install_text, $utf8_bom) - [System.IO.File]::WriteAllText("$package_dir\tools\chocolateyUninstall.ps1", $uninstall_text, $utf8_bom) - - &choco.exe pack --out $out_path --no-progress --limit-output "$package_dir\$($package.name).nuspec" - Remove-Item -Path $package_dir -Force -Recurse > $null - } - Remove-Item -Path "$root_path\tools" -Force -Recurse > $null - Remove-Item -Path $nuspec_src > $null - -- name: set up Chocolatey sources - win_chocolatey_source: - name: '{{ item.name }}' - priority: '{{ item.priority }}' - source: '{{ item.src }}' - state: present - with_items: - - name: ansible-test - priority: 1 - src: '{{ test_choco_source }}' - - name: ansible-test-override - priority: 2 - src: '{{ test_choco_source2 }}' - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: ensure test package is uninstalled after tests - win_chocolatey: - name: '{{ test_choco_packages }}' - state: absent - - - name: remove test sources - win_chocolatey_source: - name: '{{ item }}' - state: absent - with_items: - - ansible-test - - ansible-test-override - - - name: remove testing dir - win_file: - path: '{{ test_choco_path }}' - state: absent diff --git a/test/integration/targets/win_chocolatey/tasks/tests.yml b/test/integration/targets/win_chocolatey/tasks/tests.yml deleted file mode 100644 index 5eb2016340..0000000000 --- a/test/integration/targets/win_chocolatey/tasks/tests.yml +++ /dev/null @@ -1,610 +0,0 @@ ---- -- name: raise failure when state=present and name=all - win_chocolatey: - name: all - state: present - register: fail_all_present - failed_when: fail_all_present.msg != "Cannot specify the package name as 'all' when state=present" - -- name: raise failure when state=reinstalled and name=all - win_chocolatey: - name: all - state: reinstalled - register: fail_all_reinstalled - failed_when: fail_all_reinstalled.msg != "Cannot specify the package name as 'all' when state=reinstalled" - -- name: install package (check mode) - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - check_mode: yes - register: install_check - -- name: get result of install package (check mode) - win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }} - register: install_actual_check - failed_when: not install_actual_check.rc in [0, 2] # v0.10.12+ returns 2 for no package - -- name: assert install package (check mode) - assert: - that: - - install_check is changed - - install_actual_check.stdout_lines == [] - -- name: install package - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - register: install - -- name: get result of install package - win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }} - register: install_actual - -- name: get package info of install package - win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw - register: install_actual_info - -- name: assert install package - assert: - that: - - install is changed - - install_actual.stdout_lines == [test_choco_package1 + "|0.1.0"] - - (install_actual_info.stdout|from_json).allow_empty_checksums == False - - (install_actual_info.stdout|from_json).force == False - - (install_actual_info.stdout|from_json).force_x86 == False - - (install_actual_info.stdout|from_json).ignore_checksums == False - - (install_actual_info.stdout|from_json).install_args == None - - (install_actual_info.stdout|from_json).override_args == False - - (install_actual_info.stdout|from_json).package_params == {} - - (install_actual_info.stdout|from_json).proxy_url == None - - (install_actual_info.stdout|from_json).source == "normal" - - (install_actual_info.stdout|from_json).timeout == "2700000" - -- name: install package (idempotent) - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - register: install_again - -- name: assert install package (idempotent) - assert: - that: - - not install_again is changed - -- name: remove package (check mode) - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: absent - check_mode: yes - register: remove_check - -- name: get result of remove package (check mode) - win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }} - register: remove_actual_check - -- name: assert remove package (check mode) - assert: - that: - - remove_check is changed - - remove_actual_check.stdout_lines == [test_choco_package1 + "|0.1.0"] - -- name: remove package - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: absent - register: remove - -- name: get result of remove package - win_command: choco.exe list --local-only --exact --limit-output {{ test_choco_package1|quote }} - register: remove_actual - failed_when: not remove_actual.rc in [0, 2] - -- name: check if removed package file still exists - win_stat: - path: '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' - register: remove_actual_info - -- name: assert remove package - assert: - that: - - remove is changed - - remove_actual.stdout_lines == [] - - remove_actual_info.stat.exists == False - -- name: remove package (idempotent) - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: absent - register: remove_again - -- name: assert remove_package (idempotent) - assert: - that: - - not remove_again is changed - -- name: install multiple packages with timeout - win_chocolatey: - name: '{{ test_choco_packages }}' - state: present - timeout: 1000 - register: install_multiple - -- name: get list of installed packages with timeout - win_command: choco.exe list --local-only --limit-output ansible - register: install_multiple_actual - -- name: get info on package 1 - win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw - register: install_multiple_package1 - -- name: get info on package 2 - win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package2 }}-1.0.0.txt' -Raw - register: install_multiple_package2 - -- name: assert install multiple packages with timeout - assert: - that: - - install_multiple is changed - - install_multiple_actual.stdout_lines == [test_choco_package1 + "|0.1.0", test_choco_package2 + "|1.0.0"] - - (install_multiple_package1.stdout|from_json).allow_empty_checksums == False - - (install_multiple_package1.stdout|from_json).force == False - - (install_multiple_package1.stdout|from_json).force_x86 == False - - (install_multiple_package1.stdout|from_json).ignore_checksums == False - - (install_multiple_package1.stdout|from_json).install_args == None - - (install_multiple_package1.stdout|from_json).override_args == False - - (install_multiple_package1.stdout|from_json).package_params == {} - - (install_multiple_package1.stdout|from_json).proxy_url == None - - (install_multiple_package1.stdout|from_json).source == "normal" - - (install_multiple_package1.stdout|from_json).timeout == "1000000" - - (install_multiple_package2.stdout|from_json).allow_empty_checksums == False - - (install_multiple_package2.stdout|from_json).force == False - - (install_multiple_package2.stdout|from_json).force_x86 == False - - (install_multiple_package2.stdout|from_json).ignore_checksums == False - - (install_multiple_package2.stdout|from_json).install_args == None - - (install_multiple_package2.stdout|from_json).override_args == False - - (install_multiple_package2.stdout|from_json).package_params == {} - - (install_multiple_package2.stdout|from_json).proxy_url == None - - (install_multiple_package2.stdout|from_json).source == "normal" - - (install_multiple_package2.stdout|from_json).timeout == "1000000" - -- name: install multiple packages (idempotent) - win_chocolatey: - name: '{{ test_choco_packages }}' - state: present - register: install_multiple_again - -- name: assert install multiple packages (idempotent) - assert: - that: - - not install_multiple_again is changed - -- name: remove multiple packages - win_chocolatey: - name: '{{ test_choco_packages }}' - state: absent - register: remove_multiple - -- name: get list of installed packages after removal - win_command: choco.exe list --local-only --limit-output ansible - register: remove_multiple_actual - failed_when: not remove_multiple_actual.rc in [0, 2] - -- name: get info on package 1 - win_stat: - path: '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' - register: remove_multiple_package1 - -- name: get info on package 2 - win_stat: - path: '{{ test_choco_path }}\{{ test_choco_package2 }}-1.0.0.txt' - register: remove_multiple_package2 - -- name: assert remove multiple packages - assert: - that: - - remove_multiple is changed - - remove_multiple_actual.stdout_lines == [] - - remove_multiple_package1.stat.exists == False - - remove_multiple_package2.stat.exists == False - -- name: remove multiple packages (idempotent) - win_chocolatey: - name: '{{ test_choco_packages }}' - state: absent - register: remove_multiple_again - -- name: assert remove multiple packages (idempotent) - assert: - that: - - not remove_multiple_again is changed - -- name: install package with params - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - install_args: /install_arg 1 /install_arg 2 - override_args: yes - package_params: /param1 /param2:value - allow_empty_checksums: yes - architecture: x86 - force: yes - ignore_checksums: yes - proxy_url: http://proxyhost - version: 0.0.1 - register: install_params - -- name: get result of install package with params - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }} - register: install_params_actual - -- name: get info of install package with params - win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.0.1.txt' - register: install_params_info - -- name: assert install package with params - assert: - that: - - install_params is changed - - install_params_actual.stdout_lines == [test_choco_package1 + "|0.0.1"] - - (install_params_info.stdout|from_json).allow_empty_checksums == True - - (install_params_info.stdout|from_json).force == True - - (install_params_info.stdout|from_json).force_x86 == True - - (install_params_info.stdout|from_json).ignore_checksums == True - - (install_params_info.stdout|from_json).install_args == "/install_arg 1 /install_arg 2" - - (install_params_info.stdout|from_json).override_args == True - - (install_params_info.stdout|from_json).package_params.keys()|count == 2 - - (install_params_info.stdout|from_json).package_params.param1 == True - - (install_params_info.stdout|from_json).package_params.param2 == "value" - - (install_params_info.stdout|from_json).proxy_url == "http://proxyhost" - - (install_params_info.stdout|from_json).source == "normal" - - (install_params_info.stdout|from_json).timeout == "2700000" - -- name: install package with version (idempotent) - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - version: 0.0.1 - register: install_with_version - -- name: assert install package with version (idempotent) - assert: - that: - - not install_with_version is changed - -- name: fail to install side by side package - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - version: 0.1.0 - register: fail_multiple_versions - failed_when: fail_multiple_versions.msg != "Chocolatey package '" + test_choco_package1 + "' is already installed with version(s) '0.0.1' but was expecting '0.1.0'. Either change the expected version, set state=latest, set allow_multiple=yes, or set force=yes to continue" - -- name: force the upgrade of an existing version - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - version: 0.1.0 - force: yes - register: force_different_version - -- name: get result of force the upgrade of an existing version - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }} - register: force_different_version_actual - -- name: get result of forced package install file - win_stat: - path: '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' - register: force_different_version_info - -- name: assert force the upgrade of an existing version - assert: - that: - - force_different_version is changed - - force_different_version_actual.stdout_lines == [test_choco_package1 + "|0.1.0"] - - force_different_version_info.stat.exists - -- name: remove package after force clobbered everything - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: absent - ignore_errors: yes # the mock package created doesn't really handle force well - -- name: install package with reference to source name - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - source: ansible-test-override - register: install_source_name - -- name: get result of install package with reference to source name - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }} - register: install_source_name_actual - -- name: get result fo installed package with reference to source name info - win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw - register: install_source_name_info - -- name: assert install package with reference to source name - assert: - that: - - install_source_name is changed - - install_source_name_actual.stdout_lines == [test_choco_package1 + "|0.1.0"] - - (install_source_name_info.stdout|from_json).source == "override" - -- name: reinstall package without source override - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: reinstalled - register: reinstalled_package - -- name: get result of reinstalled package without source override - win_shell: Get-Content -Path '{{ test_choco_path }}\{{ test_choco_package1 }}-0.1.0.txt' -Raw - register: reinstalled_package_info - -- name: assert reinstall package without source override - assert: - that: - - reinstalled_package is changed - - (reinstalled_package_info.stdout|from_json).source == "normal" - -- name: downgrade package - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: downgrade - version: 0.0.1 - register: downgraded_package - -- name: get result of downgrade package - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }} - register: downgraded_package_actual - -- name: assert downgrade package - assert: - that: - - downgraded_package is changed - - downgraded_package_actual.stdout_lines == [test_choco_package1 + "|0.0.1"] - -- name: downgrade package (idempotent) - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: downgrade - version: 0.0.1 - register: downgraded_package_again - -- name: assert downgrade package (idempotent) - assert: - that: - - not downgraded_package_again is changed - -- name: downgrade package without version specified - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: downgrade - register: downgrade_without_version - -- name: get result of downgrade without version - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }} - register: downgrade_without_version_actual - -- name: assert downgrade package without version specified - assert: - that: - - not downgrade_without_version is changed - - downgrade_without_version_actual.stdout_lines == [test_choco_package1 + "|0.0.1"] - -- name: upgrade package - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: latest - register: upgrade_package - -- name: get result of upgrade package - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }} - register: upgrade_package_actual - -- name: assert upgrade package - assert: - that: - - upgrade_package is changed - - upgrade_package_actual.stdout_lines == [test_choco_package1 + "|0.1.0"] - -- name: upgrade package (idempotent) - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: latest - register: upgrade_package_again - -- name: assert upgrade package (idempotent) - assert: - that: - - not upgrade_package_again is changed - -- name: install prerelease package - win_chocolatey: - name: '{{ test_choco_package2 }}' - state: present - allow_prerelease: yes - register: install_prerelease - -- name: get result of install prerelease package - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package2|quote }} - register: install_prerelease_actual - -- name: assert install prerelease package - assert: - that: - - install_prerelease is changed - - install_prerelease_actual.stdout_lines == [test_choco_package2 + "|1.0.1-beta1"] - -- name: downgrade package - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: downgrade - version: 0.0.1 - -- name: upgrade all packages - win_chocolatey: - name: all - state: latest - register: all_latest - -- name: get result of upgrade all packages - win_command: choco.exe list --local-only --limit-output --exact {{ test_choco_package1|quote }} - register: all_latest_actual - -- name: assert upgrade all packages - assert: - that: - - all_latest is changed - - all_latest_actual.stdout_lines == [test_choco_package1 + "|0.1.0"] - -- name: install newer version of package - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - -- name: install older package with allow_multiple - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - allow_multiple: True - version: '0.0.1' - register: allow_multiple - -- name: get result of install older package with allow_multiple - win_command: choco.exe list --local-only --limit-output --all-versions - register: allow_multiple_actual - -- name: assert install older package with allow_multiple - assert: - that: - - allow_multiple is changed - - '"ansible|0.1.0" in allow_multiple_actual.stdout_lines' - - '"ansible|0.0.1" in allow_multiple_actual.stdout_lines' - -- name: pin 2 packages (check mode) - win_chocolatey: - name: - - '{{ test_choco_package1 }}' - - '{{ test_choco_package2 }}' - state: present - pinned: yes - register: pin_multiple_check - check_mode: True - -- name: get result of pin 2 packages (check mode) - win_command: choco.exe pin list --limit-output - register: pin_multiple_actual_check - -- name: assert pin 2 packages (check mode) - assert: - that: - - pin_multiple_check is changed - - pin_multiple_actual_check.stdout == "" - -- name: pin 2 packages - win_chocolatey: - name: - - '{{ test_choco_package1 }}' - - '{{ test_choco_package2 }}' - state: present - pinned: yes - register: pin_multiple - -- name: get result of pin 2 packages - win_command: choco.exe pin list --limit-output - register: pin_multiple_actual - -- name: assert pin 2 packages - assert: - that: - - pin_multiple is changed - - pin_multiple_actual.stdout_lines == ["ansible|0.1.0", "ansible-test|1.0.1-beta1"] - -- name: pin 2 packages (idempotent) - win_chocolatey: - name: - - '{{ test_choco_package1 }}' - - '{{ test_choco_package2 }}' - state: present - pinned: yes - register: pin_multiple_again - -- name: assert pin 2 packages (idempoent) - assert: - that: - - not pin_multiple_again is changed - -- name: pin specific older version - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - pinned: yes - version: '0.0.1' - register: pin_older - -- name: get result of pin specific older version - win_command: choco.exe pin list --limit-output - register: pin_older_actual - -- name: assert pin specific older version - assert: - that: - - pin_older is changed - - pin_older_actual.stdout_lines == ["ansible|0.1.0", "ansible|0.0.1", "ansible-test|1.0.1-beta1"] - -- name: unpin package at version - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: present - pinned: no - version: '0.1.0' - register: unpin_version - -- name: get result of unpin package at version - win_command: choco.exe pin list --limit-output - register: unpin_version_actual - -- name: assert unpin package at version - assert: - that: - - unpin_version is changed - - unpin_version_actual.stdout_lines == ["ansible|0.0.1", "ansible-test|1.0.1-beta1"] - -- name: unpin multiple packages without a version - win_chocolatey: - name: - - '{{ test_choco_package1 }}' - - '{{ test_choco_package2 }}' - state: present - pinned: no - register: unpin_multiple - -- name: get result of unpin multiple packages without a version - win_command: choco.exe pin list --limit-output - register: unpin_multiple_actual - -- name: assert unpin multiple packages without a version - assert: - that: - - unpin_multiple is changed - - unpin_multiple_actual.stdout == "" - -- name: uninstall specific version installed with allow_multiple - win_chocolatey: - name: '{{ test_choco_package1 }}' - state: absent - version: '0.0.1' - register: remove_multiple - -- name: get result of uninstall specific version installed with allow_multiple - win_command: choco.exe list --local-only --limit-output --all-versions - register: remove_multiple_actual - -- name: assert uninstall specific version installed with allow_multiple - assert: - that: - - remove_multiple is changed - - '"ansible|0.0.1" not in remove_multiple_actual.stdout_lines' - - '"ansible|0.1.0" in remove_multiple_actual.stdout_lines' diff --git a/test/integration/targets/win_chocolatey_config/aliases b/test/integration/targets/win_chocolatey_config/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_chocolatey_config/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_chocolatey_config/tasks/main.yml b/test/integration/targets/win_chocolatey_config/tasks/main.yml deleted file mode 100644 index 046ed78a1e..0000000000 --- a/test/integration/targets/win_chocolatey_config/tasks/main.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- name: ensure Chocolatey is installed - win_chocolatey: - name: chocolatey - state: present - -- name: create a copy of the existing config file - win_copy: - src: C:\ProgramData\chocolatey\config\chocolatey.config - dest: C:\ProgramData\chocolatey\config\chocolatey.config.ansiblebak - remote_src: yes - -- name: unset config setting as baseline - win_chocolatey_config: - name: cacheLocation - state: absent - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: restore config file - win_copy: - src: C:\ProgramData\chocolatey\config\chocolatey.config.ansiblebak - dest: C:\ProgramData\chocolatey\config\chocolatey.config - remote_src: yes - - - name: remove the backup config file - win_file: - path: C:\ProgramData\chocolatey\config\chocolatey.config.ansiblebak - state: absent diff --git a/test/integration/targets/win_chocolatey_config/tasks/tests.yml b/test/integration/targets/win_chocolatey_config/tasks/tests.yml deleted file mode 100644 index 3ed538e838..0000000000 --- a/test/integration/targets/win_chocolatey_config/tasks/tests.yml +++ /dev/null @@ -1,141 +0,0 @@ ---- -- name: fail if value is not set and state=present - win_chocolatey_config: - name: cacheLocation - state: present - register: fail_no_value - failed_when: 'fail_no_value.msg != "Get-AnsibleParam: Missing required argument: value"' - -- name: fail to set invalid config name - win_chocolatey_config: - name: fake - state: present - value: value - register: fail_invalid_name - failed_when: '"The Chocolatey config ''fake'' is not an existing config value, check the spelling. Valid config names: " not in fail_invalid_name.msg' - -- name: set config setting (check mode) - win_chocolatey_config: - name: cacheLocation - state: present - value: C:\temp - check_mode: yes - register: set_check - -- name: get actual config setting (check mode) - win_command: choco.exe config get -r --name cacheLocation - register: set_actual_check - -- name: assert set config setting (check mode) - assert: - that: - - set_check is changed - - set_actual_check.stdout_lines == [""] - -- name: set config setting - win_chocolatey_config: - name: cacheLocation - state: present - value: C:\temp - register: set - -- name: get actual config setting - win_command: choco.exe config get -r --name cacheLocation - register: set_actual - -- name: assert set config setting - assert: - that: - - set is changed - - set_actual.stdout_lines == ["C:\\temp"] - -- name: change config value (check mode) - win_chocolatey_config: - name: cacheLocation - state: present - value: C:\temp2 - check_mode: yes - register: change_check - -- name: get actual config setting (check mode) - win_command: choco.exe config get -r --name cacheLocation - register: change_actual_check - -- name: assert change config value (check mode) - assert: - that: - - change_check is changed - - change_actual_check.stdout_lines == ["C:\\temp"] - -- name: change config value - win_chocolatey_config: - name: cacheLocation - state: present - value: C:\temp2 - register: change - -- name: get actual config setting - win_command: choco.exe config get -r --name cacheLocation - register: change_actual - -- name: assert change config value - assert: - that: - - change is changed - - change_actual.stdout_lines == ["C:\\temp2"] - -- name: change config value (idempotent) - win_chocolatey_config: - name: cacheLocation - state: present - value: C:\temp2 - register: change_again - -- name: assert change config value (idempotent) - assert: - that: - - not change_again is changed - -- name: unset config value (check mode) - win_chocolatey_config: - name: cacheLocation - state: absent - check_mode: yes - register: unset_check - -- name: get actual config setting (check mode) - win_command: choco.exe config get -r --name cacheLocation - register: unset_actual_check - -- name: assert unset config value (check mode) - assert: - that: - - unset_check is changed - - unset_actual_check.stdout_lines == ["C:\\temp2"] - -- name: unset config value - win_chocolatey_config: - name: cacheLocation - state: absent - register: unset - -- name: get actual config setting - win_command: choco.exe config get -r --name cacheLocation - register: unset_actual - -- name: assert unset config value - assert: - that: - - unset is changed - - unset_actual.stdout_lines == [""] - -- name: unset config value (idempotent) - win_chocolatey_config: - name: cacheLocation - state: absent - register: unset_again - -- name: assert unset config value (idempotent) - assert: - that: - - not unset_again is changed diff --git a/test/integration/targets/win_chocolatey_facts/aliases b/test/integration/targets/win_chocolatey_facts/aliases deleted file mode 100644 index 4c08975b17..0000000000 --- a/test/integration/targets/win_chocolatey_facts/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group6 diff --git a/test/integration/targets/win_chocolatey_facts/tasks/main.yml b/test/integration/targets/win_chocolatey_facts/tasks/main.yml deleted file mode 100644 index 8f2b458034..0000000000 --- a/test/integration/targets/win_chocolatey_facts/tasks/main.yml +++ /dev/null @@ -1,69 +0,0 @@ ---- -- name: ensure Chocolatey is installed - win_chocolatey: - name: chocolatey - state: present - -- name: create test source - win_chocolatey_source: - name: test|repo # use a pipe as that's a delimiter with Chocolatey, test edge case - state: disabled - admin_only: yes - allow_self_service: yes - bypass_proxy: yes - priority: 9 - source: http://test-server/chocolatey - source_username: test-user - source_password: password - certificate: C:\temp\cert.pfx - - -- name: set a config value - win_chocolatey_config: - name: proxyUser - state: present - value: test-user - -- block: - - name: Gather facts from chocolatey - win_chocolatey_facts: - - always: - - name: remove test source - win_chocolatey_source: - name: test|repo - state: absent - - - name: unset config value - win_chocolatey_config: - name: proxyUser - state: absent - -- name: assert facts from chocolatey - assert: - that: - - ansible_chocolatey is not changed - - ansible_chocolatey.config.commandExecutionTimeoutSeconds == 2700 - - ansible_chocolatey.config.proxyBypassOnLocal == True - - ansible_chocolatey.config.proxyUser == 'test-user' - - ansible_chocolatey.feature.checksumFiles == true - - ansible_chocolatey.packages[0].package == 'chocolatey' - - ansible_chocolatey.packages[0].version is defined - - ansible_chocolatey.sources[0].admin_only == False - - ansible_chocolatey.sources[0].allow_self_service == False - - ansible_chocolatey.sources[0].bypass_proxy == False - - ansible_chocolatey.sources[0].certificate == None - - ansible_chocolatey.sources[0].disabled == False - - ansible_chocolatey.sources[0].name == 'chocolatey' - - ansible_chocolatey.sources[0].priority == 0 - - ansible_chocolatey.sources[0].source == 'https://chocolatey.org/api/v2/' - - ansible_chocolatey.sources[0].source_username == None - - ansible_chocolatey.sources[1].admin_only == True - - ansible_chocolatey.sources[1].allow_self_service == True - - ansible_chocolatey.sources[1].bypass_proxy == True - - ansible_chocolatey.sources[1].certificate == 'C:\\temp\\cert.pfx' - - ansible_chocolatey.sources[1].disabled == True - - ansible_chocolatey.sources[1].name == 'test|repo' - - ansible_chocolatey.sources[1].priority == 9 - - ansible_chocolatey.sources[1].source == 'http://test-server/chocolatey' - - ansible_chocolatey.sources[1].source_username == 'test-user' diff --git a/test/integration/targets/win_chocolatey_feature/aliases b/test/integration/targets/win_chocolatey_feature/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_chocolatey_feature/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py b/test/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py deleted file mode 100644 index 8dff044d1a..0000000000 --- a/test/integration/targets/win_chocolatey_feature/filter_plugins/choco_checksum_state.py +++ /dev/null @@ -1,14 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - - -def choco_checksum_state(value): - return [i for i in value if i.startswith("checksumFiles|")][0].split("|")[1] == "Enabled" - - -class FilterModule(object): - - def filters(self): - return { - 'choco_checksum_state': choco_checksum_state - } diff --git a/test/integration/targets/win_chocolatey_feature/tasks/main.yml b/test/integration/targets/win_chocolatey_feature/tasks/main.yml deleted file mode 100644 index c2100be01f..0000000000 --- a/test/integration/targets/win_chocolatey_feature/tasks/main.yml +++ /dev/null @@ -1,20 +0,0 @@ ---- -- name: ensure Chocolatey is installed - win_chocolatey: - name: chocolatey - state: present - -- name: ensure we start from a baseline for test feature - win_chocolatey_feature: - name: checksumFiles - state: disabled - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: set feature back to enabled - win_chocolatey_feature: - name: checksumFiles - state: enabled diff --git a/test/integration/targets/win_chocolatey_feature/tasks/tests.yml b/test/integration/targets/win_chocolatey_feature/tasks/tests.yml deleted file mode 100644 index 94bbb7a9ce..0000000000 --- a/test/integration/targets/win_chocolatey_feature/tasks/tests.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -- name: fail on invalid feature - win_chocolatey_feature: - name: failFeature - state: enabled - register: fail_res - failed_when: '"Invalid feature name ''failFeature'' specified, valid features are: " not in fail_res.msg' - -- name: enable disabled feature (check mode) - win_chocolatey_feature: - name: checksumFiles - state: enabled - check_mode: yes - register: enable_check - -- name: get actual state of feature (check mode) - win_command: choco.exe feature list -r - register: enable_actual_check - -- name: assert enable disabled feature (check mode) - assert: - that: - - enable_check is changed - - enable_actual_check.stdout_lines|choco_checksum_state == False - -- name: enable disabled feature - win_chocolatey_feature: - name: checksumFiles - state: enabled - register: enable - -- name: get actual state of feature - win_command: choco.exe feature list -r - register: enable_actual - -- name: assert enable disabled feature - assert: - that: - - enable is changed - - enable_actual.stdout_lines|choco_checksum_state == True - -- name: enable disabled feature (idempotent) - win_chocolatey_feature: - name: checksumFiles - state: enabled - register: enable_again - -- name: assert enable disabled feature (idempotent) - assert: - that: - - not enable_again is changed - -- name: disable enabled feature (check mode) - win_chocolatey_feature: - name: checksumFiles - state: disabled - check_mode: yes - register: disable_check - -- name: get actual state of feature (check mode) - win_command: choco.exe feature list -r - register: disable_actual_check - -- name: assert disable enabled feature (check mode) - assert: - that: - - disable_check is changed - - disable_actual_check.stdout_lines|choco_checksum_state == True - -- name: disable enabled feature - win_chocolatey_feature: - name: checksumFiles - state: disabled - register: disable - -- name: get actual state of feature - win_command: choco.exe feature list -r - register: disable_actual - -- name: assert disable enabled feature - assert: - that: - - disable is changed - - disable_actual.stdout_lines|choco_checksum_state == False - -- name: disable enabled feature (idempotent) - win_chocolatey_feature: - name: checksumFiles - state: disabled - register: disable_again - -- name: assert disable enabled feature (idempotent) - assert: - that: - - not disable_again is changed diff --git a/test/integration/targets/win_chocolatey_source/aliases b/test/integration/targets/win_chocolatey_source/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_chocolatey_source/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_chocolatey_source/defaults/main.yml b/test/integration/targets/win_chocolatey_source/defaults/main.yml deleted file mode 100644 index 0d8c67825e..0000000000 --- a/test/integration/targets/win_chocolatey_source/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -# use some weird chars to test out the parser -test_chocolatey_name: test'|"source 123^ diff --git a/test/integration/targets/win_chocolatey_source/library/choco_source.ps1 b/test/integration/targets/win_chocolatey_source/library/choco_source.ps1 deleted file mode 100644 index 5724c6f0c2..0000000000 --- a/test/integration/targets/win_chocolatey_source/library/choco_source.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -#!powershell - -# Copyright: (c) 2019, Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -#Requires -Module Ansible.ModuleUtils.Legacy - -$result = @{ - changed = $false - sources = [System.Collections.Generic.List`1[System.Collections.Hashtable]]@() -} - -$choco_app = Get-Command -Name choco.exe -CommandType Application -$choco_config_path = "$(Split-Path -Path (Split-Path -Path $choco_app.Path))\config\chocolatey.config" - -[xml]$choco_config = Get-Content -LiteralPath $choco_config_path -foreach ($xml_source in $choco_config.chocolatey.sources.GetEnumerator()) { - $source_username = $xml_source.Attributes.GetNamedItem("user") - if ($null -ne $source_username) { - $source_username = $source_username.Value - } - - # 0.9.9.9+ - $priority = $xml_source.Attributes.GetNamedItem("priority") - if ($null -ne $priority) { - $priority = [int]$priority.Value - } - - # 0.9.10+ - $certificate = $xml_source.Attributes.GetNamedItem("certificate") - if ($null -ne $certificate) { - $certificate = $certificate.Value - } - - # 0.10.4+ - $bypass_proxy = $xml_source.Attributes.GetNamedItem("bypassProxy") - if ($null -ne $bypass_proxy) { - $bypass_proxy = [System.Convert]::ToBoolean($bypass_proxy.Value) - } - $allow_self_service = $xml_source.Attributes.GetNamedItem("selfService") - if ($null -ne $allow_self_service) { - $allow_self_service = [System.Convert]::ToBoolean($allow_self_service.Value) - } - - # 0.10.8+ - $admin_only = $xml_source.Attributes.GetNamedItem("adminOnly") - if ($null -ne $admin_only) { - $admin_only = [System.Convert]::ToBoolean($admin_only.Value) - } - - $source_info = @{ - name = $xml_source.id - source = $xml_source.value - disabled = [System.Convert]::ToBoolean($xml_source.disabled) - source_username = $source_username - priority = $priority - certificate = $certificate - bypass_proxy = $bypass_proxy - allow_self_service = $allow_self_service - admin_only = $admin_only - } - $result.sources.Add($source_info) -} - -Exit-Json -obj $result diff --git a/test/integration/targets/win_chocolatey_source/tasks/main.yml b/test/integration/targets/win_chocolatey_source/tasks/main.yml deleted file mode 100644 index 0b57cc5554..0000000000 --- a/test/integration/targets/win_chocolatey_source/tasks/main.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -- name: ensure Chocolatey is installed - win_chocolatey: - name: chocolatey - state: present - -- name: remove original Chocolatey source at the start of the test - win_chocolatey_source: - name: Chocolatey - state: absent - -- name: ensure test Chocolatey source is removed - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: absent - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: ensure original Chocolatey source is re-added - win_chocolatey_source: - name: Chocolatey - source: https://chocolatey.org/api/v2/ - state: present - - - name: remove test Chocolatey source - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: absent diff --git a/test/integration/targets/win_chocolatey_source/tasks/tests.yml b/test/integration/targets/win_chocolatey_source/tasks/tests.yml deleted file mode 100644 index 0bf9763c42..0000000000 --- a/test/integration/targets/win_chocolatey_source/tasks/tests.yml +++ /dev/null @@ -1,373 +0,0 @@ ---- -- name: create source (check mode) - win_chocolatey_source: - name: chocolatey - source: https://chocolatey.org/api/v2/ - state: present - register: create_check - check_mode: yes - -- name: check if source exists (check mode) - choco_source: - register: create_actual_check - -- name: assert create source (check mode) - assert: - that: - - create_check is changed - - create_actual_check.sources == [] - -- name: create source - win_chocolatey_source: - name: chocolatey - source: https://chocolatey.org/api/v2/ - state: present - register: create - -- name: check if source exists - choco_source: - register: create_actual - -- name: assert create source - assert: - that: - - create is changed - - create_actual.sources|length == 1 - - create_actual.sources[0].name == 'chocolatey' - - create_actual.sources[0].source == 'https://chocolatey.org/api/v2/' - - create_actual.sources[0].disabled == False - - create_actual.sources[0].source_username == None - - create_actual.sources[0].priority == 0 - - create_actual.sources[0].certificate == None - - create_actual.sources[0].bypass_proxy == False - - create_actual.sources[0].allow_self_service == False - - create_actual.sources[0].admin_only == False - -- name: create source (idempotent) - win_chocolatey_source: - name: chocolatey - source: https://chocolatey.org/api/v2/ - state: present - register: create_again - -- name: assert create source (idempotent) - assert: - that: - - not create_again is changed - -- name: remove source (check mode) - win_chocolatey_source: - name: chocolatey - state: absent - register: remove_check - check_mode: yes - -- name: check if source is removed (check mode) - choco_source: - register: remove_actual_check - -- name: assert remove source (check mode) - assert: - that: - - remove_check is changed - - remove_actual_check.sources == create_actual.sources - -- name: remove source - win_chocolatey_source: - name: chocolatey - state: absent - register: remove - -- name: check if source is removed - choco_source: - register: remove_actual - -- name: assert remove source - assert: - that: - - remove is changed - - remove_actual.sources == [] - -- name: remove source (idempotent) - win_chocolatey_source: - name: chocolatey - state: absent - register: remove_again - -- name: assert remove source (idempotent) - assert: - that: - - not remove_again is changed - -- name: create a disabled service (check mode) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - source: C:\chocolatey repos - source_username: username - source_password: password - certificate: C:\cert.pfx - certificate_password: password - bypass_proxy: yes - priority: 1 - state: disabled - register: create_special_check - check_mode: yes - -- name: check if source is created (check mode) - choco_source: - register: create_special_actual_check - -- name: assert create a disabled service (check mode) - assert: - that: - - create_special_check is changed - - create_special_actual_check.sources == [] - -- name: create a disabled service - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - source: C:\chocolatey repos - source_username: username - source_password: password - certificate: C:\cert.pfx - certificate_password: password - bypass_proxy: yes - priority: 1 - state: disabled - register: create_special - -- name: check if source is created - choco_source: - register: create_special_actual - -- name: assert create a disabled service - assert: - that: - - create_special is changed - - create_special_actual.sources|length == 1 - - create_special_actual.sources[0].name == test_chocolatey_name - - create_special_actual.sources[0].source == 'C:\\chocolatey repos' - - create_special_actual.sources[0].disabled == True - - create_special_actual.sources[0].source_username == 'username' - - create_special_actual.sources[0].priority == 1 - - create_special_actual.sources[0].certificate == 'C:\\cert.pfx' - - create_special_actual.sources[0].bypass_proxy == True - - create_special_actual.sources[0].allow_self_service == False - - create_special_actual.sources[0].admin_only == False - -- name: create a disabled service pass always update - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - source: C:\chocolatey repos - source_username: username - source_password: password - certificate: C:\cert.pfx - certificate_password: password - bypass_proxy: yes - priority: 1 - state: disabled - register: create_special_pass_always - -- name: assert create a disabled service pass always update - assert: - that: - - create_special_pass_always is changed - -- name: create a disabled service (idempotent) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - source: C:\chocolatey repos - source_username: username - source_password: password - certificate: C:\cert.pfx - certificate_password: password - bypass_proxy: yes - priority: 1 - state: disabled - update_password: on_create - register: create_special_again - -- name: assert create a disabled service (idempotent) - assert: - that: - - not create_special_again is changed - -- name: edit an existing source (check mode) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - source: C:\chocolatey repos2 - source_username: username2 - source_password: password2 - certificate: C:\cert2.pfx - priority: '5' - state: present - update_password: on_create - admin_only: yes - allow_self_service: yes - register: modify_source_check - check_mode: yes - -- name: check if source is changed (check mode) - choco_source: - register: modify_source_check_actual - -- name: assert edit an existing source (check mode) - assert: - that: - - modify_source_check is changed - - modify_source_check_actual.sources == create_special_actual.sources - -- name: edit an existing source - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - source: C:\chocolatey repos2 - source_username: username2 - source_password: password2 - certificate: C:\cert2.pfx - priority: '5' - state: present - update_password: on_create - admin_only: yes - allow_self_service: yes - register: modify_source - -- name: check if source is changed - choco_source: - register: modify_source_actual - -- name: assert edit an existing source - assert: - that: - - modify_source is changed - - modify_source_actual.sources[0].name == test_chocolatey_name - - modify_source_actual.sources[0].source == 'C:\\chocolatey repos2' - - modify_source_actual.sources[0].disabled == False - - modify_source_actual.sources[0].source_username == 'username2' - - modify_source_actual.sources[0].priority == 5 - - modify_source_actual.sources[0].certificate == 'C:\\cert2.pfx' - - modify_source_actual.sources[0].bypass_proxy == False - - modify_source_actual.sources[0].allow_self_service == True - - modify_source_actual.sources[0].admin_only == True - -- name: edit an existing source (idempotent) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - source: C:\chocolatey repos2 - source_username: username2 - source_password: password2 - certificate: C:\cert2.pfx - priority: '5' - state: present - update_password: on_create - admin_only: yes - allow_self_service: yes - register: modify_source_again - -- name: assert edit an existing source (idempotent) - assert: - that: - - not modify_source_again is changed - -- name: disable source (check mode) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: disabled - register: disable_source_check - check_mode: True - -- name: get result of disable source (check mode) - choco_source: - register: disable_source_actual_check - -- name: assert disable source (check mode) - assert: - that: - - disable_source_check is changed - - disable_source_actual_check.sources == modify_source_actual.sources - -- name: disable source - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: disabled - register: disable_source - -- name: get result of disable source - choco_source: - register: disable_source_actual - -- name: assert disable source - assert: - that: - - disable_source is changed - - disable_source_actual.sources[0].name == test_chocolatey_name - - disable_source_actual.sources[0].source == 'C:\\chocolatey repos2' - - disable_source_actual.sources[0].disabled == True - - disable_source_actual.sources[0].source_username == 'username2' - - disable_source_actual.sources[0].priority == 5 - - disable_source_actual.sources[0].certificate == 'C:\\cert2.pfx' - - disable_source_actual.sources[0].bypass_proxy == False - - disable_source_actual.sources[0].allow_self_service == True - - disable_source_actual.sources[0].admin_only == True - -- name: disable source (idempotent) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: disabled - register: disable_source_again - -- name: assert disable source (idempotent) - assert: - that: - - not disable_source_again is changed - -- name: enable source (check mode) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: present - register: enable_source_check - check_mode: True - -- name: get result of enable source (check mode) - choco_source: - register: enable_source_actual_check - -- name: assert enable source (check mode) - assert: - that: - - enable_source_check is changed - - enable_source_actual_check.sources == disable_source_actual.sources - -- name: enable source - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: present - register: enable_source - -- name: get result of enable source - choco_source: - register: enable_source_actual - -- name: assert enable source - assert: - that: - - enable_source is changed - - enable_source_actual.sources[0].name == test_chocolatey_name - - enable_source_actual.sources[0].source == 'C:\\chocolatey repos2' - - enable_source_actual.sources[0].disabled == False - - enable_source_actual.sources[0].source_username == 'username2' - - enable_source_actual.sources[0].priority == 5 - - enable_source_actual.sources[0].certificate == 'C:\\cert2.pfx' - - enable_source_actual.sources[0].bypass_proxy == False - - enable_source_actual.sources[0].allow_self_service == True - - enable_source_actual.sources[0].admin_only == True - -- name: enable source (idempotent) - win_chocolatey_source: - name: '{{ test_chocolatey_name }}' - state: present - register: enable_source_again - -- name: assert enable source (idempotent) - assert: - that: - - not enable_source_again is changed diff --git a/test/integration/targets/win_computer_description/aliases b/test/integration/targets/win_computer_description/aliases deleted file mode 100644 index eca3c7641a..0000000000 --- a/test/integration/targets/win_computer_description/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group3 -skip/windows/2008 diff --git a/test/integration/targets/win_computer_description/defaults/main.yml b/test/integration/targets/win_computer_description/defaults/main.yml deleted file mode 100644 index 166a5248c2..0000000000 --- a/test/integration/targets/win_computer_description/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -test_description: This is my computer -test_organization: iddqd -test_owner: BFG -test_description2: This is not my computer -test_organization2: idkfa -test_owner2: CACODEMON diff --git a/test/integration/targets/win_computer_description/tasks/main.yml b/test/integration/targets/win_computer_description/tasks/main.yml deleted file mode 100644 index 95e5deda8d..0000000000 --- a/test/integration/targets/win_computer_description/tasks/main.yml +++ /dev/null @@ -1,200 +0,0 @@ ---- -- name: Blank out description, organization and owner - win_computer_description: - description: "" - organization: "" - owner: "" - register: blank_set - check_mode: no - -- name: Change description, organization and owner in check mode - win_computer_description: - description: "{{ test_description }}" - organization: "{{ test_organization }}" - owner: "{{ test_owner }}" - register: change1_checkmode - check_mode: yes - -- name: Change description, organization and owner - win_computer_description: - description: "{{ test_description }}" - organization: "{{ test_organization }}" - owner: "{{ test_owner }}" - register: change1_set - check_mode: no - -- name: Change description, organization and owner 2nd time, there should be no change happening - win_computer_description: - description: "{{ test_description }}" - organization: "{{ test_organization }}" - owner: "{{ test_owner }}" - register: change1_set2 - check_mode: no - -- name: Assert that the above tasks returned the expected results - assert: - that: - - change1_checkmode is changed - - change1_set is changed - - change1_set2 is not changed - -- name: Get machine description - win_shell: (Get-CimInstance -class "Win32_OperatingSystem").description - register: description1_changed - -- name: Get organization name - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion - name: RegisteredOrganization - register: organization1_changed - -- name: Get owner - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion - name: RegisteredOwner - register: owner1_changed - -- name: Assert that retrieved values are equal to the values provided in the variables - assert: - that: - - description1_changed.stdout == "{{ test_description }}\r\n" - - organization1_changed.value == "{{ test_organization }}" - - owner1_changed.value == "{{ test_owner }}" - -- name: Change description and owner only in check mode - win_computer_description: - description: "{{ test_description2 }}" - owner: "{{ test_owner2 }}" - register: change2_checkmode - check_mode: yes - -- name: Change description and owner only - win_computer_description: - description: "{{ test_description2 }}" - owner: "{{ test_owner2 }}" - register: change2_set - check_mode: no - -- name: Change description and owner only 2nd time, there should be no change happening - win_computer_description: - description: "{{ test_description2 }}" - owner: "{{ test_owner2 }}" - register: change2_set2 - check_mode: no - -- name: Assert that the above tasks returned the expected results - assert: - that: - - change2_checkmode is changed - - change2_set is changed - - change2_set2 is not changed - -- name: Get machine description - win_shell: (Get-CimInstance -class "Win32_OperatingSystem").description - register: description2_changed - -- name: Get organization name - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion - name: RegisteredOrganization - register: organization2_changed - -- name: Get owner - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion - name: RegisteredOwner - register: owner2_changed - -- name: Assert that retrieved values are equal to the desired values - assert: - that: - - description2_changed.stdout == "{{ test_description2 }}\r\n" - - organization2_changed.value == "{{ test_organization }}" - - owner2_changed.value == "{{ test_owner2 }}" - -- name: Change organization only in check mode - win_computer_description: - organization: "{{ test_organization2 }}" - register: change3_checkmode - check_mode: yes - -- name: Change organization only in check mode - win_computer_description: - organization: "{{ test_organization2 }}" - register: change3_set - check_mode: no - -- name: Change organization only in check mode - win_computer_description: - organization: "{{ test_organization2 }}" - register: change3_set2 - check_mode: no - -- name: Assert that the above tasks returned the expected results - assert: - that: - - change3_checkmode is changed - - change3_set is changed - - change3_set2 is not changed - -- name: Get machine description - win_shell: (Get-CimInstance -class "Win32_OperatingSystem").description - register: description3_changed - -- name: Get organization name - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion - name: RegisteredOrganization - register: organization3_changed - -- name: Get owner - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion - name: RegisteredOwner - register: owner3_changed - -- name: Assert that retrieved values are equal to the desired values - assert: - that: - - description3_changed.stdout == "{{ test_description2 }}\r\n" - - organization3_changed.value == "{{ test_organization2 }}" - - owner3_changed.value == "{{ test_owner2 }}" - -- name: Try to apply the same values again in check mode, there should be no change - win_computer_description: - description: "{{ test_description2 }}" - organization: "{{ test_organization2 }}" - owner: "{{ test_owner2 }}" - register: change4_checkmode - check_mode: yes - -- name: Try to apply the same values again, there should be no change - win_computer_description: - description: "{{ test_description2 }}" - organization: "{{ test_organization2 }}" - owner: "{{ test_owner2 }}" - register: change4_set - check_mode: no - -- name: Try to apply the same values again for 2nd time, there should be no change - win_computer_description: - description: "{{ test_description2 }}" - organization: "{{ test_organization2 }}" - owner: "{{ test_owner2 }}" - register: change4_set2 - check_mode: no - -- name: Assert that the above tasks returned the expected results - assert: - that: - - change4_checkmode is not changed - - change4_set is not changed - - change4_set2 is not changed - -- name: Blank the test values - win_computer_description: - description: '' - organization: '' - owner: '' - register: blank2_set - check_mode: no diff --git a/test/integration/targets/win_credential/aliases b/test/integration/targets/win_credential/aliases deleted file mode 100644 index 6036e173f1..0000000000 --- a/test/integration/targets/win_credential/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group7 diff --git a/test/integration/targets/win_credential/defaults/main.yml b/test/integration/targets/win_credential/defaults/main.yml deleted file mode 100644 index c6dffc0a0f..0000000000 --- a/test/integration/targets/win_credential/defaults/main.yml +++ /dev/null @@ -1,19 +0,0 @@ -# The certificate in files/cert.pfx was generated with the following commands -# -# cat > client.cnf <<EOL -# [ssl_client] -# basicConstraints = CA:FALSE -# nsCertType = client -# keyUsage = digitalSignature, keyEncipherment -# extendedKeyUsage = clientAuth -# EOL -# -# openssl genrsa -aes256 -passout pass:password1 -out cert.key 2048 -# openssl req -new -subj '/CN=ansible.domain.com' -key cert.key -out cert.req -passin pass:password1 -# openssl x509 -sha256 -req -in cert.req -days 24855 -signkey cert.key -out cert.crt -extensions ssl_client -extfile client.cnf -passin pass:password1 -# openssl pkcs12 -export -in cert.crt -inkey cert.key -out cert.pfx -passin pass:password1 -passout pass:password1 ---- -test_credential_dir: '{{ win_output_dir }}\win_credential_manager' -test_hostname: ansible.domain.com -key_password: password1 -cert_thumbprint: 56841AAFDD19D7DF474BDA24D01D88BD8025A00A diff --git a/test/integration/targets/win_credential/files/cert.pfx b/test/integration/targets/win_credential/files/cert.pfx Binary files differdeleted file mode 100644 index 9cffb6696f..0000000000 --- a/test/integration/targets/win_credential/files/cert.pfx +++ /dev/null diff --git a/test/integration/targets/win_credential/library/test_cred_facts.ps1 b/test/integration/targets/win_credential/library/test_cred_facts.ps1 deleted file mode 100644 index d5db8d275c..0000000000 --- a/test/integration/targets/win_credential/library/test_cred_facts.ps1 +++ /dev/null @@ -1,498 +0,0 @@ -#!powershell - -# Copyright: (c) 2018, Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -#AnsibleRequires -CSharpUtil Ansible.Basic -#Requires -Module Ansible.ModuleUtils.AddType - -$spec = @{ - options = @{ - name = @{ type = "str"; required = $true } - type = @{ type = "str"; required = $true; choices = @("domain_password", "domain_certificate", "generic_password", "generic_certificate") } - } - supports_check_mode = $true -} - -$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec) - -$name = $module.Params.name -$type = $module.Params.type - -Add-CSharpType -AnsibleModule $module -References @' -using Microsoft.Win32.SafeHandles; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.ConstrainedExecution; -using System.Runtime.InteropServices; -using System.Text; - -namespace Ansible.CredentialManager -{ - internal class NativeHelpers - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class CREDENTIAL - { - public CredentialFlags Flags; - public CredentialType Type; - [MarshalAs(UnmanagedType.LPWStr)] public string TargetName; - [MarshalAs(UnmanagedType.LPWStr)] public string Comment; - public FILETIME LastWritten; - public UInt32 CredentialBlobSize; - public IntPtr CredentialBlob; - public CredentialPersist Persist; - public UInt32 AttributeCount; - public IntPtr Attributes; - [MarshalAs(UnmanagedType.LPWStr)] public string TargetAlias; - [MarshalAs(UnmanagedType.LPWStr)] public string UserName; - - public static explicit operator Credential(CREDENTIAL v) - { - byte[] secret = new byte[(int)v.CredentialBlobSize]; - if (v.CredentialBlob != IntPtr.Zero) - Marshal.Copy(v.CredentialBlob, secret, 0, secret.Length); - - List<CredentialAttribute> attributes = new List<CredentialAttribute>(); - if (v.AttributeCount > 0) - { - CREDENTIAL_ATTRIBUTE[] rawAttributes = new CREDENTIAL_ATTRIBUTE[v.AttributeCount]; - Credential.PtrToStructureArray(rawAttributes, v.Attributes); - attributes = rawAttributes.Select(x => (CredentialAttribute)x).ToList(); - } - - string userName = v.UserName; - if (v.Type == CredentialType.DomainCertificate || v.Type == CredentialType.GenericCertificate) - userName = Credential.UnmarshalCertificateCredential(userName); - - return new Credential - { - Type = v.Type, - TargetName = v.TargetName, - Comment = v.Comment, - LastWritten = (DateTimeOffset)v.LastWritten, - Secret = secret, - Persist = v.Persist, - Attributes = attributes, - TargetAlias = v.TargetAlias, - UserName = userName, - Loaded = true, - }; - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct CREDENTIAL_ATTRIBUTE - { - [MarshalAs(UnmanagedType.LPWStr)] public string Keyword; - public UInt32 Flags; // Set to 0 and is reserved - public UInt32 ValueSize; - public IntPtr Value; - - public static explicit operator CredentialAttribute(CREDENTIAL_ATTRIBUTE v) - { - byte[] value = new byte[v.ValueSize]; - Marshal.Copy(v.Value, value, 0, (int)v.ValueSize); - - return new CredentialAttribute - { - Keyword = v.Keyword, - Flags = v.Flags, - Value = value, - }; - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct FILETIME - { - internal UInt32 dwLowDateTime; - internal UInt32 dwHighDateTime; - - public static implicit operator long(FILETIME v) { return ((long)v.dwHighDateTime << 32) + v.dwLowDateTime; } - public static explicit operator DateTimeOffset(FILETIME v) { return DateTimeOffset.FromFileTime(v); } - public static explicit operator FILETIME(DateTimeOffset v) - { - return new FILETIME() - { - dwLowDateTime = (UInt32)v.ToFileTime(), - dwHighDateTime = ((UInt32)v.ToFileTime() >> 32), - }; - } - } - - [Flags] - public enum CredentialCreateFlags : uint - { - PreserveCredentialBlob = 1, - } - - [Flags] - public enum CredentialFlags - { - None = 0, - PromptNow = 2, - UsernameTarget = 4, - } - - public enum CredMarshalType : uint - { - CertCredential = 1, - UsernameTargetCredential, - BinaryBlobCredential, - UsernameForPackedCredential, - BinaryBlobForSystem, - } - } - - internal class NativeMethods - { - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool CredDeleteW( - [MarshalAs(UnmanagedType.LPWStr)] string TargetName, - CredentialType Type, - UInt32 Flags); - - [DllImport("advapi32.dll")] - public static extern void CredFree( - IntPtr Buffer); - - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool CredMarshalCredentialW( - NativeHelpers.CredMarshalType CredType, - SafeMemoryBuffer Credential, - out SafeCredentialBuffer MarshaledCredential); - - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool CredReadW( - [MarshalAs(UnmanagedType.LPWStr)] string TargetName, - CredentialType Type, - UInt32 Flags, - out SafeCredentialBuffer Credential); - - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool CredUnmarshalCredentialW( - [MarshalAs(UnmanagedType.LPWStr)] string MarshaledCredential, - out NativeHelpers.CredMarshalType CredType, - out SafeCredentialBuffer Credential); - - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool CredWriteW( - NativeHelpers.CREDENTIAL Credential, - NativeHelpers.CredentialCreateFlags Flags); - } - - internal class SafeCredentialBuffer : SafeHandleZeroOrMinusOneIsInvalid - { - public SafeCredentialBuffer() : base(true) { } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - protected override bool ReleaseHandle() - { - NativeMethods.CredFree(handle); - return true; - } - } - - internal class SafeMemoryBuffer : SafeHandleZeroOrMinusOneIsInvalid - { - public SafeMemoryBuffer() : base(true) { } - public SafeMemoryBuffer(int cb) : base(true) - { - base.SetHandle(Marshal.AllocHGlobal(cb)); - } - public SafeMemoryBuffer(IntPtr handle) : base(true) - { - base.SetHandle(handle); - } - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - protected override bool ReleaseHandle() - { - Marshal.FreeHGlobal(handle); - return true; - } - } - - public class Win32Exception : System.ComponentModel.Win32Exception - { - private string _exception_msg; - public Win32Exception(string message) : this(Marshal.GetLastWin32Error(), message) { } - public Win32Exception(int errorCode, string message) : base(errorCode) - { - _exception_msg = String.Format("{0} - {1} (Win32 Error Code {2}: 0x{3})", message, base.Message, errorCode, errorCode.ToString("X8")); - } - public override string Message { get { return _exception_msg; } } - public static explicit operator Win32Exception(string message) { return new Win32Exception(message); } - } - - public enum CredentialPersist - { - Session = 1, - LocalMachine = 2, - Enterprise = 3, - } - - public enum CredentialType - { - Generic = 1, - DomainPassword = 2, - DomainCertificate = 3, - DomainVisiblePassword = 4, - GenericCertificate = 5, - DomainExtended = 6, - Maximum = 7, - MaximumEx = 1007, - } - - public class CredentialAttribute - { - public string Keyword; - public UInt32 Flags; - public byte[] Value; - } - - public class Credential - { - public CredentialType Type; - public string TargetName; - public string Comment; - public DateTimeOffset LastWritten; - public byte[] Secret; - public CredentialPersist Persist; - public List<CredentialAttribute> Attributes = new List<CredentialAttribute>(); - public string TargetAlias; - public string UserName; - - // Used to track whether the credential has been loaded into the store or not - public bool Loaded { get; internal set; } - - public void Delete() - { - if (!Loaded) - return; - - if (!NativeMethods.CredDeleteW(TargetName, Type, 0)) - throw new Win32Exception(String.Format("CredDeleteW({0}) failed", TargetName)); - Loaded = false; - } - - public void Write(bool preserveExisting) - { - string userName = UserName; - // Convert the certificate thumbprint to the string expected - if (Type == CredentialType.DomainCertificate || Type == CredentialType.GenericCertificate) - userName = Credential.MarshalCertificateCredential(userName); - - NativeHelpers.CREDENTIAL credential = new NativeHelpers.CREDENTIAL - { - Flags = NativeHelpers.CredentialFlags.None, - Type = Type, - TargetName = TargetName, - Comment = Comment, - LastWritten = new NativeHelpers.FILETIME(), - CredentialBlobSize = (UInt32)(Secret == null ? 0 : Secret.Length), - CredentialBlob = IntPtr.Zero, // Must be allocated and freed outside of this to ensure no memory leaks - Persist = Persist, - AttributeCount = (UInt32)(Attributes.Count), - Attributes = IntPtr.Zero, // Attributes must be allocated and freed outside of this to ensure no memory leaks - TargetAlias = TargetAlias, - UserName = userName, - }; - - using (SafeMemoryBuffer credentialBlob = new SafeMemoryBuffer((int)credential.CredentialBlobSize)) - { - if (Secret != null) - Marshal.Copy(Secret, 0, credentialBlob.DangerousGetHandle(), Secret.Length); - credential.CredentialBlob = credentialBlob.DangerousGetHandle(); - - // Store the CREDENTIAL_ATTRIBUTE value in a safe memory buffer and make sure we dispose in all cases - List<SafeMemoryBuffer> attributeBuffers = new List<SafeMemoryBuffer>(); - try - { - int attributeLength = Attributes.Sum(a => Marshal.SizeOf(typeof(NativeHelpers.CREDENTIAL_ATTRIBUTE))); - byte[] attributeBytes = new byte[attributeLength]; - int offset = 0; - foreach (CredentialAttribute attribute in Attributes) - { - SafeMemoryBuffer attributeBuffer = new SafeMemoryBuffer(attribute.Value.Length); - attributeBuffers.Add(attributeBuffer); - if (attribute.Value != null) - Marshal.Copy(attribute.Value, 0, attributeBuffer.DangerousGetHandle(), attribute.Value.Length); - - NativeHelpers.CREDENTIAL_ATTRIBUTE credentialAttribute = new NativeHelpers.CREDENTIAL_ATTRIBUTE - { - Keyword = attribute.Keyword, - Flags = attribute.Flags, - ValueSize = (UInt32)(attribute.Value == null ? 0 : attribute.Value.Length), - Value = attributeBuffer.DangerousGetHandle(), - }; - int attributeStructLength = Marshal.SizeOf(typeof(NativeHelpers.CREDENTIAL_ATTRIBUTE)); - - byte[] attrBytes = new byte[attributeStructLength]; - using (SafeMemoryBuffer tempBuffer = new SafeMemoryBuffer(attributeStructLength)) - { - Marshal.StructureToPtr(credentialAttribute, tempBuffer.DangerousGetHandle(), false); - Marshal.Copy(tempBuffer.DangerousGetHandle(), attrBytes, 0, attributeStructLength); - } - Buffer.BlockCopy(attrBytes, 0, attributeBytes, offset, attributeStructLength); - offset += attributeStructLength; - } - - using (SafeMemoryBuffer attributes = new SafeMemoryBuffer(attributeBytes.Length)) - { - if (attributeBytes.Length != 0) - Marshal.Copy(attributeBytes, 0, attributes.DangerousGetHandle(), attributeBytes.Length); - credential.Attributes = attributes.DangerousGetHandle(); - - NativeHelpers.CredentialCreateFlags createFlags = 0; - if (preserveExisting) - createFlags |= NativeHelpers.CredentialCreateFlags.PreserveCredentialBlob; - - if (!NativeMethods.CredWriteW(credential, createFlags)) - throw new Win32Exception(String.Format("CredWriteW({0}) failed", TargetName)); - } - } - finally - { - foreach (SafeMemoryBuffer attributeBuffer in attributeBuffers) - attributeBuffer.Dispose(); - } - } - Loaded = true; - } - - public static Credential GetCredential(string target, CredentialType type) - { - SafeCredentialBuffer buffer; - if (!NativeMethods.CredReadW(target, type, 0, out buffer)) - { - int lastErr = Marshal.GetLastWin32Error(); - - // Not running with CredSSP or Become so cannot manage the user's credentials - if (lastErr == 0x00000520) // ERROR_NO_SUCH_LOGON_SESSION - throw new InvalidOperationException("Failed to access the user's credential store, run the module with become or CredSSP"); - else if (lastErr == 0x00000490) // ERROR_NOT_FOUND - return null; - throw new Win32Exception(lastErr, "CredEnumerateW() failed"); - } - - using (buffer) - { - NativeHelpers.CREDENTIAL credential = (NativeHelpers.CREDENTIAL)Marshal.PtrToStructure( - buffer.DangerousGetHandle(), typeof(NativeHelpers.CREDENTIAL)); - return (Credential)credential; - } - } - - public static string MarshalCertificateCredential(string thumbprint) - { - // CredWriteW requires the UserName field to be the value of CredMarshalCredentialW() when writting a - // certificate auth. This converts the UserName property to the format required. - - // While CERT_CREDENTIAL_INFO is the correct structure, we manually marshal the data in order to - // support different cert hash lengths in the future. - // https://docs.microsoft.com/en-us/windows/desktop/api/wincred/ns-wincred-_cert_credential_info - int hexLength = thumbprint.Length; - byte[] credInfo = new byte[sizeof(UInt32) + (hexLength / 2)]; - - // First field is cbSize which is a UInt32 value denoting the size of the total structure - Array.Copy(BitConverter.GetBytes((UInt32)credInfo.Length), credInfo, sizeof(UInt32)); - - // Now copy the byte representation of the thumbprint to the rest of the struct bytes - for (int i = 0; i < hexLength; i += 2) - credInfo[sizeof(UInt32) + (i / 2)] = Convert.ToByte(thumbprint.Substring(i, 2), 16); - - IntPtr pCredInfo = Marshal.AllocHGlobal(credInfo.Length); - Marshal.Copy(credInfo, 0, pCredInfo, credInfo.Length); - SafeMemoryBuffer pCredential = new SafeMemoryBuffer(pCredInfo); - - NativeHelpers.CredMarshalType marshalType = NativeHelpers.CredMarshalType.CertCredential; - using (pCredential) - { - SafeCredentialBuffer marshaledCredential; - if (!NativeMethods.CredMarshalCredentialW(marshalType, pCredential, out marshaledCredential)) - throw new Win32Exception("CredMarshalCredentialW() failed"); - using (marshaledCredential) - return Marshal.PtrToStringUni(marshaledCredential.DangerousGetHandle()); - } - } - - public static string UnmarshalCertificateCredential(string value) - { - NativeHelpers.CredMarshalType credType; - SafeCredentialBuffer pCredInfo; - if (!NativeMethods.CredUnmarshalCredentialW(value, out credType, out pCredInfo)) - throw new Win32Exception("CredUnmarshalCredentialW() failed"); - - using (pCredInfo) - { - if (credType != NativeHelpers.CredMarshalType.CertCredential) - throw new InvalidOperationException(String.Format("Expected unmarshalled cred type of CertCredential, received {0}", credType)); - - byte[] structSizeBytes = new byte[sizeof(UInt32)]; - Marshal.Copy(pCredInfo.DangerousGetHandle(), structSizeBytes, 0, sizeof(UInt32)); - UInt32 structSize = BitConverter.ToUInt32(structSizeBytes, 0); - - byte[] certInfoBytes = new byte[structSize]; - Marshal.Copy(pCredInfo.DangerousGetHandle(), certInfoBytes, 0, certInfoBytes.Length); - - StringBuilder hex = new StringBuilder((certInfoBytes.Length - sizeof(UInt32)) * 2); - for (int i = 4; i < certInfoBytes.Length; i++) - hex.AppendFormat("{0:x2}", certInfoBytes[i]); - - return hex.ToString().ToUpperInvariant(); - } - } - - internal static void PtrToStructureArray<T>(T[] array, IntPtr ptr) - { - IntPtr ptrOffset = ptr; - for (int i = 0; i < array.Length; i++, ptrOffset = IntPtr.Add(ptrOffset, Marshal.SizeOf(typeof(T)))) - array[i] = (T)Marshal.PtrToStructure(ptrOffset, typeof(T)); - } - } -} -'@ - -$type = switch ($type) { - "domain_password" { [Ansible.CredentialManager.CredentialType]::DomainPassword } - "domain_certificate" { [Ansible.CredentialManager.CredentialType]::DomainCertificate } - "generic_password" { [Ansible.CredentialManager.CredentialType]::Generic } - "generic_certificate" { [Ansible.CredentialManager.CredentialType]::GenericCertificate } -} - -$credential = [Ansible.CredentialManager.Credential]::GetCredential($name, $type) -if ($null -ne $credential) { - $module.Result.exists = $true - $module.Result.alias = $credential.TargetAlias - $module.Result.attributes = [System.Collections.ArrayList]@() - $module.Result.comment = $credential.Comment - $module.Result.name = $credential.TargetName - $module.Result.persistence = $credential.Persist.ToString() - $module.Result.type = $credential.Type.ToString() - $module.Result.username = $credential.UserName - - if ($null -ne $credential.Secret) { - $module.Result.secret = [System.Convert]::ToBase64String($credential.Secret) - } else { - $module.Result.secret = $null - } - - foreach ($attribute in $credential.Attributes) { - $attribute_info = @{ - name = $attribute.Keyword - } - if ($null -ne $attribute.Value) { - $attribute_info.data = [System.Convert]::ToBase64String($attribute.Value) - } else { - $attribute_info.data = $null - } - $module.Result.attributes.Add($attribute_info) > $null - } -} else { - $module.Result.exists = $false -} - -$module.ExitJson() - diff --git a/test/integration/targets/win_credential/meta/main.yml b/test/integration/targets/win_credential/meta/main.yml deleted file mode 100644 index bdea853d75..0000000000 --- a/test/integration/targets/win_credential/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- prepare_win_tests diff --git a/test/integration/targets/win_credential/tasks/main.yml b/test/integration/targets/win_credential/tasks/main.yml deleted file mode 100644 index 67f6b946f4..0000000000 --- a/test/integration/targets/win_credential/tasks/main.yml +++ /dev/null @@ -1,64 +0,0 @@ ---- -- name: ensure test dir is present - win_file: - path: '{{ test_credential_dir }}' - state: directory - -- name: copy the pfx certificate - win_copy: - src: cert.pfx - dest: '{{ test_credential_dir }}\cert.pfx' - -- name: import the pfx into the personal store - win_certificate_store: - path: '{{ test_credential_dir }}\cert.pfx' - state: present - store_location: CurrentUser - store_name: My - password: '{{ key_password }}' - vars: &become_vars - ansible_become: True - ansible_become_method: runas - ansible_become_user: '{{ ansible_user }}' - ansible_become_pass: '{{ ansible_password }}' - -- name: ensure test credentials are removed before testing - win_credential: - name: '{{ test_hostname }}' - type: '{{ item }}' - state: absent - vars: *become_vars - with_items: - - domain_password - - domain_certificate - - generic_password - - generic_certificate - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: remove the pfx from the personal store - win_certificate_store: - state: absent - thumbprint: '{{ cert_thumbprint }}' - store_location: CurrentUser - store_name: My - - - name: remove test credentials - win_credential: - name: '{{ test_hostname }}' - type: '{{ item }}' - state: absent - vars: *become_vars - with_items: - - domain_password - - domain_certificate - - generic_password - - generic_certificate - - - name: remove test dir - win_file: - path: '{{ test_credential_dir }}' - state: absent diff --git a/test/integration/targets/win_credential/tasks/tests.yml b/test/integration/targets/win_credential/tasks/tests.yml deleted file mode 100644 index cec2cf0236..0000000000 --- a/test/integration/targets/win_credential/tasks/tests.yml +++ /dev/null @@ -1,638 +0,0 @@ ---- -- name: fail to run the module without become - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username - secret: password - state: present - register: fail_no_become - failed_when: '"Failed to access the user''s credential store, run the module with become" not in fail_no_become.msg' - -- name: create domain user credential (check mode) - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username - secret: password - state: present - register: domain_user_check - check_mode: True - vars: &become_vars - ansible_become: True - ansible_become_method: runas - ansible_become_user: '{{ ansible_user }}' - ansible_become_pass: '{{ ansible_password }}' - -- name: get result of create domain user credential (check mode) - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: domain_user_actual_check - vars: *become_vars - -- name: asset create domain user credential (check mode) - assert: - that: - - domain_user_check is changed - - not domain_user_actual_check.exists - -- name: create domain user credential - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username - secret: password - state: present - register: domain_user - vars: *become_vars - -- name: get result of create domain user credential - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: domain_user_actual - vars: *become_vars - -- name: asset create domain user credential - assert: - that: - - domain_user is changed - - domain_user_actual.exists - - domain_user_actual.alias == None - - domain_user_actual.attributes == [] - - domain_user_actual.comment == None - - domain_user_actual.name == test_hostname - - domain_user_actual.persistence == "LocalMachine" - - domain_user_actual.secret == "" - - domain_user_actual.type == "DomainPassword" - - domain_user_actual.username == "DOMAIN\\username" - -- name: create domain user credential again always update - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username - secret: password - state: present - register: domain_user_again_always - vars: *become_vars - -- name: create domain user credential again on_create - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username - secret: password - update_secret: on_create - state: present - register: domain_user_again_on_create - vars: *become_vars - -- name: assert create domain user credential again - assert: - that: - - domain_user_again_always is changed - - not domain_user_again_on_create is changed - -- name: update credential (check mode) - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username2 - alias: ansible - attributes: - - name: attribute 1 - data: attribute 1 value - - name: attribute 2 - data: '{{ "attribute 2 value" | b64encode }}' - data_format: base64 - comment: Credential comment - persistence: enterprise - state: present - register: update_cred_check - check_mode: True - vars: *become_vars - -- name: get result of update credential (check mode) - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: update_cred_actual_check - vars: *become_vars - -- name: assert update credential (check mode) - assert: - that: - - update_cred_check is changed - - update_cred_actual_check.exists - - update_cred_actual_check.alias == None - - update_cred_actual_check.attributes == [] - - update_cred_actual_check.comment == None - - update_cred_actual_check.name == test_hostname - - update_cred_actual_check.persistence == "LocalMachine" - - update_cred_actual_check.secret == "" - - update_cred_actual_check.type == "DomainPassword" - - update_cred_actual_check.username == "DOMAIN\\username" - -- name: update credential - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username2 - alias: ansible - attributes: - - name: attribute 1 - data: attribute 1 value - - name: attribute 2 - data: '{{ "attribute 2 value" | b64encode }}' - data_format: base64 - comment: Credential comment - persistence: enterprise - state: present - register: update_cred - vars: *become_vars - -- name: get result of update credential - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: update_cred_actual - vars: *become_vars - -- name: assert update credential - assert: - that: - - update_cred is changed - - update_cred_actual.exists - - update_cred_actual.alias == "ansible" - - update_cred_actual.attributes|count == 2 - - update_cred_actual.attributes[0].name == "attribute 1" - - update_cred_actual.attributes[0].data == "attribute 1 value"|b64encode - - update_cred_actual.attributes[1].name == "attribute 2" - - update_cred_actual.attributes[1].data == "attribute 2 value"|b64encode - - update_cred_actual.comment == "Credential comment" - - update_cred_actual.name == test_hostname - - update_cred_actual.persistence == "Enterprise" - - update_cred_actual.secret == "" - - update_cred_actual.type == "DomainPassword" - - update_cred_actual.username == "DOMAIN\\username2" - -- name: update credential again - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username2 - alias: ansible - attributes: - - name: attribute 1 - data: attribute 1 value - - name: attribute 2 - data: '{{ "attribute 2 value" | b64encode }}' - data_format: base64 - comment: Credential comment - persistence: enterprise - state: present - register: update_cred_again - vars: *become_vars - -- name: assert update credential again - assert: - that: - - not update_cred_again is changed - -- name: add new attribute - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username2 - alias: ansible - attributes: - - name: attribute 1 - data: attribute 1 value - - name: attribute 2 - data: '{{ "attribute 2 value" | b64encode }}' - data_format: base64 - - name: attribute 3 - data: attribute 3 value - comment: Credential comment - persistence: enterprise - state: present - register: add_attribute - vars: *become_vars - -- name: get result of add new attribute - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: add_attribute_actual - vars: *become_vars - -- name: assert add new attribute - assert: - that: - - add_attribute is changed - - add_attribute_actual.attributes|count == 3 - - add_attribute_actual.attributes[0].name == "attribute 1" - - add_attribute_actual.attributes[0].data == "attribute 1 value"|b64encode - - add_attribute_actual.attributes[1].name == "attribute 2" - - add_attribute_actual.attributes[1].data == "attribute 2 value"|b64encode - - add_attribute_actual.attributes[2].name == "attribute 3" - - add_attribute_actual.attributes[2].data == "attribute 3 value"|b64encode - -- name: remove attribute - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username2 - alias: ansible - attributes: - - name: attribute 1 - data: attribute 1 value - - name: attribute 2 - data: '{{ "attribute 2 value" | b64encode }}' - data_format: base64 - comment: Credential comment - persistence: enterprise - state: present - register: remove_attribute - vars: *become_vars - -- name: get result of remove attribute - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: remove_attribute_actual - vars: *become_vars - -- name: assert remove attribute - assert: - that: - - remove_attribute is changed - - remove_attribute_actual.attributes|count == 2 - - remove_attribute_actual.attributes[0].name == "attribute 1" - - remove_attribute_actual.attributes[0].data == "attribute 1 value"|b64encode - - remove_attribute_actual.attributes[1].name == "attribute 2" - - remove_attribute_actual.attributes[1].data == "attribute 2 value"|b64encode - -- name: edit attribute - win_credential: - name: '{{ test_hostname }}' - type: domain_password - username: DOMAIN\username2 - alias: ansible - attributes: - - name: attribute 1 - data: attribute 1 value new - - name: attribute 2 - data: '{{ "attribute 2 value" | b64encode }}' - data_format: base64 - comment: Credential comment - persistence: enterprise - state: present - register: edit_attribute - vars: *become_vars - -- name: get result of edit attribute - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: edit_attribute_actual - vars: *become_vars - -- name: assert remove attribute - assert: - that: - - edit_attribute is changed - - edit_attribute_actual.attributes|count == 2 - - edit_attribute_actual.attributes[0].name == "attribute 1" - - edit_attribute_actual.attributes[0].data == "attribute 1 value new"|b64encode - - edit_attribute_actual.attributes[1].name == "attribute 2" - - edit_attribute_actual.attributes[1].data == "attribute 2 value"|b64encode - -- name: remove credential (check mode) - win_credential: - name: '{{ test_hostname }}' - type: domain_password - state: absent - register: remove_cred_check - check_mode: True - vars: *become_vars - -- name: get result of remove credential (check mode) - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: remove_cred_actual_check - vars: *become_vars - -- name: assert remove credential (check mode) - assert: - that: - - remove_cred_check is changed - - remove_cred_actual_check.exists - -- name: remove credential - win_credential: - name: '{{ test_hostname }}' - type: domain_password - state: absent - register: remove_cred - vars: *become_vars - -- name: get result of remove credential - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_password - register: remove_cred_actual - vars: *become_vars - -- name: assert remove credential - assert: - that: - - remove_cred is changed - - not remove_cred_actual.exists - -- name: remove credential again - win_credential: - name: '{{ test_hostname }}' - type: domain_password - state: absent - register: remove_cred_again - vars: *become_vars - -- name: assert remove credential again - assert: - that: - - not remove_cred_again is changed - -# https://github.com/ansible/ansible/issues/67278 -- name: create credential with wildcard - win_credential: - name: '*.{{ test_hostname }}' - type: domain_password - username: DOMAIN\username - secret: password - state: present - persistence: enterprise - register: wildcard_cred - vars: *become_vars - -- name: get result of create credential with wildcard - test_cred_facts: - name: '*.{{ test_hostname }}' - type: domain_password - register: wildcard_cred_actual - vars: *become_vars - -- name: assert create credential with wildcard - assert: - that: - - wildcard_cred is changed - - wildcard_cred_actual.name == '*.' ~ test_hostname - -- name: remove credential with wildcard - win_credential: - name: '*.{{ test_hostname }}' - type: domain_password - state: absent - register: wildcard_remove - vars: *become_vars - -- name: get result of remove credential with wildcard - test_cred_facts: - name: '*.{{ test_hostname }}' - type: domain_password - register: wildcard_remove_actual - vars: *become_vars - -- name: assert remove credential with wildcard - assert: - that: - - wildcard_remove is changed - - not wildcard_remove_actual.exists - -- name: create generic password (check mode) - win_credential: - name: '{{ test_hostname }}' - type: generic_password - persistence: enterprise - username: genericuser - secret: genericpass - state: present - register: generic_password_check - check_mode: True - vars: *become_vars - -- name: get result of create generic password (check mode) - test_cred_facts: - name: '{{ test_hostname }}' - type: generic_password - register: generic_password_actual_check - vars: *become_vars - -- name: assert result of create generic password (check mode) - assert: - that: - - generic_password_check is changed - - not generic_password_actual_check.exists - -- name: create generic password - win_credential: - name: '{{ test_hostname }}' - type: generic_password - persistence: enterprise - username: genericuser - secret: genericpass - state: present - register: generic_password - vars: *become_vars - -- name: get result of create generic password - test_cred_facts: - name: '{{ test_hostname }}' - type: generic_password - register: generic_password_actual - vars: *become_vars - -- name: set encoded password result - set_fact: - encoded_pass: '{{ "genericpass" | string | b64encode(encoding="utf-16-le") }}' - -- name: assert create generic password - assert: - that: - - generic_password is changed - - generic_password_actual.exists - - generic_password_actual.alias == None - - generic_password_actual.attributes == [] - - generic_password_actual.comment == None - - generic_password_actual.name == test_hostname - - generic_password_actual.persistence == "Enterprise" - - generic_password_actual.secret == encoded_pass - - generic_password_actual.type == "Generic" - - generic_password_actual.username == "genericuser" - -- name: create generic password again - win_credential: - name: '{{ test_hostname }}' - type: generic_password - persistence: enterprise - username: genericuser - secret: genericpass - state: present - register: generic_password_again - vars: *become_vars - -- name: assert create generic password again - assert: - that: - - not generic_password_again is changed - -- name: fail to create certificate cred with invalid thumbprint - win_credential: - name: '{{ test_hostname }}' - type: domain_certificate - username: 00112233445566778899AABBCCDDEEFF00112233 - state: present - register: fail_invalid_cert - failed_when: fail_invalid_cert.msg != "Failed to find certificate with the thumbprint 00112233445566778899AABBCCDDEEFF00112233 in the CurrentUser\\My store" - vars: *become_vars - -- name: create domain certificate cred (check mode) - win_credential: - name: '{{ test_hostname }}' - type: domain_certificate - username: '{{ cert_thumbprint }}' - state: present - register: domain_cert_check - check_mode: True - vars: *become_vars - -- name: get result of create domain certificate cred (check mode) - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_certificate - register: domain_cert_actual_check - vars: *become_vars - -- name: assert create domain certificate cred (check mode) - assert: - that: - - domain_cert_check is changed - - not domain_cert_actual_check.exists - -- name: create domain certificate cred - win_credential: - name: '{{ test_hostname }}' - type: domain_certificate - username: '{{ cert_thumbprint }}' - state: present - register: domain_cert - vars: *become_vars - -- name: get result of create domain certificate cred - test_cred_facts: - name: '{{ test_hostname }}' - type: domain_certificate - register: domain_cert_actual - vars: *become_vars - -- name: assert create domain certificate cred - assert: - that: - - domain_cert is changed - - domain_cert_actual.exists - - domain_cert_actual.alias == None - - domain_cert_actual.attributes == [] - - domain_cert_actual.comment == None - - domain_cert_actual.name == test_hostname - - domain_cert_actual.persistence == "LocalMachine" - - domain_cert_actual.secret == "" - - domain_cert_actual.type == "DomainCertificate" - - domain_cert_actual.username == cert_thumbprint - -- name: create domain certificate cred again - win_credential: - name: '{{ test_hostname }}' - type: domain_certificate - username: '{{ cert_thumbprint }}' - state: present - register: domain_cert_again - vars: *become_vars - -- name: assert create domain certificate cred again - assert: - that: - - not domain_cert_again is changed - -- name: create generic certificate cred (check mode) - win_credential: - name: '{{ test_hostname }}' - type: generic_certificate - username: '{{ cert_thumbprint }}' - secret: '{{ "pin code" | b64encode }}' - secret_format: base64 - state: present - register: generic_cert_check - check_mode: True - vars: *become_vars - -- name: get result of create generic certificate cred (check mode) - test_cred_facts: - name: '{{ test_hostname }}' - type: generic_certificate - register: generic_cert_actual_check - vars: *become_vars - -- name: assert create generic certificate cred (check mode) - assert: - that: - - generic_cert_check is changed - - not generic_cert_actual_check.exists - -- name: create generic certificate cred - win_credential: - name: '{{ test_hostname }}' - type: generic_certificate - username: '{{ cert_thumbprint }}' - secret: '{{ "pin code" | b64encode }}' - secret_format: base64 - state: present - register: generic_cert - vars: *become_vars - -- name: get result of create generic certificate cred - test_cred_facts: - name: '{{ test_hostname }}' - type: generic_certificate - register: generic_cert_actual - vars: *become_vars - -- name: assert create generic certificate cred - assert: - that: - - generic_cert is changed - - generic_cert_actual.exists - - generic_cert_actual.alias == None - - generic_cert_actual.attributes == [] - - generic_cert_actual.comment == None - - generic_cert_actual.name == test_hostname - - generic_cert_actual.persistence == "LocalMachine" - - generic_cert_actual.secret == "pin code" | b64encode - - generic_cert_actual.type == "GenericCertificate" - - generic_cert_actual.username == cert_thumbprint - -- name: create generic certificate cred again - win_credential: - name: '{{ test_hostname }}' - type: generic_certificate - username: '{{ cert_thumbprint }}' - state: present - register: generic_cert_again - vars: *become_vars - -- name: assert create generic certificate cred again - assert: - that: - - not generic_cert_again is changed diff --git a/test/integration/targets/win_data_deduplication/aliases b/test/integration/targets/win_data_deduplication/aliases deleted file mode 100644 index 5f7ed526d6..0000000000 --- a/test/integration/targets/win_data_deduplication/aliases +++ /dev/null @@ -1,4 +0,0 @@ -shippable/windows/group4 -skip/windows/2008 -skip/windows/2008-R2 -skip/windows/2012 diff --git a/test/integration/targets/win_data_deduplication/meta/main.yml b/test/integration/targets/win_data_deduplication/meta/main.yml deleted file mode 100644 index 9f37e96cd9..0000000000 --- a/test/integration/targets/win_data_deduplication/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- setup_remote_tmp_dir diff --git a/test/integration/targets/win_data_deduplication/tasks/main.yml b/test/integration/targets/win_data_deduplication/tasks/main.yml deleted file mode 100644 index ae6be90ecb..0000000000 --- a/test/integration/targets/win_data_deduplication/tasks/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -- include: pre_test.yml diff --git a/test/integration/targets/win_data_deduplication/tasks/pre_test.yml b/test/integration/targets/win_data_deduplication/tasks/pre_test.yml deleted file mode 100644 index f72955e46b..0000000000 --- a/test/integration/targets/win_data_deduplication/tasks/pre_test.yml +++ /dev/null @@ -1,40 +0,0 @@ ---- -- set_fact: - AnsibleVhdx: '{{ remote_tmp_dir }}\AnsiblePart.vhdx' - -- name: Install FS-Data-Deduplication - win_feature: - name: FS-Data-Deduplication - include_sub_features: true - state: present - register: data_dedup_feat_reg - -- name: Reboot windows after the feature has been installed - win_reboot: - reboot_timeout: 3600 - when: - - data_dedup_feat_reg.success - - data_dedup_feat_reg.reboot_required - -- name: Copy VHDX scripts - win_template: - src: "{{ item.src }}" - dest: '{{ remote_tmp_dir }}\{{ item.dest }}' - loop: - - { src: partition_creation_script.j2, dest: partition_creation_script.txt } - - { src: partition_deletion_script.j2, dest: partition_deletion_script.txt } - -- name: Create partition - win_command: diskpart.exe /s {{ remote_tmp_dir }}\partition_creation_script.txt - -- name: Format T with NTFS - win_format: - drive_letter: T - file_system: ntfs - -- name: Run tests - block: - - include: tests.yml - always: - - name: Detach disk - win_command: diskpart.exe /s {{ remote_tmp_dir }}\partition_deletion_script.txt diff --git a/test/integration/targets/win_data_deduplication/tasks/tests.yml b/test/integration/targets/win_data_deduplication/tasks/tests.yml deleted file mode 100644 index 64a4292713..0000000000 --- a/test/integration/targets/win_data_deduplication/tasks/tests.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- - -- name: Enable Data Deduplication on the T drive - check mode - win_data_deduplication: - drive_letter: "T" - state: present - settings: - no_compress: true - minimum_file_age_days: 2 - minimum_file_size: 0 - check_mode: yes - register: win_data_deduplication_enable_check_mode - -- name: Check that it was successful with a change - check mode - assert: - that: - - win_data_deduplication_enable_check_mode is changed - -- name: Enable Data Deduplication on the T drive - win_data_deduplication: - drive_letter: "T" - state: present - settings: - no_compress: true - minimum_file_age_days: 2 - minimum_file_size: 0 - register: win_data_deduplication_enable - -- name: Check that it was successful with a change - assert: - that: - - win_data_deduplication_enable is changed - -- name: Enable Data Deduplication on the T drive - win_data_deduplication: - drive_letter: "T" - state: present - settings: - no_compress: true - minimum_file_age_days: 2 - minimum_file_size: 0 - register: win_data_deduplication_enable_again - -- name: Check that it was successful without a change - assert: - that: - - win_data_deduplication_enable_again is not changed diff --git a/test/integration/targets/win_data_deduplication/templates/partition_creation_script.j2 b/test/integration/targets/win_data_deduplication/templates/partition_creation_script.j2 deleted file mode 100644 index 8e47fda95b..0000000000 --- a/test/integration/targets/win_data_deduplication/templates/partition_creation_script.j2 +++ /dev/null @@ -1,11 +0,0 @@ -create vdisk file="{{ AnsibleVhdx }}" maximum=2000 type=fixed - -select vdisk file="{{ AnsibleVhdx }}" - -attach vdisk - -convert mbr - -create partition primary - -assign letter="T" diff --git a/test/integration/targets/win_data_deduplication/templates/partition_deletion_script.j2 b/test/integration/targets/win_data_deduplication/templates/partition_deletion_script.j2 deleted file mode 100644 index c2be9cd144..0000000000 --- a/test/integration/targets/win_data_deduplication/templates/partition_deletion_script.j2 +++ /dev/null @@ -1,3 +0,0 @@ -select vdisk file="{{ AnsibleVhdx }}" - -detach vdisk diff --git a/test/integration/targets/win_disk_facts/aliases b/test/integration/targets/win_disk_facts/aliases deleted file mode 100644 index e4adbabbe2..0000000000 --- a/test/integration/targets/win_disk_facts/aliases +++ /dev/null @@ -1,3 +0,0 @@ -shippable/windows/group2 -skip/windows/2008 # The Storage PowerShell module was introduced in W2K12 -skip/windows/2008-R2 # The Storage PowerShell module was introduced in W2K12 diff --git a/test/integration/targets/win_disk_facts/tasks/main.yml b/test/integration/targets/win_disk_facts/tasks/main.yml deleted file mode 100644 index b4b4fecb94..0000000000 --- a/test/integration/targets/win_disk_facts/tasks/main.yml +++ /dev/null @@ -1,13 +0,0 @@ -# NOTE: The win_disk_facts module only works on Win2012R2+ - -- name: check whether storage module is available (windows 2008 r2 or later) - win_shell: '(Get-Module -Name Storage -ListAvailable | Measure-Object).Count -eq 1' - register: win_feature_has_storage_module - changed_when: false - -- name: Only run tests when Windows is capable - when: win_feature_has_storage_module.stdout | trim | bool == True - block: - - - name: Test in normal mode - include: tests.yml diff --git a/test/integration/targets/win_disk_facts/tasks/tests.yml b/test/integration/targets/win_disk_facts/tasks/tests.yml deleted file mode 100644 index ca3fda82cb..0000000000 --- a/test/integration/targets/win_disk_facts/tasks/tests.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: get disk facts on the target - win_disk_facts: - register: disks_found - -- name: assert disk facts - assert: - that: - - disks_found.changed == false - - disks_found.ansible_facts.ansible_disks[0].number is defined - - disks_found.ansible_facts.ansible_disks[0].guid is defined - - disks_found.ansible_facts.ansible_disks[0].location is defined - - disks_found.ansible_facts.ansible_disks[0].path is defined - - disks_found.ansible_facts.ansible_disks[0].read_only is defined - - disks_found.ansible_facts.ansible_disks[0].clustered is defined - - disks_found.ansible_facts.ansible_disks[0].bootable is defined - - disks_found.ansible_facts.ansible_disks[0].physical_disk.size is defined - - disks_found.ansible_facts.ansible_disks[0].physical_disk.operational_status is defined - - disks_found.ansible_facts.ansible_disks[0].win32_disk_drive is defined diff --git a/test/integration/targets/win_dns_record/aliases b/test/integration/targets/win_dns_record/aliases deleted file mode 100644 index 9ad549d4a6..0000000000 --- a/test/integration/targets/win_dns_record/aliases +++ /dev/null @@ -1,3 +0,0 @@ -shippable/windows/group2 -skip/windows/2008 -skip/windows/2008-R2 diff --git a/test/integration/targets/win_dns_record/defaults/main.yml b/test/integration/targets/win_dns_record/defaults/main.yml deleted file mode 100644 index 496102481c..0000000000 --- a/test/integration/targets/win_dns_record/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -win_dns_record_zone: test.ansible.local -win_dns_record_revzone: 0.0.255.in-addr.arpa -win_dns_record_revzone_network: 255.0.0.0/24 diff --git a/test/integration/targets/win_dns_record/tasks/clean.yml b/test/integration/targets/win_dns_record/tasks/clean.yml deleted file mode 100644 index db9431648e..0000000000 --- a/test/integration/targets/win_dns_record/tasks/clean.yml +++ /dev/null @@ -1,17 +0,0 @@ -- name: Remove test zone, if present - win_shell: | - $zone = '{{ item }}' - $fail_on_missing = '{{ fail_on_missing | default(true) }}' - - Trap { If (-not $fail_on_missing) { continue } } - Remove-DnsServerZone -Name $zone -Force - - # win_file could also do this, but it would need to know where the - # SystemRoot is located via fact gathering, which we cannot assume. - Trap { If (-not $fail_on_missing) { continue } } - Remove-Item -Path $env:SystemRoot\system32\dns\$zone.dns - - $true # so pipeline exits cleanly if an error was ignored above - loop: - - '{{ win_dns_record_zone }}' - - '{{ win_dns_record_revzone }}' diff --git a/test/integration/targets/win_dns_record/tasks/main.yml b/test/integration/targets/win_dns_record/tasks/main.yml deleted file mode 100644 index 97375e4463..0000000000 --- a/test/integration/targets/win_dns_record/tasks/main.yml +++ /dev/null @@ -1,12 +0,0 @@ -# We do an explicit OS version check here *INSTEAD OF* the usual test for -# cmdlet existence. That's because a cmdlet test here won't work without first -# installing the DNS feature, but we don't want to install the feature on OS' -# that can't be supported anyway. Hence this fallback to an explicit OS version -# test. -- name: check OS version is supported - win_shell: 'if ([Environment]::OSVersion.Version -ge [Version]"6.2") { $true } else { $false }' - register: os_supported - -- name: run tests on supported hosts - include: tests.yml - when: os_supported.stdout | trim | bool diff --git a/test/integration/targets/win_dns_record/tasks/tests-A.yml b/test/integration/targets/win_dns_record/tasks/tests-A.yml deleted file mode 100644 index 05910c774c..0000000000 --- a/test/integration/targets/win_dns_record/tasks/tests-A.yml +++ /dev/null @@ -1,186 +0,0 @@ -- name: 'TYPE=A - creation (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 1.2.3.4, type: A} - register: cmd_result - check_mode: yes - -- name: 'TYPE=A - creation get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - creation check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=A - creation' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 1.2.3.4, type: A} - register: cmd_result - -- name: 'TYPE=A - creation get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - creation check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '1.2.3.4\r\n' - -- name: 'TYPE=A - creation (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 1.2.3.4, type: A} - register: cmd_result - -- name: 'TYPE=A - creation get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - creation check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '1.2.3.4\r\n' - - -- name: 'TYPE=A - update address (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, type: A} - register: cmd_result - check_mode: yes - -- name: 'TYPE=A - update address get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - update address check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '1.2.3.4\r\n' - -- name: 'TYPE=A - update address' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, type: A} - register: cmd_result - -- name: 'TYPE=A - update address get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - update address check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '5.6.7.8\r\n' - -- name: 'TYPE=A - update address (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, type: A} - register: cmd_result - -- name: 'TYPE=A - update address get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv4Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - update address check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '5.6.7.8\r\n' - - -- name: 'TYPE=A - update TTL (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, ttl: 7200, type: A} - register: cmd_result - check_mode: yes - -- name: 'TYPE=A - update TTL get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - update TTL check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '3600\r\n' - -- name: 'TYPE=A - update TTL' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, ttl: 7200, type: A} - register: cmd_result - -- name: 'TYPE=A - update TTL get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - update TTL check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '7200\r\n' - -- name: 'TYPE=A - update TTL (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: 5.6.7.8, ttl: 7200, type: A} - register: cmd_result - -- name: 'TYPE=A - update TTL get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - update TTL check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '7200\r\n' - - -- name: 'TYPE=A - remove record (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: A, state: absent} - register: cmd_result - check_mode: yes - -- name: 'TYPE=A - remove record get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - remove record check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'exists\r\n' - -- name: 'TYPE=A - remove record' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: A, state: absent} - register: cmd_result - -- name: 'TYPE=A - remove record get results' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - remove record check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=A - remove record (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: A, state: absent} - register: cmd_result - -- name: 'TYPE=A - remove record get results (idempotent)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType A -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=A - remove record check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'absent\r\n' diff --git a/test/integration/targets/win_dns_record/tasks/tests-AAAA.yml b/test/integration/targets/win_dns_record/tasks/tests-AAAA.yml deleted file mode 100644 index cb32a8296b..0000000000 --- a/test/integration/targets/win_dns_record/tasks/tests-AAAA.yml +++ /dev/null @@ -1,186 +0,0 @@ -- name: 'TYPE=AAAA - creation (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::1', type: AAAA} - register: cmd_result - check_mode: yes - -- name: 'TYPE=AAAA - creation get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - creation check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=AAAA - creation' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::1', type: AAAA} - register: cmd_result - -- name: 'TYPE=AAAA - creation get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - creation check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '2001:db8::1\r\n' - -- name: 'TYPE=AAAA - creation (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::1', type: AAAA} - register: cmd_result - -- name: 'TYPE=AAAA - creation get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - creation check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '2001:db8::1\r\n' - - -- name: 'TYPE=AAAA - update address (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', type: AAAA} - register: cmd_result - check_mode: yes - -- name: 'TYPE=AAAA - update address get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - update address check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '2001:db8::1\r\n' - -- name: 'TYPE=AAAA - update address' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', type: AAAA} - register: cmd_result - -- name: 'TYPE=AAAA - update address get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - update address check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '2001:db8::2\r\n' - -- name: 'TYPE=AAAA - update address (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', type: AAAA} - register: cmd_result - -- name: 'TYPE=AAAA - update address get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty IPv6Address | Select -ExpandProperty IPAddressToString" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - update address check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '2001:db8::2\r\n' - - -- name: 'TYPE=AAAA - update TTL (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', ttl: 7200, type: AAAA} - register: cmd_result - check_mode: yes - -- name: 'TYPE=AAAA - update TTL get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - update TTL check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '3600\r\n' - -- name: 'TYPE=AAAA - update TTL' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', ttl: 7200, type: AAAA} - register: cmd_result - -- name: 'TYPE=AAAA - update TTL get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - update TTL check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '7200\r\n' - -- name: 'TYPE=AAAA - update address (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: '2001:db8::2', ttl: 7200, type: AAAA} - register: cmd_result - -- name: 'TYPE=AAAA - update address get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - update address check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '7200\r\n' - - -- name: 'TYPE=AAAA - remove record (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: AAAA, state: absent} - register: cmd_result - check_mode: yes - -- name: 'TYPE=AAAA - remove record get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - remove record check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'exists\r\n' - -- name: 'TYPE=AAAA - remove record' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: AAAA, state: absent} - register: cmd_result - -- name: 'TYPE=AAAA - remove record get results' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - remove record check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=AAAA - remove record (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: AAAA, state: absent} - register: cmd_result - -- name: 'TYPE=AAAA - remove record get results (idempotent)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType AAAA -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=AAAA - remove record check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'absent\r\n' diff --git a/test/integration/targets/win_dns_record/tasks/tests-CNAME.yml b/test/integration/targets/win_dns_record/tasks/tests-CNAME.yml deleted file mode 100644 index f75a176a08..0000000000 --- a/test/integration/targets/win_dns_record/tasks/tests-CNAME.yml +++ /dev/null @@ -1,186 +0,0 @@ -- name: 'TYPE=CNAME - creation (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: www.ansible.com, type: CNAME} - register: cmd_result - check_mode: yes - -- name: 'TYPE=CNAME - creation get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - creation check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=CNAME - creation' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: www.ansible.com, type: CNAME} - register: cmd_result - -- name: 'TYPE=CNAME - creation get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - creation check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'www.ansible.com.\r\n' - -- name: 'TYPE=CNAME - creation (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: www.ansible.com, type: CNAME} - register: cmd_result - -- name: 'TYPE=CNAME - creation get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - creation check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'www.ansible.com.\r\n' - - -- name: 'TYPE=CNAME - update address (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, type: CNAME} - register: cmd_result - check_mode: yes - -- name: 'TYPE=CNAME - update address get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - update address check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'www.ansible.com.\r\n' - -- name: 'TYPE=CNAME - update address' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, type: CNAME} - register: cmd_result - -- name: 'TYPE=CNAME - update address get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - update address check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'docs.ansible.com.\r\n' - -- name: 'TYPE=CNAME - update address (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, type: CNAME} - register: cmd_result - -- name: 'TYPE=CNAME - update address get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty HostNameAlias" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - update address check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'docs.ansible.com.\r\n' - - -- name: 'TYPE=CNAME - update TTL (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, ttl: 7200, type: CNAME} - register: cmd_result - check_mode: yes - -- name: 'TYPE=CNAME - update TTL get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - update TTL check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '3600\r\n' - -- name: 'TYPE=CNAME - update TTL' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, ttl: 7200, type: CNAME} - register: cmd_result - -- name: 'TYPE=CNAME - update TTL get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - update TTL check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '7200\r\n' - -- name: 'TYPE=CNAME - update TTL (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, value: docs.ansible.com, ttl: 7200, type: CNAME} - register: cmd_result - -- name: 'TYPE=CNAME - update TTL get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - update TTL check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '7200\r\n' - - -- name: 'TYPE=CNAME - remove record (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: CNAME, state: absent} - register: cmd_result - check_mode: yes - -- name: 'TYPE=CNAME - remove record get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - remove record check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'exists\r\n' - -- name: 'TYPE=CNAME - remove record' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: CNAME, state: absent} - register: cmd_result - -- name: 'TYPE=CNAME - remove record get results' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - remove record check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=CNAME - remove record (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: test1, type: CNAME, state: absent} - register: cmd_result - -- name: 'TYPE=CNAME - remove record get results (idempotent)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_zone }}' -Name 'test1' -RRType CNAME -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=CNAME - remove record check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'absent\r\n' diff --git a/test/integration/targets/win_dns_record/tasks/tests-PTR.yml b/test/integration/targets/win_dns_record/tasks/tests-PTR.yml deleted file mode 100644 index 6f48ab8cae..0000000000 --- a/test/integration/targets/win_dns_record/tasks/tests-PTR.yml +++ /dev/null @@ -1,186 +0,0 @@ -- name: 'TYPE=PTR - creation (check mode)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-mirror.example.com, type: PTR} - register: cmd_result - check_mode: yes - -- name: 'TYPE=PTR - creation get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - creation check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=PTR - creation' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-mirror.example.com, type: PTR} - register: cmd_result - -- name: 'TYPE=PTR - creation get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - creation check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'ansible-mirror.example.com.\r\n' - -- name: 'TYPE=PTR - creation (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-mirror.example.com, type: PTR} - register: cmd_result - -- name: 'TYPE=PTR - creation get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - creation check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'ansible-mirror.example.com.\r\n' - - -- name: 'TYPE=PTR - update address (check mode)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, type: PTR} - register: cmd_result - check_mode: yes - -- name: 'TYPE=PTR - update address get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - update address check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'ansible-mirror.example.com.\r\n' - -- name: 'TYPE=PTR - update address' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, type: PTR} - register: cmd_result - -- name: 'TYPE=PTR - update address get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - update address check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'ansible-altmirror.example.com.\r\n' - -- name: 'TYPE=PTR - update address (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, type: PTR} - register: cmd_result - -- name: 'TYPE=PTR - update address get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty RecordData | Select -ExpandProperty PtrDomainName" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - update address check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'ansible-altmirror.example.com.\r\n' - - -- name: 'TYPE=PTR - update TTL (check mode)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, ttl: 7200, type: PTR} - register: cmd_result - check_mode: yes - -- name: 'TYPE=PTR - update TTL get results (check mode)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - update TTL check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '3600\r\n' - -- name: 'TYPE=PTR - update TTL' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, ttl: 7200, type: PTR} - register: cmd_result - -- name: 'TYPE=PTR - update TTL get results' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - update TTL check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == '7200\r\n' - -- name: 'TYPE=PTR - update TTL (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, value: ansible-altmirror.example.com, ttl: 7200, type: PTR} - register: cmd_result - -- name: 'TYPE=PTR - update TTL get results (idempotent)' - win_command: powershell.exe "Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore | Select -ExpandProperty TimeToLive | Select -ExpandProperty TotalSeconds" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - update TTL check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == '7200\r\n' - - -- name: 'TYPE=PTR - remove record (check mode)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, type: PTR, state: absent} - register: cmd_result - check_mode: yes - -- name: 'TYPE=PTR - remove record get results (check mode)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - remove record check results (check mode)' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'exists\r\n' - -- name: 'TYPE=PTR - remove record' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, type: PTR, state: absent} - register: cmd_result - -- name: 'TYPE=PTR - remove record get results' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - remove record check results' - assert: - that: - - cmd_result is changed - - cmd_result_actual.stdout == 'absent\r\n' - -- name: 'TYPE=PTR - remove record (idempotent)' - win_dns_record: {zone: '{{ win_dns_record_revzone }}', name: 7, type: PTR, state: absent} - register: cmd_result - -- name: 'TYPE=PTR - remove record get results (idempotent)' - win_command: powershell.exe "If (Get-DnsServerResourceRecord -ZoneName '{{ win_dns_record_revzone }}' -Name '7' -RRType PTR -Node -ErrorAction:Ignore) { 'exists' } else { 'absent' }" - register: cmd_result_actual - changed_when: false - -- name: 'TYPE=PTR - remove record check results (idempotent)' - assert: - that: - - cmd_result is not changed - - cmd_result_actual.stdout == 'absent\r\n' diff --git a/test/integration/targets/win_dns_record/tasks/tests-diff.yml b/test/integration/targets/win_dns_record/tasks/tests-diff.yml deleted file mode 100644 index f5adaf369a..0000000000 --- a/test/integration/targets/win_dns_record/tasks/tests-diff.yml +++ /dev/null @@ -1,63 +0,0 @@ -# Diff tests are present because those records have to be created MANUALLY by -# the win_dns_record module when in check mode, as there is otherwise no way in -# Windows DNS to *simulate* a record or change. - - -- name: 'Diff test - creation (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A} - register: create_check - check_mode: yes - diff: yes - -- name: 'Diff test - creation' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A} - register: create_do - diff: yes - -- name: 'Diff test - creation check results' - assert: - that: - - create_check.diff.before == create_do.diff.before - - create_check.diff.before == '' - - create_check.diff.after == create_do.diff.after - - create_check.diff.after == "[{{ win_dns_record_zone }}] diff_host 3600 IN A 1.2.3.4\n" - - -- name: 'Diff test - update TTL (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A, ttl: 7200} - register: update_check - check_mode: yes - diff: yes - -- name: 'Diff test - update TTL' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, value: 1.2.3.4, type: A, ttl: 7200} - register: update_do - diff: yes - -- name: 'Diff test - update TTL check results' - assert: - that: - - update_check.diff.before == update_do.diff.before - - update_check.diff.before == "[{{ win_dns_record_zone }}] diff_host 3600 IN A 1.2.3.4\n" - - update_check.diff.after == update_do.diff.after - - update_check.diff.after == "[{{ win_dns_record_zone }}] diff_host 7200 IN A 1.2.3.4\n" - - -- name: 'Diff test - deletion (check mode)' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, type: A, state: absent} - register: delete_check - check_mode: yes - diff: yes - -- name: 'Diff test - deletion' - win_dns_record: {zone: '{{ win_dns_record_zone }}', name: diff_host, type: A, state: absent} - register: delete_do - diff: yes - -- name: 'Diff test - deletion check results' - assert: - that: - - delete_check.diff.before == delete_do.diff.before - - delete_check.diff.before == "[{{ win_dns_record_zone }}] diff_host 7200 IN A 1.2.3.4\n" - - delete_check.diff.after == delete_do.diff.after - - delete_check.diff.after == '' diff --git a/test/integration/targets/win_dns_record/tasks/tests.yml b/test/integration/targets/win_dns_record/tasks/tests.yml deleted file mode 100644 index f2ed38f531..0000000000 --- a/test/integration/targets/win_dns_record/tasks/tests.yml +++ /dev/null @@ -1,32 +0,0 @@ -- name: ensure DNS services are installed - win_feature: - name: DNS - state: present - register: dns_install - -- name: reboot server if needed - win_reboot: - when: dns_install.reboot_required - -- name: Clean slate - import_tasks: clean.yml - vars: - fail_on_missing: false - -- block: - - name: Create the forward zone - win_shell: Add-DnsServerPrimaryZone -Name '{{ win_dns_record_zone }}' -ZoneFile '{{ win_dns_record_zone}}.dns' - - name: Create the reverse zone - win_shell: Add-DnsServerPrimaryZone -NetworkID '{{ win_dns_record_revzone_network }}' -ZoneFile '{{ win_dns_record_revzone}}.dns' - - - import_tasks: tests-A.yml - - import_tasks: tests-AAAA.yml - - import_tasks: tests-CNAME.yml - - import_tasks: tests-PTR.yml - - import_tasks: tests-diff.yml - - always: - - name: Clean slate - import_tasks: clean.yml - vars: - fail_on_missing: true diff --git a/test/integration/targets/win_domain_computer/aliases b/test/integration/targets/win_domain_computer/aliases deleted file mode 100644 index ad7ccf7ada..0000000000 --- a/test/integration/targets/win_domain_computer/aliases +++ /dev/null @@ -1 +0,0 @@ -unsupported diff --git a/test/integration/targets/win_domain_computer/tasks/main.yml b/test/integration/targets/win_domain_computer/tasks/main.yml deleted file mode 100644 index 98f18acac2..0000000000 --- a/test/integration/targets/win_domain_computer/tasks/main.yml +++ /dev/null @@ -1,71 +0,0 @@ -# this won't run in Ansible's integration tests until we get a domain set up -# these are here if someone wants to run the module tests locally on their own -# domain. -# Requirements: -# LDAP Base path set in defaults/main.yml like DC=ansible,DC=local -# Custom OU path set in defaults/main.yml like OU=ou1,DC=ansible,DC=local ---- -- name: run win_domain_users test - hosts: win_domain_computer_testing_host - vars: - test_win_domain_computer_ldap_base: "{{ test_ad_ou }}" - test_win_domain_computer_ou_path: "{{ test_ad_group_ou }}" - test_win_domain_computer_name: "test_computer.{{ test_domain_name }}" - tasks: - - - name: ensure the computer is deleted before the test - win_domain_computer: - name: '{{ test_win_domain_computer_name }}' - state: absent - - # -------------------------------------------------------------------------- - - - name: Test computer with long name and distinct sam_account_name - vars: - test_win_domain_computer_long_name: '{{ test_win_domain_computer_name }}_with_long_name' - test_win_domain_computer_sam_account_name: '{{ test_win_domain_computer_name }}$' - block: - - # ---------------------------------------------------------------------- - - name: create computer with long name and distinct sam_account_name - win_domain_computer: - name: '{{ test_win_domain_computer_long_name }}' - sam_account_name: '{{ test_win_domain_computer_sam_account_name }}' - enabled: yes - state: present - register: create_distinct_sam_account_name - check_mode: yes - - - name: get actual computer with long name and distinct sam_account_name - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADComputer -Identity '{{ test_win_domain_computer_sam_account_name }}'" - register: create_distinct_sam_account_name_check - ignore_errors: True - - - name: assert create computer with long name and distinct sam_account_name - assert: - that: - - create_distinct_sam_account_name is changed - - create_distinct_sam_account_name_check.rc == 1 - - - name: (Idempotence) create computer with long name and distinct sam_account_name - win_domain_computer: - name: '{{ test_win_domain_computer_long_name }}' - sam_account_name: '{{ test_win_domain_computer_sam_account_name }}' - enabled: yes - state: present - register: create_distinct_sam_account_name_idempotence - check_mode: yes - - - name: (Idempotence) assert create computer with long name and distinct sam_account_name - assert: - that: - - create_distinct_sam_account_name_idempotence is not changed - - - name: ensure the test group is deleted after the test - win_domain_computer: - name: '{{ test_win_domain_computer_long_name }}' - sam_account_name: '{{ test_win_domain_computer_sam_account_name }}' - state: absent - ignore_protection: True - - # ---------------------------------------------------------------------- diff --git a/test/integration/targets/win_domain_group/aliases b/test/integration/targets/win_domain_group/aliases deleted file mode 100644 index ad7ccf7ada..0000000000 --- a/test/integration/targets/win_domain_group/aliases +++ /dev/null @@ -1 +0,0 @@ -unsupported diff --git a/test/integration/targets/win_domain_group/defaults/main.yml b/test/integration/targets/win_domain_group/defaults/main.yml deleted file mode 100644 index b02643ee0c..0000000000 --- a/test/integration/targets/win_domain_group/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -test_win_domain_group_ldap_base: DC=ansible,DC=local -test_win_domain_group_ou_path: OU=ou1,DC=ansible,DC=local -test_win_domain_group_name: Moo Cow diff --git a/test/integration/targets/win_domain_group/tasks/main.yml b/test/integration/targets/win_domain_group/tasks/main.yml deleted file mode 100644 index 663a59a1b8..0000000000 --- a/test/integration/targets/win_domain_group/tasks/main.yml +++ /dev/null @@ -1,353 +0,0 @@ -# this won't run in Ansible's integration tests until we get a domain set up -# these are here if someone wants to run the module tests locally on their own -# domain. -# Requirements: -# LDAP Base path set in defaults/main.yml like DC=ansible,DC=local -# Custom OU path set in defaults/main.yml like OU=ou1,DC=ansible,DC=local ---- -- name: ensure the test group is deleted before the test - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: absent - ignore_protection: True - -- name: fail pass in an invalid path - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - organizational_unit: OU=fakeou,{{test_win_domain_group_ldap_base}} - register: fail_invalid_path - failed_when: fail_invalid_path.msg != 'the group path OU=fakeou,' + test_win_domain_group_ldap_base + ' does not exist, please specify a valid LDAP path' - -- name: create group with defaults check - win_domain_group: - name: '{{test_win_domain_group_name}}' - scope: global - state: present - register: create_default_check - check_mode: yes - -- name: get actual group with defaults check - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADGroup -Identity '{{test_win_domain_group_name}}'" - register: create_default_actual_check - ignore_errors: True - -- name: assert create group with defaults checl - assert: - that: - - create_default_check is changed - - create_default_actual_check.rc == 1 - -- name: create group with defaults - win_domain_group: - name: '{{test_win_domain_group_name}}' - scope: global - state: present - register: create_default - -- name: get actual group with defaults - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADGroup -Identity '{{test_win_domain_group_name}}'" - register: create_default_actual - -- name: assert create group with defaults - assert: - that: - - create_default is created - - create_default is changed - - create_default.category == 'Security' - - create_default.description == None - - create_default.display_name == None - - create_default.distinguished_name == 'CN=' + test_win_domain_group_name + ',CN=Users,' + test_win_domain_group_ldap_base - - create_default.group_scope == 'Global' - - create_default.guid is defined - - create_default.managed_by == None - - create_default.name == test_win_domain_group_name - - create_default.protected_from_accidental_deletion == False - - create_default.sid is defined - - create_default_actual.rc == 0 - -- name: create group with defaults again - win_domain_group: - name: '{{test_win_domain_group_name}}' - scope: global - state: present - register: create_default_again - -- name: assert create group with defaults again - assert: - that: - - create_default_again is not changed - - create_default_again is not created - -- name: remove group check - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: absent - register: remove_group_check - check_mode: yes - -- name: get actual remove group check - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADGroup -Identity '{{test_win_domain_group_name}}'" - register: remove_group_actual_check - -- name: assert remove group check - assert: - that: - - remove_group_check is changed - - remove_group_actual_check.rc == 0 - -- name: remove group - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: absent - register: remove_group - -- name: get actual remove group - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADGroup -Identity '{{test_win_domain_group_name}}'" - register: remove_group_actual - ignore_errors: True - -- name: assert remove group - assert: - that: - - remove_group is changed - - remove_group is not created - - remove_group_actual.rc == 1 - -- name: remove group again - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: absent - register: remove_group_again - -- name: assert remove group again - assert: - that: - - remove_group_again is not changed - - remove_group_again is not created - -- name: create non default group check - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - description: Group Description - display_name: Group Display Name - managed_by: Domain Admins - organizational_unit: '{{test_win_domain_group_ou_path}}' - category: distribution - scope: domainlocal - attributes: - mail: test@email.com - wWWHomePage: www.google.com - protect: True - register: create_non_default_check - check_mode: yes - -- name: get actual create non default group check - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADGroup -Identity '{{test_win_domain_group_name}}'" - register: create_non_default_actual_check - ignore_errors: True - -- name: assert create non default group check - assert: - that: - - create_non_default_check is changed - - create_non_default_check is created - - create_non_default_actual_check.rc == 1 - -- name: create non default group - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - description: Group Description - display_name: Group Display Name - managed_by: Domain Admins - organizational_unit: '{{test_win_domain_group_ou_path}}' - category: distribution - scope: domainlocal - attributes: - mail: test@email.com - wWWHomePage: www.google.com - protect: True - register: create_non_default - -- name: get actual create non default group - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADGroup -Identity '{{test_win_domain_group_name}}'" - register: create_non_default_actual - ignore_errors: True - -- name: assert create non default group - assert: - that: - - create_non_default is changed - - create_non_default is created - - create_non_default.category == 'Distribution' - - create_non_default.description == 'Group Description' - - create_non_default.display_name == 'Group Display Name' - - create_non_default.distinguished_name == 'CN=' + test_win_domain_group_name + ',' + test_win_domain_group_ou_path - - create_non_default.group_scope == 'DomainLocal' - - create_non_default.guid is defined - - create_non_default.managed_by == 'CN=Domain Admins,CN=Users,' + test_win_domain_group_ldap_base - - create_non_default.name == test_win_domain_group_name - - create_non_default.protected_from_accidental_deletion == True - - create_non_default.sid is defined - - create_non_default.attributes.mail == 'test@email.com' - - create_non_default.attributes.wWWHomePage == 'www.google.com' - - create_non_default_actual.rc == 0 - -- name: create non default group again - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - description: Group Description - display_name: Group Display Name - managed_by: Domain Admins - organizational_unit: '{{test_win_domain_group_ou_path}}' - category: distribution - scope: domainlocal - attributes: - mail: test@email.com - wWWHomePage: www.google.com - register: create_non_default_again - -- name: assert create non default group again - assert: - that: - - create_non_default_again is not changed - - create_non_default_again is not created - -- name: try and move group with protection mode on - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - organizational_unit: CN=Users,{{test_win_domain_group_ldap_base}} - register: fail_move_with_protection - failed_when: fail_move_with_protection.msg != 'cannot move group ' + test_win_domain_group_name + ' when ProtectedFromAccidentalDeletion is turned on, run this module with ignore_protection=true to override this' - -- name: modify existing group check - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - description: New Description - display_name: New Display Name - managed_by: Administrator - organizational_unit: 'CN=Users,{{test_win_domain_group_ldap_base}}' - category: security - scope: global - attributes: - mail: anothertest@email.com - ignore_protection: True - register: modify_existing_check - check_mode: yes - -- name: get actual of modify existing group check - win_command: powershell.exe "Import-Module ActiveDirectory; (Get-ADGroup -Identity '{{test_win_domain_group_name}}').DistinguishedName" - register: modify_existing_actual_check - -- name: assert modify existing group check - assert: - that: - - modify_existing_check is changed - - modify_existing_check is not created - - modify_existing_actual_check.stdout == 'CN=' + test_win_domain_group_name + ',' + test_win_domain_group_ou_path + '\r\n' - -- name: modify existing group - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - description: New Description - display_name: New Display Name - managed_by: Administrator - organizational_unit: CN=Users,{{test_win_domain_group_ldap_base}} - category: security - scope: global - attributes: - mail: anothertest@email.com - protect: True - ignore_protection: True - register: modify_existing - -- name: get actual of modify existing group - win_command: powershell.exe "Import-Module ActiveDirectory; (Get-ADGroup -Identity '{{test_win_domain_group_name}}').DistinguishedName" - register: modify_existing_actual - -- name: assert modify existing group - assert: - that: - - modify_existing is changed - - modify_existing is not created - - modify_existing.category == 'Security' - - modify_existing.description == 'New Description' - - modify_existing.display_name == 'New Display Name' - - modify_existing.distinguished_name == 'CN=' + test_win_domain_group_name + ',CN=Users,' + test_win_domain_group_ldap_base - - modify_existing.group_scope == 'Global' - - modify_existing.guid is defined - - modify_existing.managed_by == 'CN=Administrator,CN=Users,' + test_win_domain_group_ldap_base - - modify_existing.name == test_win_domain_group_name - - modify_existing.protected_from_accidental_deletion == True - - modify_existing.sid is defined - - modify_existing.attributes.mail == 'anothertest@email.com' - - modify_existing_actual.stdout == 'CN=' + test_win_domain_group_name + ',CN=Users,' + test_win_domain_group_ldap_base + '\r\n' - -- name: modify existing group again - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - description: New Description - display_name: New Display Name - managed_by: Administrator - organizational_unit: CN=Users,{{test_win_domain_group_ldap_base}} - category: Security - scope: global - attributes: - mail: anothertest@email.com - protect: True - ignore_protection: True - register: modify_existing_again - -- name: assert modify existing group again - assert: - that: - - modify_existing_again is not changed - - modify_existing_again is not created - -- name: fail change managed_by to invalid user - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: present - scope: global - managed_by: fake user - register: fail_invalid_managed_by_user - failed_when: fail_invalid_managed_by_user.msg != 'failed to find managed_by user or group fake user to be used for comparison' - -- name: fail delete group with protection mode on - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: absent - register: fail_delete_with_protection - failed_when: fail_delete_with_protection.msg != 'cannot delete group ' + test_win_domain_group_name + ' when ProtectedFromAccidentalDeletion is turned on, run this module with ignore_protection=true to override this' - -- name: delete group with protection mode on - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: absent - ignore_protection: True - register: delete_with_force - -- name: get actual delete group with protection mode on - win_command: powershell.exe "Import-Module ActiveDirectory; Get-ADGroup -Identity '{{test_win_domain_group_name}}'" - register: delete_with_force_actual - ignore_errors: True - -- name: assert delete group with protection mode on - assert: - that: - - delete_with_force is changed - - delete_with_force is not created - - delete_with_force_actual.rc == 1 - -- name: ensure the test group is deleted after the test - win_domain_group: - name: '{{test_win_domain_group_name}}' - state: absent - ignore_protection: True diff --git a/test/integration/targets/win_domain_object_info/aliases b/test/integration/targets/win_domain_object_info/aliases deleted file mode 100644 index ad7ccf7ada..0000000000 --- a/test/integration/targets/win_domain_object_info/aliases +++ /dev/null @@ -1 +0,0 @@ -unsupported diff --git a/test/integration/targets/win_domain_object_info/handlers/main.yml b/test/integration/targets/win_domain_object_info/handlers/main.yml deleted file mode 100644 index 76a2a0f762..0000000000 --- a/test/integration/targets/win_domain_object_info/handlers/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -- name: remove test domain user - win_domain_user: - name: '{{ test_user.distinguished_name }}' - state: absent diff --git a/test/integration/targets/win_domain_object_info/tasks/main.yml b/test/integration/targets/win_domain_object_info/tasks/main.yml deleted file mode 100644 index 54ea126aa9..0000000000 --- a/test/integration/targets/win_domain_object_info/tasks/main.yml +++ /dev/null @@ -1,125 +0,0 @@ -# These tests can't run in CI, this is really just a basic smoke tests for local runs. ---- -- name: assert better error message on auth failure - win_domain_object_info: - identity: id - register: fail_auth - failed_when: '"Failed to contact the AD server, this could be caused by the double hop problem" not in fail_auth.msg' - vars: - ansible_winrm_transport: ntlm - ansible_psrp_auth: ntlm - -- name: create test ad user - win_domain_user: - name: Ansible Test - firstname: Ansible - surname: Test - company: Contoso R Us - password: Password01 - state: present - password_never_expires: yes - groups: - - Domain Users - enabled: false - register: test_user - notify: remove test domain user - -- name: set a binary attribute and return other useful info missing from above - win_shell: | - Set-ADUser -Identity '{{ test_user.sid }}' -Replace @{ audio = @([byte[]]@(1, 2, 3, 4), [byte[]]@(5, 6, 7, 8)) } - - $user = Get-ADUser -Identity '{{ test_user.sid }}' -Properties modifyTimestamp, ObjectGUID - - [TimeZoneInfo]::ConvertTimeToUtc($user.modifyTimestamp).ToString('o') - $user.ObjectGUID.ToString() - ([System.Security.Principal.SecurityIdentifier]'{{ test_user.sid }}').Translate([System.Security.Principal.NTAccount]).Value - register: test_user_extras - -- name: set other test info for easier access - set_fact: - test_user_mod_date: '{{ test_user_extras.stdout_lines[0] }}' - test_user_id: '{{ test_user_extras.stdout_lines[1] }}' - test_user_name: '{{ test_user_extras.stdout_lines[2] }}' - -- name: get properties for single user by DN - win_domain_object_info: - identity: '{{ test_user.distinguished_name }}' - register: by_identity - check_mode: yes # Just verifies it runs in check mode - -- name: assert get properties for single user by DN - assert: - that: - - not by_identity is changed - - by_identity.objects | length == 1 - - by_identity.objects[0].keys() | list | length == 4 - - by_identity.objects[0].DistinguishedName == test_user.distinguished_name - - by_identity.objects[0].Name == 'Ansible Test' - - by_identity.objects[0].ObjectClass == 'user' - - by_identity.objects[0].ObjectGUID == test_user_id - -- name: get specific properties by GUID - win_domain_object_info: - identity: '{{ test_user_id }}' - properties: - - audio # byte[] - - company # string - - department # not set - - logonCount # int - - modifyTimestamp # DateTime - - nTSecurityDescriptor # SecurityDescriptor as SDDL - - objectSID # SID - - ProtectedFromAccidentalDeletion # bool - - sAMAccountType # Test out the enum string attribute that we add - - userAccountControl # Test ou the enum string attribute that we add - register: by_guid_custom_props - -- name: assert get specific properties by GUID - assert: - that: - - not by_guid_custom_props is changed - - by_guid_custom_props.objects | length == 1 - - by_guid_custom_props.objects[0].DistinguishedName == test_user.distinguished_name - - by_guid_custom_props.objects[0].Name == 'Ansible Test' - - by_guid_custom_props.objects[0].ObjectClass == 'user' - - by_guid_custom_props.objects[0].ObjectGUID == test_user_id - - not by_guid_custom_props.objects[0].ProtectedFromAccidentalDeletion - - by_guid_custom_props.objects[0].audio == ['BQYHCA==', 'AQIDBA=='] - - by_guid_custom_props.objects[0].company == 'Contoso R Us' - - by_guid_custom_props.objects[0].department == None - - by_guid_custom_props.objects[0].logonCount == 0 - - by_guid_custom_props.objects[0].modifyTimestamp == test_user_mod_date - - by_guid_custom_props.objects[0].nTSecurityDescriptor.startswith('O:DAG:DAD:AI(') - - by_guid_custom_props.objects[0].objectSID.Name == test_user_name - - by_guid_custom_props.objects[0].objectSID.Sid == test_user.sid - - by_guid_custom_props.objects[0].sAMAccountType == 805306368 - - by_guid_custom_props.objects[0].sAMAccountType_AnsibleFlags == ['SAM_USER_OBJECT'] - - by_guid_custom_props.objects[0].userAccountControl == 66050 - - by_guid_custom_props.objects[0].userAccountControl_AnsibleFlags == ['ADS_UF_ACCOUNTDISABLE', 'ADS_UF_NORMAL_ACCOUNT', 'ADS_UF_DONT_EXPIRE_PASSWD'] - -- name: get invalid property - win_domain_object_info: - filter: sAMAccountName -eq 'Ansible Test' - properties: - - FakeProperty - register: invalid_prop_warning - -- name: assert get invalid property - assert: - that: - - not invalid_prop_warning is changed - - invalid_prop_warning.objects | length == 0 - - invalid_prop_warning.warnings | length == 1 - - '"Failed to retrieve properties for AD object" not in invalid_prop_warning.warnings[0]' - -- name: get by ldap filter returning multiple - win_domain_object_info: - ldap_filter: (&(objectClass=computer)(objectCategory=computer)) - properties: '*' - register: multiple_ldap - -- name: assert get by ldap filter returning multiple - assert: - that: - - not multiple_ldap is changed - - multiple_ldap.objects | length > 1 diff --git a/test/integration/targets/win_dotnet_ngen/aliases b/test/integration/targets/win_dotnet_ngen/aliases deleted file mode 100644 index 4c08975b17..0000000000 --- a/test/integration/targets/win_dotnet_ngen/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group6 diff --git a/test/integration/targets/win_dotnet_ngen/tasks/main.yml b/test/integration/targets/win_dotnet_ngen/tasks/main.yml deleted file mode 100644 index 146eeb3c52..0000000000 --- a/test/integration/targets/win_dotnet_ngen/tasks/main.yml +++ /dev/null @@ -1,20 +0,0 @@ -# this only tests check mode as the full run can take several minutes to -# complete, this way we at least verify the script is parsable ---- -- name: run in check mode - win_dotnet_ngen: - register: result_check - check_mode: yes - -- name: assert run in check mode - assert: - that: - - result_check is changed - - result_check.dotnet_ngen_update_exit_code == 0 - - result_check.dotnet_ngen_update_output == "check mode output for C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\ngen.exe update /force" - - result_check.dotnet_ngen_eqi_exit_code == 0 - - result_check.dotnet_ngen_eqi_output == "check mode output for C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\ngen.exe executeQueuedItems" - - result_check.dotnet_ngen64_update_exit_code == 0 - - result_check.dotnet_ngen64_update_output == "check mode output for C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\ngen.exe update /force" - - result_check.dotnet_ngen64_eqi_exit_code == 0 - - result_check.dotnet_ngen64_eqi_output == "check mode output for C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\ngen.exe executeQueuedItems" diff --git a/test/integration/targets/win_eventlog/aliases b/test/integration/targets/win_eventlog/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_eventlog/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_eventlog/tasks/main.yml b/test/integration/targets/win_eventlog/tasks/main.yml deleted file mode 100644 index dcc075fcc8..0000000000 --- a/test/integration/targets/win_eventlog/tasks/main.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: Run tests for win_eventlog in normal mode - import_tasks: tests.yml - vars: - in_check_mode: no - -- name: Run tests for win_eventlog in check-mode - import_tasks: tests.yml - vars: - in_check_mode: yes - check_mode: yes diff --git a/test/integration/targets/win_eventlog/tasks/tests.yml b/test/integration/targets/win_eventlog/tasks/tests.yml deleted file mode 100644 index b369362ee1..0000000000 --- a/test/integration/targets/win_eventlog/tasks/tests.yml +++ /dev/null @@ -1,447 +0,0 @@ -# Test code for win_eventlog - -# (c) 2017, Andrew Saraceni <andrew.saraceni@gmail.com> -# -# 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 <http://www.gnu.org/licenses/>. - -- name: Remove potentially leftover logs - win_eventlog: - name: "{{ item }}" - state: absent - with_items: - - WinEventLogTest - - NewWinEventLogTest - - -- name: Add log without sources - win_eventlog: - name: WinEventLogTest - state: present - register: add_log_without_sources - failed_when: add_log_without_sources.changed != false or add_log_without_sources.msg != "You must specify one or more sources when creating a log for the first time" - - -- name: Add log - win_eventlog: &wel_present - name: WinEventLogTest - sources: - - WinEventLogSource1 - - WinEventLogSource2 - state: present - register: add_log - -- name: Test add_log (normal mode) - assert: - that: - - add_log.changed == true - - add_log.exists == true - - add_log.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - add_log.sources_changed == ["WinEventLogSource1", "WinEventLogSource2"] - when: not in_check_mode - -- name: Test add_log (check-mode) - assert: - that: - - add_log.changed == true - - add_log.exists == false - - add_log.sources_changed == [] - when: in_check_mode - - -- name: Add log (again) - win_eventlog: *wel_present - register: add_log_again - -- name: Test add_log_again (normal mode) - assert: - that: - - add_log_again.changed == false - - add_log_again.exists == true - - add_log_again.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - add_log_again.sources_changed == [] - when: not in_check_mode - - -- name: Run tests for normal mode only (expects event log) - when: not in_check_mode - block: - - - name: Change default source - win_eventlog: - <<: *wel_present - sources: - - WinEventLogTest - category_file: C:\TestApp\AppCategories.dll - register: change_default_source - failed_when: change_default_source.changed != false or change_default_source.msg != "Cannot modify default source WinEventLogTest of log WinEventLogTest - you must remove the log" - - - - name: Change source category - win_eventlog: &welc_present - <<: *wel_present - sources: - - WinEventLogSource1 - category_file: C:\TestApp\AppCategories.dll - register: change_source_category - - - name: Test change_source_category - assert: - that: - - change_source_category.changed == true - - change_source_category.exists == true - - change_source_category.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - change_source_category.sources_changed == ["WinEventLogSource1"] - - - - name: Change source category (again) - win_eventlog: *welc_present - register: change_source_category_again - - - name: Test change_source_category_again - assert: - that: - - change_source_category_again.changed == false - - change_source_category_again.exists == true - - change_source_category_again.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - change_source_category_again.sources_changed == [] - - - - name: Change source message - win_eventlog: &welm_present - <<: *welc_present - message_file: C:\TestApp\AppMessages.dll - register: change_source_message - - - name: Test change_source_message - assert: - that: - - change_source_message.changed == true - - change_source_message.exists == true - - change_source_message.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - change_source_message.sources_changed == ["WinEventLogSource1"] - - - - name: Change source message (again) - win_eventlog: *welm_present - register: change_source_message_again - - - name: Test change_source_message_again - assert: - that: - - change_source_message_again.changed == false - - change_source_message_again.exists == true - - change_source_message_again.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - change_source_message_again.sources_changed == [] - - - - name: Change source parameter - win_eventlog: &welp_present - <<: *welm_present - parameter_file: C:\TestApp\AppParameters.dll - register: change_source_parameter - - - name: Test change_source_parameter - assert: - that: - - change_source_parameter.changed == true - - change_source_parameter.exists == true - - change_source_parameter.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - change_source_parameter.sources_changed == ["WinEventLogSource1"] - - - - name: Change source parameter (again) - win_eventlog: *welp_present - register: change_source_parameter_again - - - name: Test change_source_parameter_again - assert: - that: - - change_source_parameter_again.changed == false - - change_source_parameter_again.exists == true - - change_source_parameter_again.sources == ["WinEventLogSource1", "WinEventLogSource2", "WinEventLogTest"] - - change_source_parameter_again.sources_changed == [] - - - - name: Change log maximum size - win_eventlog: &wels_present - <<: *wel_present - maximum_size: 256MB - register: change_log_maximum_size - - - name: Test change_log_maximum_size - assert: - that: - - change_log_maximum_size.changed == true - - change_log_maximum_size.exists == true - - change_log_maximum_size.maximum_size_kb == 262144 - - - - name: Change log maximum size (again) - win_eventlog: *wels_present - register: change_log_maximum_size_again - - - name: Test change_log_maximum_size_again - assert: - that: - - change_log_maximum_size_again.changed == false - - change_log_maximum_size_again.exists == true - - change_log_maximum_size_again.maximum_size_kb == 262144 - - - - name: Change log invalid maximum size 1 - win_eventlog: - <<: *wel_present - maximum_size: 256 MB - register: change_log_invalid_maximum_size_1 - failed_when: change_log_invalid_maximum_size_1.changed != false or change_log_invalid_maximum_size_1.msg != "Maximum size 256 MB is not properly specified" - - - - name: Change log invalid maximum size 2 - win_eventlog: - <<: *wel_present - maximum_size: 5GB - register: change_log_invalid_maximum_size_2 - failed_when: change_log_invalid_maximum_size_2.changed != false or change_log_invalid_maximum_size_2.msg != "Maximum size must be between 64KB and 4GB" - - - - name: Change log invalid maximum size 3 - win_eventlog: - <<: *wel_present - maximum_size: 129KB - register: change_log_invalid_maximum_size_3 - failed_when: change_log_invalid_maximum_size_3.changed != false or change_log_invalid_maximum_size_3.msg != "Maximum size must be divisible by 64KB" - - - - name: Change log retention days - win_eventlog: &welr_present - <<: *wels_present - retention_days: 128 - register: change_log_retention_days - - - name: Test change_log_retention_days - assert: - that: - - change_log_retention_days.changed == true - - change_log_retention_days.exists == true - - change_log_retention_days.retention_days == 128 - - - - name: Change log retention days (again) - win_eventlog: *welr_present - register: change_log_retention_days_again - - - name: Test change_log_retention_days_again - assert: - that: - - change_log_retention_days_again.changed == false - - change_log_retention_days_again.exists == true - - change_log_retention_days_again.retention_days == 128 - - - - name: Change log overflow action - win_eventlog: &welo_present - <<: *wels_present - overflow_action: OverwriteAsNeeded - register: change_log_overflow_action - - - name: Test change_log_overflow_action - assert: - that: - - change_log_overflow_action.changed == true - - change_log_overflow_action.exists == true - - change_log_overflow_action.overflow_action == "OverwriteAsNeeded" - - - - name: Change log overflow action (again) - win_eventlog: *welo_present - register: change_log_overflow_action_again - - - name: Test change_log_overflow_action_again - assert: - that: - - change_log_overflow_action_again.changed == false - - change_log_overflow_action_again.exists == true - - change_log_overflow_action_again.overflow_action == "OverwriteAsNeeded" - - - - name: Add log with existing source - win_eventlog: &wele_present - name: NewWinEventLogTest - sources: - - WinEventLogSource1 - state: present - register: add_log_with_existing_source - failed_when: add_log_with_existing_source.changed != false or add_log_with_existing_source.msg != "Source WinEventLogSource1 already exists and cannot be created" - - - - name: Add new log - win_eventlog: - <<: *wele_present - sources: - - NewWinEventLogSource1 - - - name: Change source for different log - win_eventlog: - <<: *wele_present - sources: - - WinEventLogSource1 - category_file: C:\TestApp\AppCategories.dll - register: change_source_for_different_log - failed_when: change_source_for_different_log.changed != false or change_source_for_different_log.msg != "Source WinEventLogSource1 does not belong to log NewWinEventLogTest and cannot be modified" - - - name: Remove new log - win_eventlog: - name: NewWinEventLogTest - state: absent - - - - name: Add entry to log - win_shell: Write-EventLog -LogName WinEventLogTest -Source WinEventLogSource1 -EntryType Information -EventId 12345 -Message "Test message" - - - name: Verify add entry - win_eventlog: - name: WinEventLogTest - state: present - register: verify_add_entry - - - name: Test verify_add_entry - assert: - that: - - verify_add_entry.changed == false - - verify_add_entry.exists == true - - verify_add_entry.entries == 1 - - - - name: Clear log - win_eventlog: &wel_clear - name: WinEventLogTest - state: clear - register: clear_log - - - name: Test clear_log - assert: - that: - - clear_log.changed == true - - clear_log.exists == true - - clear_log.entries == 0 - when: not in_check_mode - - - - name: Clear log (again) - win_eventlog: *wel_clear - register: clear_log_again - - - name: Test clear_log_again - assert: - that: - - clear_log_again.changed == false - - clear_log_again.exists == true - - clear_log_again.entries == 0 - when: in_check_mode - - -- name: Clear absent log - win_eventlog: - name: WinEventLogTest - state: clear - register: clear_absent_log - when: in_check_mode - failed_when: clear_absent_log.changed != false or clear_absent_log.msg != "Cannot clear log WinEventLogTest as it does not exist" - - -- name: Remove default source - win_eventlog: &weld_absent - name: WinEventLogTest - sources: - - WinEventLogTest - state: absent - register: remove_default_source - failed_when: remove_default_source.changed != false or remove_default_source.msg != "Cannot remove default source WinEventLogTest from log WinEventLogTest - you must remove the log" - - -- name: Remove source - win_eventlog: &wels_absent - <<: *weld_absent - sources: - - WinEventLogSource1 - register: remove_source - -- name: Test remove_source (normal mode) - assert: - that: - - remove_source.changed == true - - remove_source.exists == true - - remove_source.sources == ["WinEventLogSource2", "WinEventLogTest"] - - remove_source.sources_changed == ["WinEventLogSource1"] - when: not in_check_mode - -- name: Test remove_source (check-mode) - assert: - that: - - remove_source.changed == false - - remove_source.exists == false - - remove_source.sources_changed == [] - when: in_check_mode - - -- name: Remove source (again) - win_eventlog: *wels_absent - register: remove_source_again - -- name: Test remove_source_again (normal mode) - assert: - that: - - remove_source_again.changed == false - - remove_source_again.exists == true - - remove_source.sources == ["WinEventLogSource2", "WinEventLogTest"] - - remove_source_again.sources_changed == [] - when: not in_check_mode - - -- name: Remove log - win_eventlog: &wel_absent - name: WinEventLogTest - state: absent - register: remove_log - -- name: Test remove_log (normal mode) - assert: - that: - - remove_log.changed == true - - remove_log.exists == false - - remove_log.sources_changed == ["WinEventLogSource2", "WinEventLogTest"] - when: not in_check_mode - -- name: Test remove_log (check-mode) - assert: - that: - - remove_log.changed == false - - remove_log.exists == false - - remove_log.sources_changed == [] - when: in_check_mode - - -- name: Remove log (again) - win_eventlog: *wel_absent - register: remove_log_again - -- name: Test remove_log_again (normal mode) - assert: - that: - - remove_log_again.changed == false - - remove_log_again.exists == false - - remove_log_again.sources_changed == [] - when: not in_check_mode diff --git a/test/integration/targets/win_eventlog_entry/aliases b/test/integration/targets/win_eventlog_entry/aliases deleted file mode 100644 index 215e0b0692..0000000000 --- a/test/integration/targets/win_eventlog_entry/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group4 diff --git a/test/integration/targets/win_eventlog_entry/defaults/main.yml b/test/integration/targets/win_eventlog_entry/defaults/main.yml deleted file mode 100644 index 611d16ec0e..0000000000 --- a/test/integration/targets/win_eventlog_entry/defaults/main.yml +++ /dev/null @@ -1,6 +0,0 @@ -win_test_log_source: - log: WinEventLogEntryTest - source: WinEventLogEntrySource -win_test_log_source_extra: - log: ExtraWinEventLogEntryTest - source: ExtraWinEventLogEntrySource diff --git a/test/integration/targets/win_eventlog_entry/library/test_win_eventlog_entry.ps1 b/test/integration/targets/win_eventlog_entry/library/test_win_eventlog_entry.ps1 deleted file mode 100644 index 2af179b5f6..0000000000 --- a/test/integration/targets/win_eventlog_entry/library/test_win_eventlog_entry.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -#!powershell - -# (c) 2017, Andrew Saraceni <andrew.saraceni@gmail.com> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -#Requires -Module Ansible.ModuleUtils.Legacy - -# Test module used to grab the latest entry from an event log and output its properties - -$ErrorActionPreference = "Stop" - -$params = Parse-Args $args -supports_check_mode $true -$log = Get-AnsibleParam -obj $params -name "log" -type "str" -failifempty $true - -$result = @{ - changed = $false -} - -try { - $log_entry = Get-EventLog -LogName $log | Select-Object -First 1 -Property * -} -catch { - Fail-Json -obj $result -message "Could not find any entries for log $log" -} - -$result.source = $log_entry.Source -$result.event_id = $log_entry.EventID -$result.message = $log_entry.Message -$result.entry_type = $log_entry.EntryType.ToString() -$result.category = $log_entry.CategoryNumber -$result.raw_data = $log_entry.Data -join "," - -Exit-Json -obj $result diff --git a/test/integration/targets/win_eventlog_entry/tasks/main.yml b/test/integration/targets/win_eventlog_entry/tasks/main.yml deleted file mode 100644 index 142a3897a6..0000000000 --- a/test/integration/targets/win_eventlog_entry/tasks/main.yml +++ /dev/null @@ -1,33 +0,0 @@ -# win_shell invocations can eventually be replaced with win_eventlog -- name: Remove potentially leftover test logs and sources - win_shell: Remove-EventLog -LogName "{{ item.log }}" -ErrorAction SilentlyContinue - with_items: - - "{{ win_test_log_source }}" - - "{{ win_test_log_source_extra }}" - failed_when: no - -- name: Add new test logs and sources - win_shell: New-EventLog -LogName "{{ item.log }}" -Source "{{ item.source }}" - with_items: - - "{{ win_test_log_source }}" - - "{{ win_test_log_source_extra }}" - -- name: Run tests for win_eventlog_entry - block: - - - name: Test in normal mode - import_tasks: tests.yml - vars: - in_check_mode: no - - - name: Test in check-mode - import_tasks: tests.yml - vars: - in_check_mode: yes - check_mode: yes - -- name: Remove test logs and sources - win_shell: Remove-EventLog -LogName "{{ item.log }}" - with_items: - - "{{ win_test_log_source }}" - - "{{ win_test_log_source_extra }}" diff --git a/test/integration/targets/win_eventlog_entry/tasks/tests.yml b/test/integration/targets/win_eventlog_entry/tasks/tests.yml deleted file mode 100644 index 17b78eb0ef..0000000000 --- a/test/integration/targets/win_eventlog_entry/tasks/tests.yml +++ /dev/null @@ -1,159 +0,0 @@ -# Test code for win_eventlog_entry - -# (c) 2017, Andrew Saraceni <andrew.saraceni@gmail.com> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -- name: Add entry to fake log - win_eventlog_entry: - log: FakeLogName - source: "{{ win_test_log_source.source }}" - event_id: 12345 - message: This is a test log entry message - register: add_entry_to_fake_log - failed_when: add_entry_to_fake_log.changed != false or add_entry_to_fake_log.msg != "Log FakeLogName does not exist and cannot be written to" - - -- name: Add entry from fake source - win_eventlog_entry: - log: "{{ win_test_log_source.log }}" - source: FakeSourceName - event_id: 12345 - message: This is a test log entry message - register: add_entry_from_fake_source - failed_when: add_entry_from_fake_source.changed != false or add_entry_from_fake_source.msg != "Source FakeSourceName does not exist" - - -- name: Add entry with invalid event_id - win_eventlog_entry: - log: "{{ win_test_log_source.log }}" - source: "{{ win_test_log_source.source }}" - event_id: 67000 - message: This is a test log entry message - register: add_entry_with_invalid_event_id - failed_when: add_entry_with_invalid_event_id.changed != false or add_entry_with_invalid_event_id.msg != "Event ID must be between 0 and 65535" - - -- name: Add entry from other log source - win_eventlog_entry: - log: "{{ win_test_log_source.log }}" - source: "{{ win_test_log_source_extra.source }}" - event_id: 12345 - message: This is a test log entry message - register: add_entry_from_other_log_source - failed_when: add_entry_from_other_log_source.changed != false or add_entry_from_other_log_source.msg != "Source {{ win_test_log_source_extra.source }} does not belong to log {{ win_test_log_source.log }} and cannot be written to" - - -- name: Add entry - win_eventlog_entry: &wele - log: "{{ win_test_log_source.log }}" - source: "{{ win_test_log_source.source }}" - event_id: 12345 - message: This is a test log entry message - register: add_entry - -- name: Test add_entry - assert: - that: - - add_entry.changed == true - - add_entry.msg == "Entry added to log {{ win_test_log_source.log }} from source {{ win_test_log_source.source }}" - -- name: Test add_entry count (normal mode) - win_shell: (Get-EventLog -LogName "{{ win_test_log_source.log }}").Count - register: add_entry_count - failed_when: add_entry_count.stdout_lines[0] != "1" - when: not in_check_mode - -- name: Test add_entry result (normal mode) - test_win_eventlog_entry: - log: "{{ win_test_log_source.log }}" - register: add_entry_result - when: not in_check_mode - -- name: Test add_entry_result (normal mode) - assert: - that: - - add_entry_result.source == win_test_log_source.source - - add_entry_result.event_id == 12345 - - add_entry_result.message == "This is a test log entry message" - when: not in_check_mode - - -- name: Add entry (again) - win_eventlog_entry: *wele - register: add_entry_again - -- name: Test add_entry_again (normal mode) - assert: - that: - - add_entry_again.changed == true - - add_entry_again.msg == "Entry added to log {{ win_test_log_source.log }} from source {{ win_test_log_source.source }}" - when: not in_check_mode - -- name: Test add_entry_again count (normal mode) - win_shell: (Get-EventLog -LogName "{{ win_test_log_source.log }}").Count - register: add_entry_again_count - failed_when: add_entry_again_count.stdout_lines[0] != "2" - when: not in_check_mode - - -- name: Add entry all options - win_eventlog_entry: &wele_ao - <<: *wele - event_id: 500 - message: This is a test error message - entry_type: Error - category: 5 - raw_data: 10,20 - register: add_entry_all_options - -- name: Test add_entry_all_options - assert: - that: - - add_entry_all_options.changed == true - - add_entry_all_options.msg == "Entry added to log {{ win_test_log_source.log }} from source {{ win_test_log_source.source }}" - -- name: Test add_entry_all_options count (normal mode) - win_shell: (Get-EventLog -LogName "{{ win_test_log_source.log }}").Count - register: add_entry_all_options_count - failed_when: add_entry_all_options_count.stdout_lines[0] != "3" - when: not in_check_mode - -- name: Test add_entry_all_options result (normal mode) - test_win_eventlog_entry: - log: "{{ win_test_log_source.log }}" - register: add_entry_all_options_result - when: not in_check_mode - -- name: Test add_entry_all_options_result (normal mode) - assert: - that: - - add_entry_all_options_result.source == win_test_log_source.source - - add_entry_all_options_result.event_id == 500 - - add_entry_all_options_result.message == "This is a test error message" - - add_entry_all_options_result.entry_type == "Error" - - add_entry_all_options_result.category == 5 - - add_entry_all_options_result.raw_data == "10,20" - when: not in_check_mode - - -- name: Add entry all options (again) - win_eventlog_entry: *wele_ao - register: add_entry_all_options_again - -- name: Test add_entry_all_options_again (normal mode) - assert: - that: - - add_entry_all_options_again.changed == true - - add_entry_all_options_again.msg == "Entry added to log {{ win_test_log_source.log }} from source {{ win_test_log_source.source }}" - when: not in_check_mode - -- name: Test add_entry_all_options_again count (normal mode) - win_shell: (Get-EventLog -LogName "{{ win_test_log_source.log }}").Count - register: add_entry_all_options_again_count - failed_when: add_entry_all_options_again_count.stdout_lines[0] != "4" - when: not in_check_mode - - -- name: Clear event log entries - win_shell: Clear-EventLog -LogName "{{ win_test_log_source.log }}" - when: not in_check_mode diff --git a/test/integration/targets/win_file_compression/aliases b/test/integration/targets/win_file_compression/aliases deleted file mode 100644 index 4c08975b17..0000000000 --- a/test/integration/targets/win_file_compression/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group6 diff --git a/test/integration/targets/win_file_compression/defaults/main.yml b/test/integration/targets/win_file_compression/defaults/main.yml deleted file mode 100644 index ae24afe7c3..0000000000 --- a/test/integration/targets/win_file_compression/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -test_win_file_compression_suffix: win_file_compression .ÅÑŚÌβŁÈ [$!@^&test(;)] -test_win_file_compression_sub_directories: - - 'a' - - 'b' -test_win_file_compression_filename: 'foo.bar' diff --git a/test/integration/targets/win_file_compression/meta/main.yml b/test/integration/targets/win_file_compression/meta/main.yml deleted file mode 100644 index 9f37e96cd9..0000000000 --- a/test/integration/targets/win_file_compression/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- setup_remote_tmp_dir diff --git a/test/integration/targets/win_file_compression/tasks/main.yml b/test/integration/targets/win_file_compression/tasks/main.yml deleted file mode 100644 index 9237c5e61a..0000000000 --- a/test/integration/targets/win_file_compression/tasks/main.yml +++ /dev/null @@ -1,224 +0,0 @@ ---- -- name: set fact of special testing dir - set_fact: - test_directory: '{{ remote_tmp_dir }}\{{ test_win_file_compression_suffix }}' - -- name: create sub directories - win_file: - state: directory - path: "{{ test_directory }}\\{{ item }}" - loop: "{{ test_win_file_compression_sub_directories }}" - -- name: set main directory as hidden to test out edge cases - win_shell: (Get-Item -LiteralPath '{{ test_directory }}').Attributes = [System.IO.FileAttributes]::Hidden - -- name: Compress parent directory - win_file_compression: - path: "{{ test_directory }}" - state: present - register: result - -- name: Get actual attributes for parent directory - win_stat: - path: "{{ test_directory }}" - register: folder_info - -- assert: - that: - - "'Compressed' in folder_info.stat.attributes" - - "result.changed == true" - -- name: Get actual attributes for sub directories - win_stat: - path: "{{ test_directory }}\\{{ item }}" - register: subfolder_info - loop: "{{ test_win_file_compression_sub_directories }}" - -- assert: - that: - - "'Compressed' not in item.stat.attributes" - loop: "{{ subfolder_info.results }}" - -- name: Compress parent directory (idempotent) - win_file_compression: - path: "{{ test_directory }}" - state: present - register: result - -- assert: - that: - - "result.changed == false" - -- name: Compress parent directory and all subdirectories - win_file_compression: - path: "{{ test_directory }}" - state: present - recurse: yes - register: result - -- name: Get actual attributes for parent directory - win_stat: - path: "{{ test_directory }}" - register: folder_info - -- assert: - that: - - "'Compressed' in folder_info.stat.attributes" - - "result.changed == true" - -- name: Get actual attributes for sub directories - win_stat: - path: "{{ test_directory }}\\{{ item }}" - register: subfolder_info - loop: "{{ test_win_file_compression_sub_directories }}" - -- assert: - that: - - "'Compressed' in item.stat.attributes" - loop: "{{ subfolder_info.results }}" - -- name: Compress parent directory and all subdirectories (idempotent) - win_file_compression: - path: "{{ test_directory }}" - state: present - recurse: yes - register: result - -- assert: - that: - - "result.changed == false" - -- name: Uncompress parent directory - win_file_compression: - path: "{{ test_directory }}" - state: absent - recurse: no - register: result - -- name: Get actual attributes for parent directory - win_stat: - path: "{{ test_directory }}" - register: folder_info - -- assert: - that: - - "'Compressed' not in folder_info.stat.attributes" - - "result.changed == true" - -- name: Get actual attributes for sub directories - win_stat: - path: "{{ test_directory }}\\{{ item }}" - register: subfolder_info - loop: "{{ test_win_file_compression_sub_directories }}" - -- assert: - that: - - "'Compressed' in item.stat.attributes" - loop: "{{ subfolder_info.results }}" - -- name: Uncompress parent directory (idempotent) - win_file_compression: - path: "{{ test_directory }}" - state: absent - recurse: no - register: result - -- assert: - that: - - "result.changed == false" - -- name: Uncompress parent directory and all subdirectories - win_file_compression: - path: "{{ test_directory }}" - state: absent - recurse: yes - register: result - -- name: Get actual attributes for parent directory - win_stat: - path: "{{ test_directory }}" - register: folder_info - -- assert: - that: - - "'Compressed' not in folder_info.stat.attributes" - - "result.changed == true" - -- name: Get actual attributes for sub directories - win_stat: - path: "{{ test_directory }}\\{{ item }}" - register: subfolder_info - loop: "{{ test_win_file_compression_sub_directories }}" - -- assert: - that: - - "'Compressed' not in item.stat.attributes" - loop: "{{ subfolder_info.results }}" - -- name: Uncompress parent directory and all subdirectories (idempotent) - win_file_compression: - path: "{{ test_directory }}" - state: absent - recurse: yes - register: result - -- assert: - that: - - "result.changed == false" - -- name: Create test file - win_file: - state: touch - path: "{{ test_directory }}\\{{ test_win_file_compression_filename }}" - -- name: Compress specific file - win_file_compression: - path: "{{ test_directory }}\\{{ test_win_file_compression_filename }}" - state: present - register: result - -- name: Get actual attributes of file - win_stat: - path: "{{ test_directory }}\\{{ test_win_file_compression_filename }}" - register: testfile_info - -- assert: - that: - - "result.changed == true" - - "'Compressed' in testfile_info.stat.attributes" - -- name: Compress specific file (idempotent) - win_file_compression: - path: "{{ test_directory }}\\{{ test_win_file_compression_filename }}" - state: present - register: result - -- assert: - that: - - "result.changed == false" - -- name: Uncompress specific file - win_file_compression: - path: "{{ test_directory }}\\{{ test_win_file_compression_filename }}" - state: absent - register: result - -- name: Get actual attributes of file - win_stat: - path: "{{ test_directory }}\\{{ test_win_file_compression_filename }}" - register: testfile_info - -- assert: - that: - - "result.changed == true" - - "'Compressed' not in testfile_info.stat.attributes" - -- name: Uncompress specific file (idempotent) - win_file_compression: - path: "{{ test_directory }}\\{{ test_win_file_compression_filename }}" - state: absent - register: result - -- assert: - that: - - "result.changed == false" diff --git a/test/integration/targets/win_firewall/aliases b/test/integration/targets/win_firewall/aliases deleted file mode 100644 index 3ca843d7c3..0000000000 --- a/test/integration/targets/win_firewall/aliases +++ /dev/null @@ -1,5 +0,0 @@ -shippable/windows/group2 -skip/windows/2008 -skip/windows/2008-R2 -skip/windows/2012 -skip/windows/2012-R2 diff --git a/test/integration/targets/win_firewall/tasks/main.yml b/test/integration/targets/win_firewall/tasks/main.yml deleted file mode 100644 index 522a5e59c9..0000000000 --- a/test/integration/targets/win_firewall/tasks/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -# NOTE: The win_firewall module only works on WMF 5+ - -- setup: - -- name: Test Windows capabilities - raw: Get-Command Get-NetFirewallProfile -ErrorAction SilentlyContinue; return $? - failed_when: no - register: get_netfirewallprofile - -- name: Only run tests when Windows is capable - when: get_netfirewallprofile.rc == 0 and ansible_powershell_version >= 5 - block: - - name: Turn off Windows Firewall (begin) - win_firewall: - profiles: [ Domain, Private, Public ] - state: disabled - register: firewall_off - - - name: Test firewall_off - assert: - that: - - not firewall_off.Domain.enabled - - not firewall_off.Private.enabled - - not firewall_off.Public.enabled - - - - name: Test in normal mode - import_tasks: tests.yml - vars: - in_check_mode: no - - - - name: Test in check-mode - import_tasks: tests.yml - vars: - in_check_mode: yes - check_mode: yes - - - - name: Turn on Windows Firewall (end) - win_firewall: - profiles: [ Domain, Private, Public ] - state: enabled - register: firewall_on - - - name: Test firewall_on - assert: - that: - - firewall_on is changed - - firewall_on.Domain.enabled - - firewall_on.Private.enabled - - firewall_on.Public.enabled diff --git a/test/integration/targets/win_firewall/tasks/tests.yml b/test/integration/targets/win_firewall/tasks/tests.yml deleted file mode 100644 index ae5874ca5b..0000000000 --- a/test/integration/targets/win_firewall/tasks/tests.yml +++ /dev/null @@ -1,185 +0,0 @@ -# We start with firewall turned off - -- name: Turn off Windows Firewall again - win_firewall: - profiles: [ Domain, Private, Public ] - state: disabled - register: firewall_off_again - -- name: Test firewall_off_again - assert: - that: - - firewall_off_again is not changed - - not firewall_off_again.Domain.enabled - - not firewall_off_again.Private.enabled - - not firewall_off_again.Public.enabled - -- name: Turn on Windows Firewall on Public - win_firewall: - profiles: [ Public ] - state: enabled - register: firewall_public_on - -- name: Test firewall_public_on - assert: - that: - - firewall_public_on is changed - - not firewall_public_on.Domain.enabled - - not firewall_public_on.Private.enabled - - firewall_public_on.Public.enabled - - -- name: Turn on Windows Firewall on Public again - win_firewall: - profiles: [ Public ] - state: enabled - register: firewall_public_on_again - -- name: Test firewall_public_on_again (normal mode) - assert: - that: - - firewall_public_on_again is not changed - - not firewall_public_on_again.Domain.enabled - - not firewall_public_on_again.Private.enabled - - firewall_public_on_again.Public.enabled - when: not in_check_mode - -- name: Test firewall_public_on_again (check-mode) - assert: - that: - - firewall_public_on_again is changed - - not firewall_public_on_again.Domain.enabled - - not firewall_public_on_again.Private.enabled - - firewall_public_on_again.Public.enabled - when: in_check_mode - - -# On purpose not a list -- name: Turn on Windows Firewall on Domain - win_firewall: - profiles: Domain - state: enabled - register: firewall_domain_on - -- name: Test firewall_domain_on (normal mode) - assert: - that: - - firewall_domain_on is changed - - firewall_domain_on.Domain.enabled - - not firewall_domain_on.Private.enabled - - firewall_domain_on.Public.enabled - when: not in_check_mode - -- name: Test firewall_domain_on (check-mode) - assert: - that: - - firewall_domain_on is changed - - firewall_domain_on.Domain.enabled - - not firewall_domain_on.Private.enabled - - not firewall_domain_on.Public.enabled - when: in_check_mode - - -- name: Turn on Windows Firewall on Domain again - win_firewall: - profiles: [ Domain ] - state: enabled - register: firewall_domain_on_again - -- name: Test firewall_domain_on_again (normal mode) - assert: - that: - - firewall_domain_on_again is not changed - - firewall_domain_on.Domain.enabled - - not firewall_domain_on.Private.enabled - - firewall_domain_on.Public.enabled - when: not in_check_mode - -- name: Test firewall_domain_on_again (check-mode) - assert: - that: - - firewall_domain_on_again is changed - - firewall_domain_on.Domain.enabled - - not firewall_domain_on.Private.enabled - - not firewall_domain_on.Public.enabled - when: in_check_mode - - -- name: Turn on Windows Firewall - win_firewall: - profiles: [ Domain, Private, Public ] - state: enabled - register: firewall_on - -- name: Test firewall_on - assert: - that: - - firewall_on is changed - - firewall_on.Domain.enabled - - firewall_on.Private.enabled - - firewall_on.Public.enabled - - -# On purpose no profiles added -- name: Turn on Windows Firewall again - win_firewall: - state: enabled - register: firewall_on_again - -- name: Test firewall_on_again (normal mode) - assert: - that: - - firewall_on_again is not changed - - firewall_on_again.Domain.enabled - - firewall_on_again.Private.enabled - - firewall_on_again.Public.enabled - when: not in_check_mode - -- name: Test firewall_on_again (check-mode) - assert: - that: - - firewall_on_again is changed - - firewall_on_again.Domain.enabled - - firewall_on_again.Private.enabled - - firewall_on_again.Public.enabled - when: in_check_mode - - -# On purpose no profiles added -- name: Turn off Windows Firewall - win_firewall: - state: disabled - register: firewall_off2 - -- name: Test firewall_off2 (normal mode) - assert: - that: - - firewall_off2 is changed - - not firewall_off2.Domain.enabled - - not firewall_off2.Private.enabled - - not firewall_off2.Public.enabled - when: not in_check_mode - -- name: Test firewall_off2 (check-mode) - assert: - that: - - firewall_off2 is not changed - - not firewall_off2.Domain.enabled - - not firewall_off2.Private.enabled - - not firewall_off2.Public.enabled - when: in_check_mode - - -- name: Turn off Windows Firewall again - win_firewall: - profiles: [ Domain, Private, Public ] - state: disabled - register: firewall_off2_again - -- name: Test firewall_off2_again (normal mode) - assert: - that: - - firewall_off2_again is not changed - - not firewall_off2_again.Domain.enabled - - not firewall_off2_again.Private.enabled - - not firewall_off2_again.Public.enabled diff --git a/test/integration/targets/win_firewall_rule/aliases b/test/integration/targets/win_firewall_rule/aliases deleted file mode 100644 index 215e0b0692..0000000000 --- a/test/integration/targets/win_firewall_rule/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group4 diff --git a/test/integration/targets/win_firewall_rule/tasks/main.yml b/test/integration/targets/win_firewall_rule/tasks/main.yml deleted file mode 100644 index fe0d1aa088..0000000000 --- a/test/integration/targets/win_firewall_rule/tasks/main.yml +++ /dev/null @@ -1,474 +0,0 @@ -- name: Remove potentially leftover firewall rule - win_firewall_rule: - name: http - state: absent - action: allow - direction: in - -- name: Add firewall rule - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - register: add_firewall_rule - -- name: Check that creating new firewall rule succeeds with a change - assert: - that: - - add_firewall_rule.changed == true - -- name: Add same firewall rule (again) - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - register: add_firewall_rule_again - -- name: Check that creating same firewall rule succeeds without a change - assert: - that: - - add_firewall_rule_again.changed == false - -- name: Remove firewall rule - win_firewall_rule: - name: http - enabled: yes - state: absent - localport: 80 - action: allow - direction: in - protocol: tcp - register: remove_firewall_rule - -- name: Check that removing existing firewall rule succeeds with a change - assert: - that: - - remove_firewall_rule.changed == true - -- name: Remove absent firewall rule - win_firewall_rule: - name: http - enabled: yes - state: absent - localport: 80 - action: allow - direction: in - protocol: tcp - register: remove_absent_firewall_rule - -- name: Check that removing non existing firewall rule succeeds without a change - assert: - that: - - remove_absent_firewall_rule.changed == false - -- name: Add firewall rule - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - -- name: Change firewall rule - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: block - direction: in - protocol: tcp - register: change_firewall_rule - -- name: Check that changing firewall rule succeeds - assert: - that: - - change_firewall_rule.changed == true - -- name: Disable firewall rule - win_firewall_rule: - name: http - enabled: no - -- name: Get the actual values from the changed firewall rule - win_shell: '(New-Object -ComObject HNetCfg.FwPolicy2).Rules | Where-Object { $_.Name -eq "http" } | Foreach-Object { $_.LocalPorts; $_.Enabled; $_.Action; $_.Direction; $_.Protocol }' - register: firewall_rule_actual - -- name: Ensure that disabling the rule did not change the previous values - assert: - that: - - "firewall_rule_actual.stdout_lines[0] == '80'" # LocalPorts = 80 - - "firewall_rule_actual.stdout_lines[1] == 'False'" # Enabled = False - - "firewall_rule_actual.stdout_lines[2] == '0'" # Action = block - - "firewall_rule_actual.stdout_lines[3] == '1'" # Direction = in - - "firewall_rule_actual.stdout_lines[4] == '6'" # Protocol = tcp - -- name: Add firewall rule when remoteip is range - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.0.1-192.168.0.5 - action: allow - direction: in - protocol: tcp - -- name: Add same firewall rule when remoteip is range (again) - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.0.1-192.168.0.5 - action: allow - direction: in - protocol: tcp - register: add_firewall_rule_with_range_remoteip_again - -- name: Check that creating same firewall rule when remoteip is range succeeds without a change - assert: - that: - - add_firewall_rule_with_range_remoteip_again.changed == false - -- name: Add firewall rule when remoteip in CIDR notation - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.0.0/24 - action: allow - direction: in - protocol: tcp - -- name: Add same firewall rule when remoteip in CIDR notation (again) - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.0.0/24 - action: allow - direction: in - protocol: tcp - register: add_firewall_rule_with_cidr_remoteip_again - -- name: Check that creating same firewall rule succeeds without a change when remoteip in CIDR notation - assert: - that: - - add_firewall_rule_with_cidr_remoteip_again.changed == false - -- name: Add firewall rule when remoteip contains a netmask - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.1.0/255.255.255.0 - action: allow - direction: in - protocol: tcp - -- name: Add same firewall rule when remoteip contains a netmask (again) - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.1.0/255.255.255.0 - action: allow - direction: in - protocol: tcp - register: add_firewall_rule_remoteip_contains_netmask_again - -- name: Check that creating same firewall rule succeeds without a change when remoteip contains a netmask - assert: - that: - - add_firewall_rule_remoteip_contains_netmask_again.changed == false - -- name: Add firewall rule when remoteip is IPv4 - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.0.1 - action: allow - direction: in - protocol: tcp - -- name: Add same firewall rule when remoteip is IPv4 (again) - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.0.1 - action: allow - direction: in - protocol: tcp - register: add_firewall_rule_with_ipv4_remoteip_again - -- name: Check that creating same firewall rule when remoteip is IPv4 succeeds without a change - assert: - that: - - add_firewall_rule_with_ipv4_remoteip_again.changed == false - -- name: Add firewall rule when remoteip contains a netmask - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.2.0/255.255.255.0 - action: allow - direction: in - protocol: tcp - -- name: Add same firewall rule when remoteip in CIDR notation - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - remoteip: 192.168.2.0/24 - action: allow - direction: in - protocol: tcp - register: add_same_firewall_rule_with_cidr_remoteip - -- name: Check that creating same firewall rule succeeds without a change when remoteip contains a netmask or CIDR - assert: - that: - - add_same_firewall_rule_with_cidr_remoteip.changed == false - -- name: Add firewall rule with multiple ports - win_firewall_rule: - name: http - enabled: yes - state: present - localport: '80,81' - action: allow - direction: in - protocol: tcp - register: add_firewall_rule_with_multiple_ports - -- name: Check that creating firewall rule with multiple ports succeeds with a change - assert: - that: - - add_firewall_rule_with_multiple_ports.changed == true - -- name: Add firewall rule with interface types in string format - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - interfacetypes: 'ras,lan,wireless' - register: add_firewall_rule_with_string_interface_types - -- name: Check that creating firewall rule with interface types in string format succeeds with a change - assert: - that: - - add_firewall_rule_with_string_interface_types.changed == true - -- name: Add firewall rule with interface types in list format - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - interfacetypes: [ras, lan] - register: add_firewall_rule_with_list_interface_types - -- name: Check that creating firewall rule with interface types in list format succeeds with a change - assert: - that: - - add_firewall_rule_with_list_interface_types.changed == true - -- name: Add firewall rule with interface type 'any' - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - interfacetypes: any - register: add_firewall_rule_with_interface_type_any - -- name: Check that creating firewall rule with interface type 'any' succeeds with a change - assert: - that: - - add_firewall_rule_with_interface_type_any.changed == true - -- name: Add firewall rule with edge traversal option 'deferapp' - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - edge: deferapp - register: add_firewall_rule_with_edge_traversal - -# Setup action creates ansible_distribution_version variable -- action: setup - -- name: Check that creating firewall rule with enge traversal option 'deferapp' succeeds with a change - assert: - that: - - add_firewall_rule_with_edge_traversal.changed == true - # Works on windows >= Windows 7/Windows Server 2008 R2 - when: ansible_distribution_version is version('6.1', '>=') - -- name: Add firewall rule with 'authenticate' secure flag - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - security: authenticate - register: add_firewall_rule_with_secure_flags - -- name: Check that creating firewall rule with secure flag 'authenticate' succeeds with a change - assert: - that: - - add_firewall_rule_with_secure_flags.changed == true - # Works on windows >= Windows 8/Windows Server 2012 - when: ansible_distribution_version is version('6.2', '>=') - -- name: Add firewall rule with profiles in string format - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - profiles: 'domain,public' - register: add_firewall_rule_with_string_profiles - -- name: Check that creating firewall rule with profiles in string format succeeds with a change - assert: - that: - - add_firewall_rule_with_string_profiles.changed == true - -- name: Set firewall rule profile back to 'all' - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - profiles: [Domain, Public, Private] - register: add_firewall_rule_with_string_profiles - -- name: Check that setting firewall rule profile back to 'all' succeeds with a change - assert: - that: - - add_firewall_rule_with_string_profiles.changed == true - -- name: Add firewall rule with profiles in list format - win_firewall_rule: - name: http - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - profiles: [Domain, Private] - register: add_firewall_rule_with_list_profiles - -- name: Check that creating firewall rule with profiles in list format succeeds with a change - assert: - that: - - add_firewall_rule_with_list_profiles.changed == true - -# Test for variable expansion in the path -- name: Add rule with path that needs to be expanded - win_firewall_rule: - name: VarExpansionTest - enabled: yes - state: present - action: allow - direction: in - protocol: tcp - program: '%SystemRoot%\system32\svchost.exe' - -- name: Add same rule with path that needs to be expanded - win_firewall_rule: - name: VarExpansionTest - enabled: yes - state: present - action: allow - direction: in - protocol: tcp - program: '%SystemRoot%\system32\svchost.exe' - register: add_firewall_rule_with_var_expand_path - -- name: Check that creating same firewall rule with expanded vars identified - assert: - that: - - add_firewall_rule_with_var_expand_path.changed == false - -- name: Add firewall rule for application group - win_firewall_rule: - name: Rule for application group - enabled: yes - state: present - localport: 80 - action: allow - direction: in - protocol: tcp - group: application - register: add_firewall_rule_with_group - -- name: Check that creating firewall rule for application group succeeds with a change - assert: - that: - - add_firewall_rule_with_group.changed == true - -# Test icmptypecode -- name: Add rule with icmptypecode - win_firewall_rule: - name: icmptest - enabled: yes - state: present - action: allow - direction: in - protocol: icmpv4 - icmp_type_code: '8:*' - register: add_firewall_rule_with_icmptypecode - -- name: Check that creating same firewall rule with expanded vars identified - assert: - that: - - add_firewall_rule_with_icmptypecode.changed == true diff --git a/test/integration/targets/win_format/aliases b/test/integration/targets/win_format/aliases deleted file mode 100644 index 3aa71f86ab..0000000000 --- a/test/integration/targets/win_format/aliases +++ /dev/null @@ -1,3 +0,0 @@ -shippable/windows/group4 -skip/windows/2008 -skip/windows/2008-R2 diff --git a/test/integration/targets/win_format/meta/main.yml b/test/integration/targets/win_format/meta/main.yml deleted file mode 100644 index 9f37e96cd9..0000000000 --- a/test/integration/targets/win_format/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- setup_remote_tmp_dir diff --git a/test/integration/targets/win_format/tasks/main.yml b/test/integration/targets/win_format/tasks/main.yml deleted file mode 100644 index de773469df..0000000000 --- a/test/integration/targets/win_format/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -- name: Check if Format-Volume is supported - win_shell: if (Get-Command -Name Format-Volume -ErrorAction SilentlyContinue) { $true } else { $false } - register: module_present - -- include: pre_test.yml - when: module_present.stdout | trim | bool diff --git a/test/integration/targets/win_format/tasks/pre_test.yml b/test/integration/targets/win_format/tasks/pre_test.yml deleted file mode 100644 index edc59ae52c..0000000000 --- a/test/integration/targets/win_format/tasks/pre_test.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- set_fact: - AnsibleVhdx: '{{ remote_tmp_dir }}\AnsiblePart.vhdx' - -- name: Copy VHDX scripts - win_template: - src: "{{ item.src }}" - dest: '{{ remote_tmp_dir }}\{{ item.dest }}' - loop: - - { src: partition_creation_script.j2, dest: partition_creation_script.txt } - - { src: partition_deletion_script.j2, dest: partition_deletion_script.txt } - -- name: Create partition - win_command: diskpart.exe /s {{ remote_tmp_dir }}\partition_creation_script.txt - -- name: Run tests - block: - - include: tests.yml - always: - - name: Detach disk - win_command: diskpart.exe /s {{ remote_tmp_dir }}\partition_deletion_script.txt diff --git a/test/integration/targets/win_format/tasks/tests.yml b/test/integration/targets/win_format/tasks/tests.yml deleted file mode 100644 index 5036164eab..0000000000 --- a/test/integration/targets/win_format/tasks/tests.yml +++ /dev/null @@ -1,182 +0,0 @@ ---- -- win_shell: $AnsiPart = Get-Partition -DriveLetter T; $AnsiVol = Get-Volume -DriveLetter T; "$($AnsiPart.Size),$($AnsiVol.Size)" - register: shell_result - -- name: Assert volume size is 0 for pristine volume - assert: - that: - - shell_result.stdout | trim == "2096037888,0" - -- name: Get partition access path - win_shell: (Get-Partition -DriveLetter T).AccessPaths[1] - register: shell_partition_result - -- name: Try to format using mutually exclusive parameters - win_format: - drive_letter: T - path: "{{ shell_partition_result.stdout | trim }}" - register: format_mutex_result - ignore_errors: True - -- assert: - that: - - format_mutex_result is failed - - 'format_mutex_result.msg == "parameters are mutually exclusive: drive_letter, path, label"' - -- name: Fully format volume and assign label (check) - win_format: - drive_letter: T - new_label: Formatted - full: True - allocation_unit_size: 8192 - register: format_result_check - check_mode: True - -- win_shell: $AnsiPart = Get-Partition -DriveLetter T; $AnsiVol = Get-Volume -DriveLetter T; "$($AnsiPart.Size),$($AnsiVol.Size),$($AnsiVol.FileSystemLabel),$((Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'T:'" -Property BlockSize).BlockSize)" - register: formatted_value_result_check - -- name: Fully format volume and assign label - win_format: - drive_letter: T - new_label: Formatted - full: True - allocation_unit_size: 8192 - register: format_result - -- win_shell: $AnsiPart = Get-Partition -DriveLetter T; $AnsiVol = Get-Volume -DriveLetter T; "$($AnsiPart.Size),$($AnsiVol.Size),$($AnsiVol.FileSystemLabel),$((Get-CimInstance -ClassName Win32_Volume -Filter "DriveLetter = 'T:'" -Property BlockSize).BlockSize)" - register: formatted_value_result - -- assert: - that: - - format_result_check is changed - - format_result is changed - - formatted_value_result_check.stdout | trim == "2096037888,0,," - - formatted_value_result.stdout | trim == "2096037888,2096029696,Formatted,8192" - -- name: Format NTFS volume with integrity streams enabled - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: ntfs - integrity_streams: True - ignore_errors: True - register: ntfs_integrity_streams - -- assert: - that: - - ntfs_integrity_streams is failed - - 'ntfs_integrity_streams.msg == "Integrity streams can be enabled only on ReFS volumes. You specified: ntfs"' - -- name: Format volume (require force_format for specifying different file system) - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: fat32 - ignore_errors: True - register: require_force_format - -- assert: - that: - - require_force_format is failed - - 'require_force_format.msg == "Force format must be specified since target file system: fat32 is different from the current file system of the volume: ntfs"' - -- name: Format volume (forced) (check) - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: refs - force: True - check_mode: True - ignore_errors: True - register: not_pristine_forced_check - -- name: Format volume (forced) - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: refs - force: True - register: not_pristine_forced - -- name: Format volume (forced) (idempotence will not work) - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: refs - force: True - register: not_pristine_forced_idem_fails - -- name: Format volume (idempotence) - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: refs - register: not_pristine_forced_idem - -- assert: - that: - - not_pristine_forced_check is changed - - not_pristine_forced is changed - - not_pristine_forced_idem_fails is changed - - not_pristine_forced_idem is not changed - -- name: Add a file - win_file: - path: T:\path\to\directory - state: directory - -- name: Format volume with file inside without force and same fs - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - register: format_volume_without_force_same_fs - -- name: Format volume (forced) - to test case for files existing and a different fs - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: ntfs - force: True - -- name: Add a file - win_file: - path: T:\path\to\directory - state: directory - register: add_file_to_volume - -- name: Format volume with file inside without force - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - file_system: refs - register: format_volume_without_force - ignore_errors: True - -- name: Format volume with file inside with force - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - force: True - register: format_volume_with_force - -- assert: - that: - - add_file_to_volume is changed - - format_volume_without_force is failed - - format_volume_without_force_same_fs is not changed - - 'format_volume_without_force.msg == "Force format must be specified to format non-pristine volumes"' - - format_volume_with_force is changed - -- name: Reformat using different alu without force format - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - allocation_unit_size: 8192 - file_system: ntfs - register: reformat_using_alu_without_force - ignore_errors: True - -- assert: - that: - - reformat_using_alu_without_force is failed - -- name: Reformat using different alu using force format - win_format: - path: "{{ shell_partition_result.stdout | trim }}" - allocation_unit_size: 8192 - file_system: ntfs - force: True - register: reformat_using_alu_with_force - -- assert: - that: - - reformat_using_alu_with_force is changed diff --git a/test/integration/targets/win_format/templates/partition_creation_script.j2 b/test/integration/targets/win_format/templates/partition_creation_script.j2 deleted file mode 100644 index 8e47fda95b..0000000000 --- a/test/integration/targets/win_format/templates/partition_creation_script.j2 +++ /dev/null @@ -1,11 +0,0 @@ -create vdisk file="{{ AnsibleVhdx }}" maximum=2000 type=fixed - -select vdisk file="{{ AnsibleVhdx }}" - -attach vdisk - -convert mbr - -create partition primary - -assign letter="T" diff --git a/test/integration/targets/win_format/templates/partition_deletion_script.j2 b/test/integration/targets/win_format/templates/partition_deletion_script.j2 deleted file mode 100644 index c2be9cd144..0000000000 --- a/test/integration/targets/win_format/templates/partition_deletion_script.j2 +++ /dev/null @@ -1,3 +0,0 @@ -select vdisk file="{{ AnsibleVhdx }}" - -detach vdisk diff --git a/test/integration/targets/win_hosts/aliases b/test/integration/targets/win_hosts/aliases deleted file mode 100644 index 6036e173f1..0000000000 --- a/test/integration/targets/win_hosts/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group7 diff --git a/test/integration/targets/win_hosts/defaults/main.yml b/test/integration/targets/win_hosts/defaults/main.yml deleted file mode 100644 index c6270216d6..0000000000 --- a/test/integration/targets/win_hosts/defaults/main.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -test_win_hosts_cname: testhost -test_win_hosts_ip: 192.168.168.1 - -test_win_hosts_aliases_set: - - alias1 - - alias2 - - alias3 - - alias4 - -test_win_hosts_aliases_remove: - - alias3 - - alias4 diff --git a/test/integration/targets/win_hosts/meta/main.yml b/test/integration/targets/win_hosts/meta/main.yml deleted file mode 100644 index 9f37e96cd9..0000000000 --- a/test/integration/targets/win_hosts/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- setup_remote_tmp_dir diff --git a/test/integration/targets/win_hosts/tasks/main.yml b/test/integration/targets/win_hosts/tasks/main.yml deleted file mode 100644 index 0997375f9f..0000000000 --- a/test/integration/targets/win_hosts/tasks/main.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- name: take a copy of the original hosts file - win_copy: - src: C:\Windows\System32\drivers\etc\hosts - dest: '{{ remote_tmp_dir }}\hosts' - remote_src: yes - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: restore hosts file - win_copy: - src: '{{ remote_tmp_dir }}\hosts' - dest: C:\Windows\System32\drivers\etc\hosts - remote_src: yes diff --git a/test/integration/targets/win_hosts/tasks/tests.yml b/test/integration/targets/win_hosts/tasks/tests.yml deleted file mode 100644 index a29e01a708..0000000000 --- a/test/integration/targets/win_hosts/tasks/tests.yml +++ /dev/null @@ -1,189 +0,0 @@ ---- - -- name: add a simple host with address - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - register: add_ip - -- assert: - that: - - "add_ip.changed == true" - -- name: get actual dns result - win_shell: "try{ [array]$t = [Net.DNS]::GetHostEntry('{{ test_win_hosts_cname }}') } catch { return 'false' } if ($t[0].HostName -eq '{{ test_win_hosts_cname }}' -and $t[0].AddressList[0].toString() -eq '{{ test_win_hosts_ip }}'){ return 'true' } else { return 'false' }" - register: add_ip_actual - -- assert: - that: - - "add_ip_actual.stdout_lines[0]|lower == 'true'" - -- name: add a simple host with ipv4 address (idempotent) - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - register: add_ip - -- assert: - that: - - "add_ip.changed == false" - -- name: remove simple host - win_hosts: - state: absent - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - register: remove_ip - -- assert: - that: - - "remove_ip.changed == true" - -- name: get actual dns result - win_shell: "try{ [array]$t = [Net.DNS]::GetHostEntry('{{ test_win_hosts_cname}}') } catch { return 'false' } if ($t[0].HostName -eq '{{ test_win_hosts_cname }}' -and $t[0].AddressList[0].toString() -eq '{{ test_win_hosts_ip }}'){ return 'true' } else { return 'false' }" - register: remove_ip_actual - failed_when: "remove_ip_actual.rc == 0" - -- assert: - that: - - "remove_ip_actual.stdout_lines[0]|lower == 'false'" - -- name: remove simple host (idempotent) - win_hosts: - state: absent - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - register: remove_ip - -- assert: - that: - - "remove_ip.changed == false" - -- name: add host and set aliases - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - aliases: "{{ test_win_hosts_aliases_set | union(test_win_hosts_aliases_remove) }}" - action: set - register: set_aliases - -- assert: - that: - - "set_aliases.changed == true" - -- name: get actual dns result for host - win_shell: "try{ [array]$t = [Net.DNS]::GetHostEntry('{{ test_win_hosts_cname }}') } catch { return 'false' } if ($t[0].HostName -eq '{{ test_win_hosts_cname }}' -and $t[0].AddressList[0].toString() -eq '{{ test_win_hosts_ip }}'){ return 'true' } else { return 'false' }" - register: set_aliases_actual_host - -- assert: - that: - - "set_aliases_actual_host.stdout_lines[0]|lower == 'true'" - -- name: get actual dns results for aliases - win_shell: "try{ [array]$t = [Net.DNS]::GetHostEntry('{{ item }}') } catch { return 'false' } if ($t[0].HostName -eq '{{ test_win_hosts_cname }}' -and $t[0].AddressList[0].toString() -eq '{{ test_win_hosts_ip }}'){ return 'true' } else { return 'false' }" - register: set_aliases_actual - with_items: "{{ test_win_hosts_aliases_set | union(test_win_hosts_aliases_remove) }}" - -- assert: - that: - - "item.stdout_lines[0]|lower == 'true'" - with_items: "{{ set_aliases_actual.results }}" - -- name: add host and set aliases (idempotent) - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - aliases: "{{ test_win_hosts_aliases_set | union(test_win_hosts_aliases_remove) }}" - action: set - register: set_aliases - -- assert: - that: - - "set_aliases.changed == false" - -- name: remove aliases from the list - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - aliases: "{{ test_win_hosts_aliases_remove }}" - action: remove - register: remove_aliases - -- assert: - that: - - "remove_aliases.changed == true" - -- name: get actual dns result for removed aliases - win_shell: "try{ [array]$t = [Net.DNS]::GetHostEntry('{{ item }}') } catch { return 'false' } if ($t[0].HostName -eq '{{ test_win_hosts_cname }}' -and $t[0].AddressList[0].toString() -eq '{{ test_win_hosts_ip }}'){ return 'true' } else { return 'false' }" - register: remove_aliases_removed_actual - failed_when: "remove_aliases_removed_actual.rc == 0" - with_items: "{{ test_win_hosts_aliases_remove }}" - -- assert: - that: - - "item.stdout_lines[0]|lower == 'false'" - with_items: "{{ remove_aliases_removed_actual.results }}" - -- name: get actual dns result for remaining aliases - win_shell: "try{ [array]$t = [Net.DNS]::GetHostEntry('{{ item }}') } catch { return 'false' } if ($t[0].HostName -eq '{{ test_win_hosts_cname }}' -and $t[0].AddressList[0].toString() -eq '{{ test_win_hosts_ip }}'){ return 'true' } else { return 'false' }" - register: remove_aliases_remain_actual - with_items: "{{ test_win_hosts_aliases_set | difference(test_win_hosts_aliases_remove) }}" - -- assert: - that: - - "item.stdout_lines[0]|lower == 'true'" - with_items: "{{ remove_aliases_remain_actual.results }}" - -- name: remove aliases from the list (idempotent) - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - aliases: "{{ test_win_hosts_aliases_remove }}" - action: remove - register: remove_aliases - -- assert: - that: - - "remove_aliases.changed == false" - -- name: add aliases back - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - aliases: "{{ test_win_hosts_aliases_remove }}" - action: add - register: add_aliases - -- assert: - that: - - "add_aliases.changed == true" - -- name: get actual dns results for aliases - win_shell: "try{ [array]$t = [Net.DNS]::GetHostEntry('{{ item }}') } catch { return 'false' } if ($t[0].HostName -eq '{{ test_win_hosts_cname }}' -and $t[0].AddressList[0].toString() -eq '{{ test_win_hosts_ip }}'){ return 'true' } else { return 'false' }" - register: add_aliases_actual - with_items: "{{ test_win_hosts_aliases_set | union(test_win_hosts_aliases_remove) }}" - -- assert: - that: - - "item.stdout_lines[0]|lower == 'true'" - with_items: "{{ add_aliases_actual.results }}" - -- name: add aliases back (idempotent) - win_hosts: - state: present - ip_address: "{{ test_win_hosts_ip }}" - canonical_name: "{{ test_win_hosts_cname }}" - aliases: "{{ test_win_hosts_aliases_remove }}" - action: add - register: add_aliases - -- assert: - that: - - "add_aliases.changed == false" diff --git a/test/integration/targets/win_hotfix/aliases b/test/integration/targets/win_hotfix/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_hotfix/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_hotfix/defaults/main.yml b/test/integration/targets/win_hotfix/defaults/main.yml deleted file mode 100644 index 22edea7c16..0000000000 --- a/test/integration/targets/win_hotfix/defaults/main.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -# these hotfixes, are for Hyper-V, there may be a chance the system already has them -# but in most cases for our CI purposes they wouldn't be present -test_win_hotfix_good_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_hotfix/windows8.1-kb3027108-v2-x64_66366c7be2d64d83b63cac42bc40c0a3c01bc70d.msu -test_win_hotfix_reboot_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_hotfix/windows8.1-kb2913659-v2-x64_963a4d890c9ff9cc83a97cf54305de6451038ba4.msu -test_win_hotfix_bad_url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_hotfix/windows8-rt-kb3172729-x64_69cab4c7785b1faa3fc450f32bed4873d53bb96f.msu -test_win_hotfix_path: C:\ansible\win_hotfix - -test_win_hotfix_kb: KB3027108 -test_win_hotfix_identifier: Package_for_KB3027108~31bf3856ad364e35~amd64~~6.3.2.0 - -test_win_hotfix_reboot_kb: KB2913659 -test_win_hotfix_reboot_identifier: Package_for_KB2913659~31bf3856ad364e35~amd64~~6.3.2.0 diff --git a/test/integration/targets/win_hotfix/tasks/main.yml b/test/integration/targets/win_hotfix/tasks/main.yml deleted file mode 100644 index 8ae7a35003..0000000000 --- a/test/integration/targets/win_hotfix/tasks/main.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- -- name: filter servers that can support DISM - win_command: powershell.exe "Import-Module -Name DISM" - register: eligable_servers - ignore_errors: True - -- name: fail to run module on servers that don't support DISM - win_hotfix: - path: fake - state: present - register: fail_no_dism - failed_when: fail_no_dism.msg != 'The DISM PS module needs to be installed, this can be done through the windows-adk chocolately package' - when: eligable_servers.rc != 0 - -- name: run tests on hosts that support DISM - include_tasks: tests.yml - when: eligable_servers.rc == 0 - -- name: set output to true if running Server 2012 R2 - win_command: powershell.exe "$version = [Environment]::OSVersion.Version; if ($version.Major -eq 6 -and $version.Minor -eq 3) { 'true' } else { 'false' }" - register: test_hotfix - -- block: - - name: ensure hotfixes are uninstalled before tests - win_hotfix: - hotfix_identifier: '{{item}}' - state: absent - register: pre_uninstall - with_items: - - '{{test_win_hotfix_identifier}}' - - '{{test_win_hotfix_reboot_identifier}}' - - - name: reboot after pre test uninstall if required - win_reboot: - when: pre_uninstall.results[0].reboot_required == True or pre_uninstall.results[1].reboot_required == True - - - name: run actual hotfix tests on Server 2012 R2 only - include_tasks: tests_2012R2.yml - - always: - - name: ensure hotfixes are uninstalled after tests - win_hotfix: - hotfix_identifier: '{{item}}' - state: absent - register: post_uninstall - with_items: - - '{{test_win_hotfix_identifier}}' - - '{{test_win_hotfix_reboot_identifier}}' - - - name: reboot after post test uninstall if required - win_reboot: - when: post_uninstall.results[0].reboot_required == True or post_uninstall.results[1].reboot_required == True - - when: test_hotfix.stdout_lines[0] == "true" diff --git a/test/integration/targets/win_hotfix/tasks/tests.yml b/test/integration/targets/win_hotfix/tasks/tests.yml deleted file mode 100644 index 8e7a7df379..0000000000 --- a/test/integration/targets/win_hotfix/tasks/tests.yml +++ /dev/null @@ -1,35 +0,0 @@ -# only basic tests, doesn't actually install/uninstall and hotfixes ---- -- name: fail when source isn't set - win_hotfix: - state: present - register: fail_no_source - failed_when: fail_no_source.msg != 'source must be set when state=present' - -- name: fail when identifier or kb isn't set on absent - win_hotfix: - state: absent - register: fail_no_key - failed_when: fail_no_key.msg != 'either hotfix_identifier or hotfix_kb needs to be set when state=absent' - -- name: remove an identifier that isn't installed - win_hotfix: - hotfix_identifier: fake~identifier - state: absent - register: remove_missing_hotfix_identifier - -- name: assert remove an identifier that isn't installed - assert: - that: - - remove_missing_hotfix_identifier is not changed - -- name: remove a kb that isn't installed - win_hotfix: - hotfix_kb: KB123456 - state: absent - register: remove_missing_hotfix_kb - -- name: assert remove a kb that isn't installed - assert: - that: - - remove_missing_hotfix_kb is not changed diff --git a/test/integration/targets/win_hotfix/tasks/tests_2012R2.yml b/test/integration/targets/win_hotfix/tasks/tests_2012R2.yml deleted file mode 100644 index 2f04fd70a1..0000000000 --- a/test/integration/targets/win_hotfix/tasks/tests_2012R2.yml +++ /dev/null @@ -1,253 +0,0 @@ ---- -- name: create test staging folder - win_file: - path: '{{test_win_hotfix_path}}' - state: directory - -- name: download hotfix - win_get_url: - url: '{{test_win_hotfix_good_url}}' - dest: '{{test_win_hotfix_path}}\good.msu' - -- name: download reboot hotfix - win_get_url: - url: '{{test_win_hotfix_reboot_url}}' - dest: '{{test_win_hotfix_path}}\reboot.msu' - -- name: download bad hotfix - win_get_url: - url: '{{test_win_hotfix_bad_url}}' - dest: '{{test_win_hotfix_path}}\bad.msu' - -- name: fail install install hotfix where kb doesn't match - win_hotfix: - hotfix_kb: KB0000000 - source: '{{test_win_hotfix_path}}\good.msu' - state: present - register: fail_install_invalid_kb - failed_when: fail_install_invalid_kb.msg != 'the hotfix KB KB0000000 does not match with the source msu KB ' + test_win_hotfix_kb + ', please omit or specify the correct KB to continue' - -- name: fail install install hotfix where identifier doesn't match - win_hotfix: - hotfix_identifier: invalid - source: '{{test_win_hotfix_path}}\good.msu' - state: present - register: fail_install_invalid_identifier - failed_when: fail_install_invalid_identifier.msg != 'the hotfix identifier invalid does not match with the source msu identifier ' + test_win_hotfix_identifier + ', please omit or specify the correct identifier to continue' - -- name: fail install not applicable hotfix - win_hotfix: - source: '{{test_win_hotfix_path}}\bad.msu' - state: present - register: fail_install_not_applicable - failed_when: fail_install_not_applicable.msg != 'hotfix package is not applicable for this server' - -- name: install hotfix check - win_hotfix: - source: '{{test_win_hotfix_path}}\good.msu' - state: present - register: install_hotfix_check - check_mode: yes - -- name: get result of install hotfix check - win_command: powershell.exe Get-Hotfix -Id {{test_win_hotfix_kb}} - register: install_hotfix_actual_check - ignore_errors: True - -- name: assert install hotfix check - assert: - that: - - install_hotfix_check is changed - - install_hotfix_check.kb == test_win_hotfix_kb - - install_hotfix_check.identifier == test_win_hotfix_identifier - - install_hotfix_actual_check.rc != 0 - -- name: install hotfix - win_hotfix: - source: '{{test_win_hotfix_path}}\good.msu' - state: present - register: install_hotfix - -- name: get result of install hotfix - win_command: powershell.exe Get-Hotfix -Id {{test_win_hotfix_kb}} - register: install_hotfix_actual - -- name: assert install hotfix - assert: - that: - - install_hotfix is changed - - install_hotfix.kb == test_win_hotfix_kb - - install_hotfix.identifier == test_win_hotfix_identifier - - install_hotfix.reboot_required == False - - install_hotfix_actual.rc == 0 - -- name: install hotfix again - win_hotfix: - source: '{{test_win_hotfix_path}}\good.msu' - state: present - register: install_hotfix_again - -- name: assert install hotfix again - assert: - that: - - install_hotfix_again is not changed - - install_hotfix_again.kb == test_win_hotfix_kb - - install_hotfix_again.identifier == test_win_hotfix_identifier - - install_hotfix_again.reboot_required == False - -- name: uninstall hotfix check - win_hotfix: - hotfix_identifier: '{{test_win_hotfix_identifier}}' - state: absent - register: uninstall_hotfix_check - check_mode: yes - -- name: get result of uninstall hotfix check - win_command: powershell.exe Get-Hotfix -Id {{test_win_hotfix_kb}} - register: uninstall_hotfix_actual_check - -- name: assert uninstall hotfix check - assert: - that: - - uninstall_hotfix_check is changed - - uninstall_hotfix_check.kb == test_win_hotfix_kb - - uninstall_hotfix_check.identifier == test_win_hotfix_identifier - - uninstall_hotfix_actual_check.rc == 0 - -- name: uninstall hotfix - win_hotfix: - hotfix_identifier: '{{test_win_hotfix_identifier}}' - state: absent - register: uninstall_hotfix - -- name: get result of uninstall hotfix - win_command: powershell.exe Get-Hotfix -Id {{test_win_hotfix_kb}} - register: uninstall_hotfix_actual - ignore_errors: True - -- name: assert uninstall hotfix - assert: - that: - - uninstall_hotfix is changed - - uninstall_hotfix.kb == test_win_hotfix_kb - - uninstall_hotfix.identifier == test_win_hotfix_identifier - - uninstall_hotfix.reboot_required == False - - uninstall_hotfix_actual.rc != 0 - -- name: uninstall hotfix again - win_hotfix: - hotfix_identifier: '{{test_win_hotfix_identifier}}' - state: absent - register: uninstall_hotfix_again - -- name: assert uninstall hotfix again - assert: - that: - - uninstall_hotfix_again is not changed - - uninstall_hotfix_again.reboot_required == False - -- name: install reboot hotfix - win_hotfix: - hotfix_kb: '{{test_win_hotfix_reboot_kb}}' - source: '{{test_win_hotfix_path}}\reboot.msu' - state: present - register: install_reboot_hotfix - -- name: get result of install reboot hotfix - win_command: powershell.exe Get-Hotfix -Id {{test_win_hotfix_reboot_kb}} - register: install_hotfix_reboot_actual - -- name: assert install reboot hotfix - assert: - that: - - install_reboot_hotfix is changed - - install_reboot_hotfix.kb == test_win_hotfix_reboot_kb - - install_reboot_hotfix.identifier == test_win_hotfix_reboot_identifier - - install_reboot_hotfix.reboot_required == True - - install_hotfix_reboot_actual.rc == 0 - -- name: run install reboot again before rebooting - win_hotfix: - source: '{{test_win_hotfix_path}}\reboot.msu' - state: present - register: install_before_rebooting - -- name: assert install reboot again before rebooting - assert: - that: - - install_before_rebooting is not changed - - install_before_rebooting.reboot_required == True - -- win_reboot: - -- name: install reboot hotfix again - win_hotfix: - hotfix_identifier: '{{test_win_hotfix_reboot_identifier}}' - source: '{{test_win_hotfix_path}}\reboot.msu' - state: present - register: install_reboot_hotfix_again - -- name: assert install reboot hotfix again - assert: - that: - - install_reboot_hotfix_again is not changed - - install_reboot_hotfix_again.reboot_required == False - -- name: uninstall hotfix with kb check - win_hotfix: - hotfix_kb: '{{test_win_hotfix_reboot_kb}}' - state: absent - register: uninstall_hotfix_kb_check - check_mode: yes - -- name: get result of uninstall hotfix with kb check - win_command: powershell.exe Get-Hotfix -Id {{test_win_hotfix_reboot_kb}} - register: uninstall_hotfix_kb_actual_check - -- name: assert uninstall hotfix with kb check - assert: - that: - - uninstall_hotfix_kb_check is changed - - uninstall_hotfix_kb_check.kb == test_win_hotfix_reboot_kb - - uninstall_hotfix_kb_check.identifier == test_win_hotfix_reboot_identifier - - uninstall_hotfix_kb_check.reboot_required == False - - uninstall_hotfix_kb_actual_check.rc == 0 - -- name: uninstall hotfix with kb - win_hotfix: - hotfix_kb: '{{test_win_hotfix_reboot_kb}}' - state: absent - register: uninstall_hotfix_kb - -- name: get result of uninstall hotfix with kb - win_command: powershell.exe Get-Hotfix -Id {{test_win_hotfix_kb}} - register: uninstall_hotfix_kb_actual - ignore_errors: True - -- name: assert uninstall hotfix with kb - assert: - that: - - uninstall_hotfix_kb is changed - - uninstall_hotfix_kb.kb == test_win_hotfix_reboot_kb - - uninstall_hotfix_kb.identifier == test_win_hotfix_reboot_identifier - - uninstall_hotfix_kb.reboot_required == True - - uninstall_hotfix_kb_actual.rc != 0 - -- win_reboot: - -- name: uninstall hotfix with kb again - win_hotfix: - hotfix_kb: '{{test_win_hotfix_reboot_kb}}' - state: absent - register: uninstall_hotfix_kb_again - -- name: assert uninstall hotfix with kb again - assert: - that: - - uninstall_hotfix_kb_again is not changed - - uninstall_hotfix_kb_again.reboot_required == False - -- name: remove test staging folder - win_file: - path: '{{test_win_hotfix_path}}' - state: absent diff --git a/test/integration/targets/win_http_proxy/aliases b/test/integration/targets/win_http_proxy/aliases deleted file mode 100644 index 215e0b0692..0000000000 --- a/test/integration/targets/win_http_proxy/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group4 diff --git a/test/integration/targets/win_http_proxy/tasks/main.yml b/test/integration/targets/win_http_proxy/tasks/main.yml deleted file mode 100644 index 5da9aa7fec..0000000000 --- a/test/integration/targets/win_http_proxy/tasks/main.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- name: make sure we start the tests with no proxy set - win_http_proxy: - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: remove any explicit proxy settings - win_http_proxy: - - - name: reset WinINet proxy settings - win_inet_proxy: diff --git a/test/integration/targets/win_http_proxy/tasks/tests.yml b/test/integration/targets/win_http_proxy/tasks/tests.yml deleted file mode 100644 index c68ea611b7..0000000000 --- a/test/integration/targets/win_http_proxy/tasks/tests.yml +++ /dev/null @@ -1,265 +0,0 @@ ---- -- name: ensure we fail when proxy is not set with bypass - win_http_proxy: - bypass: abc - register: fail_bypass - failed_when: 'fail_bypass.msg != "missing parameter(s) required by ''bypass'': proxy"' - -- name: ensure we fail when proxy and source is set - win_http_proxy: - proxy: proxy - source: ie - register: fail_source - failed_when: 'fail_source.msg != "parameters are mutually exclusive: proxy, source"' - -- name: ensure we fail if an invalid protocol is specified - win_http_proxy: - proxy: - fail1: fail - fail2: fail - register: fail_protocol - failed_when: 'fail_protocol.msg != "Invalid keys found in proxy: fail1, fail2. Valid keys are http, https, ftp, socks."' - -# WinHTTP does not validate on set, this ensures the module checks and revert any failed attempts at setting the proxy -# FIXME: Only certain hosts seem to have a strict winhttp definition, we can't run this in CI for now -#- name: ensure we fail if invalid value is set -# win_http_proxy: -# proxy: fake=proxy -# register: fail_invalid -# failed_when: fail_invalid.msg != "Unknown error when trying to set proxy 'fake=proxy' or bypass ''" -# -#- name: check proxy is still set to Direct access -# win_command: netsh winhttp show proxy -# register: fail_invalid_actual -# failed_when: fail_invalid_actual.stdout_lines[3]|trim != "Direct access (no proxy server)." - -- name: set a proxy using a string (check) - win_http_proxy: - proxy: proxyhost - register: proxy_str_check - check_mode: True - -- name: get result of set a proxy using a string (check) - win_command: netsh winhttp show proxy - register: proxy_str_actual_check - -- name: assert set a proxy using a string (check) - assert: - that: - - proxy_str_check is changed - - proxy_str_actual_check.stdout_lines[3]|trim == "Direct access (no proxy server)." - -- name: set a proxy using a string - win_http_proxy: - proxy: proxyhost - register: proxy_str - -- name: get result of set a proxy using a string - win_command: netsh winhttp show proxy - register: proxy_str_actual - -- name: assert set a proxy using a string - assert: - that: - - proxy_str is changed - - 'proxy_str_actual.stdout_lines[3]|trim == "Proxy Server(s) : proxyhost"' - - 'proxy_str_actual.stdout_lines[4]|trim == "Bypass List : (none)"' - -- name: set a proxy using a string (idempotent) - win_http_proxy: - proxy: proxyhost - register: proxy_str_again - -- name: assert set a proxy using a string (idempotent) - assert: - that: - - not proxy_str_again is changed - -- name: change a proxy and set bypass (check) - win_http_proxy: - proxy: proxyhost:8080 - bypass: - - abc - - def - - <local> - register: change_proxy_check - check_mode: True - -- name: get result of change a proxy and set bypass (check) - win_command: netsh winhttp show proxy - register: change_proxy_actual_check - -- name: assert change a proxy and set bypass (check) - assert: - that: - - change_proxy_check is changed - - 'change_proxy_actual_check.stdout_lines[3]|trim == "Proxy Server(s) : proxyhost"' - - 'change_proxy_actual_check.stdout_lines[4]|trim == "Bypass List : (none)"' - -- name: change a proxy and set bypass - win_http_proxy: - proxy: proxyhost:8080 - bypass: - - abc - - def - - <local> - register: change_proxy - -- name: get result of change a proxy and set bypass - win_command: netsh winhttp show proxy - register: change_proxy_actual - -- name: assert change a proxy and set bypass - assert: - that: - - change_proxy is changed - - 'change_proxy_actual.stdout_lines[3]|trim == "Proxy Server(s) : proxyhost:8080"' - - 'change_proxy_actual.stdout_lines[4]|trim == "Bypass List : abc;def;<local>"' - -- name: change a proxy and set bypass (idempotent) - win_http_proxy: - proxy: proxyhost:8080 - bypass: abc,def,<local> - register: change_proxy_again - -- name: assert change a proxy and set bypass (idempotent) - assert: - that: - - not change_proxy_again is changed - -- name: change bypass list - win_http_proxy: - proxy: proxyhost:8080 - bypass: - - abc - - <-loopback> - register: change_bypass - -- name: get result of change bypass list - win_command: netsh winhttp show proxy - register: change_bypass_actual - -- name: assert change bypass list - assert: - that: - - change_bypass is changed - - 'change_bypass_actual.stdout_lines[3]|trim == "Proxy Server(s) : proxyhost:8080"' - - 'change_bypass_actual.stdout_lines[4]|trim == "Bypass List : abc;<-loopback>"' - -- name: remove proxy without options (check) - win_http_proxy: - register: remove_proxy_check - check_mode: yes - -- name: get result of remove proxy without options (check) - win_command: netsh winhttp show proxy - register: remove_proxy_actual_check - -- name: assert remove proxy without options (check) - assert: - that: - - remove_proxy_check is changed - - 'remove_proxy_actual_check.stdout_lines[3]|trim == "Proxy Server(s) : proxyhost:8080"' - - 'remove_proxy_actual_check.stdout_lines[4]|trim == "Bypass List : abc;<-loopback>"' - -- name: remove proxy without options - win_http_proxy: - register: remove_proxy - -- name: get result of remove proxy without options - win_command: netsh winhttp show proxy - register: remove_proxy_actual - -- name: assert remove proxy without options - assert: - that: - - remove_proxy is changed - - remove_proxy_actual.stdout_lines[3]|trim == "Direct access (no proxy server)." - -- name: remove proxy without options (idempotent) - win_http_proxy: - register: remove_proxy_again - -- name: assert remove proxy without options (idempotent) - assert: - that: - - not remove_proxy_again is changed - -- name: set proxy with dictionary - win_http_proxy: - proxy: - http: proxy:8080 - https: proxy:8443 - ftp: proxy:821 - socks: proxy:888 - register: set_dict - -- name: get result of set proxy with dictionary - win_command: netsh winhttp show proxy - register: set_dict_actual - -- name: assert set proxy with dictionary - assert: - that: - - set_dict is changed - - 'set_dict_actual.stdout_lines[3]|trim == "Proxy Server(s) : http=proxy:8080;https=proxy:8443;ftp=proxy:821;socks=proxy:888"' - - 'set_dict_actual.stdout_lines[4]|trim == "Bypass List : (none)"' - -- name: set proxy protocol with str - win_http_proxy: - proxy: http=proxy:8080;https=proxy:8443;ftp=proxy:821;socks=proxy:888 - register: set_str_protocol - -- name: assert set proxy protocol with str - assert: - that: - - not set_str_protocol is changed - -- name: remove proxy with empty string - win_http_proxy: - proxy: '' - register: remove_empty_str - -- name: get result of remove proxy with empty string - win_command: netsh winhttp show proxy - register: remove_empty_str_actual - -- name: assert remove proxy with empty string - assert: - that: - - remove_empty_str is changed - - remove_empty_str_actual.stdout_lines[3]|trim == "Direct access (no proxy server)." - -- name: set explicit proxy for WinINet - win_inet_proxy: - proxy: proxyhost:8080 - bypass: - - abc - - def - - <local> - -- name: import proxy from IE - win_http_proxy: - source: ie - register: import_ie - -- name: get result of import proxy from IE - win_command: netsh winhttp show proxy - register: import_ie_actual - -- name: assert import proxy from IE - assert: - that: - - import_ie is changed - - 'import_ie_actual.stdout_lines[3]|trim == "Proxy Server(s) : proxyhost:8080"' - - 'import_ie_actual.stdout_lines[4]|trim == "Bypass List : abc;def;<local>"' - -- name: import proxy from IE (idempotent) - win_http_proxy: - source: ie - register: import_ie_again - -- name: assert import proxy from IE (idempotent) - assert: - that: - - not import_ie_again is changed diff --git a/test/integration/targets/win_iis_webapplication/aliases b/test/integration/targets/win_iis_webapplication/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_iis_webapplication/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_iis_webapplication/defaults/main.yml b/test/integration/targets/win_iis_webapplication/defaults/main.yml deleted file mode 100644 index e5a582dee1..0000000000 --- a/test/integration/targets/win_iis_webapplication/defaults/main.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- - -test_app_name: TestApp - -test_site_name: 'Test Site' - -test_user: testuser -test_password: testpass - -test_physical_path: "{{ remote_tmp_dir }}" -test_apppool: 'testapppool' diff --git a/test/integration/targets/win_iis_webapplication/meta/main.yml b/test/integration/targets/win_iis_webapplication/meta/main.yml deleted file mode 100644 index e3dd5fb100..0000000000 --- a/test/integration/targets/win_iis_webapplication/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: -- setup_remote_tmp_dir diff --git a/test/integration/targets/win_iis_webapplication/tasks/main.yml b/test/integration/targets/win_iis_webapplication/tasks/main.yml deleted file mode 100644 index 83614f17f3..0000000000 --- a/test/integration/targets/win_iis_webapplication/tasks/main.yml +++ /dev/null @@ -1,70 +0,0 @@ ---- -# Cannot use win_feature to install IIS on Server 2008. -# Run a brief check and skip hosts that don't support -# that operation - -# Run on Server 2012 and higher -- block: - - name: ensure IIS features are installed - win_feature: - name: Web-Server - state: present - include_management_tools: True - register: feature_install - - - name: reboot after feature install - win_reboot: - when: feature_install.reboot_required - - # may be possible that copy corrupts the file - - name: Get iis configuration checksum - win_stat: - path: '{{ ansible_env.SystemRoot }}\System32\inetsrv\config\applicationHost.config' - checksum_algorithm: sha1 - register: stat_result - - - name: take a copy of the original iis configuration - win_copy: - src: '{{ ansible_env.SystemRoot }}\System32\inetsrv\config\applicationHost.config' - dest: '{{ ansible_env.TEMP }}\applicationHost.config' - remote_src: yes - register: copy_result - - - assert: - that: - - "stat_result.stat.checksum == copy_result.checksum" - - # Tests - - name: run tests on hosts that support it - include_tasks: tests.yml - - always: - # Cleanup - - name: remove test application - win_iis_webapplication: - state: absent - site: "{{ test_site_name }}" - name: "{{ test_app_name }}" - - - name: remove test application pool - win_iis_webapppool: - name: "{{ test_apppool }}" - state: absent - - - name: remove test site - win_iis_website: - name: "{{ test_site_name }}" - state: absent - - - name: restore iis configuration - win_copy: - src: '{{ ansible_env.TEMP }}\applicationHost.config' - dest: '{{ ansible_env.SystemRoot }}\System32\inetsrv\config\applicationHost.config' - remote_src: yes - register: copy_result - - - assert: - that: - - "stat_result.stat.checksum == copy_result.checksum" - - when: ansible_distribution_version is version('6.2','ge') diff --git a/test/integration/targets/win_iis_webapplication/tasks/tests.yml b/test/integration/targets/win_iis_webapplication/tasks/tests.yml deleted file mode 100644 index 135cccfeca..0000000000 --- a/test/integration/targets/win_iis_webapplication/tasks/tests.yml +++ /dev/null @@ -1,91 +0,0 @@ ---- -- name: test site exists, but stopped in case of duplicate web binding - win_iis_website: - name: "{{ test_site_name }}" - state: stopped - physical_path: 'C:\inetpub\wwwroot' - -- name: test app is absent (baseline) - win_iis_webapplication: - state: absent - site: "{{ test_site_name }}" - name: "{{ test_app_name }}" - -- name: create test app - win_iis_webapplication: - state: present - site: "{{ test_site_name }}" - name: "{{ test_app_name }}" - physical_path: "{{ test_physical_path }}" - register: result - -- assert: - that: - - 'result.changed == true' - - 'result.physical_path == test_physical_path' - -- name: create test app (idempotent) - win_iis_webapplication: - state: present - site: "{{ test_site_name }}" - name: "{{ test_app_name }}" - physical_path: "{{ test_physical_path }}" - register: result - -- assert: - that: - - 'result.changed == false' - - 'result.physical_path == test_physical_path' - -- name: set test app credentials - win_iis_webapplication: - state: present - site: "{{ test_site_name }}" - name: "{{ test_app_name }}" - connect_as: specific_user - username: "{{ test_user }}" - password: "{{ test_password }}" - register: result - -- assert: - that: - - 'result.changed == true' - - 'result.physical_path == test_physical_path' - - "result.connect_as == 'specific_user'" - -- name: set test app credentials (idempotent) - win_iis_webapplication: - state: present - site: "{{ test_site_name }}" - name: "{{ test_app_name }}" - connect_as: specific_user - username: "{{ test_user }}" - password: "{{ test_password }}" - register: result - -- assert: - that: - - 'result.changed == false' - - 'result.physical_path == test_physical_path' - - "result.connect_as == 'specific_user'" - -- name: create new test application pool - win_iis_webapppool: - name: "{{ test_apppool }}" - state: present - -- name: change app pool and use pass through authentication - win_iis_webapplication: - state: present - site: "{{ test_site_name }}" - name: "{{ test_app_name }}" - connect_as: pass_through - application_pool: "{{ test_apppool }}" - register: result - -- assert: - that: - - 'result.changed == true' - - 'result.physical_path == test_physical_path' - - "result.connect_as == 'pass_through'" - - "result.application_pool == test_apppool" diff --git a/test/integration/targets/win_iis_webapppool/aliases b/test/integration/targets/win_iis_webapppool/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_iis_webapppool/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_iis_webapppool/defaults/main.yml b/test/integration/targets/win_iis_webapppool/defaults/main.yml deleted file mode 100644 index bd0f15c998..0000000000 --- a/test/integration/targets/win_iis_webapppool/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -test_iis_webapppool_name: TestPool
\ No newline at end of file diff --git a/test/integration/targets/win_iis_webapppool/tasks/main.yml b/test/integration/targets/win_iis_webapppool/tasks/main.yml deleted file mode 100644 index ea30d7e567..0000000000 --- a/test/integration/targets/win_iis_webapppool/tasks/main.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -# Cannot use win_feature to install IIS on Server 2008. -# Run a brief check and skip hosts that don't support -# that operation -- name: check if win_feature will work on test host - win_command: powershell.exe "Get-WindowsFeature" - register: module_available - failed_when: False - -# Run actual tests -- block: - - name: ensure IIS features are installed - win_feature: - name: Web-Server - state: present - include_management_tools: True - register: feature_install - - - name: reboot after feature install - win_reboot: - when: feature_install.reboot_required - - - name: set version of IIS for tests - win_file_version: - path: C:\Windows\System32\inetsrv\w3wp.exe - register: iis_version - - - name: ensure test pool is deleted as a baseline - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: absent - - # Tests - - name: run tests on hosts that support it - include_tasks: tests.yml - - always: - # Cleanup - - name: ensure test pool is deleted - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: absent - when: module_available.rc == 0 diff --git a/test/integration/targets/win_iis_webapppool/tasks/tests.yml b/test/integration/targets/win_iis_webapppool/tasks/tests.yml deleted file mode 100644 index e47f9f05c1..0000000000 --- a/test/integration/targets/win_iis_webapppool/tasks/tests.yml +++ /dev/null @@ -1,424 +0,0 @@ ---- -- name: create default pool check - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: started - register: create_default_check - check_mode: yes - -- name: get actual of create default pool check - win_command: powershell.exe "Import-Module WebAdministration; Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}" - register: create_default_actual_check - failed_when: False - -- name: assert create default pool check - assert: - that: - - create_default_check is changed - - create_default_actual_check.rc == 1 - -- name: create default pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - register: create_default - -- name: get actual of create default pool - win_command: powershell.exe "Import-Module WebAdministration; Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}" - register: create_default_actual - failed_when: False - -- name: assert create default pool - assert: - that: - - create_default is changed - - create_default.info.attributes.name == test_iis_webapppool_name - - create_default.info.attributes.startMode == 'OnDemand' - - create_default.info.attributes.state == 'Started' - - create_default_actual.rc == 0 - -- name: change attributes of pool check - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - managedPipelineMode: 1 # Using an enum value - cpu.limit: 95 # Nested values - processModel.identityType: LocalSystem # Using an enum name - processModel.loadUserProfile: True - register: change_pool_attributes_check - check_mode: yes - -- name: assert change attributes of pool check - assert: - that: - - change_pool_attributes_check is changed - - change_pool_attributes_check.info == create_default.info - -- name: change attributes of pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - managedPipelineMode: 1 # Using an enum value - cpu.limit: 95 # Nested values - processModel.identityType: LocalSystem # Using an enum name - processModel.loadUserProfile: True - test: True - register: change_pool_attributes - -- name: assert change attributes of pool - assert: - that: - - change_pool_attributes is changed - - change_pool_attributes.info.attributes.managedPipelineMode == 'Classic' - - change_pool_attributes.info.cpu.limit == 95 - - change_pool_attributes.info.processModel.identityType == 'LocalSystem' - - change_pool_attributes.info.processModel.loadUserProfile == True - -- name: change attributes of pool again - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - managedPipelineMode: 1 # Using an enum value - cpu.limit: 95 # Nested values - processModel.identityType: LocalSystem # Using an enum name - processModel.loadUserProfile: True - register: change_pool_attributes_again - -- name: assert change attributes of pool again - assert: - that: - - change_pool_attributes_again is not changed - - change_pool_attributes_again.info == change_pool_attributes.info - -- name: change more complex variables check - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - queueLength: 500 - recycling.periodicRestart.requests: 10 # Deeply nested attribute - recycling.periodicRestart.time: "00:00:05:00.000000" # Timespan with string - processModel.pingResponseTime: "00:03:00" # Timespan without days or milliseconds - register: change_complex_attributes_check - check_mode: yes - -- name: assert change more complex variables check - assert: - that: - - change_complex_attributes_check is changed - - change_complex_attributes_check.info == change_pool_attributes_again.info - -- name: change more complex variables - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - queueLength: 500 - recycling.periodicRestart.requests: 10 # Deeply nested attribute - recycling.periodicRestart.time: "00:00:05:00.000000" # Timespan with string - processModel.pingResponseTime: "00:03:00" # Timespan without days or milliseconds - register: change_complex_attributes - -- name: assert change more complex variables - assert: - that: - - change_complex_attributes is changed - - change_complex_attributes.info.attributes.queueLength == 500 - - change_complex_attributes.info.recycling.periodicRestart.requests == 10 - - change_complex_attributes.info.recycling.periodicRestart.time.TotalSeconds == 300 - - change_complex_attributes.info.processModel.pingResponseTime.TotalSeconds == 180 - -- name: change more complex variables again - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - queueLength: 500 - recycling.periodicRestart.requests: 10 # Deeply nested attribute - recycling.periodicRestart.time: "00:00:05:00.000000" # Timespan with string - processModel.pingResponseTime: "00:03:00" # Timespan without days or milliseconds - register: change_complex_attributes_again - -- name: assert change more complex variables again - assert: - that: - - change_complex_attributes_again is not changed - - change_complex_attributes_again.info == change_complex_attributes.info - -- name: stop web pool check - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: stopped - register: stop_pool_check - check_mode: yes - -- name: get actual status of pool check - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: stop_pool_actual_check - -- name: assert stop web pool check - assert: - that: - - stop_pool_check is changed - - stop_pool_actual_check.stdout == 'Started\r\n' - -- name: stop web pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: stopped - register: stop_pool - -- name: get actual status of pool - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: stop_pool_actual - -- name: assert stop web pool - assert: - that: - - stop_pool is changed - - stop_pool_actual.stdout == 'Stopped\r\n' - -- name: stop web pool again - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: stopped - register: stop_pool_again - -- name: get actual status of pool again - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: stop_pool_actual_again - -- name: assert stop web pool again - assert: - that: - - stop_pool_again is not changed - - stop_pool_actual_again.stdout == 'Stopped\r\n' - -- name: start web pool check - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: started - register: start_pool_check - check_mode: yes - -- name: get actual status of pool check - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: start_pool_actual_check - -- name: assert start web pool check - assert: - that: - - start_pool_check is changed - - start_pool_actual_check.stdout == 'Stopped\r\n' - -- name: start web pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: started - register: start_pool - -- name: get actual status of pool - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: start_pool_actual - -- name: assert start web pool - assert: - that: - - start_pool is changed - - start_pool_actual.stdout == 'Started\r\n' - -- name: start web pool again - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: started - register: start_pool_again - -- name: get actual status of pool again - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: start_pool_actual_again - -- name: assert start web pool again - assert: - that: - - start_pool_again is not changed - - start_pool_actual_again.stdout == 'Started\r\n' - -- name: restart web pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: restarted - register: restart_pool - -- name: get actual status of pool - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: restart_pool_actual - -- name: assert restart web pool - assert: - that: - - restart_pool is changed - - restart_pool_actual.stdout == 'Started\r\n' - -- name: stop pool before restart on stop test - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: stopped - -- name: restart from stopped web pool check - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: restarted - register: restart_from_stop_pool_check - check_mode: yes - -- name: get actual status of pool check - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: restart_from_stop_pool_actual_check - -- name: assert restart from stopped web pool check - assert: - that: - - restart_from_stop_pool_check is changed - - restart_from_stop_pool_actual_check.stdout == 'Stopped\r\n' - -- name: restart from stopped web pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: restarted - register: restart_from_stop_pool - -- name: get actual status of pool - win_command: powershell.exe "Import-Module WebAdministration; (Get-Item -Path IIS:\AppPools\{{test_iis_webapppool_name}}).state" - register: restart_from_stop_pool_actual - -- name: assert restart from stopped web pool - assert: - that: - - restart_from_stop_pool is changed - - restart_from_stop_pool_actual.stdout == 'Started\r\n' - -- name: set web pool attribute that is a collection (check mode) - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - recycling.periodicRestart.schedule: "00:10:00,10:10:00" - register: collection_change_check - check_mode: yes - -- name: get result of set web pool attribute that is a collection (check mode) - win_shell: | - Import-Module WebAdministration - (Get-ItemProperty -Path "IIS:\AppPools\{{test_iis_webapppool_name}}" -Name recycling.periodicRestart.schedule).Collection | ForEach-Object { $_.value.ToString() } - register: collection_change_result_check - -- name: assert results of set web pool attribute that is a collection (check mode) - assert: - that: - - collection_change_check is changed - - collection_change_result_check.stdout == "" - -- name: set web pool attribute that is a collection - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - recycling.periodicRestart.schedule: "00:10:00,10:10:00" - register: collection_change - -- name: get result of set web pool attribute that is a collection - win_shell: | - Import-Module WebAdministration - (Get-ItemProperty -Path "IIS:\AppPools\{{test_iis_webapppool_name}}" -Name recycling.periodicRestart.schedule).Collection | ForEach-Object { $_.value.ToString() } - register: collection_change_result - -- name: assert results of set web pool attribute that is a collection - assert: - that: - - collection_change is changed - - collection_change_result.stdout_lines == [ "00:10:00", "10:10:00" ] - -- name: set web pool attribute that is a collection (idempotent) - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - recycling.periodicRestart.schedule: [ "00:10:00", "10:10:00" ] - register: collection_change_again - -- name: assert results of set web pool attribute that is a collection (idempotent) - assert: - that: - - collection_change_again is not changed - -# The following tests are only for IIS versions 8.0 or newer -- block: - - name: delete test pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: absent - - - name: create test pool - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - register: iis_attributes_blank - - - name: change attributes for newer IIS version check - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - startMode: AlwaysRunning - processModel.identityType: SpecificUser - processModel.userName: '{{ansible_user}}' - processModel.password: '{{ansible_password}}' - register: iis_attributes_new_check - check_mode: yes - - - name: assert change attributes for newer IIS version check - assert: - that: - - iis_attributes_new_check is changed - - iis_attributes_new_check.info == iis_attributes_blank.info - - - name: change attributes for newer IIS version - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - startMode: AlwaysRunning - processModel.identityType: SpecificUser - processModel.userName: '{{ansible_user}}' - processModel.password: '{{ansible_password}}' - register: iis_attributes_new - - - name: assert change attributes for newer IIS version - assert: - that: - - iis_attributes_new is changed - - iis_attributes_new.info.attributes.startMode == 'AlwaysRunning' - - iis_attributes_new.info.processModel.identityType == 'SpecificUser' - - iis_attributes_new.info.processModel.userName == ansible_user - - - name: change attributes for newer IIS version again - win_iis_webapppool: - name: '{{test_iis_webapppool_name}}' - state: present - attributes: - startMode: AlwaysRunning - processModel.identityType: 3 - processModel.userName: '{{ansible_user}}' - processModel.password: '{{ansible_password}}' - register: iis_attributes_new_again - - - name: assert change attributes for newer IIS version again - assert: - that: - - iis_attributes_new_again is not changed - - iis_attributes_new_again.info == iis_attributes_new.info - - when: iis_version.win_file_version.file_major_part|int > 7 diff --git a/test/integration/targets/win_iis_webbinding/aliases b/test/integration/targets/win_iis_webbinding/aliases deleted file mode 100644 index 4f4664b685..0000000000 --- a/test/integration/targets/win_iis_webbinding/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group5 diff --git a/test/integration/targets/win_iis_webbinding/defaults/main.yml b/test/integration/targets/win_iis_webbinding/defaults/main.yml deleted file mode 100644 index 13f0bc333f..0000000000 --- a/test/integration/targets/win_iis_webbinding/defaults/main.yml +++ /dev/null @@ -1,30 +0,0 @@ -test_iis_site_name: default web site - -http_vars: - protocol: http - port: 80 - ip: '*' - -http_header_vars: - protocol: http - port: 80 - ip: '*' - header: test.com - -https_vars: - protocol: https - port: 443 - ip: '*' - -https_header_vars: - protocol: https - port: 443 - ip: '*' - header: test.com - ssl_flags: 1 - -https_wc_vars: - protocol: https - port: 443 - ip: '127.0.0.1' - header: wc.test.com diff --git a/test/integration/targets/win_iis_webbinding/library/test_get_webbindings.ps1 b/test/integration/targets/win_iis_webbinding/library/test_get_webbindings.ps1 deleted file mode 100644 index 84ef10b75a..0000000000 --- a/test/integration/targets/win_iis_webbinding/library/test_get_webbindings.ps1 +++ /dev/null @@ -1,113 +0,0 @@ -#!powershell - -# Copyright: (c) 2017, Noah Sparks <nsparks@outlook.com> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -#Requires -Module Ansible.ModuleUtils.Legacy - -$params = Parse-Args -arguments $args -supports_check_mode $true - -$name = Get-AnsibleParam $params -name "name" -type str -failifempty $true -aliases 'website' -$host_header = Get-AnsibleParam $params -name "host_header" -type str -$protocol = Get-AnsibleParam $params -name "protocol" -type str -default 'http' -$port = Get-AnsibleParam $params -name "port" -type int -default '80' -$ip = Get-AnsibleParam $params -name "ip" -default '*' - -$result = @{ - changed = $false -} -function Create-BindingInfo { - $ht = @{ - 'bindingInformation' = $args[0].bindingInformation - 'ip' = $args[0].bindingInformation.split(':')[0] - 'port' = [int]$args[0].bindingInformation.split(':')[1] - 'hostheader' = $args[0].bindingInformation.split(':')[2] - 'isDsMapperEnabled' = $args[0].isDsMapperEnabled - 'protocol' = $args[0].protocol - 'certificateStoreName' = $args[0].certificateStoreName - 'certificateHash' = $args[0].certificateHash - } - - #handle sslflag support - If ([version][System.Environment]::OSVersion.Version -lt [version]'6.2') - { - $ht.sslFlags = 'not supported' - } - Else - { - $ht.sslFlags = [int]$args[0].sslFlags - } - - Return $ht -} - -# Used instead of get-webbinding to ensure we always return a single binding -# pass it $binding_parameters hashtable -function Get-SingleWebBinding { - - Try { - $site_bindings = get-webbinding -name $args[0].name - } - Catch { - # 2k8r2 throws this error when you run get-webbinding with no bindings in iis - If (-not $_.Exception.Message.CompareTo('Cannot process argument because the value of argument "obj" is null. Change the value of argument "obj" to a non-null value')) - { - Throw $_.Exception.Message - } - Else { return } - } - - Foreach ($binding in $site_bindings) - { - $splits = $binding.bindingInformation -split ':' - - if ( - $args[0].protocol -eq $binding.protocol -and - $args[0].ipaddress -eq $splits[0] -and - $args[0].port -eq $splits[1] -and - $args[0].hostheader -eq $splits[2] - ) - { - Return $binding - } - } -} - -# create binding search splat -$binding_parameters = @{ - Name = $name - Protocol = $protocol - Port = $port - IPAddress = $ip -} - -# insert host header to search if specified, otherwise it will return * (all bindings matching protocol/ip) -If ($host_header) -{ - $binding_parameters.HostHeader = $host_header -} -Else -{ - $binding_parameters.HostHeader = [string]::Empty -} - -# Get bindings matching parameters -Try { - $current_bindings = Get-SingleWebBinding $binding_parameters -} -Catch { - Fail-Json -obj $result -message "Failed to retrieve bindings with Get-SingleWebBinding - $($_.Exception.Message)" -} - -If ($current_bindings) -{ - Try { - $binding_info = Create-BindingInfo $current_bindings - } - Catch { - Fail-Json -obj $result -message "Failed to create binding info - $($_.Exception.Message)" - } - - $result.binding = $binding_info -} -exit-json -obj $result
\ No newline at end of file diff --git a/test/integration/targets/win_iis_webbinding/tasks/failures.yml b/test/integration/targets/win_iis_webbinding/tasks/failures.yml deleted file mode 100644 index 92736fe1bb..0000000000 --- a/test/integration/targets/win_iis_webbinding/tasks/failures.yml +++ /dev/null @@ -1,70 +0,0 @@ -- name: failure check define * for host header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: '*' - protocol: http - ip: '*' - register: failure - failed_when: failure.msg != "To make or remove a catch-all binding, please omit the host_header parameter entirely rather than specify host_header *" - -- debug: - var: failure - verbosity: 1 - -- block: - - name: get all websites from server - raw: powershell.exe "(get-website).name" - register: existing_sites - - - name: ensure all sites are removed for clean testing - win_iis_website: - name: "{{ item }}" - state: absent - with_items: - - "{{ existing_sites.stdout_lines }}" - - - name: add testremove site - win_iis_website: - name: testremove - state: started - physical_path: c:\inetpub\wwwroot - - - name: add bindings to testremove - win_iis_webbinding: - name: testremove - ip: "{{ item.ip }}" - port: "{{ item.port }}" - with_items: - - {ip: 127.0.0.1, port: 80} - - {ip: '*', port: 80} - - - name: remove ip * binding from testremove - win_iis_webbinding: - name: testremove - state: absent - port: 80 - ip: '*' - - - name: get the remaining binding from testremove - test_get_webbindings: - name: testremove - port: 80 - ip: 127.0.0.1 - register: test_result - - - debug: - var: test_result - verbosity: 1 - - - name: assert that remove *:80 doesn't also remove 127.0.0.1:80 - assert: - that: - - test_result.binding.ip == '127.0.0.1' - - test_result.binding.port == 80 - - always: - - name: remove websites - win_iis_website: - name: testremove - state: absent diff --git a/test/integration/targets/win_iis_webbinding/tasks/http.yml b/test/integration/targets/win_iis_webbinding/tasks/http.yml deleted file mode 100644 index 34c4cc2c19..0000000000 --- a/test/integration/targets/win_iis_webbinding/tasks/http.yml +++ /dev/null @@ -1,317 +0,0 @@ -#cm add -#changed true, check nothing present -- name: CM add http binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: http_no_header - check_mode: yes - -- name: CM get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: get_http_no_header - changed_when: false - -- name: CM add http binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: http_header - check_mode: yes - -- name: CM get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: get_http_header - changed_when: false - -- name: CM assert changed, but not added - assert: - that: - - http_no_header is changed - - http_no_header.binding_info is none - - get_http_no_header.binding is not defined - - http_header is changed - - http_header.binding_info is none - - get_http_header.binding is not defined - -#add -#changed true, new bindings present -- name: add http binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: http_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: get_http_no_header - changed_when: false - -- name: add http binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: http_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: get_http_header - changed_when: false - -- name: assert changed and added - assert: - that: - - http_no_header is changed - - http_no_header.binding_info is defined - - http_no_header.operation_type == 'added' - - http_no_header.binding_info.ip == "{{ http_vars.ip }}" - - http_no_header.binding_info.port == {{ http_vars.port }} - - http_no_header.binding_info.protocol == "{{ http_vars.protocol }}" - - http_header is changed - - http_header.binding_info is defined - - http_header.operation_type == 'added' - - http_header.binding_info.ip == "{{ http_header_vars.ip }}" - - http_header.binding_info.port == {{ http_header_vars.port }} - - http_header.binding_info.protocol == "{{ http_header_vars.protocol }}" - - http_header.binding_info.hostheader == "{{ http_header_vars.header }}" - -#add idem -#changed false -- name: idem add http binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: http_no_header - -- name: idem add http binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: http_header - -- name: idem assert not changed - assert: - that: - - http_no_header is not changed - - http_header is not changed - -#modify -#can't test modify for http, it will add a new binding instead since -#there's no way to match existing bindings against the new parameters - -#cm remove -#changed true, bindings still present -- name: cm remove http binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: http_no_header - check_mode: yes - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: get_http_no_header - changed_when: false - -- name: cm remove http binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: http_header - check_mode: yes - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: get_http_header - changed_when: false - -- name: cm remove assert changed, but still present - assert: - that: - - http_no_header is changed - - http_no_header.binding_info is defined - - http_no_header.operation_type == 'removed' - - http_no_header.binding_info.ip == "{{ http_vars.ip }}" - - http_no_header.binding_info.port == {{ http_vars.port }} - - http_no_header.binding_info.protocol == "{{ http_vars.protocol }}" - - get_http_no_header.binding is defined - - get_http_no_header.binding.ip == "{{ http_vars.ip }}" - - get_http_no_header.binding.port == {{ http_vars.port }} - - get_http_no_header.binding.protocol == "{{ http_vars.protocol }}" - - http_header is changed - - http_header.binding_info is defined - - http_header.operation_type == 'removed' - - http_header.binding_info.ip == "{{ http_header_vars.ip }}" - - http_header.binding_info.port == {{ http_header_vars.port }} - - http_header.binding_info.protocol == "{{ http_header_vars.protocol }}" - - http_header.binding_info.hostheader == "{{ http_header_vars.header }}" - - get_http_header.binding is defined - - get_http_header.binding.ip == "{{ http_header_vars.ip }}" - - get_http_header.binding.port == {{ http_header_vars.port }} - - get_http_header.binding.protocol == "{{ http_header_vars.protocol }}" - - get_http_header.binding.hostheader == "{{ http_header_vars.header }}" - - -#remove -#changed true, bindings gone -- name: remove http binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: http_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: get_http_no_header - changed_when: false - -- name: remove http binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: http_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: get_http_header - changed_when: false - -- name: remove assert changed and gone - assert: - that: - - http_no_header is changed - - http_no_header.operation_type == 'removed' - - http_no_header.binding_info is defined - - http_no_header.binding_info.ip == "{{ http_vars.ip }}" - - http_no_header.binding_info.port == {{ http_vars.port }} - - http_no_header.binding_info.protocol == "{{ http_vars.protocol }}" - - get_http_no_header.binding is not defined - - http_header is changed - - http_header.binding_info is defined - - http_header.operation_type == 'removed' - - http_header.binding_info.ip == "{{ http_header_vars.ip }}" - - http_header.binding_info.port == {{ http_header_vars.port }} - - http_header.binding_info.protocol == "{{ http_header_vars.protocol }}" - - http_header.binding_info.hostheader == "{{ http_header_vars.header }}" - - get_http_header.binding is not defined - -#remove idem -#change false, bindings gone -- name: idem remove http binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: http_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ http_vars.protocol }}" - ip: "{{ http_vars.ip }}" - port: "{{ http_vars.port }}" - register: get_http_no_header - changed_when: false - -- name: idem remove http binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: http_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ http_header_vars.header }}" - protocol: "{{ http_header_vars.protocol }}" - ip: "{{ http_header_vars.ip }}" - port: "{{ http_header_vars.port }}" - register: get_http_header - changed_when: false - -- name: idem remove assert changed and gone - assert: - that: - - http_no_header is not changed - - http_no_header.binding_info is not defined - - get_http_no_header.binding is not defined - - http_header is not changed - - http_header.binding_info is not defined - - get_http_header.binding is not defined diff --git a/test/integration/targets/win_iis_webbinding/tasks/https-ge6.2.yml b/test/integration/targets/win_iis_webbinding/tasks/https-ge6.2.yml deleted file mode 100644 index f883c673ff..0000000000 --- a/test/integration/targets/win_iis_webbinding/tasks/https-ge6.2.yml +++ /dev/null @@ -1,459 +0,0 @@ -############## -### CM Add ### -############## -#changed true, check nothing present -- name: CM add https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_no_header - check_mode: yes - -- name: CM get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: CM add https binding with header and SNI - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - ssl_flags: 1 - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_header - check_mode: yes - -- name: CM get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: get_https_header - changed_when: false - -- name: CM assert changed, but not added - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'added' - - https_no_header.binding_info is none - - get_https_no_header.binding is not defined - - https_header is changed - - https_header.operation_type == 'added' - - https_header.binding_info is none - - get_https_header.binding is not defined - -########### -### Add ### -########### -#changed true, new bindings present -- name: add https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: add https binding with header SNI - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - ssl_flags: 1 - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: get_https_header - changed_when: false - -- name: assert changed and added - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'added' - - https_no_header.binding_info is defined - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.hostheader == '' - - https_no_header.binding_info.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - - https_header is changed - - https_header.operation_type == 'added' - - https_header.binding_info is defined - - https_header.binding_info.hostheader == "{{ https_header_vars.header }}" - - https_header.binding_info.protocol == "{{ https_header_vars.protocol }}" - - https_header.binding_info.ip == "{{ https_header_vars.ip }}" - - https_header.binding_info.port == {{ https_header_vars.port }} - - https_header.binding_info.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - - https_header.binding_info.sslFlags == 1 - -################ -### Idem Add ### -################ -#changed false -- name: idem add https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: https - ip: '*' - port: 443 - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_no_header - -- name: idem add https binding with header and SNI - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: test.com - protocol: https - ip: '*' - port: 443 - ssl_flags: 1 - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_header - -- name: idem assert not changed - assert: - that: - - https_no_header is not changed - - https_header is not changed - -################# -### CM Modify ### -################# -# changed true, verify no changes occurred - -#modify sni -- name: CM modify https binding with header, change cert - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - ssl_flags: 1 - certificate_hash: "{{ thumbprint2.stdout_lines[0] }}" - register: https_header - check_mode: yes - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: get_https_header - changed_when: false - -- name: CM assert changed but old cert - assert: - that: - - https_header is changed - - https_header.operation_type == 'updated' - - https_header.binding_info is defined - - https_header.binding_info.ip == "{{ https_header_vars.ip }}" - - https_header.binding_info.port == {{ https_header_vars.port }} - - https_header.binding_info.protocol == "{{ https_header_vars.protocol }}" - - https_header.binding_info.hostheader == "{{ https_header_vars.header }}" - - https_header.binding_info.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - - https_header.binding_info.sslFlags == 1 - - get_https_header.binding is defined - - get_https_header.binding.ip == "{{ https_header_vars.ip }}" - - get_https_header.binding.port == {{ https_header_vars.port }} - - get_https_header.binding.protocol == "{{ https_header_vars.protocol }}" - - get_https_header.binding.hostheader == "{{ https_header_vars.header }}" - - get_https_header.binding.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - - get_https_header.binding.sslFlags == 1 - -############## -### Modify ### -############## -# modify ssl flags -- name: modify https binding with header, change cert - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - ssl_flags: 1 - certificate_hash: "{{ thumbprint2.stdout_lines[0] }}" - register: https_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: get_https_header - changed_when: false - -- name: modify assert changed and new cert - assert: - that: - - https_header is changed - - https_header.operation_type == 'updated' - - https_header.binding_info is defined - - https_header.binding_info.ip == "{{ https_header_vars.ip }}" - - https_header.binding_info.port == {{ https_header_vars.port }} - - https_header.binding_info.protocol == "{{ https_header_vars.protocol }}" - - https_header.binding_info.hostheader == "{{ https_header_vars.header }}" - - https_header.binding_info.certificateHash == "{{ thumbprint2.stdout_lines[0] }}" - - https_header.binding_info.sslFlags == 1 - - get_https_header.binding is defined - - get_https_header.binding.ip == "{{ https_header_vars.ip }}" - - get_https_header.binding.port == {{ https_header_vars.port }} - - get_https_header.binding.protocol == "{{ https_header_vars.protocol }}" - - get_https_header.binding.hostheader == "{{ https_header_vars.header }}" - - get_https_header.binding.certificateHash == "{{ thumbprint2.stdout_lines[0] }}" - - get_https_header.binding.sslFlags == 1 - -################### -### Idem Modify ### -################### -#changed false - -#idem modify ssl flags -- name: idem modify https binding with header, enable SNI and change cert - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - ssl_flags: 1 - certificate_hash: "{{ thumbprint2.stdout_lines[0] }}" - register: https_header - -- name: idem assert not changed - assert: - that: - - https_header is not changed - -################# -### CM Remove ### -################# -#changed true, bindings still present -- name: cm remove https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: https_no_header - check_mode: yes - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: cm remove https binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: https_header - check_mode: yes - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: get_https_header - changed_when: false - -- name: cm remove assert changed, but still present - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'removed' - - https_no_header.binding_info is defined - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - get_https_no_header.binding is defined - - get_https_no_header.binding.ip == "{{ https_vars.ip }}" - - get_https_no_header.binding.port == {{ https_vars.port }} - - get_https_no_header.binding.protocol == "{{ https_vars.protocol }}" - - get_https_no_header.binding.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - - https_header is changed - - https_header.binding_info is defined - - https_header.operation_type == 'removed' - - https_header.binding_info.ip == "{{ https_header_vars.ip }}" - - https_header.binding_info.port == {{ https_header_vars.port }} - - https_header.binding_info.protocol == "{{ https_header_vars.protocol }}" - - https_header.binding_info.hostheader == "{{ https_header_vars.header }}" - - get_https_header.binding is defined - - get_https_header.binding.ip == "{{ https_header_vars.ip }}" - - get_https_header.binding.port == {{ https_header_vars.port }} - - get_https_header.binding.protocol == "{{ https_header_vars.protocol }}" - - get_https_header.binding.hostheader == "{{ https_header_vars.header }}" - - get_https_header.binding.certificateHash == "{{ thumbprint2.stdout_lines[0] }}" - -############## -### remove ### -############## -#changed true, bindings gone -- name: remove https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: https_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: remove https binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: https_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: get_https_header - changed_when: false - -- name: remove assert changed and gone - assert: - that: - - https_no_header is changed - - https_no_header.binding_info is defined - - https_no_header.operation_type == 'removed' - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - get_https_no_header.binding is not defined - - https_header is changed - - https_header.binding_info is defined - - https_header.operation_type == 'removed' - - https_header.binding_info.ip == "{{ https_header_vars.ip }}" - - https_header.binding_info.port == {{ https_header_vars.port }} - - https_header.binding_info.protocol == "{{ https_header_vars.protocol }}" - - https_header.binding_info.hostheader == "{{ https_header_vars.header }}" - - get_https_header.binding is not defined - -################### -### remove idem ### -################### -#change false, bindings gone -- name: idem remove https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: https_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: idem remove https binding with header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: https_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - host_header: "{{ https_header_vars.header }}" - protocol: "{{ https_header_vars.protocol }}" - ip: "{{ https_header_vars.ip }}" - port: "{{ https_header_vars.port }}" - register: get_https_header - changed_when: false - -- name: idem remove assert changed and gone - assert: - that: - - https_no_header is not changed - - https_no_header.binding_info is not defined - - get_https_no_header.binding is not defined - - https_header is not changed - - https_header.binding_info is not defined - - get_https_header.binding is not defined diff --git a/test/integration/targets/win_iis_webbinding/tasks/https-lt6.2.yml b/test/integration/targets/win_iis_webbinding/tasks/https-lt6.2.yml deleted file mode 100644 index 1950641e8d..0000000000 --- a/test/integration/targets/win_iis_webbinding/tasks/https-lt6.2.yml +++ /dev/null @@ -1,423 +0,0 @@ -############## -### CM Add ### -############## -#changed true, check nothing present -- name: CM add https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_no_header - check_mode: yes - -- name: CM get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: CM assert changed, but not added - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'added' - - https_no_header.binding_info is none - - get_https_no_header.binding is not defined - -########### -### Add ### -########### -#changed true, new bindings present -- name: add https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_no_header - -- name: assert changed and added - assert: - that: - - https_no_header is changed - - https_no_header.binding_info is defined - - https_no_header.operation_type == 'added' - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - https_no_header.binding_info.hostheader == '' - - https_no_header.binding_info.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - -################ -### Idem Add ### -################ -#changed false -- name: idem add https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint1.stdout_lines[0] }}" - register: https_no_header - -- name: idem assert not changed - assert: - that: - - https_no_header is not changed - -################# -### CM Modify ### -################# -# changed true, verify no changes occurred - -#modify sni -- name: CM modify https binding change cert - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint2.stdout_lines[0] }}" - register: https_no_header - check_mode: yes - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: CM assert changed but old cert - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'updated' - - https_no_header.binding_info is defined - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - https_no_header.binding_info.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - - get_https_no_header.binding is defined - - get_https_no_header.binding.ip == "{{ https_vars.ip }}" - - get_https_no_header.binding.port == {{ https_vars.port }} - - get_https_no_header.binding.protocol == "{{ https_vars.protocol }}" - - get_https_no_header.binding.certificateHash == "{{ thumbprint1.stdout_lines[0] }}" - -############## -### Modify ### -############## -# modify ssl flags -- name: modify https binding, change cert - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint2.stdout_lines[0] }}" - register: https_no_header - -- name: get binding info header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: modify assert changed and new cert - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'updated' - - https_no_header.binding_info is defined - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - https_no_header.binding_info.certificateHash == "{{ thumbprint2.stdout_lines[0] }}" - - get_https_no_header.binding is defined - - get_https_no_header.binding.ip == "{{ https_vars.ip }}" - - get_https_no_header.binding.port == {{ https_vars.port }} - - get_https_no_header.binding.protocol == "{{ https_vars.protocol }}" - - get_https_no_header.binding.hostheader == '' - - get_https_no_header.binding.certificateHash == "{{ thumbprint2.stdout_lines[0] }}" - -################### -### Idem Modify ### -################### -#changed false - -#idem modify ssl flags -- name: idem modify https binding and change cert - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: present - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - certificate_hash: "{{ thumbprint2.stdout_lines[0] }}" - register: https_header - -- name: idem assert not changed - assert: - that: - - https_header is not changed - -################# -### CM Remove ### -################# -#changed true, bindings still present -- name: cm remove https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: https_no_header - check_mode: yes - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: cm remove assert changed, but still present - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'removed' - - https_no_header.binding_info is defined - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - https_no_header.binding_info.certificateHash == "{{ thumbprint2.stdout_lines[0] }}" - - get_https_no_header.binding is defined - - get_https_no_header.binding.ip == "{{ https_vars.ip }}" - - get_https_no_header.binding.port == {{ https_vars.port }} - - get_https_no_header.binding.protocol == "{{ https_vars.protocol }}" - - get_https_no_header.binding.certificateHash == "{{ thumbprint2.stdout_lines[0] }}" - -############## -### remove ### -############## -#changed true, bindings gone -- name: remove https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: https_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: remove assert changed and gone - assert: - that: - - https_no_header is changed - - https_no_header.operation_type == 'removed' - - https_no_header.binding_info is defined - - https_no_header.binding_info.ip == "{{ https_vars.ip }}" - - https_no_header.binding_info.port == {{ https_vars.port }} - - https_no_header.binding_info.protocol == "{{ https_vars.protocol }}" - - get_https_no_header.binding is not defined - -################### -### remove idem ### -################### -#change false, bindings gone -- name: idem remove https binding no header - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: https_no_header - -- name: get binding info no header - test_get_webbindings: - name: "{{ test_iis_site_name }}" - protocol: "{{ https_vars.protocol }}" - ip: "{{ https_vars.ip }}" - port: "{{ https_vars.port }}" - register: get_https_no_header - changed_when: false - -- name: idem remove assert changed and gone - assert: - that: - - https_no_header is not changed - - https_no_header.binding_info is not defined - - get_https_no_header.binding is not defined - - -################## -### WC Testing ### -################## - -# Unfortunately this does not work due to some strange errors -# that are caused when using a self signed wildcard cert. -# I'm leaving this here in case someone finds a solution in the -# future. - -# - name: add https binding wildcard with header -# win_iis_webbinding: -# name: "{{ test_iis_site_name }}" -# state: present -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# certificate_hash: "{{ thumbprint_wc.stdout_lines[0] }}" -# register: https_header - -# - name: assert changed and added -# assert: -# that: -# - https_header is changed -# - https_header.added is defined -# - https_header.added.ip == "{{ https_wc_vars.ip }}" -# - https_header.added.port == {{ https_wc_vars.port }} -# - https_header.added.protocol == "{{ https_wc_vars.protocol }}" -# - https_header.added.hostheader == "{{ https_wc_vars.header }}" -# - https_header.added.certificateHash == "{{ thumbprint_wc.stdout_lines[0] }}" - - -# - name: idem add https binding wildcard with header -# win_iis_webbinding: -# name: "{{ test_iis_site_name }}" -# state: present -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# certificate_hash: "{{ thumbprint_wc.stdout_lines[0] }}" -# register: https_header - - -# - name: cm remove wildcard https binding -# win_iis_webbinding: -# name: "{{ test_iis_site_name }}" -# state: absent -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# register: https_header -# check_mode: yes - -# - name: get binding info header -# test_get_webbindings: -# name: "{{ test_iis_site_name }}" -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# register: get_https_header -# changed_when: false - -# - name: cm remove assert changed, but still present -# assert: -# that: -# - https_header is changed -# - https_header.removed is defined -# - https_header.removed.ip == "{{ https_wc_vars.ip }}" -# - https_header.removed.port == {{ https_wc_vars.port }} -# - https_header.removed.protocol == "{{ https_wc_vars.protocol }}" -# - https_header.removed.hostheader == "{{ https_wc_vars.header }}" -# - https_header.removed.certificateHash == "{{ thumbprint_wc.stdout_lines[0] }}" -# - get_https_header.binding is defined -# - get_https_header.removed.ip == "{{ https_wc_vars.ip }}" -# - get_https_header.removed.port == {{ https_wc_vars.port }} -# - get_https_header.removed.protocol == "{{ https_wc_vars.protocol }}" -# - get_https_header.removed.hostheader == "{{ https_wc_vars.header }}" -# - get_https_header.removed.certificateHash == "{{ thumbprint_wc.stdout_lines[0] }}" - -# - name: remove wildcard https binding -# win_iis_webbinding: -# name: "{{ test_iis_site_name }}" -# state: absent -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# register: https_header - -# - name: get binding info header -# test_get_webbindings: -# name: "{{ test_iis_site_name }}" -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# register: get_https_header -# changed_when: false - - -# - name: remove assert changed and gone -# assert: -# that: -# - https_header is changed -# - https_header.removed is defined -# - https_header.removed.ip == "{{ https_wc_vars.ip }}" -# - https_header.removed.port == {{ https_wc_vars.port }} -# - https_header.removed.protocol == "{{ https_wc_vars.protocol }}" -# - https_header.removed.hostheader == "{{ https_wc_vars.header }}" -# - https_header.removed.certificateHash == "{{ thumbprint_wc.stdout_lines[0] }}" -# - get_https_header.binding is not defined - -# - name: idem remove wildcard https binding -# win_iis_webbinding: -# name: "{{ test_iis_site_name }}" -# state: absent -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# register: https_header - -# - name: get binding info header -# test_get_webbindings: -# name: "{{ test_iis_site_name }}" -# host_header: "{{ https_wc_vars.header }}" -# protocol: "{{ https_wc_vars.protocol }}" -# ip: "{{ https_wc_vars.ip }}" -# port: "{{ https_wc_vars.port }}" -# register: get_https_header -# changed_when: false - -# - name: idem remove assert changed and gone -# assert: -# that: -# - https_header is not changed -# - https_header.removed is not defined -# - get_https_header.binding is not defined diff --git a/test/integration/targets/win_iis_webbinding/tasks/main.yml b/test/integration/targets/win_iis_webbinding/tasks/main.yml deleted file mode 100644 index 3c918cb826..0000000000 --- a/test/integration/targets/win_iis_webbinding/tasks/main.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -# Cannot use win_feature to install IIS on Server 2008. -# Run a brief check and skip hosts that don't support -# that operation -#seems "raw" is the only module that works on 2008 non-r2. win_command and win_shell both failed -- name: register os version (seems integration tests don't gather this fact) - raw: powershell.exe "gwmi Win32_OperatingSystem | select -expand version" - register: os_version - changed_when: False - -- block: - - include_tasks: setup.yml - - include_tasks: http.yml - - include_tasks: https-lt6.2.yml - when: os_version.stdout_lines[0] is version('6.2','lt') - - include_tasks: https-ge6.2.yml - when: os_version.stdout_lines[0] is version('6.2','ge') - - include_tasks: failures.yml - - always: - - name: get all websites from server - raw: powershell.exe "(get-website).name" - register: existing_sites - - - name: ensure all sites are removed for clean testing - win_iis_website: - name: "{{ item }}" - state: absent - with_items: - - "{{ existing_sites.stdout_lines }}" - - - name: cleanup certreq files - win_file: - path: "{{ item }}" - state: absent - with_items: - - c:\windows\temp\certreq1.txt - - c:\windows\temp\certreq2.txt - - c:\windows\temp\certreqwc.txt - - c:\windows\temp\certreqresp1.txt - - c:\windows\temp\certreqresp2.txt - - c:\windows\temp\certreqrespwc.txt - - - name: remove certs - raw: 'remove-item cert:\localmachine\my\{{ item }} -force -ea silentlycontinue' - with_items: - - "{{ thumbprint1.stdout_lines[0] }}" - - "{{ thumbprint2.stdout_lines[0] }}" - - "{{ thumbprint_wc.stdout_lines[0] }}" - - - name: remove IIS features after test - win_feature: - name: Web-Server - state: absent - includ_sub_features: True - include_management_tools: True - register: feature_uninstall - - - name: reboot after feature install - win_reboot: - when: feature_uninstall.reboot_required - when: os_version.stdout_lines[0] is version('6.1','gt') diff --git a/test/integration/targets/win_iis_webbinding/tasks/setup.yml b/test/integration/targets/win_iis_webbinding/tasks/setup.yml deleted file mode 100644 index 708f3edcf2..0000000000 --- a/test/integration/targets/win_iis_webbinding/tasks/setup.yml +++ /dev/null @@ -1,93 +0,0 @@ -- name: reboot before feature install to ensure server is in clean state - win_reboot: - -- name: ensure IIS features are installed - win_feature: - name: Web-Server - state: present - includ_sub_features: True - include_management_tools: True - register: feature_install - -- name: reboot after feature install - win_reboot: - when: feature_install.reboot_required - -- name: get all websites from server - raw: powershell.exe "(get-website).name" - register: existing_sites - -- name: ensure all sites are removed for clean testing - win_iis_website: - name: "{{ item }}" - state: absent - with_items: - - "{{ existing_sites.stdout_lines }}" - -- name: add testing site {{ test_iis_site_name }} - win_iis_website: - name: "{{ test_iis_site_name }}" - physical_path: c:\inetpub\wwwroot - -- name: ensure all bindings are removed prior to starting testing - win_iis_webbinding: - name: "{{ test_iis_site_name }}" - state: absent - protocol: "{{ item.protocol }}" - port: "{{ item.port }}" - with_items: - - {protocol: http, port: 80} - - {protocol: https, port: 443} - -- name: copy certreq file - win_copy: - content: |- - [NewRequest] - Subject = "CN={{ item.name }}" - KeyLength = 2048 - KeyAlgorithm = RSA - MachineKeySet = true - RequestType = Cert - dest: "{{ item.dest }}" - with_items: - - {name: test.com, dest: 'c:\windows\temp\certreq1.txt'} - - {name: test1.com, dest: 'c:\windows\temp\certreq2.txt'} - - {name: '*.test.com', dest: 'c:\windows\temp\certreqwc.txt'} - -- name: make sure response files are absent - win_file: - path: "{{ item }}" - state: absent - with_items: - - 'c:\windows\temp\certreqresp1.txt' - - 'c:\windows\temp\certreqresp2.txt' - - 'c:\windows\temp\certreqrespwc.txt' - -- name: create self signed cert from certreq - win_command: certreq -new -machine {{ item.req }} {{ item.resp }} - with_items: - - {req: 'c:\windows\temp\certreq1.txt', resp: 'c:\windows\temp\certreqresp1.txt'} - - {req: 'c:\windows\temp\certreq2.txt', resp: 'c:\windows\temp\certreqresp2.txt'} - - {req: 'c:\windows\temp\certreqwc.txt', resp: 'c:\windows\temp\certreqrespwc.txt'} - -- name: register certificate thumbprint1 - raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN=test.com"})[0].Thumbprint' - register: thumbprint1 - -- name: register certificate thumbprint2 - raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN=test1.com"})[0].Thumbprint' - register: thumbprint2 - -- name: register certificate thumbprint_wc - raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN=*.test.com"})[0].Thumbprint' - register: thumbprint_wc - -- debug: - var: thumbprint1.stdout - verbosity: 1 -- debug: - var: thumbprint2.stdout - verbosity: 1 -- debug: - var: thumbprint_wc.stdout - verbosity: 1 diff --git a/test/integration/targets/win_inet_proxy/aliases b/test/integration/targets/win_inet_proxy/aliases deleted file mode 100644 index 215e0b0692..0000000000 --- a/test/integration/targets/win_inet_proxy/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group4 diff --git a/test/integration/targets/win_inet_proxy/library/win_inet_proxy_info.ps1 b/test/integration/targets/win_inet_proxy/library/win_inet_proxy_info.ps1 deleted file mode 100644 index d52b11d3ad..0000000000 --- a/test/integration/targets/win_inet_proxy/library/win_inet_proxy_info.ps1 +++ /dev/null @@ -1,275 +0,0 @@ -#!powershell - -# Copyright: (c) 2019, Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -#AnsibleRequires -CSharpUtil Ansible.Basic -#Requires -Module Ansible.ModuleUtils.AddType - -$spec = @{ - options = @{ - connection = @{ type = "str" } - } - supports_check_mode = $true -} - -$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec) - -$connection = $module.Params.connection - -$win_inet_invoke = @' -using Microsoft.Win32.SafeHandles; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Runtime.ConstrainedExecution; -using System.Runtime.InteropServices; - -namespace Ansible.WinINetProxyInfo -{ - internal class NativeHelpers - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class INTERNET_PER_CONN_OPTION_LISTW : IDisposable - { - public UInt32 dwSize; - public IntPtr pszConnection; - public UInt32 dwOptionCount; - public UInt32 dwOptionError; - public IntPtr pOptions; - - public INTERNET_PER_CONN_OPTION_LISTW() - { - dwSize = (UInt32)Marshal.SizeOf(this); - } - - public void Dispose() - { - if (pszConnection != IntPtr.Zero) - Marshal.FreeHGlobal(pszConnection); - if (pOptions != IntPtr.Zero) - Marshal.FreeHGlobal(pOptions); - GC.SuppressFinalize(this); - } - ~INTERNET_PER_CONN_OPTION_LISTW() { this.Dispose(); } - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class INTERNET_PER_CONN_OPTIONW : IDisposable - { - public INTERNET_PER_CONN_OPTION dwOption; - public ValueUnion Value; - - [StructLayout(LayoutKind.Explicit)] - public class ValueUnion - { - [FieldOffset(0)] - public UInt32 dwValue; - - [FieldOffset(0)] - public IntPtr pszValue; - - [FieldOffset(0)] - public System.Runtime.InteropServices.ComTypes.FILETIME ftValue; - } - - public void Dispose() - { - // We can't just check if Value.pszValue is not IntPtr.Zero as the union means it could be set even - // when the value is a UInt32 or FILETIME. We check against a known string option type and only free - // the value in those cases. - List<INTERNET_PER_CONN_OPTION> stringOptions = new List<INTERNET_PER_CONN_OPTION> - { - { INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_AUTOCONFIG_URL }, - { INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_PROXY_BYPASS }, - { INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_PROXY_SERVER } - }; - if (Value != null && Value.pszValue != IntPtr.Zero && stringOptions.Contains(dwOption)) - Marshal.FreeHGlobal(Value.pszValue); - GC.SuppressFinalize(this); - } - ~INTERNET_PER_CONN_OPTIONW() { this.Dispose(); } - } - - public enum INTERNET_OPTION : uint - { - INTERNET_OPTION_PER_CONNECTION_OPTION = 75, - } - - public enum INTERNET_PER_CONN_OPTION : uint - { - INTERNET_PER_CONN_FLAGS = 1, - INTERNET_PER_CONN_PROXY_SERVER = 2, - INTERNET_PER_CONN_PROXY_BYPASS = 3, - INTERNET_PER_CONN_AUTOCONFIG_URL = 4, - INTERNET_PER_CONN_AUTODISCOVERY_FLAGS = 5, - INTERNET_PER_CONN_FLAGS_UI = 10, // IE8+ - Included with Windows 7 and Server 2008 R2 - } - - [Flags] - public enum PER_CONN_FLAGS : uint - { - PROXY_TYPE_DIRECT = 0x00000001, - PROXY_TYPE_PROXY = 0x00000002, - PROXY_TYPE_AUTO_PROXY_URL = 0x00000004, - PROXY_TYPE_AUTO_DETECT = 0x00000008, - } - } - - internal class NativeMethods - { - [DllImport("Wininet.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool InternetQueryOptionW( - IntPtr hInternet, - NativeHelpers.INTERNET_OPTION dwOption, - SafeMemoryBuffer lpBuffer, - ref UInt32 lpdwBufferLength); - } - - internal class SafeMemoryBuffer : SafeHandleZeroOrMinusOneIsInvalid - { - public SafeMemoryBuffer() : base(true) { } - public SafeMemoryBuffer(int cb) : base(true) - { - base.SetHandle(Marshal.AllocHGlobal(cb)); - } - public SafeMemoryBuffer(IntPtr handle) : base(true) - { - base.SetHandle(handle); - } - - [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - protected override bool ReleaseHandle() - { - Marshal.FreeHGlobal(handle); - return true; - } - } - - public class WinINetProxy - { - private string Connection; - - public string AutoConfigUrl; - public bool AutoDetect; - public string Proxy; - public string ProxyBypass; - - public WinINetProxy(string connection) - { - Connection = connection; - Refresh(); - } - - public void Refresh() - { - using (var connFlags = CreateConnOption(NativeHelpers.INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_FLAGS_UI)) - using (var autoConfigUrl = CreateConnOption(NativeHelpers.INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_AUTOCONFIG_URL)) - using (var server = CreateConnOption(NativeHelpers.INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_PROXY_SERVER)) - using (var bypass = CreateConnOption(NativeHelpers.INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_PROXY_BYPASS)) - { - NativeHelpers.INTERNET_PER_CONN_OPTIONW[] options = new NativeHelpers.INTERNET_PER_CONN_OPTIONW[] - { - connFlags, autoConfigUrl, server, bypass - }; - - try - { - QueryOption(options, Connection); - } - catch (Win32Exception e) - { - if (e.NativeErrorCode == 87) // ERROR_INVALID_PARAMETER - { - // INTERNET_PER_CONN_FLAGS_UI only works for IE8+, try the fallback in case we are still working - // with an ancient version. - connFlags.dwOption = NativeHelpers.INTERNET_PER_CONN_OPTION.INTERNET_PER_CONN_FLAGS; - QueryOption(options, Connection); - } - else - throw; - } - - NativeHelpers.PER_CONN_FLAGS flags = (NativeHelpers.PER_CONN_FLAGS)connFlags.Value.dwValue; - - AutoConfigUrl = flags.HasFlag(NativeHelpers.PER_CONN_FLAGS.PROXY_TYPE_AUTO_PROXY_URL) - ? Marshal.PtrToStringUni(autoConfigUrl.Value.pszValue) : null; - AutoDetect = flags.HasFlag(NativeHelpers.PER_CONN_FLAGS.PROXY_TYPE_AUTO_DETECT); - if (flags.HasFlag(NativeHelpers.PER_CONN_FLAGS.PROXY_TYPE_PROXY)) - { - Proxy = Marshal.PtrToStringUni(server.Value.pszValue); - ProxyBypass = Marshal.PtrToStringUni(bypass.Value.pszValue); - } - else - { - Proxy = null; - ProxyBypass = null; - } - } - } - - internal static NativeHelpers.INTERNET_PER_CONN_OPTIONW CreateConnOption(NativeHelpers.INTERNET_PER_CONN_OPTION option) - { - return new NativeHelpers.INTERNET_PER_CONN_OPTIONW - { - dwOption = option, - Value = new NativeHelpers.INTERNET_PER_CONN_OPTIONW.ValueUnion(), - }; - } - - internal static void QueryOption(NativeHelpers.INTERNET_PER_CONN_OPTIONW[] options, string connection = null) - { - using (NativeHelpers.INTERNET_PER_CONN_OPTION_LISTW optionList = new NativeHelpers.INTERNET_PER_CONN_OPTION_LISTW()) - using (SafeMemoryBuffer optionListPtr = MarshalOptionList(optionList, options, connection)) - { - UInt32 bufferSize = optionList.dwSize; - if (!NativeMethods.InternetQueryOptionW( - IntPtr.Zero, - NativeHelpers.INTERNET_OPTION.INTERNET_OPTION_PER_CONNECTION_OPTION, - optionListPtr, - ref bufferSize)) - { - throw new Win32Exception(); - } - - for (int i = 0; i < options.Length; i++) - { - IntPtr opt = IntPtr.Add(optionList.pOptions, i * Marshal.SizeOf(typeof(NativeHelpers.INTERNET_PER_CONN_OPTIONW))); - NativeHelpers.INTERNET_PER_CONN_OPTIONW option = (NativeHelpers.INTERNET_PER_CONN_OPTIONW)Marshal.PtrToStructure(opt, - typeof(NativeHelpers.INTERNET_PER_CONN_OPTIONW)); - options[i].Value = option.Value; - option.Value = null; // Stops the GC from freeing the same memory twice - } - } - } - - internal static SafeMemoryBuffer MarshalOptionList(NativeHelpers.INTERNET_PER_CONN_OPTION_LISTW optionList, - NativeHelpers.INTERNET_PER_CONN_OPTIONW[] options, string connection) - { - optionList.pszConnection = Marshal.StringToHGlobalUni(connection); - optionList.dwOptionCount = (UInt32)options.Length; - - int optionSize = Marshal.SizeOf(typeof(NativeHelpers.INTERNET_PER_CONN_OPTIONW)); - optionList.pOptions = Marshal.AllocHGlobal(optionSize * options.Length); - for (int i = 0; i < options.Length; i++) - { - IntPtr option = IntPtr.Add(optionList.pOptions, i * optionSize); - Marshal.StructureToPtr(options[i], option, false); - } - - SafeMemoryBuffer optionListPtr = new SafeMemoryBuffer((int)optionList.dwSize); - Marshal.StructureToPtr(optionList, optionListPtr.DangerousGetHandle(), false); - return optionListPtr; - } - } -} -'@ -Add-CSharpType -References $win_inet_invoke -AnsibleModule $module - -$proxy = New-Object -TypeName Ansible.WinINetProxyInfo.WinINetProxy -ArgumentList @(,$connection) -$module.Result.auto_config_url = $proxy.AutoConfigUrl -$module.Result.auto_detect = $proxy.AutoDetect -$module.Result.proxy = $proxy.Proxy -$module.Result.bypass = $proxy.ProxyBypass - -$module.ExitJson() diff --git a/test/integration/targets/win_inet_proxy/library/win_phonebook_entry.ps1 b/test/integration/targets/win_inet_proxy/library/win_phonebook_entry.ps1 deleted file mode 100644 index 1746921f6d..0000000000 --- a/test/integration/targets/win_inet_proxy/library/win_phonebook_entry.ps1 +++ /dev/null @@ -1,521 +0,0 @@ -#!powershell - -# Copyright: (c) 2019, Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -#AnsibleRequires -CSharpUtil Ansible.Basic -#Requires -Module Ansible.ModuleUtils.AddType - -# This is a very basic skeleton of a possible Windows module for managing RAS connections. It is mostly barebones -# to enable testing for win_inet_proxy but I've done a bit of extra work in the PInvoke space to possible expand -# sometime in the future. - -$spec = @{ - options = @{ - device_type = @{ - type = "str" - choices = @("atm", "framerelay", "generic", "rda", "isdn", "modem", "pad", - "parallel", "pppoe", "vpn", "serial", "sonet", "sw56", "x25") - } - device_name = @{ type = "str" } - framing_protocol = @{ type = "str"; choices = @("ppp", "ras", "slip") } - name = @{ type = "str"; required = $true } - options = @{ type = "list" } - state = @{ type = "str"; choices = @("absent", "present"); default = "present" } - type = @{ type = "str"; choices = @("broadband", "direct", "phone", "vpn")} - } - required_if = @( - ,@("state", "present", @("type", "device_name", "device_type", "framing_protocol")) - ) - supports_check_mode = $false -} - -$module = [Ansible.Basic.AnsibleModule]::Create($args, $spec) - -$device_type = $module.Params.device_type -$device_name = $module.Params.device_name -$framing_protocol = $module.Params.framing_protocol -$name = $module.Params.name -$options = $module.Params.options -$state = $module.Params.state -$type = $module.Params.type - -$module.Result.guid = [System.Guid]::Empty - -$win_ras_invoke = @' -using System; -using System.Runtime.InteropServices; - -namespace Ansible.WinPhonebookEntry -{ - public class NativeHelpers - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public class RASENTRYW - { - public UInt32 dwSize; - public RasEntryOptions dwfOptions; - public UInt32 dwCountryId; - public UInt32 dwCountryCode; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)] public string szAreaCode; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 129)] public string szLocalPhoneNumber; - public UInt32 dwAlternateOffset; - public RASIPADDR ipaddr; - public RASIPADDR ipaddrDns; - public RASIPADDR ipaddrDnsAlt; - public RASIPADDR ipaddrWins; - public RASIPADDR ipaddrWinsAlt; - public UInt32 dwFrameSize; - public RasNetProtocols dwfNetProtocols; - public RasFramingProtocol dwFramingProtocol; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szScript; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szAutodialDll; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szAutodialFunc; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 17)] public string szDeviceType; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 129)] public string szDeviceName; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 33)] public string szX25PadType; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 201)] public string szX25Address; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 201)] public string szX25Facilities; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 201)] public string szX25UserData; - public UInt32 dwChannels; - public UInt32 dwReserved1; - public UInt32 dwReserved2; - public UInt32 dwSubEntries; - public RasDialMode dwDialMode; - public UInt32 dwDialExtraPercent; - public UInt32 dwDialExtraSampleSeconds; - public UInt32 dwHangUpExtraPercent; - public UInt32 dwHangUpExtraSampleSeconds; - public UInt32 dwIdleDisconnectSeconds; - public RasEntryTypes dwType; - public RasEntryEncryption dwEntryptionType; - public UInt32 dwCustomAuthKey; - public Guid guidId; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szCustomDialDll; - public RasVpnStrategy dwVpnStrategy; - public RasEntryOptions2 dwfOptions2; - public UInt32 dwfOptions3; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string szDnsSuffix; - public UInt32 dwTcpWindowSize; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szPrerequisitePbk; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 257)] public string szPrerequisiteEntry; - public UInt32 dwRedialCount; - public UInt32 dwRedialPause; - public RASIPV6ADDR ipv6addrDns; - public RASIPV6ADDR ipv6addrDnsAlt; - public UInt32 dwIPv4InterfaceMatrix; - public UInt32 dwIPv6InterfaceMatrix; - // Server 2008 R2 / Windows 7+ - // We cannot include these fields when running in Server 2008 as it will break the SizeOf calc of the struct -#if !LONGHORN - public RASIPV6ADDR ipv6addr; - public UInt32 dwIPv6PrefixLength; - public UInt32 dwNetworkOutageTime; -#endif - - public RASENTRYW() - { - this.dwSize = (UInt32)Marshal.SizeOf(this); - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct RASIPADDR - { - public byte a; - public byte b; - public byte c; - public byte d; - } - - [StructLayout(LayoutKind.Sequential)] - public struct RASIPV6ADDR - { - byte a; - byte b; - byte c; - byte d; - byte e; - byte f; - byte g; - byte h; - byte i; - byte j; - byte k; - byte l; - byte m; - byte n; - byte o; - byte p; - } - - public enum RasDialMode : uint - { - RASEDM_DialAll = 1, - RASEDM_DialAsNeeded = 2, - } - - public enum RasEntryEncryption : uint - { - ET_None = 0, - ET_Require = 1, - ET_RequireMax = 2, - ET_Optional = 3 - } - - [Flags] - public enum RasEntryOptions : uint - { - RASEO_UseCountryAndAreaCodes = 0x00000001, - RASEO_SpecificIpAddr = 0x00000002, - RASEO_SpecificNameServers = 0x00000004, - RASEO_IpHeaderCompression = 0x00000008, - RASEO_RemoteDefaultGateway = 0x00000010, - RASEO_DisableLcpExtensions = 0x00000020, - RASEO_TerminalBeforeDial = 0x00000040, - RASEO_TerminalAfterDial = 0x00000080, - RASEO_ModemLights = 0x00000100, - RASEO_SwCompression = 0x00000200, - RASEO_RequireEncrptedPw = 0x00000400, - RASEO_RequireMsEncrptedPw = 0x00000800, - RASEO_RequireDataEncrption = 0x00001000, - RASEO_NetworkLogon = 0x00002000, - RASEO_UseLogonCredentials = 0x00004000, - RASEO_PromoteAlternates = 0x00008000, - RASEO_SecureLocalFiles = 0x00010000, - RASEO_RequireEAP = 0x00020000, - RASEO_RequirePAP = 0x00040000, - RASEO_RequireSPAP = 0x00080000, - RASEO_Custom = 0x00100000, - RASEO_PreviewPhoneNumber = 0x00200000, - RASEO_SharedPhoneNumbers = 0x00800000, - RASEO_PreviewUserPw = 0x01000000, - RASEO_PreviewDomain = 0x02000000, - RASEO_ShowDialingProgress = 0x04000000, - RASEO_RequireCHAP = 0x08000000, - RASEO_RequireMsCHAP = 0x10000000, - RASEO_RequireMsCHAP2 = 0x20000000, - RASEO_RequireW95MSCHAP = 0x40000000, - RASEO_CustomScript = 0x80000000, - } - - [Flags] - public enum RasEntryOptions2 : uint - { - RASEO2_None = 0x00000000, - RASEO2_SecureFileAndPrint = 0x00000001, - RASEO2_SecureClientForMSNet = 0x00000002, - RASEO2_DontNegotiateMultilink = 0x00000004, - RASEO2_DontUseRasCredentials = 0x00000008, - RASEO2_UsePreSharedKey = 0x00000010, - RASEO2_Internet = 0x00000020, - RASEO2_DisableNbtOverIP = 0x00000040, - RASEO2_UseGlobalDeviceSettings = 0x00000080, - RASEO2_ReconnectIfDropped = 0x00000100, - RASEO2_SharePhoneNumbers = 0x00000200, - RASEO2_SecureRoutingCompartment = 0x00000400, - RASEO2_UseTypicalSettings = 0x00000800, - RASEO2_IPv6SpecificNameServers = 0x00001000, - RASEO2_IPv6RemoteDefaultGateway = 0x00002000, - RASEO2_RegisterIpWithDNS = 0x00004000, - RASEO2_UseDNSSuffixForRegistration = 0x00008000, - RASEO2_IPv4ExplicitMetric = 0x00010000, - RASEO2_IPv6ExplicitMetric = 0x00020000, - RASEO2_DisableIKENameEkuCheck = 0x00040000, - // Server 2008 R2 / Windows 7+ - RASEO2_DisableClassBasedStaticRoute = 0x00800000, - RASEO2_SpecificIPv6Addr = 0x01000000, - RASEO2_DisableMobility = 0x02000000, - RASEO2_RequireMachineCertificates = 0x04000000, - // Server 2012 / Windows 8+ - RASEO2_UsePreSharedKeyForIkev2Initiator = 0x00800000, - RASEO2_UsePreSharedKeyForIkev2Responder = 0x01000000, - RASEO2_CacheCredentials = 0x02000000, - // Server 2012 R2 / Windows 8.1+ - RASEO2_AutoTriggerCapable = 0x04000000, - RASEO2_IsThirdPartyProfile = 0x08000000, - RASEO2_AuthTypeIsOtp = 0x10000000, - // Server 2016 / Windows 10+ - RASEO2_IsAlwaysOn = 0x20000000, - RASEO2_IsPrivateNetwork = 0x40000000, - } - - public enum RasEntryTypes : uint - { - RASET_Phone = 1, - RASET_Vpn = 2, - RASET_Direct = 3, - RASET_Internet = 4, - RASET_Broadband = 5, - } - - public enum RasFramingProtocol : uint - { - RASFP_Ppp = 0x00000001, - RASFP_Slip = 0x00000002, - RASFP_Ras = 0x00000004 - } - - [Flags] - public enum RasNetProtocols : uint - { - RASNP_NetBEUI = 0x00000001, - RASNP_Ipx = 0x00000002, - RASNP_Ip = 0x00000004, - RASNP_Ipv6 = 0x00000008 - } - - public enum RasVpnStrategy : uint - { - VS_Default = 0, - VS_PptpOnly = 1, - VS_PptpFirst = 2, - VS_L2tpOnly = 3, - VS_L2tpFirst = 4, - VS_SstpOnly = 5, - VS_SstpFirst = 6, - VS_Ikev2Only = 7, - VS_Ikev2First = 8, - VS_GREOnly = 9, - VS_PptpSstp = 12, - VS_L2tpSstp = 13, - VS_Ikev2Sstp = 14, - } - } - - internal class NativeMethods - { - [DllImport("Rasapi32.dll", CharSet = CharSet.Unicode)] - public static extern UInt32 RasDeleteEntryW( - string lpszPhonebook, - string lpszEntry); - - [DllImport("Rasapi32.dll", CharSet = CharSet.Unicode)] - public static extern UInt32 RasGetEntryPropertiesW( - string lpszPhonebook, - string lpszEntry, - [In, Out] NativeHelpers.RASENTRYW lpRasEntry, - ref UInt32 dwEntryInfoSize, - IntPtr lpbDeviceInfo, - ref UInt32 dwDeviceInfoSize); - - [DllImport("Rasapi32.dll", CharSet = CharSet.Unicode)] - public static extern UInt32 RasSetEntryPropertiesW( - string lpszPhonebook, - string lpszEntry, - NativeHelpers.RASENTRYW lpRasEntry, - UInt32 dwEntryInfoSize, - IntPtr lpbDeviceInfo, - UInt32 dwDeviceInfoSize); - - [DllImport("Rasapi32.dll", CharSet = CharSet.Unicode)] - public static extern UInt32 RasValidateEntryNameW( - string lpszPhonebook, - string lpszEntry); - } - - public class Phonebook - { - public static void CreateEntry(string entry, NativeHelpers.RASENTRYW details) - { - UInt32 res = NativeMethods.RasSetEntryPropertiesW(null, entry, details, - details.dwSize, IntPtr.Zero, 0); - - if (res != 0) - throw new Exception(String.Format("RasSetEntryPropertiesW({0}) failed {1}", entry, res)); - } - - public static void DeleteEntry(string entry) - { - UInt32 res = NativeMethods.RasDeleteEntryW(null, entry); - if (res != 0) - throw new Exception(String.Format("RasDeleteEntryW({0}) failed {1}", entry, res)); - } - - public static NativeHelpers.RASENTRYW GetEntry(string entry) - { - NativeHelpers.RASENTRYW details = new NativeHelpers.RASENTRYW(); - UInt32 dwEntryInfoSize = details.dwSize; - UInt32 dwDeviceInfoSize = 0; - - UInt32 res = NativeMethods.RasGetEntryPropertiesW(null, entry, details, ref dwEntryInfoSize, - IntPtr.Zero, ref dwDeviceInfoSize); - - if (res != 0) - throw new Exception(String.Format("RasGetEntryPropertiesW({0}) failed {1}", entry, res)); - - return details; - } - - public static bool IsValidEntry(string entry) - { - // 183 == ENTRY_ALREADY_EXISTS - return NativeMethods.RasValidateEntryNameW(null, entry) == 183; - } - } -} -'@ - -$add_type_params = @{ - Reference = $win_ras_invoke - AnsibleModule = $module -} -# We need to set a custom compile option when running on Server 2008 due to the change in the RASENTRYW structure -$os_version = [Version](Get-Item -LiteralPath $env:SystemRoot\System32\kernel32.dll).VersionInfo.ProductVersion -if ($os_version -lt [Version]"6.1") { - $add_type_params.CompileSymbols = @("LONGHORN") -} -Add-CSharpType @add_type_params - -$exists = [Ansible.WinPhonebookEntry.Phonebook]::IsValidEntry($name) -if ($exists) { - $entry = [Ansible.WinPhonebookEntry.Phonebook]::GetEntry($name) - $module.Result.guid = $entry.guidId -} - -if ($state -eq "present") { - # Convert the input values to enum values - $expected_type = switch ($type) { - "broadband" { [Ansible.WinPhonebookEntry.NativeHelpers+RasEntryTypes]::RASET_Broadband } - "direct" { [Ansible.WinPhonebookEntry.NativeHelpers+RasEntryTypes]::RASET_Direct } - "phone" { [Ansible.WinPhonebookEntry.NativeHelpers+RasEntryTypes]::RASET_Phone } - "vpn" { [Ansible.WinPhonebookEntry.NativeHelpers+RasEntryTypes]::RASET_Vpn } - } - - $expected_framing_protocol = switch ($framing_protocol) { - "ppp" { [Ansible.WinPhonebookEntry.NativeHelpers+RasFramingProtocol]::RASFP_Ppp } - "ras" { [Ansible.WinPhonebookEntry.NativeHelpers+RasFramingProtocol]::RASFP_Ras } - "slip" { [Ansible.WinPhonebookEntry.NativeHelpers+RasFramingProtocol]::RASFP_Slip } - } - - $expected_options1 = [System.Collections.Generic.List`1[String]]@() - $expected_options2 = [System.Collections.Generic.List`1[String]]@() - $invalid_options = [System.Collections.Generic.List`1[String]]@() - foreach ($option in $options) { - # See https://msdn.microsoft.com/en-us/25c46850-4fb7-47a9-9645-139f0e869559 for more info on the options - # TODO: some of these options are set to indicate entries in RASENTRYW, we should automatically add them - # based on the input values. - switch ($option) { - # dwfOptions - "use_country_and_area_codes" { $expected_options1.Add("RASEO_UseCountryAndAreaCode") } - "specific_ip_addr" { $expected_options1.Add("RASEO_SpecificIpAddr") } - "specific_name_servers" { $expected_options1.Add("RASEO_SpecificNameServers") } - "ip_header_compression" { $expected_options1.Add("RASEO_IpHeaderCompression") } - "remote_default_gateway" { $expected_options1.Add("RASEO_RemoteDefaultGateway") } - "disable_lcp_extensions" { $expected_options1.Add("RASEO_DisableLcpExtensions") } - "terminal_before_dial" { $expected_options1.Add("RASEO_TerminalBeforeDial") } - "terminal_after_dial" { $expected_options1.Add("RASEO_TerminalAfterDial") } - "modem_lights" { $expected_options1.Add("RASEO_ModemLights") } - "sw_compression" { $expected_options1.Add("RASEO_SwCompression") } - "require_encrypted_password" { $expected_options1.Add("RASEO_RequireEncrptedPw") } - "require_ms_encrypted_password" { $expected_options1.Add("RASEO_RequireMsEncrptedPw") } - "require_data_encryption" { $expected_options1.Add("RASEO_RequireDataEncrption") } - "network_logon" { $expected_options1.Add("RASEO_NetworkLogon") } - "use_logon_credentials" { $expected_options1.Add("RASEO_UseLogonCredentials") } - "promote_alternates" { $expected_options1.Add("RASEO_PromoteAlternates") } - "secure_local_files" { $expected_options1.Add("RASEO_SecureLocalFiles") } - "require_eap" { $expected_options1.Add("RASEO_RequireEAP") } - "require_pap" { $expected_options1.Add("RASEO_RequirePAP") } - "require_spap" { $expected_options1.Add("RASEO_RequireSPAP") } - "custom" { $expected_options1.Add("RASEO_Custom") } - "preview_phone_number" { $expected_options1.Add("RASEO_PreviewPhoneNumber") } - "shared_phone_numbers" { $expected_options1.Add("RASEO_SharedPhoneNumbers") } - "preview_user_password" { $expected_options1.Add("RASEO_PreviewUserPw") } - "preview_domain" { $expected_options1.Add("RASEO_PreviewDomain") } - "show_dialing_progress" { $expected_options1.Add("RASEO_ShowDialingProgress") } - "require_chap" { $expected_options1.Add("RASEO_RequireCHAP") } - "require_ms_chap" { $expected_options1.Add("RASEO_RequireMsCHAP") } - "require_ms_chap2" { $expected_options1.Add("RASEO_RequireMsCHAP2") } - "require_w95_ms_chap" { $expected_options1.Add("RASEO_RequireW95MSCHAP") } - "custom_script" { $expected_options1.Add("RASEO_CustomScript") } - # dwfOptions2 - "secure_file_and_print" { $expected_options2.Add("RASEO2_SecureFileAndPrint") } - "secure_client_for_ms_net" { $expected_options2.Add("RASEO2_SecureClientForMSNet") } - "dont_negotiate_multilink" { $expected_options2.Add("RASEO2_DontNegotiateMultilink") } - "dont_use_ras_credential" { $expected_options2.Add("RASEO2_DontUseRasCredentials") } - "use_pre_shared_key" { $expected_options2.Add("RASEO2_UsePreSharedKey") } - "internet" { $expected_options2.Add("RASEO2_Internet") } - "disable_nbt_over_ip" { $expected_options2.Add("RASEO2_DisableNbtOverIP") } - "use_global_device_settings" { $expected_options2.Add("RASEO2_UseGlobalDeviceSettings") } - "reconnect_if_dropped" { $expected_options2.Add("RASEO2_ReconnectIfDropped") } - "share_phone_numbers" { $expected_options2.Add("RASEO2_SharePhoneNumbers") } - "secure_routing_compartment" { $expected_options2.Add("RASEO2_SecureRoutingCompartment") } - "use_typical_settings" { $expected_options2.Add("RASEO2_UseTypicalSettings") } - "ipv6_specific_name_servers" { $expected_options2.Add("RASEO2_IPv6SpecificNameServers") } - "ipv6_remote_default_gateway" { $expected_options2.Add("RASEO2_IPv6RemoteDefaultGateway") } - "register_ip_with_dns" { $expected_options2.Add("RASEO2_RegisterIpWithDNS") } - "use_dns_suffix_for_registration" { $expected_options2.Add("RASEO2_UseDNSSuffixForRegistration") } - "ipv4_explicit_metric" { $expected_options2.Add("RASEO2_IPv4ExplicitMetric") } - "ipv6_explicit_metric" { $expected_options2.Add("RASEO2_IPv6ExplicitMetric") } - "disable_ike_name_eku_check" { $expected_options2.Add("RASEO2_DisableIKENameEkuCheck") } - # TODO: Version check for the below, OS Version >= 6.1 - "disable_class_based_static_route" { $expected_options2.Add("RASEO2_DisableClassBasedStaticRoute") } - "specific_ipv6_addr" { $expected_options2.Add("RASEO2_SpecificIPv6Addr") } - "disable_mobility" { $expected_options2.Add("RASEO2_DisableMobility") } - "require_machine_certificates" { $expected_options2.Add("RASEO2_RequireMachineCertificates") } - # TODO: Version check for the below, OS Version >= 6.2 - "use_pre_shared_key_for_ikev2_initiator" { $expected_options2.Add("RASEO2_UsePreSharedKeyForIkev2Initiator") } - "use_pre_shared_key_for_ikev2_responder" { $expected_options2.Add("RASEO2_UsePreSharedKeyForIkev2Responder") } - "cache_credentials" { $expected_options2.Add("RASEO2_CacheCredentials") } - # TODO: Version check for the below, OS Version >= 6.3 - "auto_trigger_capable" { $expected_options2.Add("RASEO2_AutoTriggerCapable") } - "is_third_party_profile" { $expected_options2.Add("RASEO2_IsThirdPartyProfile") } - "auth_type_is_otp" { $expected_options2.Add("RASEO2_AuthTypeIsOtp") } - # TODO: Version check for the below, OS Version >= 10.0 - "is_always_on" { $expected_options2.Add("RASEO2_IsAlwaysOn") } - "is_private_network" { $expected_options2.Add("RASEO2_IsPrivateNetwork") } - default { $invalid_options.Add($option) } - } - } - if ($invalid_options.Count -gt 0) { - $module.FailJson("Encountered invalid options: $($invalid_options -join ", ")") - } - $expected_options1 = [Ansible.WinPhonebookEntry.NativeHelpers+RasEntryOptions]($expected_options1 -join ", ") - $expected_options2 = [Ansible.WinPhonebookEntry.NativeHelpers+RasEntryOptions2]($expected_options2 -join ", ") - - $property_map = @{ - szDeviceName = $device_name - szDeviceType = $device_type - dwFramingProtocol = $expected_framing_protocol - dwfOptions = $expected_options1 - dwfOptions2 = $expected_options2 - dwType = $expected_type - } - - if (-not $exists) { - $entry = New-Object -TypeName Ansible.WinPhonebookEntry.NativeHelpers+RASENTRYW - foreach ($kvp in $property_map.GetEnumerator()) { - $entry."$($kvp.Key)" = $kvp.Value - } - - [Ansible.WinPhonebookEntry.Phonebook]::CreateEntry($name, $entry) - $module.Result.changed = $true - - # Once created we then get the entry object again to retrieve the unique GUID ID to return - $entry = [Ansible.WinPhonebookEntry.Phonebook]::GetEntry($name) - $module.Result.guid = $entry.guidId - } else { - $entry = [Ansible.WinPhonebookEntry.Phonebook]::GetEntry($name) - $changed = $false - foreach ($kvp in $property_map.GetEnumerator()) { - $key = $kvp.Key - $actual_value = $entry.$key - if ($actual_value -ne $kvp.Value) { - $entry.$key = $kvp.Value - $changed = $true - } - } - - if ($changed) { - [Ansible.WinPhonebookEntry.Phonebook]::CreateEntry($name, $entry) - $module.Result.changed = $true - } - } -} else { - if ($exists) { - [Ansible.WinPhonebookEntry.Phonebook]::DeleteEntry($name) - $module.Result.changed = $true - } -} - -$module.ExitJson() diff --git a/test/integration/targets/win_inet_proxy/tasks/main.yml b/test/integration/targets/win_inet_proxy/tasks/main.yml deleted file mode 100644 index f92a60eab5..0000000000 --- a/test/integration/targets/win_inet_proxy/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -- name: make sure we start the tests with the defaults - win_inet_proxy: - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: reset proxy back to defaults - win_inet_proxy: - - - name: remove phonebook entry - win_phonebook_entry: - name: Ansible Test Dialup - state: absent diff --git a/test/integration/targets/win_inet_proxy/tasks/tests.yml b/test/integration/targets/win_inet_proxy/tasks/tests.yml deleted file mode 100644 index 47ddfbe2e8..0000000000 --- a/test/integration/targets/win_inet_proxy/tasks/tests.yml +++ /dev/null @@ -1,308 +0,0 @@ ---- -- name: ensure we fail when proxy is not set with bypass - win_inet_proxy: - bypass: abc - register: fail_bypass - failed_when: 'fail_bypass.msg != "missing parameter(s) required by ''bypass'': proxy"' - -- name: ensure we fail if an invalid protocol is specified - win_inet_proxy: - proxy: - fail1: fail - fail2: fail - register: fail_proxy - failed_when: 'fail_proxy.msg != "Invalid keys found in proxy: fail1, fail2. Valid keys are http, https, ftp, socks."' - -- name: ensure we fail if invalid value is set - win_inet_proxy: - proxy: fake=proxy - register: fail_invalid - failed_when: fail_invalid.msg != "Unknown error when trying to set auto_config_url '', proxy 'fake=proxy', or bypass ''" - -- name: ensure we fail if an invalid connection is set - win_inet_proxy: - connection: Fake Connection - register: fail_connection - failed_when: fail_connection.msg != "The connection 'Fake Connection' does not exist." - -- name: check proxy is still set to Direct access - win_inet_proxy_info: - register: fail_invalid_actual - failed_when: fail_invalid_actual.proxy == 'fake=proxy' - -- name: disable auto detect (check) - win_inet_proxy: - auto_detect: no - register: disable_auto_detect_check - check_mode: yes - -- name: get result of disable auto detect (check) - win_inet_proxy_info: - register: disable_auto_detect_actual_check - -- name: assert disable auto detect (check) - assert: - that: - - disable_auto_detect_check is changed - - disable_auto_detect_actual_check.auto_detect - -- name: disable auto detect - win_inet_proxy: - auto_detect: no - register: disable_auto_detect - -- name: get result of disable auto detect - win_inet_proxy_info: - register: disable_auto_detect_actual - -- name: assert disable auto detect - assert: - that: - - disable_auto_detect is changed - - not disable_auto_detect_actual.auto_detect - -- name: disable auto detect (idempotent) - win_inet_proxy: - auto_detect: no - register: disable_auto_detect_again - -- name: assert disable auto detect (idempotent) - assert: - that: - - not disable_auto_detect_again is changed - -- name: set auto config url - win_inet_proxy: - auto_config_url: http://ansible.com/proxy.pac - register: set_auto_url - -- name: get result of set auto config url - win_inet_proxy_info: - register: set_auto_url_actual - -- name: assert set auto config url - assert: - that: - - set_auto_url is changed - - set_auto_url_actual.auto_detect - - set_auto_url_actual.auto_config_url == 'http://ansible.com/proxy.pac' - -- name: set auto config url (idempotent) - win_inet_proxy: - auto_config_url: http://ansible.com/proxy.pac - register: set_auto_url_again - -- name: set auto config url (idempotent) - assert: - that: - - not set_auto_url_again is changed - -- name: set a proxy using a string - win_inet_proxy: - proxy: proxyhost - register: proxy_str - -- name: get result of set a proxy using a string - win_inet_proxy_info: - register: proxy_str_actual - -- name: assert set a proxy using a string - assert: - that: - - proxy_str is changed - - proxy_str_actual.auto_detect - - proxy_str_actual.auto_config_url == None - - proxy_str_actual.proxy == 'proxyhost' - -- name: set a proxy using a string (idempotent) - win_inet_proxy: - proxy: proxyhost - register: proxy_str_again - -- name: assert set a proxy using a string (idempotent) - assert: - that: - - not proxy_str_again is changed - -- name: change a proxy and set bypass - win_inet_proxy: - proxy: proxyhost:8080 - bypass: - - abc - - def - - <local> - register: change_proxy - -- name: get result of change a proxy and set bypass - win_inet_proxy_info: - register: change_proxy_actual - -- name: assert change a proxy and set bypass - assert: - that: - - change_proxy is changed - - change_proxy_actual.proxy == 'proxyhost:8080' - - change_proxy_actual.bypass == 'abc;def;<local>' - -- name: change a proxy and set bypass (idempotent) - win_inet_proxy: - proxy: proxyhost:8080 - bypass: abc,def,<local> - register: change_proxy_again - -- name: assert change a proxy and set bypass (idempotent) - assert: - that: - - not change_proxy_again is changed - -- name: change bypass list - win_inet_proxy: - proxy: proxyhost:8080 - bypass: - - abc - - <-loopback> - register: change_bypass - -- name: get reuslt of change bypass list - win_inet_proxy_info: - register: change_bypass_actual - -- name: assert change bypass list - assert: - that: - - change_bypass is changed - - change_bypass_actual.proxy == 'proxyhost:8080' - - change_bypass_actual.bypass == 'abc;<-loopback>' - -- name: remove proxy without options - win_inet_proxy: - register: remove_proxy - -- name: get result of remove proxy without options - win_inet_proxy_info: - register: remove_proxy_actual - -- name: assert remove proxy without options - assert: - that: - - remove_proxy is changed - - remove_proxy_actual.auto_detect == True - - remove_proxy_actual.auto_config_url == None - - remove_proxy_actual.proxy == None - - remove_proxy_actual.bypass == None - -- name: remove proxy without options (idempotent) - win_inet_proxy: - register: remove_proxy_again - -- name: assert remove proxy without options (idempotent) - assert: - that: - - not remove_proxy_again is changed - -- name: set proxy with dictionary - win_inet_proxy: - proxy: - http: proxy:8080 - https: proxy:8443 - ftp: proxy:821 - socks: proxy:888 - register: set_dict - -- name: get result of set proxy with dictionary - win_inet_proxy_info: - register: set_dict_actual - -- name: assert set proxy with dictionary - assert: - that: - - set_dict is changed - - set_dict_actual.proxy == 'http=proxy:8080;https=proxy:8443;ftp=proxy:821;socks=proxy:888' - -- name: set proxy protocol with str - win_inet_proxy: - proxy: http=proxy:8080;https=proxy:8443;ftp=proxy:821;socks=proxy:888 - register: set_str_protocol - -- name: assert set proxy protocol with str - assert: - that: - - not set_str_protocol is changed - -- name: remove proxy with empty string - win_inet_proxy: - proxy: '' - register: remove_empty_str - -- name: get result of remove proxy with empty string - win_inet_proxy_info: - register: remove_empty_str_actual - -- name: assert remove proxy with empty string - assert: - that: - - remove_empty_str is changed - - remove_empty_str_actual.proxy == None - -- name: create test phonebook entry - win_phonebook_entry: - name: Ansible Test Dialup - device_type: pppoe - device_name: WAN Miniport (PPPOE) - framing_protocol: ppp - options: - - remote_default_gateway - - require_pap - - internet - type: broadband - state: present - -- name: set proxy for specific connection - win_inet_proxy: - connection: Ansible Test Dialup - auto_detect: no - auto_config_url: proxy.com - proxy: proxyhost:8080 - bypass: proxyhost - register: set_connection - -- name: get result for set proxy for specific connection - win_inet_proxy_info: - connection: Ansible Test Dialup - register: set_connection_actual - -- name: get result for LAN connection proxy - win_inet_proxy_info: - register: set_connection_lan_actual - -- name: assert set proxy for specific connection - assert: - that: - - set_connection is changed - - set_connection_actual.auto_detect == False - - set_connection_actual.auto_config_url == 'proxy.com' - - set_connection_actual.proxy == 'proxyhost:8080' - - set_connection_actual.bypass == 'proxyhost' - - set_connection_lan_actual.auto_detect == True - - set_connection_lan_actual.auto_config_url == None - - set_connection_lan_actual.proxy == None - - set_connection_lan_actual.bypass == None - -- name: remove proxy for specific connection - win_inet_proxy: - connection: Ansible Test Dialup - register: remove_connection - -- name: get result of remove proxy for specific connection - win_inet_proxy_info: - connection: Ansible Test Dialup - register: remove_connection_actual - -- name: assert remove proxy for specific connection - assert: - that: - - remove_connection is changed - - remove_connection_actual.auto_detect == True - - remove_connection_actual.auto_config_url == None - - remove_connection_actual.proxy == None - - remove_connection_actual.bypass == None diff --git a/test/integration/targets/win_initialize_disk/aliases b/test/integration/targets/win_initialize_disk/aliases deleted file mode 100644 index 3fac36743f..0000000000 --- a/test/integration/targets/win_initialize_disk/aliases +++ /dev/null @@ -1,3 +0,0 @@ -shippable/windows/group6 -skip/windows/2008 -skip/windows/2008-R2 diff --git a/test/integration/targets/win_initialize_disk/defaults/main.yml b/test/integration/targets/win_initialize_disk/defaults/main.yml deleted file mode 100644 index 9cb54a30cd..0000000000 --- a/test/integration/targets/win_initialize_disk/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -AnsibleVhdx: C:\win_initialize_disk_tests\AnsiblePart.vhdx diff --git a/test/integration/targets/win_initialize_disk/tasks/main.yml b/test/integration/targets/win_initialize_disk/tasks/main.yml deleted file mode 100644 index f31c751392..0000000000 --- a/test/integration/targets/win_initialize_disk/tasks/main.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Create the temp directory - win_file: - path: C:\win_initialize_disk_tests - state: directory - -- name: Copy VHDX scripts - win_template: - src: "{{ item.src }}" - dest: C:\win_initialize_disk_tests\{{ item.dest }} - loop: - - { src: vhdx_creation_script.j2, dest: vhdx_creation_script.txt } - - { src: vhdx_deletion_script.j2, dest: vhdx_deletion_script.txt } - -- name: Create VHD - win_command: diskpart.exe /s C:\win_initialize_disk_tests\vhdx_creation_script.txt - -- name: Run tests - block: - - include: tests.yml - always: - - name: Detach disk - win_command: diskpart.exe /s C:\win_initialize_disk_tests\vhdx_deletion_script.txt - - - name: Cleanup files - win_file: - path: C:\win_initialize_disk_tests - state: absent diff --git a/test/integration/targets/win_initialize_disk/tasks/tests.yml b/test/integration/targets/win_initialize_disk/tasks/tests.yml deleted file mode 100644 index 41defd6062..0000000000 --- a/test/integration/targets/win_initialize_disk/tasks/tests.yml +++ /dev/null @@ -1,104 +0,0 @@ ---- -- name: Initialize the disk with the default partition style (check mode) - win_initialize_disk: - disk_number: 1 - register: default_part_style_check - check_mode: yes - -- name: Get result of default initialization (check mode) - win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'RAW' ) {'true'} else {'false'}" - register: default_part_style_actual_check - -- name: assert default initialization (check mode) - assert: - that: - - default_part_style_check is changed - - default_part_style_actual_check.stdout == 'true\r\n' - -- name: Initialize the disk with the default partition style - win_initialize_disk: - disk_number: 1 - register: default_part_style - -- name: Get result of default initialization - win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'GPT' ) {'true'} else {'false'}" - register: default_part_style_actual - -- name: assert default initialization - assert: - that: - - default_part_style is changed - - default_part_style_actual.stdout == 'true\r\n' - -- name: Initialize the disk with the default partition style (idempotence) - win_initialize_disk: - disk_number: 1 - register: default_part_style_idempotence - -- name: Get result of default initialization (idempotence) - win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'GPT' ) {'true'} else {'false'}" - register: default_part_style_actual_idempotence - -- name: assert default initialization (idempotence) - assert: - that: - - not default_part_style_idempotence is changed - - default_part_style_actual_idempotence.stdout == 'true\r\n' - -- name: Partition style change without force fails - win_initialize_disk: - disk_number: 1 - style: mbr - register: change_part_style - ignore_errors: True - -- name: assert failed partition style change - assert: - that: - - change_part_style is failed - -- name: Partition style change with force is successful (check mode) - win_initialize_disk: - disk_number: 1 - style: mbr - force: yes - register: change_part_style_forced_check - check_mode: yes - -- name: Get result of forced initialization (check mode) - win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'GPT' ) {'true'} else {'false'}" - register: change_part_style_forced_actual_check - -- name: assert forced initialization (check mode) - assert: - that: - - change_part_style_forced_check is changed - - change_part_style_forced_actual_check.stdout == 'true\r\n' - -- name: Partition style change with force is successful - win_initialize_disk: - disk_number: 1 - style: mbr - force: yes - register: change_part_style_forced - -- name: Get result of forced initialization - win_command: powershell.exe "if ( (Get-Disk -Number 1).PartitionStyle -eq 'MBR' ) {'true'} else {'false'}" - register: change_part_style_forced_actual - -- name: assert forced initialization - assert: - that: - - change_part_style_forced is changed - - change_part_style_forced_actual.stdout == 'true\r\n' - -- name: Unknown disk number fails - win_initialize_disk: - disk_number: 3 - register: unknown_disk_number - ignore_errors: True - -- name: assert unknown disk number fails - assert: - that: - - unknown_disk_number is failed diff --git a/test/integration/targets/win_initialize_disk/templates/vhdx_creation_script.j2 b/test/integration/targets/win_initialize_disk/templates/vhdx_creation_script.j2 deleted file mode 100644 index 4089bf379e..0000000000 --- a/test/integration/targets/win_initialize_disk/templates/vhdx_creation_script.j2 +++ /dev/null @@ -1,5 +0,0 @@ -create vdisk file="{{ AnsibleVhdx }}" maximum=2000 type=fixed - -select vdisk file="{{ AnsibleVhdx }}" - -attach vdisk diff --git a/test/integration/targets/win_initialize_disk/templates/vhdx_deletion_script.j2 b/test/integration/targets/win_initialize_disk/templates/vhdx_deletion_script.j2 deleted file mode 100644 index c2be9cd144..0000000000 --- a/test/integration/targets/win_initialize_disk/templates/vhdx_deletion_script.j2 +++ /dev/null @@ -1,3 +0,0 @@ -select vdisk file="{{ AnsibleVhdx }}" - -detach vdisk diff --git a/test/integration/targets/win_lineinfile/aliases b/test/integration/targets/win_lineinfile/aliases deleted file mode 100644 index 219895f4bc..0000000000 --- a/test/integration/targets/win_lineinfile/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group2 -skip/windows/2016 # Host takes a while to run and module isn't OS dependent diff --git a/test/integration/targets/win_lineinfile/files/test.txt b/test/integration/targets/win_lineinfile/files/test.txt deleted file mode 100644 index 8187db9f02..0000000000 --- a/test/integration/targets/win_lineinfile/files/test.txt +++ /dev/null @@ -1,5 +0,0 @@ -This is line 1 -This is line 2 -REF this is a line for backrefs REF -This is line 4 -This is line 5 diff --git a/test/integration/targets/win_lineinfile/files/test_linebreak.txt b/test/integration/targets/win_lineinfile/files/test_linebreak.txt deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/integration/targets/win_lineinfile/files/test_linebreak.txt +++ /dev/null diff --git a/test/integration/targets/win_lineinfile/files/test_quoting.txt b/test/integration/targets/win_lineinfile/files/test_quoting.txt deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/integration/targets/win_lineinfile/files/test_quoting.txt +++ /dev/null diff --git a/test/integration/targets/win_lineinfile/files/testempty.txt b/test/integration/targets/win_lineinfile/files/testempty.txt deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/integration/targets/win_lineinfile/files/testempty.txt +++ /dev/null diff --git a/test/integration/targets/win_lineinfile/files/testnoeof.txt b/test/integration/targets/win_lineinfile/files/testnoeof.txt deleted file mode 100644 index 152780b9ff..0000000000 --- a/test/integration/targets/win_lineinfile/files/testnoeof.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is line 1 -This is line 2
\ No newline at end of file diff --git a/test/integration/targets/win_lineinfile/meta/main.yml b/test/integration/targets/win_lineinfile/meta/main.yml deleted file mode 100644 index d328716dfa..0000000000 --- a/test/integration/targets/win_lineinfile/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - prepare_win_tests diff --git a/test/integration/targets/win_lineinfile/tasks/main.yml b/test/integration/targets/win_lineinfile/tasks/main.yml deleted file mode 100644 index e5f047bec3..0000000000 --- a/test/integration/targets/win_lineinfile/tasks/main.yml +++ /dev/null @@ -1,708 +0,0 @@ -# Test code for the win_lineinfile module, adapted from the standard lineinfile module tests -# -# 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 <http://www.gnu.org/licenses/>. - - -- name: deploy the test file for lineinfile - win_copy: src=test.txt dest={{win_output_dir}}/test.txt - register: result - -- name: assert that the test file was deployed - assert: - that: - - "result.changed == true" - -- name: stat the test file - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: check win_stat file result - assert: - that: - - "result.stat.exists" - - "not result.stat.isdir" - - "result.stat.checksum == '5feac65e442c91f557fc90069ce6efc4d346ab51'" - - "result is not failed" - - "result is not changed" - - -- name: insert a line at the beginning of the file, and back it up - win_lineinfile: dest={{win_output_dir}}/test.txt state=present line="New line at the beginning" insertbefore="BOF" backup=yes - register: result - -- name: check backup_file - win_stat: - path: '{{ result.backup_file }}' - register: backup_file - -- name: assert that the line was inserted at the head of the file - assert: - that: - - result.changed == true - - result.msg == 'line added' - - backup_file.stat.exists == true - -- name: stat the backup file - win_stat: path={{result.backup}} - register: result - -- name: assert the backup file matches the previous hash - assert: - that: - - "result.stat.checksum == '5feac65e442c91f557fc90069ce6efc4d346ab51'" - -- name: stat the test after the insert at the head - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test hash is what we expect for the file with the insert at the head - assert: - that: - - "result.stat.checksum == 'b526e2e044defc64dfb0fad2f56e105178f317d8'" - -- name: insert a line at the end of the file - win_lineinfile: dest={{win_output_dir}}/test.txt state=present line="New line at the end" insertafter="EOF" - register: result - -- name: assert that the line was inserted at the end of the file - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: stat the test after the insert at the end - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after the insert at the end - assert: - that: - - "result.stat.checksum == 'dd5e207e28ce694ab18e41c2b16deb74fde93b14'" - -- name: insert a line after the first line - win_lineinfile: dest={{win_output_dir}}/test.txt state=present line="New line after line 1" insertafter="^This is line 1$" - register: result - -- name: assert that the line was inserted after the first line - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: stat the test after insert after the first line - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after the insert after the first line - assert: - that: - - "result.stat.checksum == '604b17405f2088e6868af9680b7834087acdc8f4'" - -- name: insert a line before the last line - win_lineinfile: dest={{win_output_dir}}/test.txt state=present line="New line before line 5" insertbefore="^This is line 5$" - register: result - -- name: assert that the line was inserted before the last line - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: stat the test after the insert before the last line - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after the insert before the last line - assert: - that: - - "result.stat.checksum == '8f5b30e8f01578043d782e5a68d4c327e75a6e34'" - -- name: replace a line with backrefs - win_lineinfile: dest={{win_output_dir}}/test.txt state=present line="This is line 3" backrefs=yes regexp="^(REF).*$" - register: result - -- name: assert that the line with backrefs was changed - assert: - that: - - "result.changed == true" - - "result.msg == 'line replaced'" - -- name: stat the test after the backref line was replaced - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after backref line was replaced - assert: - that: - - "result.stat.checksum == 'ef6b02645908511a2cfd2df29d50dd008897c580'" - -- name: remove the middle line - win_lineinfile: dest={{win_output_dir}}/test.txt state=absent regexp="^This is line 3$" - register: result - -- name: assert that the line was removed - assert: - that: - - "result.changed == true" - - "result.msg == '1 line(s) removed'" - -- name: stat the test after the middle line was removed - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after the middle line was removed - assert: - that: - - "result.stat.checksum == '11695efa472be5c31c736bc43e055f8ac90eabdf'" - -- name: run a validation script that succeeds - win_lineinfile: dest={{win_output_dir}}/test.txt state=absent regexp="^This is line 5$" validate="sort.exe %s" - register: result - -- name: assert that the file validated after removing a line - assert: - that: - - "result.changed == true" - - "result.msg == '1 line(s) removed'" - -- name: stat the test after the validation succeeded - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after the validation succeeded - assert: - that: - - "result.stat.checksum == '39c38a30aa6ac6af9ec41f54c7ed7683f1249347'" - -- name: run a validation script that fails - win_lineinfile: dest={{win_output_dir}}/test.txt state=absent regexp="^This is line 1$" validate="sort.exe %s.foo" - register: result - ignore_errors: yes - -- name: assert that the validate failed - assert: - that: - - "result.failed == true" - -- name: stat the test after the validation failed - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches the previous after the validation failed - assert: - that: - - "result.stat.checksum == '39c38a30aa6ac6af9ec41f54c7ed7683f1249347'" - -- name: use create=yes - win_lineinfile: dest={{win_output_dir}}/new_test.txt create=yes insertbefore=BOF state=present line="This is a new file" - register: result - -- name: assert that the new file was created - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: validate that the newly created file exists - win_stat: path={{win_output_dir}}/new_test.txt - register: result - ignore_errors: yes - -- name: assert the newly created test checksum matches - assert: - that: - - "result.stat.checksum == '84faac1183841c57434693752fc3debc91b9195d'" - -# Test EOF in cases where file has no newline at EOF -- name: testnoeof deploy the file for lineinfile - win_copy: src=testnoeof.txt dest={{win_output_dir}}/testnoeof.txt - register: result - -- name: testnoeof insert a line at the end of the file - win_lineinfile: dest={{win_output_dir}}/testnoeof.txt state=present line="New line at the end" insertafter="EOF" - register: result - -- name: testempty assert that the line was inserted at the end of the file - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: testnoeof stat the no newline EOF test after the insert at the end - win_stat: path={{win_output_dir}}/testnoeof.txt - register: result - -- name: testnoeof assert test checksum matches after the insert at the end - assert: - that: - - "result.stat.checksum == '229852b09f7e9921fbcbb0ee0166ba78f7f7f261'" - -- name: add multiple lines at the end of the file - win_lineinfile: dest={{win_output_dir}}/test.txt state=present line="This is a line\r\nwith newline character" insertafter="EOF" - register: result - -- name: assert that the multiple lines was inserted - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: stat file after adding multiple lines - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after inserting multiple lines - assert: - that: - - "result.stat.checksum == '1401413cd4eac732be66cd6aceddd334c4240f86'" - - - -# Test EOF with empty file to make sure no unnecessary newline is added -- name: testempty deploy the testempty file for lineinfile - win_copy: src=testempty.txt dest={{win_output_dir}}/testempty.txt - register: result - -- name: testempty insert a line at the end of the file - win_lineinfile: dest={{win_output_dir}}/testempty.txt state=present line="New line at the end" insertafter="EOF" - register: result - -- name: testempty assert that the line was inserted at the end of the file - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: testempty stat the test after the insert at the end - win_stat: path={{win_output_dir}}/testempty.txt - register: result - -- name: testempty assert test checksum matches after the insert at the end - assert: - that: - - "result.stat.checksum == 'd3d34f11edda51be7ca5dcb0757cf3e1257c0bfe'" - - - -- name: replace a line with backrefs included in the line - win_lineinfile: dest={{win_output_dir}}/test.txt state=present line="New $1 created with the backref" backrefs=yes regexp="^This is (line 4)$" - register: result - -- name: assert that the line with backrefs was changed - assert: - that: - - "result.changed == true" - - "result.msg == 'line replaced'" - -- name: stat the test after the backref line was replaced - win_stat: path={{win_output_dir}}/test.txt - register: result - -- name: assert test checksum matches after backref line was replaced - assert: - that: - - "result.stat.checksum == 'e6ff42e926dac2274c93dff0b8a323e07ae09149'" - -################################################################### -# issue 8535 - -- name: create a new file for testing quoting issues - win_copy: src=test_quoting.txt dest={{win_output_dir}}/test_quoting.txt - register: result - -- name: assert the new file was created - assert: - that: - - result.changed - -- name: use with_items to add code-like strings to the quoting txt file - win_lineinfile: > - dest={{win_output_dir}}/test_quoting.txt - line="{{ item }}" - insertbefore="BOF" - with_items: - - "'foo'" - - "dotenv.load();" - - "var dotenv = require('dotenv');" - register: result - -- name: assert the quote test file was modified correctly - assert: - that: - - result.results|length == 3 - - result.results[0].changed - - result.results[0].item == "'foo'" - - result.results[1].changed - - result.results[1].item == "dotenv.load();" - - result.results[2].changed - - result.results[2].item == "var dotenv = require('dotenv');" - -- name: stat the quote test file - win_stat: path={{win_output_dir}}/test_quoting.txt - register: result - -- name: assert test checksum matches for quote test file - assert: - that: - - "result.stat.checksum == 'f3bccdbdfa1d7176c497ef87d04957af40ab48d2'" - -- name: append a line into the quoted file with a single quote - win_lineinfile: dest={{win_output_dir}}/test_quoting.txt line="import g'" - register: result - -- name: assert that the quoted file was changed - assert: - that: - - result.changed - -- name: stat the quote test file - win_stat: path={{win_output_dir}}/test_quoting.txt - register: result - -- name: assert test checksum matches adding line with single quote - assert: - that: - - "result.stat.checksum == 'dabf4cbe471e1797d8dcfc773b6b638c524d5237'" - -- name: insert a line into the quoted file with many double quotation strings - win_lineinfile: dest={{win_output_dir}}/test_quoting.txt line='"quote" and "unquote"' - register: result - -- name: assert that the quoted file was changed - assert: - that: - - result.changed - -- name: stat the quote test file - win_stat: path={{win_output_dir}}/test_quoting.txt - register: result - -- name: assert test checksum matches quoted line added - assert: - that: - - "result.stat.checksum == '9dc1fc1ff19942e2936564102ad37134fa83b91d'" - - -# Windows vs. Unix line separator test cases - -- name: Create windows test file with initial line - win_lineinfile: dest={{win_output_dir}}/test_windows_sep.txt create=yes insertbefore=BOF state=present line="This is a new file" - register: result - -- name: assert that the new file was created - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: validate that the newly created file exists - win_stat: path={{win_output_dir}}/test_windows_sep.txt - register: result - -- name: assert the newly created file checksum matches - assert: - that: - - "result.stat.checksum == '84faac1183841c57434693752fc3debc91b9195d'" - -- name: Test appending to the file using the default (windows) line separator - win_lineinfile: dest={{win_output_dir}}/test_windows_sep.txt insertbefore=EOF state=present line="This is the last line" - register: result - -- name: assert that the new line was added - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: stat the file - win_stat: path={{win_output_dir}}/test_windows_sep.txt - register: result - -- name: assert the file checksum matches expected checksum - assert: - that: - - "result.stat.checksum == '71a17ddd1d57ed7c7912e4fd11ecb2ead0b27033'" - - -- name: Create unix test file with initial line - win_lineinfile: dest={{win_output_dir}}/test_unix_sep.txt create=yes insertbefore=BOF state=present line="This is a new file" - register: result - -- name: assert that the new file was created - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: validate that the newly created file exists - win_stat: path={{win_output_dir}}/test_unix_sep.txt - register: result - -- name: assert the newly created file checksum matches - assert: - that: - - "result.stat.checksum == '84faac1183841c57434693752fc3debc91b9195d'" - -- name: Test appending to the file using unix line separator - win_lineinfile: dest={{win_output_dir}}/test_unix_sep.txt insertbefore=EOF state=present line="This is the last line" newline="unix" - register: result - -- name: assert that the new line was added - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - -- name: stat the file - win_stat: path={{win_output_dir}}/test_unix_sep.txt - register: result - -- name: assert the file checksum matches expected checksum - assert: - that: - - "result.stat.checksum == 'f1f634a37ab1c73efb77a71a5ad2cc87b61b17ae'" - - -# Encoding management test cases - -# Default (auto) encoding should use utf-8 with no BOM -- name: Test create file without explicit encoding results in utf-8 without BOM - win_lineinfile: dest={{win_output_dir}}/test_auto_utf8.txt create=yes insertbefore=BOF state=present line="This is a new utf-8 file" - register: result - -- name: assert that the new file was created - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-8'" - -- name: validate that the newly created file exists - win_stat: path={{win_output_dir}}/test_auto_utf8.txt - register: result - -- name: assert the newly created file checksum matches - assert: - that: - - "result.stat.checksum == 'b69fcbacca8291a4668f57fba91d7c022f1c3dc7'" - -- name: Test appending to the utf-8 without BOM file - should autodetect UTF-8 no BOM - win_lineinfile: dest={{win_output_dir}}/test_auto_utf8.txt insertbefore=EOF state=present line="This is the last line" - register: result - -- name: assert that the new line was added and encoding did not change - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-8'" - -- name: stat the file - win_stat: path={{win_output_dir}}/test_auto_utf8.txt - register: result - -- name: assert the file checksum matches - assert: - that: - - "result.stat.checksum == '64d747f1ebf8c9d793dbfd27126e4152d39a3848'" - - -# UTF-8 explicit (with BOM) -- name: Test create file with explicit utf-8 encoding results in utf-8 with a BOM - win_lineinfile: dest={{win_output_dir}}/test_utf8.txt create=yes encoding="utf-8" insertbefore=BOF state=present line="This is a new utf-8 file" - register: result - -- name: assert that the new file was created - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-8'" - -- name: validate that the newly created file exists - win_stat: path={{win_output_dir}}/test_utf8.txt - register: result - -- name: assert the newly created file checksum matches - assert: - that: - - "result.stat.checksum == 'd45344b2b3bf1cf90eae851b40612f5f37a88bbb'" - -- name: Test appending to the utf-8 with BOM file - should autodetect utf-8 with BOM encoding - win_lineinfile: dest={{win_output_dir}}/test_utf8.txt insertbefore=EOF state=present line="This is the last line" - register: result - -- name: assert that the new line was added and encoding did not change - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-8'" - -- name: stat the file - win_stat: path={{win_output_dir}}/test_utf8.txt - register: result - -- name: assert the file checksum matches - assert: - that: - - "result.stat.checksum == '9b84254489f40f258871a4c6573cacc65895ee1a'" - - -# UTF-16 explicit -- name: Test create file with explicit utf-16 encoding - win_lineinfile: dest={{win_output_dir}}/test_utf16.txt create=yes encoding="utf-16" insertbefore=BOF state=present line="This is a new utf-16 file" - register: result - -- name: assert that the new file was created - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-16'" - -- name: validate that the newly created file exists - win_stat: path={{win_output_dir}}/test_utf16.txt - register: result - -- name: assert the newly created file checksum matches - assert: - that: - - "result.stat.checksum == '785b0693cec13b60e2c232782adeda2f8a967434'" - -- name: Test appending to the utf-16 file - should autodetect utf-16 encoding - win_lineinfile: dest={{win_output_dir}}/test_utf16.txt insertbefore=EOF state=present line="This is the last line" - register: result - -- name: assert that the new line was added and encoding did not change - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-16'" - -- name: stat the file - win_stat: path={{win_output_dir}}/test_utf16.txt - register: result - -- name: assert the file checksum matches - assert: - that: - - "result.stat.checksum == '70e4eb3ba795e1ba94d262db47e4fd17c64b2e73'" - -# UTF-32 explicit -- name: Test create file with explicit utf-32 encoding - win_lineinfile: dest={{win_output_dir}}/test_utf32.txt create=yes encoding="utf-32" insertbefore=BOF state=present line="This is a new utf-32 file" - register: result - -- name: assert that the new file was created - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-32'" - -- name: validate that the newly created file exists - win_stat: path={{win_output_dir}}/test_utf32.txt - register: result - -- name: assert the newly created file checksum matches - assert: - that: - - "result.stat.checksum == '7a6e3f3604c0def431aaa813173a4ddaa10fd1fb'" - -- name: Test appending to the utf-32 file - should autodetect utf-32 encoding - win_lineinfile: dest={{win_output_dir}}/test_utf32.txt insertbefore=EOF state=present line="This is the last line" - register: result - -- name: assert that the new line was added and encoding did not change - assert: - that: - - "result.changed == true" - - "result.msg == 'line added'" - - "result.encoding == 'utf-32'" - -- name: stat the file - win_stat: path={{win_output_dir}}/test_utf32.txt - register: result - -- name: assert the file checksum matches - assert: - that: - - "result.stat.checksum == '66a72e71f42c4775f4326da95cfe82c8830e5022'" - -######################################################################### -# issue #33858 -# \r\n causes line break instead of printing literally which breaks paths. - -- name: create testing file - win_copy: - src: test_linebreak.txt - dest: "{{win_output_dir}}/test_linebreak.txt" - -- name: stat the test file - win_stat: - path: "{{win_output_dir}}/test_linebreak.txt" - register: result - -# (Get-FileHash -path C:\ansible\test\integration\targets\win_lineinfile\files\test_linebreak.txt -Algorithm sha1).hash.tolower() -- name: check win_stat file result - assert: - that: - - result.stat.exists - - not result.stat.isdir - - result.stat.checksum == 'da39a3ee5e6b4b0d3255bfef95601890afd80709' - - result is not failed - - result is not changed - -- name: insert path c:\return\new to test file - win_lineinfile: - dest: "{{win_output_dir}}/test_linebreak.txt" - line: c:\return\new - register: result_literal - -- name: insert path "c:\return\new" to test file, will cause line breaks - win_lineinfile: - dest: "{{win_output_dir}}/test_linebreak.txt" - line: "c:\return\new" - register: result_expand - -- name: assert that the lines were inserted - assert: - that: - - result_literal.changed == true - - result_literal.msg == 'line added' - - result_expand.changed == true - - result_expand.msg == 'line added' - -- name: stat the test file - win_stat: - path: "{{win_output_dir}}/test_linebreak.txt" - register: result - -- debug: - var: result - verbosity: 1 - -# expect that the file looks like this: -# c:\return\new -# c: -# eturn -# ew #or c:eturnew on windows -- name: assert that one line is literal and the other has breaks - assert: - that: - - result.stat.checksum == 'd2dfd11bc70526ff13a91153c76a7ae5595a845b' diff --git a/test/integration/targets/win_mapped_drive/aliases b/test/integration/targets/win_mapped_drive/aliases deleted file mode 100644 index 4f4664b685..0000000000 --- a/test/integration/targets/win_mapped_drive/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group5 diff --git a/test/integration/targets/win_mapped_drive/defaults/main.yml b/test/integration/targets/win_mapped_drive/defaults/main.yml deleted file mode 100644 index 6e8ed002ed..0000000000 --- a/test/integration/targets/win_mapped_drive/defaults/main.yml +++ /dev/null @@ -1,9 +0,0 @@ -test_win_mapped_drive_letter: M -test_win_mapped_drive_path: share1 -test_win_mapped_drive_path2: share2 - -test_win_mapped_drive_local_path: C:\ansible\win_mapped_drive\share1 -test_win_mapped_drive_local_path2: C:\ansible\win_mapped_drive\share2 - -test_win_mapped_drive_temp_user: TestMappedUser -test_win_mapped_drive_temp_password: aZ293jgkdslgj4 diff --git a/test/integration/targets/win_mapped_drive/tasks/main.yml b/test/integration/targets/win_mapped_drive/tasks/main.yml deleted file mode 100644 index 3e3455bef9..0000000000 --- a/test/integration/targets/win_mapped_drive/tasks/main.yml +++ /dev/null @@ -1,99 +0,0 @@ ---- -# test setup -- name: gather facts required by the tests - setup: - gather_subset: platform - -- name: ensure mapped drive is deleted before test - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - state: absent - -- name: ensure temp mapped drive user exist - win_user: - name: '{{test_win_mapped_drive_temp_user}}' - password: '{{test_win_mapped_drive_temp_password}}' - state: present - groups: - - Administrators - -- name: ensure temp folders exist - win_file: - path: '{{item}}' - state: directory - with_items: - - '{{test_win_mapped_drive_local_path}}' - - '{{test_win_mapped_drive_local_path2}}' - -# can't use win_share as it doesnt't support Server 2008 and 2008 R2 -- name: ensure shares exist - win_shell: $share = Get-WmiObject -Class Win32_Share | Where-Object { $_.Name -eq '{{item.name}}' }; if (-not $share) { $share = [wmiClass]'Win32_Share'; $share.Create('{{item.path}}', '{{item.name}}', 0) } - with_items: - - { name: '{{test_win_mapped_drive_path}}', path: '{{test_win_mapped_drive_local_path}}' } - - { name: '{{test_win_mapped_drive_path2}}', path: '{{test_win_mapped_drive_local_path2}}' } - -# This ensures we test out the split token/become behaviour -- name: ensure builtin Administrator has a split token - win_regedit: - path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System - name: FilterAdministratorToken - data: 1 - type: dword - register: admin_uac - -- name: reboot to apply Admin approval mode setting - win_reboot: - when: admin_uac is changed - -- block: - # tests - - include_tasks: tests.yml - - # test cleanup - always: - - name: remove stored credential - win_credential: - name: '{{ ansible_hostname }}' - type: domain_password - state: absent - vars: - ansible_become: yes - ansible_become_method: runas - ansible_become_user: '{{ ansible_user }}' - ansible_become_pass: '{{ ansible_password }}' - - - name: ensure mapped drive is deleted at the end of the test - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - state: absent - - - name: ensure shares are removed - win_shell: $share = Get-WmiObject -Class Win32_Share | Where-Object { $_.Name -eq '{{item}}' }; if ($share) { $share.Delete() } - with_items: - - '{{test_win_mapped_drive_path}}' - - '{{test_win_mapped_drive_path2}}' - - - name: ensure temp folders are deleted - win_file: - path: '{{item}}' - state: absent - with_items: - - '{{test_win_mapped_drive_local_path}}' - - '{{test_win_mapped_drive_local_path2}}' - - - name: ensure temp mapped driver user is deleted - win_user: - name: '{{test_win_mapped_drive_temp_user}}' - state: absent - - - name: disable Admin approval mode if changed in test - win_regedit: - path: HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System - name: FilterAdministratorToken - data: 0 - type: dword - when: admin_uac is changed - - - name: reboot to apply Admin approval mode setting - win_reboot: - when: admin_uac is changed diff --git a/test/integration/targets/win_mapped_drive/tasks/tests.yml b/test/integration/targets/win_mapped_drive/tasks/tests.yml deleted file mode 100644 index c11b534869..0000000000 --- a/test/integration/targets/win_mapped_drive/tasks/tests.yml +++ /dev/null @@ -1,344 +0,0 @@ ---- -- name: fail with invalid path - win_mapped_drive: - letter: invalid - state: absent - register: fail_invalid_letter - failed_when: "fail_invalid_letter.msg != 'letter must be a single letter from A-Z, was: invalid'" - -- name: fail without specify path when creating drive - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - state: present - register: fail_path_missing - failed_when: "fail_path_missing.msg != 'state is present but all of the following are missing: path'" - -- name: fail when specifying letter with existing physical path - win_mapped_drive: - letter: c - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - register: fail_local_letter - failed_when: fail_local_letter.msg != 'failed to create mapped drive c, this letter is in use and is pointing to a non UNC path' - -- name: create mapped drive check - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - register: create_drive_check - check_mode: yes - -- name: get actual of create mapped drive check - win_command: 'net use {{test_win_mapped_drive_letter}}:' # Get-PSDrive/Get-WmiObject/Get-CimInstance doesn't work over WinRM - register: create_drive_actual_check - failed_when: False - -- name: assert create mapped drive check - assert: - that: - - create_drive_check is changed - - create_drive_actual_check.rc == 2 # should fail with this error code when it isn't found - -- name: create mapped drive - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - register: create_drive - -- name: get actual of create mapped drive - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: create_drive_actual - -- name: assert create mapped drive - assert: - that: - - create_drive is changed - - create_drive_actual.rc == 0 - - create_drive_actual.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path}}" - -- name: create mapped drive again - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - register: create_drive_again - -- name: assert create mapped drive again - assert: - that: - - create_drive_again is not changed - -- name: change mapped drive target check - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path2}} - state: present - register: change_drive_target_check - check_mode: yes - -- name: get actual of change mapped drive target check - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: change_drive_target_actual_check - -- name: assert change mapped drive target check - assert: - that: - - change_drive_target_check is changed - - change_drive_target_actual_check.rc == 0 - - change_drive_target_actual_check.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path}}" - -- name: change mapped drive target - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path2}} - state: present - register: change_drive_target - -- name: get actual of change mapped drive target - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: change_drive_target_actual - -- name: assert change mapped drive target - assert: - that: - - change_drive_target is changed - - change_drive_target_actual.rc == 0 - - change_drive_target_actual.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path2}}" - -- name: fail to delete mapped drive if target doesn't match - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: absent - register: fail_delete_incorrect_target - failed_when: fail_delete_incorrect_target.msg != 'did not delete mapped drive ' + test_win_mapped_drive_letter + ', the target path is pointing to a different location at \\\\' + ansible_hostname + '\\' + test_win_mapped_drive_path2 - -- name: delete mapped drive check - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path2}} - state: absent - register: delete_drive_check - check_mode: yes - -- name: get actual of delete mapped drive check - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: delete_drive_actual_check - -- name: assert delete mapped drive check - assert: - that: - - delete_drive_check is changed - - delete_drive_actual_check.rc == 0 - - delete_drive_actual_check.stdout_lines[1] == "Remote name \\\\{{ansible_hostname}}\\{{test_win_mapped_drive_path2}}" - -- name: delete mapped drive - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path2}} - state: absent - register: delete_drive - -- name: get actual of delete mapped drive - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: delete_drive_actual - failed_when: False - -- name: assert delete mapped drive - assert: - that: - - delete_drive is changed - - delete_drive_actual.rc == 2 - -- name: delete mapped drive again - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path2}} - state: absent - register: delete_drive_again - -- name: assert delete mapped drive again - assert: - that: - - delete_drive_again is not changed - -# not much we can do to test out the credentials except that it sets it, winrm -# makes it hard to actually test out we can still access the mapped drive -- name: map drive with current credentials check - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - username: '{{ansible_hostname}}\{{test_win_mapped_drive_temp_user}}' - password: '{{test_win_mapped_drive_temp_password}}' - register: map_with_credentials_check - check_mode: yes - -- name: get actual of map drive with current credentials check - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: map_with_credentials_actual_check - failed_when: False - -- name: assert map drive with current credentials check - assert: - that: - - map_with_credentials_check is changed - - map_with_credentials_actual_check.rc == 2 - -- name: map drive with current credentials - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - username: '{{ansible_hostname}}\{{test_win_mapped_drive_temp_user}}' - password: '{{test_win_mapped_drive_temp_password}}' - register: map_with_credentials - -- name: get actual of map drive with current credentials - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: map_with_credentials_actual - -- name: get username of mapped network drive with credentials - win_reg_stat: - path: HKCU:\Network\{{test_win_mapped_drive_letter}} - name: UserName - register: map_with_credential_actual_username - -- name: assert map drive with current credentials - assert: - that: - - map_with_credentials is changed - - map_with_credentials_actual.rc == 0 - - map_with_credential_actual_username.value == '' # we explicitly remove the username part in the module - -- name: map drive with current credentials again - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - username: '{{ansible_hostname}}\{{test_win_mapped_drive_temp_user}}' - password: '{{test_win_mapped_drive_temp_password}}' - register: map_with_credentials_again - -- name: assert map drive with current credentials again - assert: - that: - - not map_with_credentials_again is changed - -- name: delete mapped drive without path check - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - state: absent - register: delete_without_path_check - check_mode: yes - -- name: get actual delete mapped drive without path check - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: delete_without_path_actual_check - -- name: assert delete mapped drive without path check - assert: - that: - - delete_without_path_check is changed - - delete_without_path_actual_check.rc == 0 - -- name: delete mapped drive without path - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - state: absent - register: delete_without_path - -- name: get actual delete mapped drive without path - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: delete_without_path_actual - failed_when: False - -- name: assert delete mapped drive without path check - assert: - that: - - delete_without_path is changed - - delete_without_path_actual.rc == 2 - -- name: delete mapped drive without path again - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - state: absent - register: delete_without_path_again - -- name: assert delete mapped drive without path check again - assert: - that: - - delete_without_path_again is not changed - -- name: store credential for test network account - win_credential: - name: '{{ ansible_hostname }}' - type: domain_password - username: '{{ test_win_mapped_drive_temp_user }}' - secret: '{{ test_win_mapped_drive_temp_password }}' - state: present - vars: &become_vars - ansible_become: yes - ansible_become_method: runas - ansible_become_user: '{{ ansible_user }}' - ansible_become_pass: '{{ ansible_password }}' - -- name: map drive with stored cred (check mode) - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - check_mode: yes - vars: *become_vars - register: map_with_stored_cred_check - -- name: get actual of map drive with stored cred (check mode) - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: map_with_stored_cred_actual_check - failed_when: False - -- name: assert map drive with stored cred (check mode) - assert: - that: - - map_with_stored_cred_check is changed - - map_with_stored_cred_actual_check.rc == 2 - -- name: map drive with stored cred - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - vars: *become_vars - register: map_with_stored_cred - -- name: get actual of map drive with stored cred - win_command: 'net use {{test_win_mapped_drive_letter}}:' - register: map_with_stored_cred_actual - -- name: get username of mapped network drive with stored cred - win_reg_stat: - path: HKCU:\Network\{{test_win_mapped_drive_letter}} - name: UserName - register: map_with_stored_cred_actual_username - -- name: assert map drive with stored cred - assert: - that: - - map_with_stored_cred is changed - - map_with_stored_cred_actual.rc == 0 - - map_with_stored_cred_actual_username.value == '' - -- name: map drive with stored cred again - win_mapped_drive: - letter: '{{test_win_mapped_drive_letter}}' - path: \\{{ansible_hostname}}\{{test_win_mapped_drive_path}} - state: present - vars: *become_vars - register: map_with_stored_cred_again - -- name: assert map drive with stored cred again - assert: - that: - - not map_with_stored_cred_again is changed diff --git a/test/integration/targets/win_msg/aliases b/test/integration/targets/win_msg/aliases deleted file mode 100644 index 98b74ac987..0000000000 --- a/test/integration/targets/win_msg/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group2 -unstable diff --git a/test/integration/targets/win_msg/tasks/main.yml b/test/integration/targets/win_msg/tasks/main.yml deleted file mode 100644 index 17051239fa..0000000000 --- a/test/integration/targets/win_msg/tasks/main.yml +++ /dev/null @@ -1,33 +0,0 @@ -- name: Warn user - win_msg: - display_seconds: 10 - msg: Keep calm and carry on. - register: msg_result - -- name: Test msg_result - assert: - that: - - msg_result is not failed - - msg_result is changed - - msg_result.runtime_seconds < 10 - -- name: Warn user and wait for it - win_msg: - display_seconds: 5 - msg: Keep calm and carry on. - #to: '{{ ansible_user }}' - wait: yes - register: msg_wait_result - -- name: Test msg_wait_result - assert: - that: - - msg_wait_result is not failed - - msg_wait_result is changed - - msg_wait_result.runtime_seconds > 5 - -- name: fail to send a message > 255 characters - win_msg: - msg: "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456" - register: fail_too_long - failed_when: "fail_too_long.msg != 'msg length must be less than 256 characters, current length: 256'" diff --git a/test/integration/targets/win_netbios/aliases b/test/integration/targets/win_netbios/aliases deleted file mode 100644 index 4c08975b17..0000000000 --- a/test/integration/targets/win_netbios/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group6 diff --git a/test/integration/targets/win_netbios/meta/main.yml b/test/integration/targets/win_netbios/meta/main.yml deleted file mode 100644 index e7f499ee34..0000000000 --- a/test/integration/targets/win_netbios/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- setup_win_device
\ No newline at end of file diff --git a/test/integration/targets/win_netbios/tasks/main.yml b/test/integration/targets/win_netbios/tasks/main.yml deleted file mode 100644 index 2f96287bb0..0000000000 --- a/test/integration/targets/win_netbios/tasks/main.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Test code for win_netbios module -# Copyright: (c) 2019, Thomas Moore <hi@tmmr.uk> - -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# 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 <http://www.gnu.org/licenses/>. - -- name: ensure netbios is set to default to start with - win_netbios: - state: default - -- block: - - name: run tests - include_tasks: tests.yml - - always: - - name: set netbios back to default after tests - win_netbios: - state: default
\ No newline at end of file diff --git a/test/integration/targets/win_netbios/tasks/tests.yml b/test/integration/targets/win_netbios/tasks/tests.yml deleted file mode 100644 index 961b91dc04..0000000000 --- a/test/integration/targets/win_netbios/tasks/tests.yml +++ /dev/null @@ -1,159 +0,0 @@ -# Test code for win_netbios module -# Copyright: (c) 2019, Thomas Moore <hi@tmmr.uk> - -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) -# -# 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 <http://www.gnu.org/licenses/>. - -- set_fact: - get_netbios_script: | - $adapter = Get-CimInstance -ClassName Win32_NetworkAdapter -Filter "NetConnectionID='{{ network_adapter_name }}'" - $config = Get-CimInstance -ClassName Win32_NetworkAdapterConfiguration -Filter "Index=$($adapter.DeviceID)" - $config.TcpipNetbiosOptions - -- name: disable netbios single adapter (check mode) - win_netbios: - adapter_names: '{{ network_adapter_name }}' - state: disabled - register: set_single_check - check_mode: yes - -- name: get result of disable a single adapter test (check mode) - win_shell: '{{ get_netbios_script }}' - changed_when: no - register: set_single_actual_check - -- name: assert disable a single adapter (check mode) - assert: - that: - - set_single_check is changed - - set_single_actual_check.stdout_lines == ["0"] - -- name: disable netbios single adapter - win_netbios: - adapter_names: '{{ network_adapter_name }}' - state: disabled - register: set_single - -- name: get result of disable a single adapter test - win_shell: '{{ get_netbios_script }}' - changed_when: no - register: set_single_actual - -- name: assert disable a single adapter - assert: - that: - - set_single_check is changed - - set_single_actual.stdout_lines == ["2"] - -- name: fail with invalid network adapter name - win_netbios: - state: disabled - adapter_names: - - FakeAdapterName - register: invalid_adapter - failed_when: invalid_adapter.msg != "Not all of the target adapter names could be found on the system. No configuration changes have been made. FakeAdapterName" - -- name: disable netbios all adapters (check mode) - win_netbios: - state: disabled - check_mode: yes - register: disable_check - -- name: assert disable netbios (check mode) - assert: - that: - - disable_check.changed - -- name: disable netbios all adapters - win_netbios: - state: disabled - register: netbios_disable - -- name: assert netbios disabled - assert: - that: - - netbios_disable.changed - -- name: test disable idempotence - win_netbios: - state: disabled - register: netbios_disable - -- name: test disable idempotence - assert: - that: - - not netbios_disable.changed - -- name: enable netbios all adapters (check mode) - win_netbios: - state: enabled - check_mode: yes - register: enable_check - -- name: assert enable netbios all adapters (check mode) - assert: - that: - - enable_check.changed - -- name: enable netbios all adapters - win_netbios: - state: enabled - register: netbios_enable - -- name: assert netbios enabled - assert: - that: - - netbios_enable.changed - -- name: test enable idempotence - win_netbios: - state: enabled - register: netbios_enable - -- name: assert enable idempotence - assert: - that: - - not netbios_enable.changed - -- name: default netbios all adapters (check mode) - win_netbios: - state: default - check_mode: yes - register: default_check - -- name: assert default netbios (check mode) - assert: - that: - - default_check.changed - -- name: default netbios all adapters - win_netbios: - state: default - register: default_enable - -- name: assert netbios default all adapters - assert: - that: - - default_enable.changed - -- name: test default idempotence - win_netbios: - state: default - register: netbios_default - -- name: assert default idempotence - assert: - that: - - not netbios_default.changed
\ No newline at end of file diff --git a/test/integration/targets/win_nssm/aliases b/test/integration/targets/win_nssm/aliases deleted file mode 100644 index 51c5d6aba1..0000000000 --- a/test/integration/targets/win_nssm/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group4 -skip/windows/2016 # Host takes a while to run and module isn't OS dependent diff --git a/test/integration/targets/win_nssm/defaults/main.yml b/test/integration/targets/win_nssm/defaults/main.yml deleted file mode 100644 index 6ebafb24a1..0000000000 --- a/test/integration/targets/win_nssm/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -test_service_name: ansible_nssm_test -test_win_nssm_path: '{{win_output_dir}}\win_nssm' -test_win_nssm_username: testnssmuser -test_win_nssm_password: Password123!
\ No newline at end of file diff --git a/test/integration/targets/win_nssm/tasks/main.yml b/test/integration/targets/win_nssm/tasks/main.yml deleted file mode 100644 index 49368cf1a4..0000000000 --- a/test/integration/targets/win_nssm/tasks/main.yml +++ /dev/null @@ -1,44 +0,0 @@ ---- -- name: install NSSM - win_chocolatey: - name: NSSM - state: present - -- name: ensure testing folder exists - win_file: - path: '{{test_win_nssm_path}}' - state: directory - -- name: create test user for service execution - win_user: - name: '{{test_win_nssm_username}}' - password: '{{test_win_nssm_password}}' - state: present - groups: - - Users - -# Run actual tests -- block: - - include_tasks: tests.yml - - always: - - name: ensure test service is absent - win_service: - name: '{{ test_service_name }}' - state: absent - - - name: remove test user - win_user: - name: '{{test_win_nssm_username}}' - state: absent - - - name: cleanup test folder - win_file: - path: '{{test_win_nssm_path}}' - state: absent - - - name: uninstall NSSM - win_chocolatey: - name: NSSM - state: absent - failed_when: false diff --git a/test/integration/targets/win_nssm/tasks/tests.yml b/test/integration/targets/win_nssm/tasks/tests.yml deleted file mode 100644 index d5d9d389ca..0000000000 --- a/test/integration/targets/win_nssm/tasks/tests.yml +++ /dev/null @@ -1,406 +0,0 @@ ---- -- name: get register cmd that will get service info - set_fact: - test_service_cmd: | - $res = @{} - $srvobj = Get-WmiObject Win32_Service -Filter "Name=""$service""" | Select Name,DisplayName,Description,PathName,StartMode,StartName,State - if ($srvobj) { - $srvobj | Get-Member -MemberType *Property | % { $res.($_.name) = $srvobj.($_.name) } - $res.Exists = $true - $res.Dependencies = @(Get-WmiObject -Query "Associators of {Win32_Service.Name=""$service""} Where AssocClass=Win32_DependentService" | select -ExpandProperty Name) - $res.Parameters = @{} - $srvkey = "HKLM:\SYSTEM\CurrentControlSet\Services\$service\Parameters" - Get-Item "$srvkey" | Select-Object -ExpandProperty property | % { $res.Parameters.$_ = (Get-ItemProperty -Path "$srvkey" -Name $_).$_} - } else { - $res.Exists = $false - } - ConvertTo-Json -InputObject $res -Compress - -- name: install service (check mode) - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - state: present - register: install_service_check - check_mode: yes - -- name: get result of install service (check mode) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: install_service_check_actual - -- name: assert results of install service (check mode) - assert: - that: - - install_service_check.changed == true - - (install_service_check_actual.stdout|from_json).Exists == false - -- name: install service - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - state: present - register: install_service - -- name: get result of install service - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: install_service_actual - -- name: assert results of install service - assert: - that: - - install_service.changed == true - - (install_service_actual.stdout|from_json).Exists == true - - (install_service_actual.stdout|from_json).State == 'Stopped' - - (install_service_actual.stdout|from_json).StartMode == 'Auto' - - (install_service_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - - (install_service_actual.stdout|from_json).Parameters.AppDirectory == "C:\Windows\System32" - -- name: test install service (idempotent) - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - state: present - register: install_service_again - -- name: get result of install service (idempotent) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: install_service_again_actual - -- name: assert results of install service (idempotent) - assert: - that: - - install_service_again.changed == false - - (install_service_again_actual.stdout|from_json).Exists == true - - (install_service_again_actual.stdout|from_json).State == 'Stopped' - - (install_service_again_actual.stdout|from_json).StartMode == 'Auto' - - (install_service_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - - (install_service_again_actual.stdout|from_json).Parameters.AppDirectory == "C:\Windows\System32" - -- name: install and start service - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - state: started - register: install_start_service - -- name: get result of install and start service - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: install_start_service_actual - -- name: assert results of install and start service - assert: - that: - - install_start_service.changed == true - - (install_start_service_actual.stdout|from_json).Exists == true - - (install_start_service_actual.stdout|from_json).State == 'Running' - - (install_start_service_actual.stdout|from_json).StartMode == 'Auto' - - (install_start_service_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - - (install_start_service_actual.stdout|from_json).Parameters.AppDirectory == "C:\Windows\System32" - -- name: install and start service with more parameters (check mode) - win_nssm: - name: '{{ test_service_name }}' - display_name: Ansible testing - description: win_nssm test service - application: C:\Windows\System32\cmd.exe - start_mode: manual - working_directory: '{{ test_win_nssm_path }}' - dependencies: 'tcpip,dnscache' - user: '{{ test_win_nssm_username }}' - password: '{{ test_win_nssm_password }}' - stdout_file: '{{ test_win_nssm_path }}\log.txt' - stderr_file: '{{ test_win_nssm_path }}\error.txt' - state: started - register: install_service_complex_check - check_mode: yes - -- name: get result of install and start service with more parameters (check mode) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: install_service_complex_check_actual - -- name: assert results of install and start service with more parameters (check mode) - assert: - that: - - install_service_complex_check.changed == true - - (install_service_complex_check_actual.stdout|from_json).Exists == true - - (install_service_complex_check_actual.stdout|from_json).DisplayName == '{{ test_service_name }}' - - (install_service_complex_check_actual.stdout|from_json).Description is none - - (install_service_complex_check_actual.stdout|from_json).StartMode != 'Manual' - - (install_service_complex_check_actual.stdout|from_json).StartName != '.\\' + test_win_nssm_username - - (install_service_complex_check_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - - (install_service_complex_check_actual.stdout|from_json).Parameters.AppDirectory == "C:\Windows\System32" - - '"AppStdout" not in (install_service_complex_check_actual.stdout|from_json).Parameters' - - '"AppStderr" not in (install_service_complex_check_actual.stdout|from_json).Parameters' - - (install_service_complex_check_actual.stdout|from_json).Dependencies|length == 0 - -- name: install and start service with more parameters - win_nssm: - name: '{{ test_service_name }}' - display_name: Ansible testing - description: win_nssm test service - application: C:\Windows\System32\cmd.exe - start_mode: manual - working_directory: '{{ test_win_nssm_path }}' - dependencies: 'tcpip,dnscache' - user: '{{ test_win_nssm_username }}' - password: '{{ test_win_nssm_password }}' - stdout_file: '{{ test_win_nssm_path }}\log.txt' - stderr_file: '{{ test_win_nssm_path }}\error.txt' - state: started - register: install_service_complex - -- name: get result of install and start service with more parameters - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: install_service_complex_actual - -- name: assert results of install and start service with more parameters - assert: - that: - - install_service_complex.changed == true - - (install_service_complex_actual.stdout|from_json).Exists == true - - (install_service_complex_actual.stdout|from_json).DisplayName == 'Ansible testing' - - (install_service_complex_actual.stdout|from_json).Description == 'win_nssm test service' - - (install_service_complex_actual.stdout|from_json).State == 'Running' - - (install_service_complex_actual.stdout|from_json).StartMode == 'Manual' - - (install_service_complex_actual.stdout|from_json).StartName == '.\\' + test_win_nssm_username - - (install_service_complex_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - - (install_service_complex_actual.stdout|from_json).Parameters.AppDirectory == test_win_nssm_path - - (install_service_complex_actual.stdout|from_json).Parameters.AppStdout == test_win_nssm_path + '\\log.txt' - - (install_service_complex_actual.stdout|from_json).Parameters.AppStderr == test_win_nssm_path + '\\error.txt' - - (install_service_complex_actual.stdout|from_json).Dependencies|length == 2 - - '"Tcpip" in (install_service_complex_actual.stdout|from_json).Dependencies' - - '"Dnscache" in (install_service_complex_actual.stdout|from_json).Dependencies' - -- name: install and start service with more parameters (idempotent) - win_nssm: - name: '{{ test_service_name }}' - display_name: Ansible testing - description: win_nssm test service - application: C:\Windows\System32\cmd.exe - start_mode: manual - working_directory: '{{ test_win_nssm_path }}' - # Dependencies order should not trigger a change - dependencies: 'dnscache,tcpip' - user: '{{ test_win_nssm_username }}' - password: '{{ test_win_nssm_password }}' - stdout_file: '{{ test_win_nssm_path }}\log.txt' - stderr_file: '{{ test_win_nssm_path }}\error.txt' - state: started - register: install_service_complex_again - -- name: get result of install and start service with more parameters (idempotent) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: install_service_complex_again_actual - -- name: assert results of install and start service with more parameters (idempotent) - assert: - that: - - install_service_complex_again.changed == false - - (install_service_complex_again_actual.stdout|from_json).Exists == true - - (install_service_complex_again_actual.stdout|from_json).DisplayName == 'Ansible testing' - - (install_service_complex_again_actual.stdout|from_json).Description == 'win_nssm test service' - - (install_service_complex_again_actual.stdout|from_json).State == 'Running' - - (install_service_complex_again_actual.stdout|from_json).StartMode == 'Manual' - - (install_service_complex_again_actual.stdout|from_json).StartName == '.\\' + test_win_nssm_username - - (install_service_complex_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - - (install_service_complex_again_actual.stdout|from_json).Parameters.AppDirectory == test_win_nssm_path - - (install_service_complex_again_actual.stdout|from_json).Parameters.AppStdout == test_win_nssm_path + '\\log.txt' - - (install_service_complex_again_actual.stdout|from_json).Parameters.AppStderr == test_win_nssm_path + '\\error.txt' - - (install_service_complex_again_actual.stdout|from_json).Dependencies|length == 2 - - '"Tcpip" in (install_service_complex_again_actual.stdout|from_json).Dependencies' - - '"Dnscache" in (install_service_complex_again_actual.stdout|from_json).Dependencies' - -- name: install service with string form parameters - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - arguments: '-v -Dtest.str=value "C:\with space\\"' - state: present - register: str_params - -- name: get result of install service with string form parameters - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: str_params_actual - -- name: assert results of install service with string form parameters - assert: - that: - - str_params.changed == true - - (str_params_actual.stdout|from_json).Exists == true - - (str_params_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - # Expected value: -v -Dtest.str=value "C:\with space\\" (backslashes doubled for jinja) - - (str_params_actual.stdout|from_json).Parameters.AppParameters == '-v -Dtest.str=value "C:\\with space\\\\"' - -- name: install service with string form parameters (idempotent) - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - arguments: '-v -Dtest.str=value "C:\with space\\"' - state: present - register: str_params_again - -- name: get result of install service with string form parameters (idempotent) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: str_params_again_actual - -- name: assert results of install service with string form parameters (idempotent) - assert: - that: - - str_params_again.changed == false - - (str_params_again_actual.stdout|from_json).Exists == true - - (str_params_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - # Expected value: -v -Dtest.str=value "C:\with space\\" (backslashes doubled for jinja) - - (str_params_again_actual.stdout|from_json).Parameters.AppParameters == '-v -Dtest.str=value "C:\\with space\\\\"' - -# deprecated in 2.12 -- name: install service with dict-as-string parameters - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - app_parameters: foo=true; -file.out=output.bat; -path=C:\with space\; -str=test"quotes; _=bar - register: mixed_params - -# deprecated in 2.12 -- name: get result of install service with dict-as-string parameters - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: mixed_params_actual - -# deprecated in 2.12 -- name: assert results of install service with dict-as-string parameters - assert: - that: - - mixed_params.changed == true - - (mixed_params_actual.stdout|from_json).Exists == true - - (mixed_params_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - # Expected value: bar -file.out output.bat -str "test\"quotes" foo true -path "C:\with space\\" (backslashes doubled for jinja) - - (mixed_params_actual.stdout|from_json).Parameters.AppParameters == 'bar -file.out output.bat -str "test\\"quotes" foo true -path "C:\\with space\\\\"' - -# deprecated in 2.12 -- name: install service with dict-as-string parameters (idempotent) - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - app_parameters: foo=true; -file.out=output.bat; -path=C:\with space\; -str=test"quotes; _=bar - register: mixed_params_again - -# deprecated in 2.12 -- name: get result of install service with dict-as-string parameters (idempotent) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: mixed_params_again_actual - -# deprecated in 2.12 -- name: assert results of install service with dict-as-string parameters (idempotent) - assert: - that: - - mixed_params_again.changed == false - - (mixed_params_again_actual.stdout|from_json).Exists == true - - (mixed_params_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - # Expected value: bar -file.out output.bat -str "test\"quotes" foo true -path "C:\with space\\" (backslashes doubled for jinja) - - (mixed_params_again_actual.stdout|from_json).Parameters.AppParameters == 'bar -file.out output.bat -str "test\\"quotes" foo true -path "C:\\with space\\\\"' - -- name: install service with list of parameters - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - arguments: - - -foo=bar - - -day - # Test non-string value - - 14 - # Test if dot is not interpreted as separator (see #44079) - - -file.out - # Test if spaces are escaped - - C:\with space\output.bat - - -str - # Test if quotes and backslashes are escaped - - test"quotes\ - register: list_params - -- name: get result of install service with list of parameters - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: list_params_actual - -- name: assert results of install service with list of parameters - assert: - that: - - list_params.changed == true - - (list_params_actual.stdout|from_json).Exists == true - - (list_params_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - # Expected value: -foo=bar -day 14 -file.out "C:\with space\output.bat" -str "test\"quotes\\" (backslashes doubled for jinja) - - (list_params_actual.stdout|from_json).Parameters.AppParameters == '-foo=bar -day 14 -file.out "C:\\with space\\output.bat" -str "test\\"quotes\\\\"' - -- name: install service with list of parameters (idempotent) - win_nssm: - name: '{{ test_service_name }}' - application: C:\Windows\System32\cmd.exe - arguments: - - -foo=bar - - -day - - 14 - - -file.out - - C:\with space\output.bat - - -str - - test"quotes\ - register: list_params_again - -- name: get result of install service with list of parameters (idempotent) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: list_params_again_actual - -- name: assert results of install service with list of parameters (idempotent) - assert: - that: - - list_params_again.changed == false - - (list_params_again_actual.stdout|from_json).Exists == true - - (list_params_again_actual.stdout|from_json).Parameters.Application == "C:\Windows\System32\cmd.exe" - # Expected value: -foo=bar -day 14 -file.out "C:\with space\output.bat" -str "test\"quotes\\" (backslashes doubled for jinja) - - (list_params_again_actual.stdout|from_json).Parameters.AppParameters == '-foo=bar -day 14 -file.out "C:\\with space\\output.bat" -str "test\\"quotes\\\\"' - -- name: remove service (check mode) - win_nssm: - name: '{{ test_service_name }}' - state: absent - register: remove_service_check - check_mode: yes - -- name: get result of remove service (check mode) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: remove_service_check_actual - -- name: assert results of remove service (check mode) - assert: - that: - - remove_service_check.changed == true - - (remove_service_check_actual.stdout|from_json).Exists == true - -- name: remove service - win_nssm: - name: '{{ test_service_name }}' - state: absent - register: remove_service - -- name: get result of remove service - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: remove_service_actual - -- name: assert results of remove service - assert: - that: - - remove_service.changed == true - - (remove_service_actual.stdout|from_json).Exists == false - -- name: remove service (idempotent) - win_nssm: - name: '{{ test_service_name }}' - state: absent - register: remove_service_again - -- name: get result of remove service (idempotent) - win_shell: '$service = ''{{ test_service_name }}''; {{ test_service_cmd }}' - register: remove_service_again_actual - -- name: assert results of remove service (idempotent) - assert: - that: - - remove_service_again.changed == false - - (remove_service_again_actual.stdout|from_json).Exists == false
\ No newline at end of file diff --git a/test/integration/targets/win_pagefile/aliases b/test/integration/targets/win_pagefile/aliases deleted file mode 100644 index a4da730eaa..0000000000 --- a/test/integration/targets/win_pagefile/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group3 -unstable diff --git a/test/integration/targets/win_pagefile/tasks/main.yml b/test/integration/targets/win_pagefile/tasks/main.yml deleted file mode 100644 index 81da89d356..0000000000 --- a/test/integration/targets/win_pagefile/tasks/main.yml +++ /dev/null @@ -1,235 +0,0 @@ ---- -# Get current pagefiles status -- name: Get original pagefile settings - win_pagefile: - state: query - register: original_pagefile_settings - -# Test 1: Set c pagefile with inital and maximum size -- name: Set C pagefile as 1024-2048MB - win_pagefile: - remove_all: yes - drive: C - initial_size: 1024 - maximum_size: 2048 - override: yes - state: present - register: c_pagefile - -- name: Test set c pagefile - assert: - that: - - c_pagefile.changed == true - -- name: Query all pagefiles - win_pagefile: - state: query - register: pagefiles_query - -- name: Set fact for pagefile expected result - set_fact: - expected: - pagefiles: - - caption: "C:\\ 'pagefile.sys'" - description: "'pagefile.sys' @ C:\\" - initial_size: 1024 - maximum_size: 2048 - name: "C:\\pagefile.sys" - -- name: Test query - c pagefile 1024-2048 - assert: - that: - - pagefiles_query.changed == false - - pagefiles_query.pagefiles == expected.pagefiles - - pagefiles_query.automatic_managed_pagefiles == false - - -# Test 2: Remove c pagefile -- name: Remove C pagefile - win_pagefile: - drive: C - state: absent - register: delete_c_pagefile - -- name: Test removal of c pagefile - assert: - that: - - delete_c_pagefile.changed == true - -- name: Query all pagefiles - win_pagefile: - state: query - register: pagefiles_query - -- name: Set fact for pagefile expected result - set_fact: - expected: - pagefiles: [] - -- name: Test query - no c pagefile - assert: - that: - - pagefiles_query.changed == false - - pagefiles_query.pagefiles == expected.pagefiles - - pagefiles_query.automatic_managed_pagefiles == false - - -# Test 3: Set automatic managed pagefile as true -- name: Set automatic managed pagefiles as true - win_pagefile: - automatic: yes - register: set_automatic_true - -- name: Test removal of c pagefile - assert: - that: - - set_automatic_true.changed == true - - set_automatic_true.automatic_managed_pagefiles == true - - -# Test 4: Set c pagefile as system managed pagefile -- name: Set c pagefile as system managed pagefile - win_pagefile: - drive: C - system_managed: yes - state: present - register: c_pagefile_system_managed - -- name: Test set c pagefile as system managed - assert: - that: - - c_pagefile_system_managed.changed == true - -- name: Query all pagefiles - win_pagefile: - state: query - register: pagefiles_query - -- name: Set fact for pagefile expected result - set_fact: - expected: - pagefiles: - - caption: "C:\\ 'pagefile.sys'" - description: "'pagefile.sys' @ C:\\" - initial_size: 0 - maximum_size: 0 - name: "C:\\pagefile.sys" - -- name: Test query - c pagefile 0-0 (system managed) - assert: - that: - - pagefiles_query.changed == false - - pagefiles_query.pagefiles == expected.pagefiles - - pagefiles_query.automatic_managed_pagefiles == false - -# Test 5: Test no override -- name: Set c pagefile 1024-1024, no override - win_pagefile: - drive: C - initial_size: 1024 - maximum_size: 1024 - override: no - state: present - register: c_pagefile_no_override - -- name: Test set c pagefile no override - assert: - that: - - c_pagefile_no_override.changed == false - -- name: Query all pagefiles - win_pagefile: - state: query - register: pagefiles_query - -- name: Test query - c pagefile unchanged - assert: - that: - - pagefiles_query.changed == false - - pagefiles_query.pagefiles == expected.pagefiles - - pagefiles_query.automatic_managed_pagefiles == false - - -# Test 6: Test override -- name: Set c pagefile 1024-1024, override - win_pagefile: - drive: C - initial_size: 1024 - maximum_size: 1024 - state: present - register: c_pagefile_override - -- name: Test set c pagefile no override - assert: - that: - - c_pagefile_override.changed == true - - # Test 7: Test idempotent -- name: Set c pagefile 1024-1024, idempotent - win_pagefile: - drive: C - initial_size: 1024 - maximum_size: 1024 - override: no - state: present - register: c_pagefile_idempotent - -- name: Test set c pagefile idempotent - assert: - that: - - c_pagefile_idempotent.changed == false - -- name: Query all pagefiles - win_pagefile: - state: query - register: pagefiles_query - -- name: Set fact for pagefile expected result - set_fact: - expected: - pagefiles: - - caption: "C:\\ 'pagefile.sys'" - description: "'pagefile.sys' @ C:\\" - initial_size: 1024 - maximum_size: 1024 - name: "C:\\pagefile.sys" - -- name: Test query - c pagefile 1024-1024 - assert: - that: - - pagefiles_query.changed == false - - pagefiles_query.pagefiles == expected.pagefiles - - pagefiles_query.automatic_managed_pagefiles == false - -# Test 7: Remove all pagefiles -- name: Remove all pagefiles - win_pagefile: - remove_all: true - register: remove_all_pagefiles - -- name: Set fact for pagefile expected result - set_fact: - expected: - pagefiles: [] - -- name: Test query - no pagefiles - assert: - that: - - remove_all_pagefiles.changed == true - - remove_all_pagefiles.pagefiles == expected.pagefiles - - pagefiles_query.automatic_managed_pagefiles == false - -# Return all pagefile settings to its original state -- name: Remove all pagefiles and return automatic to its original state - win_pagefile: - remove_all: yes - automatic: "{{ original_pagefile_settings.automatic_managed_pagefiles }}" - -- name: Return all previous pagefiles settings - win_pagefile: - drive: "{{ item.name[0] }}" - initial_size: "{{ item.initial_size }}" - maximum_size: "{{ item.maximum_size }}" - test_path: no - state: present - with_items: "{{ original_pagefile_settings.pagefiles }}" diff --git a/test/integration/targets/win_partition/aliases b/test/integration/targets/win_partition/aliases deleted file mode 100644 index 6f44e1916f..0000000000 --- a/test/integration/targets/win_partition/aliases +++ /dev/null @@ -1,3 +0,0 @@ -shippable/windows/group7 -skip/windows/2008 -skip/windows/2008-R2 diff --git a/test/integration/targets/win_partition/defaults/main.yml b/test/integration/targets/win_partition/defaults/main.yml deleted file mode 100644 index 1d7722b5ac..0000000000 --- a/test/integration/targets/win_partition/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -AnsibleVhdx: C:\win_partition_tests\AnsiblePart.vhdx diff --git a/test/integration/targets/win_partition/tasks/main.yml b/test/integration/targets/win_partition/tasks/main.yml deleted file mode 100644 index 46f804608b..0000000000 --- a/test/integration/targets/win_partition/tasks/main.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Create the temp directory - win_file: - path: C:\win_partition_tests - state: directory - -- name: Copy VHDX scripts - win_template: - src: "{{ item.src }}" - dest: C:\win_partition_tests\{{ item.dest }} - loop: - - { src: vhdx_creation_script.j2, dest: vhdx_creation_script.txt } - - { src: vhdx_deletion_script.j2, dest: vhdx_deletion_script.txt } - -- name: Create VHD - win_command: diskpart.exe /s C:\win_partition_tests\vhdx_creation_script.txt - -- name: Run tests - block: - - include: tests.yml - always: - - name: Detach disk - win_command: diskpart.exe /s C:\win_partition_tests\vhdx_deletion_script.txt - - - name: Cleanup files - win_file: - path: C:\win_partition_tests - state: absent diff --git a/test/integration/targets/win_partition/tasks/tests.yml b/test/integration/targets/win_partition/tasks/tests.yml deleted file mode 100644 index ebf4af81bc..0000000000 --- a/test/integration/targets/win_partition/tasks/tests.yml +++ /dev/null @@ -1,261 +0,0 @@ ---- -- name: Since partition is not present, disk_number is required to create a new partition. - win_partition: - drive_letter: D - register: incorrect_attempt_1 - ignore_errors: True - -- assert: - that: - - incorrect_attempt_1 is failed - - '"Missing required parameter: disk_number" in incorrect_attempt_1.msg' - -- name: Added disk_number but size is still absent - win_partition: - drive_letter: D - disk_number: 0 - register: incorrect_attempt_2 - ignore_errors: True - -- assert: - that: - - incorrect_attempt_2 is failed - - '"Missing required parameter: partition_size" in incorrect_attempt_2.msg' - -- name: Added size but the disk we specified earlier doesn't have enough space - win_partition: - drive_letter: D - disk_number: 1 - partition_size: 20 GiB - register: incorrect_attempt_3 - ignore_errors: True - -- assert: - that: - - incorrect_attempt_3 is failed - - '"Partition size is not supported by disk" in incorrect_attempt_3.msg' - -- name: Create 1 gib partition using drive_letter and default (huge) mbr type (check mode) - win_partition: - drive_letter: D - state: present - partition_size: 1 GiB - disk_number: 1 - active: True - register: create_small_part_check - check_mode: True - -- name: Create 1 gib partition using drive_letter and default (huge) mbr type - win_partition: - drive_letter: D - state: present - partition_size: 1 GiB - disk_number: 1 - active: True - register: create_small_part - -- name: Create 1 gib partition using drive_letter and default (huge) mbr type (idempotence) - win_partition: - drive_letter: D - state: present - partition_size: 1 GiB - disk_number: 1 - active: True - register: create_small_part_idempotence - -- name: "Check if partition was created successfully" - win_shell: $AnsiPart = Get-Partition -DriveLetter D; "$($AnsiPart.DriveLetter),$($AnsiPart.Size),$($AnsiPart.IsActive),$($AnsiPart.MbrType)" - register: get_small_part - -- assert: - that: - - create_small_part_check is changed - - create_small_part is changed - - create_small_part_idempotence is not changed - - get_small_part.stdout | trim == "D,1073741824,True,6" - -- name: "Change drive letter, maximize partition size and set partition to read only (check mode)" - win_partition: - drive_letter: E - state: present - partition_size: -1 - disk_number: 1 - partition_number: 1 - read_only: True - register: upgrade_small_part_check - check_mode: True - -- name: "Change drive letter, maximize partition size and set partition to read only" - win_partition: - drive_letter: E - state: present - partition_size: -1 - disk_number: 1 - partition_number: 1 - read_only: True - register: upgrade_small_part - -- name: "Change drive letter, maximize partition size and set partition to read only (idempotence)" - win_partition: - drive_letter: E - state: present - partition_size: -1 - disk_number: 1 - partition_number: 1 - read_only: True - register: upgrade_small_part_idempotence - -- win_shell: $AnsiPart = Get-Partition -DriveLetter E; "$($AnsiPart.DriveLetter),$($AnsiPart.Size),$($AnsiPart.IsReadOnly)" - register: get_max_part - -- name: Check if creation and updation were successful - assert: - that: - - upgrade_small_part_check is changed - - upgrade_small_part is changed - - upgrade_small_part_idempotence is not changed - - get_max_part.stdout | trim == "E,2096037888,True" - -- name: "Changing size of a read only partition" - win_partition: - drive_letter: E - partition_size: 1 GiB - register: modify_read_only_partition - ignore_errors: True - -- assert: - that: - - modify_read_only_partition is failed - -- name: "Delete partition (check mode)" - win_partition: - disk_number: 1 - partition_number: 1 - state: absent - register: delete_partition_check - check_mode: True - -- name: "Delete partition" - win_partition: - disk_number: 1 - partition_number: 1 - state: absent - register: delete_partition - -- name: "Delete partition (idempotence)" - win_partition: - disk_number: 1 - partition_number: 1 - state: absent - register: delete_partition_idempotence - -- name: "Confirm that the partition is absent" - win_shell: Get-Partition -DiskNumber 1 -PartitionNumber 1 - register: confirm_partition_deletion - ignore_errors: True - -- assert: - that: - - delete_partition_check is changed - - delete_partition is changed - - delete_partition_idempotence is not changed - - '"No matching MSFT_Partition objects found" in confirm_partition_deletion.stderr' - -- name: "Create new partition without drive letter and ifs mbr type (check mode)" - win_partition: - disk_number: 1 - partition_size: -1 - mbr_type: ifs - offline: True - register: recreate_partition_check - check_mode: True - -- name: "Create new partition without drive letter and ifs mbr type" - win_partition: - disk_number: 1 - partition_size: -1 - mbr_type: ifs - offline: True - register: recreate_partition - -- name: "Create new partition without drive letter and ifs mbr type (idempotence failure)" # Disk is full now; no idempotence without drive letters - win_partition: - disk_number: 1 - partition_size: -1 - mbr_type: ifs - offline: True - register: recreate_partition_idempotence_failure - ignore_errors: True - -- name: "Confirm that new partition is created with maximum size, is offline and is IFS" - win_shell: $AnsiPart = Get-Partition -DiskNumber 1 -PartitionNumber 1; "$($AnsiPart.Size),$($AnsiPart.IsOffline),$($AnsiPart.MbrType)" - register: confirm_recreate_partition - -- assert: - that: - - recreate_partition_check is changed - - recreate_partition is changed - - recreate_partition_idempotence_failure is failed - - confirm_recreate_partition.stdout | trim == "2096037888,True,7" - -- name: "Adding a drive letter to our partition should bring it back online (check mode)" - win_partition: - drive_letter: D - disk_number: 1 - partition_number: 1 - register: add_drive_letter_check - ignore_errors: True - check_mode: True - -- name: "Adding a drive letter to our partition should bring it back online" - win_partition: - drive_letter: D - disk_number: 1 - partition_number: 1 - register: add_drive_letter - ignore_errors: True - -- name: "Adding a drive letter to our partition should bring it back online (idempotence)" - win_partition: - drive_letter: D - disk_number: 1 - partition_number: 1 - register: add_drive_letter_idempotence - ignore_errors: True - -- name: "Confirm that drive is back online" - win_shell: $AnsiPart = Get-Partition -DiskNumber 1 -PartitionNumber 1; "$($AnsiPart.DriveLetter),$($AnsiPart.IsOffline)" - register: confirm_add_drive_letter - ignore_errors: True - -- assert: - that: - - add_drive_letter_check is changed - - add_drive_letter is changed - - add_drive_letter_idempotence is not changed - - confirm_add_drive_letter.stdout | trim == "D,False" - -- name: "Remove partition again (check mode)" - win_partition: - drive_letter: D - state: absent - register: delete_partition_again_check - check_mode: True - -- name: "Remove partition again" - win_partition: - drive_letter: D - state: absent - register: delete_partition_again - -- name: "Remove partition again (idempotence)" - win_partition: - drive_letter: D - state: absent - register: delete_partition_again_idempotence - -- assert: - that: - - delete_partition_again_check is changed - - delete_partition_again is changed - - delete_partition_again_idempotence is not changed diff --git a/test/integration/targets/win_partition/templates/vhdx_creation_script.j2 b/test/integration/targets/win_partition/templates/vhdx_creation_script.j2 deleted file mode 100644 index 905373be1e..0000000000 --- a/test/integration/targets/win_partition/templates/vhdx_creation_script.j2 +++ /dev/null @@ -1,7 +0,0 @@ -create vdisk file="{{ AnsibleVhdx }}" maximum=2000 type=fixed - -select vdisk file="{{ AnsibleVhdx }}" - -attach vdisk - -convert mbr diff --git a/test/integration/targets/win_partition/templates/vhdx_deletion_script.j2 b/test/integration/targets/win_partition/templates/vhdx_deletion_script.j2 deleted file mode 100644 index c2be9cd144..0000000000 --- a/test/integration/targets/win_partition/templates/vhdx_deletion_script.j2 +++ /dev/null @@ -1,3 +0,0 @@ -select vdisk file="{{ AnsibleVhdx }}" - -detach vdisk diff --git a/test/integration/targets/win_pester/aliases b/test/integration/targets/win_pester/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_pester/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_pester/defaults/main.yml b/test/integration/targets/win_pester/defaults/main.yml deleted file mode 100644 index 3507a0fda9..0000000000 --- a/test/integration/targets/win_pester/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -test_win_pester_path: C:\ansible\win_pester -test_report_file: c:\ansible\win_pester\test_report.xml diff --git a/test/integration/targets/win_pester/files/fail.ps1 b/test/integration/targets/win_pester/files/fail.ps1 deleted file mode 100644 index 4bd20a601c..0000000000 --- a/test/integration/targets/win_pester/files/fail.ps1 +++ /dev/null @@ -1,2 +0,0 @@ -# This makes sure that a file that does not end with *.test.ps1 does not run -throw "should never fail" diff --git a/test/integration/targets/win_pester/files/test01.tests.ps1 b/test/integration/targets/win_pester/files/test01.tests.ps1 deleted file mode 100644 index edba4db1f6..0000000000 --- a/test/integration/targets/win_pester/files/test01.tests.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -Describe -Name 'Test01' { - It -name 'First Test' { - {Get-Service} | Should Not Throw - } -}
\ No newline at end of file diff --git a/test/integration/targets/win_pester/files/test02.tests.ps1 b/test/integration/targets/win_pester/files/test02.tests.ps1 deleted file mode 100644 index 2ec2450a58..0000000000 --- a/test/integration/targets/win_pester/files/test02.tests.ps1 +++ /dev/null @@ -1,5 +0,0 @@ -Describe -Name 'Test02' { - It -name 'Second Test' { - {Get-Service} | Should Throw - } -}
\ No newline at end of file diff --git a/test/integration/targets/win_pester/files/test03.tests.ps1 b/test/integration/targets/win_pester/files/test03.tests.ps1 deleted file mode 100644 index 000155ccad..0000000000 --- a/test/integration/targets/win_pester/files/test03.tests.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -Describe -Name 'Test03 without tag' { - It -name 'Third Test without tag' { - {Get-Service} | Should Not Throw - } -} - -Describe -Name 'Test03 with tag' -Tag tag1 { - It -name 'Third Test with tag' { - {Get-Service} | Should Not Throw - } -}
\ No newline at end of file diff --git a/test/integration/targets/win_pester/files/test04.tests.ps1 b/test/integration/targets/win_pester/files/test04.tests.ps1 deleted file mode 100644 index 07d1bd43c5..0000000000 --- a/test/integration/targets/win_pester/files/test04.tests.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -Param( - $Service, - $Process -) - -Describe "Process should exist" { - it "Process $Process should be running" -Skip:([String]::IsNullOrEmpty($Process)) { - Get-Process -Name $Process -ErrorAction SilentlyContinue | Should Not BeNullOrEmpty - } -} - - - -Describe "Service should exist" -tag Service { - it "Service $Service should exist" -Skip:([String]::IsNullOrEmpty($Service)) { - Get-Service -Name $Service -ErrorAction SilentlyContinue | Should Not BeNullOrEmpty - } -} diff --git a/test/integration/targets/win_pester/tasks/main.yml b/test/integration/targets/win_pester/tasks/main.yml deleted file mode 100644 index ca04a1fe5a..0000000000 --- a/test/integration/targets/win_pester/tasks/main.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -- name: create test folder(s) - win_file: - path: '{{test_win_pester_path}}\{{item}}' - state: directory - with_items: - - Modules - - Tests - -- name: download Pester module from S3 bucket - win_get_url: - # this was downloaded straight off the Pester GitHub release page and uploaded to the S3 bucket - # https://github.com/pester/Pester/releases - url: 'https://ansible-ci-files.s3.amazonaws.com/test/integration/roles/test_win_pester/Pester-4.3.1.zip' - dest: '{{test_win_pester_path}}\Pester-4.3.1.zip' - -- name: unzip Pester module - win_unzip: - src: '{{test_win_pester_path}}\Pester-4.3.1.zip' - dest: '{{test_win_pester_path}}\Modules' - -- name: rename extracted zip to match module name - win_shell: Rename-Item -Path '{{test_win_pester_path}}\Modules\Pester-4.3.1' -NewName Pester - -- name: add custom Pester location to the PSModulePath - win_path: - name: PSModulePath - scope: machine - state: present - elements: - - '{{test_win_pester_path}}\Modules' - -- name: copy test files - win_copy: - src: files/ - dest: '{{test_win_pester_path}}\Tests' - -- block: - - name: run Pester tests - include_tasks: test.yml - vars: - test_path: '{{ test_win_pester_path }}\Tests' - - always: - - name: remove custom pester location on the PSModulePath - win_path: - name: PSModulePath - scope: machine - state: absent - elements: - - '{{test_win_pester_path}}\Modules' - - - name: delete test folder - win_file: - path: '{{test_win_pester_path}}' - state: absent diff --git a/test/integration/targets/win_pester/tasks/test.yml b/test/integration/targets/win_pester/tasks/test.yml deleted file mode 100644 index 6268633b27..0000000000 --- a/test/integration/targets/win_pester/tasks/test.yml +++ /dev/null @@ -1,134 +0,0 @@ ---- -- name: Run Pester test(s) specifying a fake test file - win_pester: - path: '{{test_path}}\fakefile.ps1' - register: fake_file - failed_when: '"Cannot find file or directory: ''" + test_path + "\\fakefile.ps1'' as it does not exist" not in fake_file.msg' - -- name: Run Pester test(s) specifying a fake folder - win_pester: - path: '{{test_path }}\fakedir' - register: fake_folder - failed_when: '"Cannot find file or directory: ''" + test_path + "\\fakedir'' as it does not exist" not in fake_folder.msg' - -- name: Run Pester test(s) specifying a test file and a higher pester version - win_pester: - path: '{{test_path}}\test01.tests.ps1' - minimum_version: '6.0.0' - register: invalid_version - failed_when: '"Pester version is not greater or equal to 6.0.0" not in invalid_version.msg' - -- name: Run Pester test(s) specifying a test file - win_pester: - path: '{{test_path}}\test01.tests.ps1' - register: file_result - -- name: assert Run Pester test(s) specify a test file - assert: - that: - - file_result.changed - - not file_result.failed - - file_result.output.TotalCount == 1 - -- name: Run Pester test(s) specifying a test file and with a minimum mandatory Pester version - win_pester: - path: '{{test_path}}\test01.tests.ps1' - minimum_version: 3.0.0 - register: file_result_with_version - -- name: assert Run Pester test(s) specifying a test file and a minimum mandatory Pester version - assert: - that: - - file_result_with_version.changed - - not file_result_with_version.failed - - file_result_with_version.output.TotalCount == 1 - -- name: Run Pester test(s) located in a folder. Folder path end with '\' - win_pester: - path: '{{test_path}}\' - register: dir_with_ending_slash - -- name: assert Run Pester test(s) located in a folder. Folder path end with '\' - assert: - that: - - dir_with_ending_slash.changed - - not dir_with_ending_slash.failed - - dir_with_ending_slash.output.TotalCount == 6 - -- name: Run Pester test(s) located in a folder. Folder path does not end with '\' - win_pester: - path: '{{test_path}}' - register: dir_without_ending_slash - -- name: assert Run Pester test(s) located in a folder. Folder does not end with '\' - assert: - that: - - dir_without_ending_slash.changed - - not dir_without_ending_slash.failed - - dir_without_ending_slash.output.TotalCount == 6 - -- name: Run Pester test(s) located in a folder and with a minimum mandatory Pester version - win_pester: - path: '{{test_path}}' - minimum_version: 3.0.0 - register: dir_with_version - -- name: assert Run Pester test(s) located in a folder and with a minimum mandatory Pester version - assert: - that: - - dir_with_version.changed - - not dir_with_version.failed - - dir_with_version.output.TotalCount == 6 - -- name: Run Pester test(s) specifying a test file without specifying tag - win_pester: - path: '{{test_path}}\test03.tests.ps1' - register: test_no_tag - -- name: assert Run Pester test(s) specifying a test file and all tests executed - assert: - that: - - test_no_tag.changed - - test_no_tag.output.TotalCount == 2 - -- name: Run Pester test(s) specifying a test file with tag - win_pester: - path: '{{test_path}}\test03.tests.ps1' - tags: tag1 - register: test_with_tag - -- name: Run Pester test(s) specifying a test file and only test with sepecified tag executed - assert: - that: - - test_with_tag.changed - - test_with_tag.output.TotalCount == 1 - -- name: Run Pester test(s) specifying a test file with parameters - win_pester: - path: '{{test_path}}\test04.tests.ps1' - test_parameters: - Process: lsass - Service: bits - register: test_with_parameter - -- name: Run Pester test(s) specifying a test file with parameters - assert: - that: - - test_with_parameter.changed - - test_with_parameter.output.PassedCount == 2 - - test_with_parameter.output.TotalCount == 2 - -- name: Run Pester test(s) specifying a test file by generating test result xml - win_pester: - path: '{{test_path}}\test03.tests.ps1' - output_file: '{{test_report_file}}' - -- name: Checks if the output result file exists - win_stat: - path: '{{test_report_file}}' - register: test_output_file - -- name: Checks if the output result file exists - assert: - that: - - test_output_file.stat.exists diff --git a/test/integration/targets/win_power_plan/aliases b/test/integration/targets/win_power_plan/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_power_plan/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_power_plan/tasks/main.yml b/test/integration/targets/win_power_plan/tasks/main.yml deleted file mode 100644 index 000d8b1a66..0000000000 --- a/test/integration/targets/win_power_plan/tasks/main.yml +++ /dev/null @@ -1,64 +0,0 @@ -# I dislike this but 2008 doesn't support the Win32_PowerPlan WMI provider -- name: get current plan details - win_shell: | - $plan_info = powercfg.exe /list - ($plan_info | Select-String -Pattern '\(([\w\s]*)\) \*$').Matches.Groups[1].Value - ($plan_info | Select-String -Pattern '\(([\w\s]*)\)$').Matches.Groups[1].Value - register: plan_info - -- set_fact: - original_plan: '{{ plan_info.stdout_lines[0] }}' - name: '{{ plan_info.stdout_lines[1] }}' - -- block: - #Test that plan detects change is needed, but doesn't actually apply change - - name: set power plan (check mode) - win_power_plan: - name: "{{ name }}" - register: set_plan_check - check_mode: yes - - - name: get result of set power plan (check mode) - win_shell: (powercfg.exe /list | Select-String -Pattern '\({{ name }}\)').Line - register: set_plan_check_result - changed_when: False - - # verify that the powershell check is showing the plan as still inactive on the system - - name: assert setting plan (check mode) - assert: - that: - - set_plan_check is changed - - not set_plan_check_result.stdout_lines[0].endswith('*') - - #Test that setting plan and that change is applied - - name: set power plan - win_power_plan: - name: "{{ name }}" - register: set_plan - - - name: get result of set power plan - win_shell: (powercfg.exe /list | Select-String -Pattern '\({{ name }}\)').Line - register: set_plan_result - changed_when: False - - - name: assert setting plan - assert: - that: - - set_plan is changed - - set_plan_result.stdout_lines[0].endswith('*') - - #Test that plan doesn't apply change if it is already set - - name: set power plan (idempotent) - win_power_plan: - name: "{{ name }}" - register: set_plan_idempotent - - - name: assert setting plan (idempotent) - assert: - that: - - set_plan_idempotent is not changed - - always: - - name: always change back plan to the original when done testing - win_power_plan: - name: '{{ original_plan }}' diff --git a/test/integration/targets/win_product_facts/aliases b/test/integration/targets/win_product_facts/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_product_facts/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_product_facts/tasks/main.yml b/test/integration/targets/win_product_facts/tasks/main.yml deleted file mode 100644 index b1427eeaa1..0000000000 --- a/test/integration/targets/win_product_facts/tasks/main.yml +++ /dev/null @@ -1,11 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2017, Dag Wieers (dagwieers) <dag@wieers.com> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -- win_product_facts: - -- assert: - that: - - ansible_os_product_id is defined - - ansible_os_product_key is defined diff --git a/test/integration/targets/win_psexec/aliases b/test/integration/targets/win_psexec/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_psexec/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_psexec/meta/main.yml b/test/integration/targets/win_psexec/meta/main.yml deleted file mode 100644 index 9f37e96cd9..0000000000 --- a/test/integration/targets/win_psexec/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- setup_remote_tmp_dir diff --git a/test/integration/targets/win_psexec/tasks/main.yml b/test/integration/targets/win_psexec/tasks/main.yml deleted file mode 100644 index 27783f9e62..0000000000 --- a/test/integration/targets/win_psexec/tasks/main.yml +++ /dev/null @@ -1,80 +0,0 @@ -# Would use [] but this has troubles with PATH and trying to find the executable so just resort to keeping a space -- name: record special path for tests - set_fact: - testing_dir: '{{ remote_tmp_dir }}\ansible win_psexec' - -- name: create special path testing dir - win_file: - path: '{{ testing_dir }}' - state: directory - -- name: Download PsExec - win_get_url: - url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_psexec/PsExec.exe - dest: '{{ testing_dir }}\PsExec.exe' - -- name: Get the existing PATH env var - win_shell: '$env:PATH' - register: system_path - changed_when: False - -- name: Run whoami - win_psexec: - command: whoami.exe - nobanner: true - register: whoami - environment: - PATH: '{{ testing_dir }};{{ system_path.stdout | trim }}' - -- name: Test whoami - assert: - that: - - whoami.rc == 0 - - whoami.stdout == '' - # FIXME: Standard output does not work or is truncated - #- whoami.stdout == '{{ ansible_hostname|lower }}' - -- name: Run whoami as SYSTEM - win_psexec: - command: whoami.exe - system: yes - nobanner: true - executable: '{{ testing_dir }}\PsExec.exe' - register: whoami_as_system - # Seems to be a bug with PsExec where the stdout can be empty, just retry the task to make this test a bit more stable - until: whoami_as_system.rc == 0 and whoami_as_system.stdout == 'nt authority\system' - retries: 3 - delay: 2 - -# FIXME: Behaviour is not consistent on all Windows systems -#- name: Run whoami as ELEVATED -# win_psexec: -# command: whoami.exe -# elevated: yes -# register: whoami_as_elevated -# -## Ensure we have basic facts -#- setup: -# -#- debug: -# msg: '{{ whoami_as_elevated.stdout|lower }} == {{ ansible_hostname|lower }}\{{ ansible_user_id|lower }}' -# -#- name: Test whoami -# assert: -# that: -# - whoami_as_elevated.rc == 0 -# - whoami_as_elevated.stdout|lower == '{{ ansible_hostname|lower }}\{{ ansible_user_id|lower }}' - -- name: Run command with multiple arguments - win_psexec: - command: powershell.exe -NonInteractive "exit 1" - ignore_errors: yes - register: whoami_multiple_args - environment: - PATH: '{{ testing_dir }};{{ system_path.stdout | trim }}' - -- name: Test command with multiple argumetns - assert: - that: - - whoami_multiple_args.rc == 1 - - whoami_multiple_args.psexec_command == "psexec.exe -accepteula powershell.exe -NonInteractive \"exit 1\"" diff --git a/test/integration/targets/win_psmodule/aliases b/test/integration/targets/win_psmodule/aliases deleted file mode 100644 index 4c08975b17..0000000000 --- a/test/integration/targets/win_psmodule/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group6 diff --git a/test/integration/targets/win_psmodule/files/module/template.nuspec b/test/integration/targets/win_psmodule/files/module/template.nuspec deleted file mode 100644 index 49fc53210f..0000000000 --- a/test/integration/targets/win_psmodule/files/module/template.nuspec +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> - <metadata> - <id>--- NAME ---</id> - <version>--- VERSION ---</version> - <authors>Ansible</authors> - <owners>Ansible</owners> - <requireLicenseAcceptance>false</requireLicenseAcceptance> - <description>Test for Ansible win_ps* modules</description> - <releaseNotes></releaseNotes> - <copyright>Copyright (c) 2019 Ansible, licensed under MIT.</copyright> - <tags>PSModule PSIncludes_Function PSFunction_--- FUNCTION --- PSCommand_--- FUNCTION ---</tags> - </metadata> -</package> diff --git a/test/integration/targets/win_psmodule/files/module/template.psd1 b/test/integration/targets/win_psmodule/files/module/template.psd1 deleted file mode 100644 index cd6709722b..0000000000 --- a/test/integration/targets/win_psmodule/files/module/template.psd1 +++ /dev/null @@ -1,17 +0,0 @@ -@{ - RootModule = '--- NAME ---.psm1' - ModuleVersion = '--- VERSION ---' - GUID = '--- GUID ---' - Author = 'Ansible' - Copyright = 'Copyright (c) 2019 Ansible, licensed under MIT.' - Description = "Test for Ansible win_ps* modules" - PowerShellVersion = '3.0' - FunctionsToExport = @( - "--- FUNCTION ---" - ) - PrivateData = @{ - PSData = @{ ---- PS_DATA --- - } - } -} diff --git a/test/integration/targets/win_psmodule/files/module/template.psm1 b/test/integration/targets/win_psmodule/files/module/template.psm1 deleted file mode 100644 index ac38fb5ed6..0000000000 --- a/test/integration/targets/win_psmodule/files/module/template.psm1 +++ /dev/null @@ -1,10 +0,0 @@ -Function --- FUNCTION --- { - return [PSCustomObject]@{ - Name = "--- NAME ---" - Version = "--- VERSION ---" - Repo = "--- REPO ---" - } -} - -Export-ModuleMember -Function --- FUNCTION --- - diff --git a/test/integration/targets/win_psmodule/files/openssl.conf b/test/integration/targets/win_psmodule/files/openssl.conf deleted file mode 100644 index 2b5685b432..0000000000 --- a/test/integration/targets/win_psmodule/files/openssl.conf +++ /dev/null @@ -1,9 +0,0 @@ -distinguished_name = req_distinguished_name - -[req_distinguished_name] - -[req_sign] -subjectKeyIdentifier=hash -basicConstraints = CA:FALSE -keyUsage = digitalSignature -extendedKeyUsage = codeSigning diff --git a/test/integration/targets/win_psmodule/files/setup_certs.sh b/test/integration/targets/win_psmodule/files/setup_certs.sh deleted file mode 100644 index 2585673161..0000000000 --- a/test/integration/targets/win_psmodule/files/setup_certs.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# Generate key used for CA cert -openssl genrsa -aes256 -out ca.key -passout pass:password 2048 - -# Generate CA certificate -openssl req -new -x509 -days 365 -key ca.key -out ca.pem -subj "/CN=Ansible Root" -passin pass:password - -# Generate key used for signing cert -openssl genrsa -aes256 -out sign.key -passout pass:password 2048 - -# Generate CSR for signing cert that includes CodeSiging extension -openssl req -new -key sign.key -out sign.csr -subj "/CN=Ansible Sign" -config openssl.conf -reqexts req_sign -passin pass:password - -# Generate signing certificate -openssl x509 -req -in sign.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out sign.pem -days 365 -extfile openssl.conf -extensions req_sign -passin pass:password - -# Create pfx that includes signing cert and cert with the pass 'password' -openssl pkcs12 -export -out sign.pfx -inkey sign.key -in sign.pem -passin pass:password -passout pass:password diff --git a/test/integration/targets/win_psmodule/files/setup_modules.ps1 b/test/integration/targets/win_psmodule/files/setup_modules.ps1 deleted file mode 100644 index dcd3bae443..0000000000 --- a/test/integration/targets/win_psmodule/files/setup_modules.ps1 +++ /dev/null @@ -1,81 +0,0 @@ -$ErrorActionPreference = "Stop" - -$template_path = $args[0] -$template_manifest = Join-Path -Path $template_path -ChildPath template.psd1 -$template_script = Join-Path -Path $template_path -ChildPath template.psm1 -$template_nuspec = Join-Path -Path $template_path -ChildPath template.nuspec -$nuget_exe = Join-Path -Path $template_path -ChildPath nuget.exe -$sign_cert = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList @( - (Join-Path -Path $template_path -ChildPath sign.pfx), - 'password', - # We need to use MachineKeySet so we can load the pfx without using become - # EphemeralKeySet would be better but it is only available starting with .NET 4.7.2 - [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::MachineKeySet -) - -$packages = @( - @{ name = "ansible-test1"; version = "1.0.0"; repo = "PSRepo 1"; function = "Get-AnsibleTest1" }, - @{ name = "ansible-test1"; version = "1.0.5"; repo = "PSRepo 1"; function = "Get-AnsibleTest1" }, - @{ name = "ansible-test1"; version = "1.1.0"; repo = "PSRepo 1"; function = "Get-AnsibleTest1" }, - @{ name = "ansible-test2"; version = "1.0.0"; repo = "PSRepo 1"; function = "Get-AnsibleTest2" }, - @{ name = "ansible-test2"; version = "1.0.0"; repo = "PSRepo 2"; function = "Get-AnsibleTest2" }, - @{ name = "ansible-test2"; version = "1.0.1"; repo = "PSRepo 1"; function = "Get-AnsibleTest2"; signed = $false }, - @{ name = "ansible-test2"; version = "1.1.0"; prerelease = "beta1"; repo = "PSRepo 1"; function = "Get-AnsibleTest2" }, - @{ name = "ansible-clobber"; version = "0.1.0"; repo = "PSRepo 1"; function = "Enable-PSTrace" } -) - -foreach ($package in $packages) { - $tmp_dir = Join-Path -Path $template_path -ChildPath $package.name - if (Test-Path -Path $tmp_dir) { - Remove-Item -Path $tmp_dir -Force -Recurse - } - New-Item -Path $tmp_dir -ItemType Directory > $null - - try { - if ($package.ContainsKey("prerelease")) { - $ps_data = "Prerelease = '$($package.prerelease)'" - $nuget_version = "$($package.version)-$($package.prerelease)" - } else { - $ps_data = "" - $nuget_version = $package.version - } - - $manifest = [System.IO.File]::ReadAllText($template_manifest) - $manifest = $manifest.Replace('--- NAME ---', $package.name).Replace('--- VERSION ---', $package.version) - $manifest = $manifest.Replace('--- GUID ---', [Guid]::NewGuid()).Replace('--- FUNCTION ---', $package.function) - - $manifest = $manifest.Replace('--- PS_DATA ---', $ps_data) - $manifest_path = Join-Path -Path $tmp_dir -ChildPath "$($package.name).psd1" - Set-Content -Path $manifest_path -Value $manifest - - $script = [System.IO.File]::ReadAllText($template_script) - $script = $script.Replace('--- NAME ---', $package.name).Replace('--- VERSION ---', $package.version) - $script = $script.Replace('--- REPO ---', $package.repo).Replace('--- FUNCTION ---', $package.function) - $script_path = Join-Path -Path $tmp_dir -ChildPath "$($package.name).psm1" - Set-Content -Path $script_path -Value $script - - $signed = if ($package.ContainsKey("signed")) { $package.signed } else { $true } - if ($signed) { - Set-AuthenticodeSignature -Certificate $sign_cert -LiteralPath $manifest_path > $null - Set-AuthenticodeSignature -Certificate $sign_cert -LiteralPath $script_path > $null - } - - # We should just be able to use Publish-Module but it fails when running over WinRM for older hosts and become - # does not fix this. It fails to respond to nuget.exe push errors when it canno find the .nupkg file. We will - # just manually do that ourselves. This also has the added benefit of being a lot quicker than Publish-Module - # which seems to take forever to publish the module. - $nuspec = [System.IO.File]::ReadAllText($template_nuspec) - $nuspec = $nuspec.Replace('--- NAME ---', $package.name).Replace('--- VERSION ---', $nuget_version) - $nuspec = $nuspec.Replace('--- FUNCTION ---', $package.function) - Set-Content -Path (Join-Path -Path $tmp_dir -ChildPath "$($package.name).nuspec") -Value $nuspec - - &$nuget_exe pack "$tmp_dir\$($package.name).nuspec" -outputdirectory $tmp_dir - - $repo_path = Join-Path -Path $template_path -ChildPath $package.repo - $nupkg_filename = "$($package.name).$($nuget_version).nupkg" - Copy-Item -Path (Join-Path -Path $tmp_dir -ChildPath $nupkg_filename) ` - -Destination (Join-Path -Path $repo_path -ChildPath $nupkg_filename) - } finally { - Remove-Item -Path $tmp_dir -Force -Recurse - } -} diff --git a/test/integration/targets/win_psmodule/handlers/main.yml b/test/integration/targets/win_psmodule/handlers/main.yml deleted file mode 100644 index a3fd646da5..0000000000 --- a/test/integration/targets/win_psmodule/handlers/main.yml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- name: re-add PSGallery repository - win_shell: Register-PSRepository -Default -InstallationPolicy Untrusted - -- name: remove registered repos - win_psrepository: - name: '{{ item }}' - state: absent - loop: - - PSRepo 1 - - PSRepo 2 - -- name: remove CA cert from trusted root store - win_certificate_store: - thumbprint: '{{ ca_cert_import.thumbprints[0] }}' - store_location: LocalMachine - store_name: Root - state: absent - -- name: remove signing key from trusted publisher store - win_certificate_store: - thumbprint: '{{ sign_cert_import.thumbprints[0] }}' - store_location: LocalMachine - store_name: TrustedPublisher - state: absent - -- name: remove test packages - win_psmodule: - name: '{{ item }}' - state: absent - loop: - - ansible-test1 - - ansible-test2 - - ansible-clobber
\ No newline at end of file diff --git a/test/integration/targets/win_psmodule/meta/main.yml b/test/integration/targets/win_psmodule/meta/main.yml deleted file mode 100644 index f0920878ae..0000000000 --- a/test/integration/targets/win_psmodule/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -dependencies: -- setup_remote_tmp_dir -- setup_win_psget diff --git a/test/integration/targets/win_psmodule/tasks/main.yml b/test/integration/targets/win_psmodule/tasks/main.yml deleted file mode 100644 index 2d7c184351..0000000000 --- a/test/integration/targets/win_psmodule/tasks/main.yml +++ /dev/null @@ -1,454 +0,0 @@ -# test code for the win_psmodule module when using winrm connection -# Copyright: (c) 2018, Wojciech Sciesinski <wojciech[at]sciesinski[dot]net> -# Copyright: (c) 2017, Daniele Lazzari <lazzari@mailup.com> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: setup test repos and modules - import_tasks: setup.yml - -# Remove the below task in Ansible 2.12 -- name: ensure warning is fired when adding a repo - win_psmodule: - name: ansible-test1 - repository: some repo - url: '{{ remote_tmp_dir }}' - state: present - register: dep_repo_add - ignore_errors: yes # will fail because this repo doesn't actually have this module - check_mode: yes - -- name: assert warning is fired when adding a repo - assert: - that: - - dep_repo_add is changed - - dep_repo_add.deprecations|length == 1 - - dep_repo_add.deprecations[0].msg == 'Adding a repo with this module is deprecated, the repository parameter should only be used to select a repo. Use win_psrepository to manage repos' - - dep_repo_add.deprecations[0].version == 2.12 - -- name: install package (check mode) - win_psmodule: - name: ansible-test1 - state: present - register: install_check - check_mode: yes - -- name: get result of install package (check mode) - win_shell: (Get-Module -ListAvailable -Name ansible-test1 | Measure-Object).Count - register: install_actual_check - -- name: assert install package (check mode) - assert: - that: - - install_check is changed - - install_actual_check.stdout | trim | int == 0 - -- name: install package - win_psmodule: - name: ansible-test1 - state: present - register: install - -- name: get result of install package - win_shell: Import-Module -Name ansible-test1; Get-AnsibleTest1 | ConvertTo-Json - register: install_actual - -- name: assert install package - assert: - that: - - install is changed - - install_actual.stdout | from_json == {"Name":"ansible-test1","Version":"1.1.0","Repo":"PSRepo 1"} - -- name: install package (idempotent) - win_psmodule: - name: ansible-test1 - state: present - register: install_again - -- name: assert install package (idempotent) - assert: - that: - - not install_again is changed - -- name: remove package (check mode) - win_psmodule: - name: ansible-test1 - state: absent - register: remove_check - check_mode: yes - -- name: get result of remove package (check mode) - win_shell: (Get-Module -ListAvailable -Name ansible-test1 | Measure-Object).Count - register: remove_actual_check - -- name: remove package (check mode) - assert: - that: - - remove_check is changed - - remove_actual_check.stdout | trim | int == 1 - -- name: remove package - win_psmodule: - name: ansible-test1 - state: absent - register: remove - -- name: get result of remove package - win_shell: (Get-Module -ListAvailable -Name ansible-test1 | Measure-Object).Count - register: remove_actual - -- name: assert remove package - assert: - that: - - remove is changed - - remove_actual.stdout | trim | int == 0 - -- name: remove package (idempotent) - win_psmodule: - name: ansible-test1 - state: absent - register: remove_again - -- name: assert remove package (idempotent) - assert: - that: - - not remove_again is changed - -- name: fail to install module that exists in multiple repos - win_psmodule: - name: ansible-test2 - state: present - register: fail_multiple_pkg - failed_when: 'fail_multiple_pkg.msg != "Problems installing ansible-test2 module: Unable to install, multiple modules matched ''ansible-test2''. Please specify a single -Repository."' - -- name: install module with specific repository - win_psmodule: - name: ansible-test2 - repository: PSRepo 2 - state: present - register: install_repo - -- name: get result of install module with specific repository - win_shell: Import-Module -Name ansible-test2; Get-AnsibleTest2 | ConvertTo-Json - register: install_repo_actual - -- name: assert install module with specific repository - assert: - that: - - install_repo is changed - - install_repo_actual.stdout | from_json == {"Name":"ansible-test2","Version":"1.0.0","Repo":"PSRepo 2"} - -- name: install module with specific repository (idempotent) - win_psmodule: - name: ansible-test2 - repository: PSRepo 2 - state: present - register: install_repo_again - -- name: assert install module with specific repository (idempotent) - assert: - that: - - not install_repo_again is changed - -- name: remove package that was installed from specific repository - win_psmodule: - name: ansible-test2 - state: absent - register: remove_repo_without_source - -- name: get result of remove package that was installed from specific repository - win_shell: (Get-Module -ListAvailable -Name ansible-test2 | Measure-Object).Count - register: remove_repo_without_source_actual - -- name: assert remove package that was installed from specific repository - assert: - that: - - remove_repo_without_source is changed - - remove_repo_without_source_actual.stdout | trim | int == 0 - -- name: fail to install required version that is missing - win_psmodule: - name: ansible-test1 - required_version: 0.9.0 - state: present - register: fail_missing_req - failed_when: '"Problems installing ansible-test1 module: No match was found for the specified search criteria" not in fail_missing_req.msg' - -- name: install required version - win_psmodule: - name: ansible-test1 - required_version: 1.0.0 - state: present - register: install_req_version - -- name: get result of install required version - win_shell: Import-Module -Name ansible-test1; Get-AnsibleTest1 | ConvertTo-Json - register: install_req_version_actual - -- name: assert install required version - assert: - that: - - install_req_version is changed - - install_req_version_actual.stdout | from_json == {"Name":"ansible-test1","Version":"1.0.0","Repo":"PSRepo 1"} - -- name: install required version (idempotent) - win_psmodule: - name: ansible-test1 - required_version: 1.0.0 - state: present - register: install_req_version_again - -- name: assert install required version (idempotent) - assert: - that: - - not install_req_version_again is changed - -- name: remove required version - win_psmodule: - name: ansible-test1 - required_version: 1.0.0 - state: absent - register: remove_req_version - -- name: get result of remove required version - win_shell: (Get-Module -ListAvailable -Name ansible-test1 | Measure-Object).Count - register: remove_req_version_actual - -- name: assert remove required version - assert: - that: - - remove_req_version is changed - - remove_req_version_actual.stdout | trim | int == 0 - -- name: remove required version (idempotent) - win_psmodule: - name: ansible-test1 - required_version: 1.0.0 - state: absent - register: remove_req_version_again - -- name: assert remove required version (idempotent) - assert: - that: - - not remove_req_version_again is changed - -- name: install min max version - win_psmodule: - name: ansible-test1 - minimum_version: 1.0.1 - maximum_version: 1.0.9 - state: present - register: install_min_max - -- name: get result of install min max version - win_shell: Import-Module -Name ansible-test1; Get-AnsibleTest1 | ConvertTo-Json - register: install_min_max_actual - -- name: assert install min max version - assert: - that: - - install_min_max is changed - - install_min_max_actual.stdout | from_json == {"Name":"ansible-test1","Version":"1.0.5","Repo":"PSRepo 1"} - -- name: install min max version (idempotent) - win_psmodule: - name: ansible-test1 - minimum_version: 1.0.1 - maximum_version: 1.0.9 - state: present - register: install_min_max_again - -- name: assert install min max version (idempotent) - assert: - that: - - not install_min_max_again is changed - -- name: update package to latest version - win_psmodule: - name: ansible-test1 - state: latest - register: update_module - -- name: get result of update package to latest version - win_shell: Import-Module -Name ansible-test1; Get-AnsibleTest1 | ConvertTo-Json - register: update_module_actual - -- name: assert update package to latest version - assert: - that: - - update_module is changed - - update_module_actual.stdout | from_json == {"Name":"ansible-test1","Version":"1.1.0","Repo":"PSRepo 1"} - -- name: update package to latest version (idempotent) - win_psmodule: - name: ansible-test1 - state: latest - register: update_module_again - -- name: assert update package to latest version (idempotent) - assert: - that: - - not update_module_again is changed - -- name: remove package that does not match min version - win_psmodule: - name: ansible-test1 - minimum_version: 2.0.0 - state: absent - register: remove_min_no_change - -- name: assert remove package that does not match min version - assert: - that: - - not remove_min_no_change is changed - -- name: remove package that does not match max version - win_psmodule: - name: ansible-test1 - maximum_version: 0.9.0 - state: absent - register: remove_max_no_change - -- name: assert remove package that does not match max version - assert: - that: - - not remove_max_no_change is changed - -- name: uninstall package to clear tests - win_psmodule: - name: ansible-test1 - state: absent - -- name: install package with max version - win_psmodule: - name: ansible-test2 - maximum_version: 1.0.0 - repository: PSRepo 1 - state: present - register: install_max - -- name: get result of install package with max version - win_shell: Import-Module -Name ansible-test2; Get-AnsibleTest2 | ConvertTo-Json - register: install_max_actual - -- name: assert install package with max version - assert: - that: - - install_max is changed - - install_max_actual.stdout | from_json == {"Name":"ansible-test2","Version":"1.0.0","Repo":"PSRepo 1"} - -- name: fail to install updated package without skip publisher - win_psmodule: - name: ansible-test2 - required_version: 1.0.1 # This version has been pureposefully not been signed for testing - repository: PSRepo 1 - state: present - register: fail_skip_pub - failed_when: '"The version ''1.0.1'' of the module ''ansible-test2'' being installed is not catalog signed" not in fail_skip_pub.msg' - -- name: install updated package provider with skip publisher - win_psmodule: - name: ansible-test2 - required_version: 1.0.1 - repository: PSRepo 1 - state: present - skip_publisher_check: yes - register: install_skip_pub - -- name: get result of install updated package provider with skip publisher - win_shell: Import-Module -Name ansible-test2; Get-AnsibleTest2 | ConvertTo-Json - register: install_skip_pub_actual - -- name: assert install updated package provider with skip publisher - assert: - that: - - install_skip_pub is changed - - install_skip_pub_actual.stdout | from_json == {"Name":"ansible-test2","Version":"1.0.1","Repo":"PSRepo 1"} - -- name: remove test package 2 for clean test - win_psmodule: - name: ansible-test2 - state: absent - -- name: fail to install clobbered module - win_psmodule: - name: ansible-clobber - state: present - register: fail_clobbering_time - failed_when: '"If you still want to install this module ''ansible-clobber'', use -AllowClobber parameter." not in fail_clobbering_time.msg' - -- name: install clobbered module - win_psmodule: - name: ansible-clobber - allow_clobber: yes - state: present - register: install_clobber - -- name: get result of install clobbered module - win_shell: Import-Module -Name ansible-clobber; Enable-PSTrace | ConvertTo-Json - register: install_clobber_actual - -- name: assert install clobbered module - assert: - that: - - install_clobber is changed - - install_clobber_actual.stdout | from_json == {"Name":"ansible-clobber","Version":"0.1.0","Repo":"PSRepo 1"} - -- name: remove clobbered module - win_psmodule: - name: ansible-clobber - state: absent - register: remove_clobber - -- name: get result of remove clobbered module - win_shell: (Get-Module -ListAvailable -Name ansible-clobber | Measure-Object).Count - register: remove_clobber_actual - -- name: assert remove clobbered module - assert: - that: - - remove_clobber is changed - - remove_clobber_actual.stdout | trim | int == 0 - -- name: fail to install prerelese module - win_psmodule: - name: ansible-test2 - repository: PSRepo 1 - required_version: 1.1.0-beta1 - state: present - register: fail_install_prerelease - failed_when: '"The ''-AllowPrerelease'' parameter must be specified when using the Prerelease string" not in fail_install_prerelease.msg' - -- name: install prerelease module - win_psmodule: - name: ansible-test2 - repository: PSRepo 1 - required_version: 1.1.0-beta1 - allow_prerelease: yes - state: present - register: install_prerelease - -- name: get result of install prerelease module - win_shell: Import-Module -Name ansible-test2; Get-AnsibleTest2 | ConvertTo-Json - register: install_prerelease_actual - -- name: assert install prerelease module - assert: - that: - - install_prerelease is changed - - install_prerelease_actual.stdout | from_json == {"Name":"ansible-test2","Version":"1.1.0","Repo":"PSRepo 1"} - -- name: remove prerelease module - win_psmodule: - name: ansible-test2 - state: absent - register: remove_prerelease - -- name: get result of remove prerelease module - win_shell: (Get-Module -ListAvailable -Name ansible-test2 | Measure-Object).Count - register: remove_prerelease_actual - -- name: assert remove prerelease module - assert: - that: - - remove_prerelease is changed - - remove_prerelease_actual.stdout | trim | int == 0 diff --git a/test/integration/targets/win_psmodule/tasks/setup.yml b/test/integration/targets/win_psmodule/tasks/setup.yml deleted file mode 100644 index 128c69eb1d..0000000000 --- a/test/integration/targets/win_psmodule/tasks/setup.yml +++ /dev/null @@ -1,115 +0,0 @@ -# Sets up 2 local repos that contains mock packages for testing. -# -# PSRepo 1 contains -# ansible-test1 - 1.0.0 -# ansible-test1 - 1.0.5 -# ansible-test1 - 1.1.0 -# ansible-test2 - 1.0.0 -# ansible-test2 - 1.0.1 (Not signed for skip_publisher tests) -# ansible-test2 - 1.1.0-beta1 -# ansible-clobber - 0.1.0 -# -# PSRepo 2 contains -# ansible-test2 - 1.0.0 -# -# These modules will have the following cmdlets -# ansible-test1 -# Get-AnsibleTest1 -# -# ansible-test2 -# Get-AnsibleTest2 -# -# ansible-clobber -# Enable-PSTrace (clobbers the Enable-PSTrace cmdlet) -# -# All cmdlets return -# [PSCustomObject]@{ -# Name = "the name of the module" -# Version = "the version of the module" -# Repo = "the repo where the module was sourced from" -# } ---- -- name: create test repo folders - win_file: - path: '{{ remote_tmp_dir }}\{{ item }}' - state: directory - loop: - - PSRepo 1 - - PSRepo 2 - -- name: register test repos - win_psrepository: - name: '{{ item.name }}' - source: '{{ remote_tmp_dir }}\{{ item.name }}' - installation_policy: '{{ item.policy }}' - notify: remove registered repos - loop: - - name: PSRepo 1 - policy: trusted - - name: PSRepo 2 - policy: untrusted - -- name: remove PSGallery repository - win_psrepository: - name: PSGallery - state: absent - notify: re-add PSGallery repository - -- name: create custom openssl conf - copy: - src: openssl.conf - dest: '{{ output_dir }}/openssl.conf' - delegate_to: localhost - -- name: get absolute path of output_dir for script - shell: echo {{ output_dir }} - delegate_to: localhost - register: output_dir_abs - -- name: create certificates for code signing - script: setup_certs.sh - args: - chdir: '{{ output_dir_abs.stdout }}' - delegate_to: localhost - -- name: copy the CA and sign certificates - win_copy: - src: '{{ output_dir }}/{{ item }}' - dest: '{{ remote_tmp_dir }}\' - loop: - - ca.pem - - sign.pem - - sign.pfx - -- name: import the CA key to the trusted root store - win_certificate_store: - path: '{{ remote_tmp_dir }}\ca.pem' - state: present - store_location: LocalMachine - store_name: Root - register: ca_cert_import - notify: remove CA cert from trusted root store - -- name: import the sign key to the trusted publisher store - win_certificate_store: - path: '{{ remote_tmp_dir }}\sign.pem' - state: present - store_location: LocalMachine - store_name: TrustedPublisher - register: sign_cert_import - notify: remove signing key from trusted publisher store - -- name: copy across module template files - win_copy: - src: module/ - dest: '{{ remote_tmp_dir }}' - -# Used in the script below to create the .nupkg for each test module -- name: download NuGet binary for module publishing - win_get_url: - url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/win_psmodule/nuget.exe - dest: '{{ remote_tmp_dir }}' - -- name: create test PowerShell modules - script: setup_modules.ps1 "{{ remote_tmp_dir }}" - notify: remove test packages diff --git a/test/integration/targets/win_psrepository/aliases b/test/integration/targets/win_psrepository/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_psrepository/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_psrepository/defaults/main.yml b/test/integration/targets/win_psrepository/defaults/main.yml deleted file mode 100644 index 3b39aecb3f..0000000000 --- a/test/integration/targets/win_psrepository/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -repository_name: My Get -repository_sourcelocation: https://www.myget.org/F/powershellgetdemo/api/v2 -repository_sourcelocation2: '{{ remote_tmp_dir }}' diff --git a/test/integration/targets/win_psrepository/meta/main.yml b/test/integration/targets/win_psrepository/meta/main.yml deleted file mode 100644 index f0920878ae..0000000000 --- a/test/integration/targets/win_psrepository/meta/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -dependencies: -- setup_remote_tmp_dir -- setup_win_psget diff --git a/test/integration/targets/win_psrepository/tasks/main.yml b/test/integration/targets/win_psrepository/tasks/main.yml deleted file mode 100644 index 65cc278853..0000000000 --- a/test/integration/targets/win_psrepository/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2018, Wojciech Sciesinski <wojciech[at]sciesinski[dot]net> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - ---- -- name: unregister the repository - win_shell: Unregister-PSRepository {{ repository_name | quote }} -ErrorAction Ignore - -- block: - - name: run all tests - include_tasks: tests.yml - - always: - - name: ensure test repo is unregistered - win_shell: Unregister-PSRepository {{ repository_name | quote }} -ErrorAction Ignore diff --git a/test/integration/targets/win_psrepository/tasks/tests.yml b/test/integration/targets/win_psrepository/tasks/tests.yml deleted file mode 100644 index 5dc80fa9af..0000000000 --- a/test/integration/targets/win_psrepository/tasks/tests.yml +++ /dev/null @@ -1,200 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2018, Wojciech Sciesinski <wojciech[at]sciesinski[dot]net> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - ---- - -- name: check adding of repository defaults - check mode - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation }}" - state: present - check_mode: True - register: adding_repository_check - -- name: get result of adding repository defaults - check mode - win_shell: (Get-PSRepository -Name {{ repository_name | quote }} -ErrorAction ignore | Measure-Object).Count - changed_when: false - register: result_adding_repository_check - -- name: test adding repository defaults - check mode - assert: - that: - - adding_repository_check is changed - - result_adding_repository_check.stdout_lines[0] == '0' - -- name: check adding repository defaults - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation }}" - state: present - register: adding_repository - -- name: get result of adding repository defaults - win_shell: | - $repo = Get-PSRepository -Name {{ repository_name | quote }} - ($repo | Measure-Object).Count - $repo.SourceLocation - $repo.InstallationPolicy - register: result_adding_repository - -- name: test adding repository defaults - assert: - that: - - adding_repository is changed - - result_adding_repository.stdout_lines[0] == '1' - - result_adding_repository.stdout_lines[1] == repository_sourcelocation - - result_adding_repository.stdout_lines[2] == 'Trusted' - -- name: check adding repository defaults - idempotent - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation }}" - state: present - register: adding_repository_again - -- name: test check adding repository defaults - idempotent - assert: - that: - - adding_repository_again is not changed - -- name: change InstallationPolicy - check mode - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation }}" - installation_policy: untrusted - check_mode: True - register: change_installation_policy_check - -- name: get result of change InstallationPolicy - check mode - win_shell: '(Get-PSRepository -Name {{ repository_name | quote }}).InstallationPolicy' - changed_when: false - register: result_change_installation_policy_check - -- name: test change InstallationPolicy - check mode - assert: - that: - - change_installation_policy_check is changed - - result_change_installation_policy_check.stdout | trim == 'Trusted' - -- name: change InstallationPolicy - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation }}" - installation_policy: untrusted - register: change_installation_policy - -- name: get result of change InstallationPolicy - win_shell: '(Get-PSRepository -Name {{ repository_name | quote }}).InstallationPolicy' - changed_when: false - register: result_change_installation_policy - -- name: test change InstallationPolicy - assert: - that: - - change_installation_policy is changed - - result_change_installation_policy.stdout | trim == 'Untrusted' - -- name: change InstallationPolicy - idempotent - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation }}" - installation_policy: untrusted - register: change_installation_policy_again - -- name: test change InstallationPolicy - idempotent - assert: - that: - - change_installation_policy_again is not changed - -- name: change source - check mode - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation2 }}" - state: present - check_mode: True - register: change_source_check - -- name: get result of change source - check mode - win_shell: | - $repo = Get-PSRepository -Name {{ repository_name | quote }} - $repo.SourceLocation - $repo.InstallationPolicy - changed_when: False - register: result_change_source_check - -- name: test change source - check mode - assert: - that: - - change_source_check is changed - - result_change_source_check.stdout_lines[0] == repository_sourcelocation - - result_change_source_check.stdout_lines[1] == 'Untrusted' - -- name: change source - win_psrepository: - name: "{{ repository_name }}" - source: "{{ repository_sourcelocation2 }}" - state: present - register: change_source - -- name: get result of change source - win_shell: | - $repo = Get-PSRepository -Name {{ repository_name | quote }} - $repo.SourceLocation - $repo.InstallationPolicy - changed_when: False - register: result_change_source - -- name: test change source - assert: - that: - - change_source is changed - - result_change_source.stdout_lines[0] == repository_sourcelocation2 - - result_change_source.stdout_lines[1] == 'Untrusted' - -- name: remove repository - check mode - win_psrepository: - name: "{{ repository_name }}" - state: absent - check_mode: True - register: removing_repository_check - -- name: get result of remove repository - check mode - win_shell: '(Get-PSRepository -Name {{ repository_name | quote }} -ErrorAction Ignore | Measure-Object).Count' - changed_when: false - register: result_removing_repository_check - -- name: test remove repository - check mode - assert: - that: - - removing_repository_check is changed - - result_removing_repository_check.stdout | trim == '1' - -- name: remove repository - win_psrepository: - name: "{{ repository_name }}" - state: absent - register: removing_repository - -- name: get result of remove repository - win_shell: '(Get-PSRepository -Name {{ repository_name | quote }} -ErrorAction Ignore | Measure-Object).Count' - changed_when: false - register: result_removing_repository - -- name: test remove repository - assert: - that: - - removing_repository is changed - - result_removing_repository.stdout | trim == '0' - -- name: remove repository - idempotent - win_psrepository: - name: "{{ repository_name }}" - state: absent - register: remove_repository_again - -- name: test remove repository - idempotent - assert: - that: - - remove_repository_again is not changed diff --git a/test/integration/targets/win_psrepository_info/aliases b/test/integration/targets/win_psrepository_info/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_psrepository_info/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_psrepository_info/defaults/main.yml b/test/integration/targets/win_psrepository_info/defaults/main.yml deleted file mode 100644 index e027079875..0000000000 --- a/test/integration/targets/win_psrepository_info/defaults/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -run_check_mode: False -suffix: "{{ '(check mode)' if run_check_mode else '' }}" -default_repository_name: PSGallery - -second_repository_name: PowerShellGetDemo -second_repository_source_location: https://www.myget.org/F/powershellgetdemo/api/v2 - -third_repository_name: OtherRepo -third_repository_source_location: http://httpbin.org/get diff --git a/test/integration/targets/win_psrepository_info/meta/main.yml b/test/integration/targets/win_psrepository_info/meta/main.yml deleted file mode 100644 index 504d9eb770..0000000000 --- a/test/integration/targets/win_psrepository_info/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - setup_win_psget diff --git a/test/integration/targets/win_psrepository_info/tasks/contains_all_fields.yml b/test/integration/targets/win_psrepository_info/tasks/contains_all_fields.yml deleted file mode 100644 index 6f3e6f5009..0000000000 --- a/test/integration/targets/win_psrepository_info/tasks/contains_all_fields.yml +++ /dev/null @@ -1,21 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2020, Brian Scholer <@briantist> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: Check for key ('{{ key }}') in result - assert: - that: key in dict_to_check - loop_control: - loop_var: key - loop: - - name - - installation_policy - - package_management_provider - - provider_options - - publish_location - - source_location - - script_source_location - - script_publish_location - - registered - - trusted diff --git a/test/integration/targets/win_psrepository_info/tasks/empty.yml b/test/integration/targets/win_psrepository_info/tasks/empty.yml deleted file mode 100644 index 9bc6d4c644..0000000000 --- a/test/integration/targets/win_psrepository_info/tasks/empty.yml +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2020, Brian Scholer <@briantist> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: Tests against the empty set of repositories - block: - - name: Get repository info {{ suffix }} - win_psrepository_info: - register: repo_info - - - name: Assert that the correct structure is returned {{ suffix }} - assert: - that: - - repo_info.repositories is defined - - repo_info.repositories is sequence() - - repo_info.repositories | length == 0 - # block - check_mode: "{{ run_check_mode }}" diff --git a/test/integration/targets/win_psrepository_info/tasks/main.yml b/test/integration/targets/win_psrepository_info/tasks/main.yml deleted file mode 100644 index 8e92dc6321..0000000000 --- a/test/integration/targets/win_psrepository_info/tasks/main.yml +++ /dev/null @@ -1,51 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2020, Brian Scholer <@briantist> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: Unregister all repositories - win_shell: | - Get-PSRepository | Unregister-PSRepository - -- block: - - name: Run Empty Tests - import_tasks: empty.yml - - - name: Run Empty Tests (check mode) - import_tasks: empty.yml - vars: - run_check_mode: True - - - name: Add the default repository - win_shell: | - Register-PSRepository -Default - - - name: Single Repository Tests - import_tasks: single.yml - - - name: Single Repository Tests (check mode) - import_tasks: single.yml - vars: - run_check_mode: True - - - name: Add two more repositories - win_shell: | - Register-PSRepository -Name '{{ second_repository_name }}' -SourceLocation '{{ second_repository_source_location }}' - Register-PSRepository -Name '{{ third_repository_name }}' -SourceLocation '{{ third_repository_source_location }}' - - - name: Multi Repository Tests - import_tasks: multiple.yml - - - name: Multi Repository Tests (check mode) - import_tasks: multiple.yml - vars: - run_check_mode: True - - always: - - name: Unregister all repositories - win_shell: | - Get-PSRepository | Unregister-PSRepository - - - name: Ensure only the default repository remains - win_shell: | - Register-PSRepository -Default diff --git a/test/integration/targets/win_psrepository_info/tasks/multiple.yml b/test/integration/targets/win_psrepository_info/tasks/multiple.yml deleted file mode 100644 index 8c5b986e7a..0000000000 --- a/test/integration/targets/win_psrepository_info/tasks/multiple.yml +++ /dev/null @@ -1,37 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2020, Brian Scholer <@briantist> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: Tests against mutiple repositories - block: - - name: Get all repository info {{ suffix }} - win_psrepository_info: - register: repo_info - - - name: Assert that the correct structure is returned {{ suffix }} - assert: - that: - - repo_info.repositories is defined - - repo_info.repositories is sequence() - - repo_info.repositories | length == 3 - - - include_tasks: contains_all_fields.yml - vars: - dict_to_check: "{{ item }}" - loop: "{{ repo_info.repositories }}" - - - name: Get two repositories with a filter {{ suffix }} - win_psrepository_info: - name: P* - register: repo_info - - - name: Assert that the correct two repositories were returned {{ suffix }} - assert: - that: - - repo_info.repositories | length == 2 - - default_repository_name in (repo_info.repositories | map(attribute='name') | list) - - second_repository_name in (repo_info.repositories | map(attribute='name') | list) - - # block - check_mode: "{{ run_check_mode }}" diff --git a/test/integration/targets/win_psrepository_info/tasks/single.yml b/test/integration/targets/win_psrepository_info/tasks/single.yml deleted file mode 100644 index 00071ec556..0000000000 --- a/test/integration/targets/win_psrepository_info/tasks/single.yml +++ /dev/null @@ -1,26 +0,0 @@ -# This file is part of Ansible - -# Copyright: (c) 2020, Brian Scholer <@briantist> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) ---- -- name: Tests against a single repository ({{ default_repository_name }}) - block: - - name: Get repository info {{ suffix }} - win_psrepository_info: - name: "{{ default_repository_name }}" - register: repo_info - - - name: Assert that the correct structure is returned {{ suffix }} - assert: - that: - - repo_info.repositories is defined - - repo_info.repositories is sequence() - - repo_info.repositories | length == 1 - - repo_info.repositories[0].name == default_repository_name - - - include_tasks: contains_all_fields.yml - vars: - dict_to_check: "{{ repo_info.repositories[0] }}" - - # block - check_mode: "{{ run_check_mode }}" diff --git a/test/integration/targets/win_rabbitmq_plugin/aliases b/test/integration/targets/win_rabbitmq_plugin/aliases deleted file mode 100644 index aefcbeb1b9..0000000000 --- a/test/integration/targets/win_rabbitmq_plugin/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group3 -disabled diff --git a/test/integration/targets/win_rabbitmq_plugin/tasks/main.yml b/test/integration/targets/win_rabbitmq_plugin/tasks/main.yml deleted file mode 100644 index 70b04132be..0000000000 --- a/test/integration/targets/win_rabbitmq_plugin/tasks/main.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Setup action creates ansible_distribution_version variable -- action: setup - -- include_tasks: tasks/tests.yml - # Works on windows >= Windows 7/Windows Server 2008 R2 - # See https://github.com/ansible/ansible/pull/28118#issuecomment-323684042 for additional info. - when: ansible_distribution_version is version('6.1', '>=') diff --git a/test/integration/targets/win_rabbitmq_plugin/tasks/tests.yml b/test/integration/targets/win_rabbitmq_plugin/tasks/tests.yml deleted file mode 100644 index 3603a9cfbd..0000000000 --- a/test/integration/targets/win_rabbitmq_plugin/tasks/tests.yml +++ /dev/null @@ -1,134 +0,0 @@ -- name: Ensure RabbitMQ installed - win_chocolatey: - name: rabbitmq - state: present - -- name: Ensure that rabbitmq_management plugin disabled - win_rabbitmq_plugin: - names: rabbitmq_management - state: disabled - -- name: Enable rabbitmq_management plugin in check mode - win_rabbitmq_plugin: - names: rabbitmq_management - state: enabled - check_mode: yes - register: enable_plugin_in_check_mode - -- name: Check that enabling plugin in check mode succeeds with a change - assert: - that: - - enable_plugin_in_check_mode.changed == true - -- name: Enable rabbitmq_management plugin in check mode again - win_rabbitmq_plugin: - names: rabbitmq_management - state: enabled - check_mode: yes - register: enable_plugin_in_check_mode_again - -- name: Check that enabling plugin in check mode does not make changes - assert: - that: - - enable_plugin_in_check_mode_again.changed == true - -- name: Enable rabbitmq_management plugin - win_rabbitmq_plugin: - names: rabbitmq_management - state: enabled - register: enable_plugin - -- name: Check that enabling plugin succeeds with a change - assert: - that: - - enable_plugin.changed == true - - enable_plugin.enabled == ['rabbitmq_management'] - -- name: Enable enabled rabbitmq_management plugin - win_rabbitmq_plugin: - names: rabbitmq_management - state: enabled - register: enable_plugin_again - -- name: Check that enabling enabled plugin succeeds without a change - assert: - that: - - enable_plugin_again.changed == false - - enable_plugin_again.enabled == [] - -- name: Enable new plugin when 'new_only' option is 'no' (by default) and there are installed plugins - win_rabbitmq_plugin: - names: rabbitmq_mqtt - state: enabled - check_mode: yes - register: enable_plugin_without_new_only - -- name: Check that 'new_only == no' option enables new plugin and disables the old one - assert: - that: - - enable_plugin_without_new_only.changed == true - - enable_plugin_without_new_only.enabled == ['rabbitmq_mqtt'] - - enable_plugin_without_new_only.disabled == ['rabbitmq_management'] - -- name: Enable new plugin when 'new_only' option is 'yes' and there are installed plugins - win_rabbitmq_plugin: - names: rabbitmq_mqtt - state: enabled - new_only: yes - check_mode: yes - register: enable_plugin_with_new_only - -- name: Check that 'new_only == yes' option just enables new plugin - assert: - that: - - enable_plugin_with_new_only.changed == true - - enable_plugin_with_new_only.enabled == ['rabbitmq_mqtt'] - - enable_plugin_with_new_only.disabled == [] - -- name: Disable rabbitmq_management plugin in check mode - win_rabbitmq_plugin: - names: rabbitmq_management - state: disabled - check_mode: yes - register: disable_plugin_in_check_mode - -- name: Check that disabling plugin in check mode succeeds with a change - assert: - that: - - disable_plugin_in_check_mode.changed == true - -- name: Disable rabbitmq_management plugin in check mode again - win_rabbitmq_plugin: - names: rabbitmq_management - state: disabled - check_mode: yes - register: disable_plugin_in_check_mode_again - -- name: Check that disabling plugin in check mode does not make changes - assert: - that: - - disable_plugin_in_check_mode_again.changed == true - -- name: Disable rabbitmq_management plugin - win_rabbitmq_plugin: - names: rabbitmq_management - state: disabled - register: disable_plugin - -- name: Check that disabling plugin succeeds with a change - assert: - that: - - disable_plugin.changed == true - - disable_plugin.disabled == ['rabbitmq_management'] - -- name: Disable disabled rabbitmq_management plugin - win_rabbitmq_plugin: - names: rabbitmq_management - state: disabled - register: disable_plugin_again - -- name: Check that disabling disabled plugin succeeds without a change - assert: - that: - - disable_plugin_again.changed == false - - disable_plugin_again.disabled == [] diff --git a/test/integration/targets/win_rds/aliases b/test/integration/targets/win_rds/aliases deleted file mode 100644 index 81b9f17ec6..0000000000 --- a/test/integration/targets/win_rds/aliases +++ /dev/null @@ -1,6 +0,0 @@ -shippable/windows/group6 -destructive -skip/windows/2008 # win_feature is required to install the RDS feature and that doesn't support 2008 -win_rds_cap -win_rds_rap -win_rds_settings diff --git a/test/integration/targets/win_rds/defaults/main.yml b/test/integration/targets/win_rds/defaults/main.yml deleted file mode 100644 index 4bc62eff12..0000000000 --- a/test/integration/targets/win_rds/defaults/main.yml +++ /dev/null @@ -1,9 +0,0 @@ -# win_rds_cap -test_win_rds_cap_name: Ansible Test CAP - -# win_rds_rap -test_win_rds_rap_name: Ansible Test RAP - -# win_rds_settings -test_win_rds_settings_path: '{{win_output_dir}}\win_rds_settings' -rds_cert_suject: rdg.test.com diff --git a/test/integration/targets/win_rds/tasks/main.yml b/test/integration/targets/win_rds/tasks/main.yml deleted file mode 100644 index 5510b8cda9..0000000000 --- a/test/integration/targets/win_rds/tasks/main.yml +++ /dev/null @@ -1,73 +0,0 @@ ---- -# Cannot use win_feature to install RDS on Server 2008 -- name: check if feature is availble - win_shell: if (Get-Command -Name Add-WindowsFeature -ErrorAction SilentlyContinue) { $true } else { $false } - changed_when: False - register: module_available - -- name: install Remote Desktop Gateway features - when: module_available.stdout | trim | bool - block: - - name: ensure Remote Desktop Gateway services are installed - win_feature: - name: - - RDS-Gateway - - RDS-Licensing - - RDS-RD-Server - state: present - register: rds_install - - - name: reboot server if needed - win_reboot: - when: rds_install.reboot_required - - # After a reboot Windows is still configuring the feature, this is a hack to wait until that is finished - - name: wait for component servicing to be finished - win_shell: | - $start = Get-Date - $path = "HKLM:\SYSTEM\CurrentControlSet\Control\Winlogon\Notifications\Components\TrustedInstaller" - $tries = 0 - while ((Get-ItemProperty -Path $path -Name Events).Events.Contains("CreateSession")) { - $tries += 1 - Start-Sleep -Seconds 5 - if (((Get-Date) - $start).TotalSeconds -gt 180) { - break - } - } - $tries - changed_when: False - - - name: run win_rds_cap integration tests - include_tasks: win_rds_cap.yml - - - name: run win_rds_rap integration tests - include_tasks: win_rds_rap.yml - - - name: run win_rds_settings integration tests - include_tasks: win_rds_settings.yml - - always: - # Server 2008 R2 requires us to remove this first before the other features - - name: remove the RDS-Gateway feature - win_feature: - name: RDS-Gateway - state: absent - register: rds_uninstall - - - name: reboot after removing RDS-Gateway feature - win_reboot: - when: rds_uninstall.reboot_required - - # Now remove the remaining features - - name: remove installed RDS feature - win_feature: - name: - - RDS-Licensing - - RDS-RD-Server - - Web-Server # not part of the initial feature install but RDS-Gateway requires this and it breaks httptester - state: absent - register: rds_uninstall2 - - - name: reboot after feature removal - win_reboot: - when: rds_uninstall2.reboot_required diff --git a/test/integration/targets/win_rds/tasks/win_rds_cap.yml b/test/integration/targets/win_rds/tasks/win_rds_cap.yml deleted file mode 100644 index 41ed2e6e4c..0000000000 --- a/test/integration/targets/win_rds/tasks/win_rds_cap.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: run tests with cleanup - block: - - name: run tests - include_tasks: win_rds_cap_tests.yml - - always: - - name: delete all CAPs - win_shell: Import-Module RemoteDesktopServices; Remove-Item -Path RDS:\GatewayServer\CAP\* -Recurse diff --git a/test/integration/targets/win_rds/tasks/win_rds_cap_tests.yml b/test/integration/targets/win_rds/tasks/win_rds_cap_tests.yml deleted file mode 100644 index 1c84cc8741..0000000000 --- a/test/integration/targets/win_rds/tasks/win_rds_cap_tests.yml +++ /dev/null @@ -1,264 +0,0 @@ ---- -- name: test create a new CAP (check mode) - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - user_groups: - - administrators - - users@builtin - state: present - register: new_cap_check - check_mode: yes - -- name: get result of create a new CAP (check mode) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}") - register: new_cap_actual_check - -- name: assert results of create a new CAP (check mode) - assert: - that: - - new_cap_check.changed == true - - new_cap_actual_check.stdout_lines[0] == "False" - -- name: test create a new CAP - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - user_groups: - - administrators - - users@builtin - state: present - register: new_cap - -- name: get result of create a new CAP - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}") - register: new_cap_actual - -- name: assert results of create a new CAP - assert: - that: - - new_cap.changed == true - - new_cap_actual.stdout_lines[0] == "True" - -- name: test create a new CAP (idempotent) - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - user_groups: - - administrators - - users@builtin - state: present - register: new_cap_again - -- name: get result of create a new CAP (idempotent) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}") - register: new_cap_actual_again - -- name: assert results of create a new CAP (idempotent) - assert: - that: - - new_cap_again.changed == false - - new_cap_actual_again.stdout_lines[0] == "True" - -- name: test edit a CAP - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - user_groups: - # Test with different group name formats - - users@builtin - - .\guests - computer_groups: - - administrators - auth_method: both - session_timeout: 20 - session_timeout_action: reauth - allow_only_sdrts_servers: true - idle_timeout: 10 - redirect_clipboard: false - redirect_drives: false - redirect_printers: false - redirect_serial: false - redirect_pnp: false - state: disabled - register: edit_cap - -- name: get result of edit a CAP - win_shell: | - Import-Module RemoteDesktopServices; - $cap_path = "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}" - $cap = @{} - Get-ChildItem -Path "$cap_path" | foreach { $cap.Add($_.Name,$_.CurrentValue) } - $cap.DeviceRedirection = @{} - Get-ChildItem -Path "$cap_path\DeviceRedirection" | foreach { $cap.DeviceRedirection.Add($_.Name, ($_.CurrentValue -eq 1)) } - $cap.UserGroups = @(Get-ChildItem -Path "$cap_path\UserGroups" | Select -ExpandProperty Name) - $cap.ComputerGroups = @(Get-ChildItem -Path "$cap_path\ComputerGroups" | Select -ExpandProperty Name) - $cap | ConvertTo-Json - register: edit_cap_actual_json - -- name: parse result of edit a CAP. - set_fact: - edit_cap_actual: '{{ edit_cap_actual_json.stdout | from_json }}' - -- name: assert results of edit a CAP - assert: - that: - - edit_cap.changed == true - - edit_cap_actual.Status == "0" - - edit_cap_actual.EvaluationOrder == "1" - - edit_cap_actual.AllowOnlySDRTSServers == "1" - - edit_cap_actual.AuthMethod == "3" - - edit_cap_actual.IdleTimeout == "10" - - edit_cap_actual.SessionTimeoutAction == "1" - - edit_cap_actual.SessionTimeout == "20" - - edit_cap_actual.DeviceRedirection.Clipboard == false - - edit_cap_actual.DeviceRedirection.DiskDrives == false - - edit_cap_actual.DeviceRedirection.PlugAndPlayDevices == false - - edit_cap_actual.DeviceRedirection.Printers == false - - edit_cap_actual.DeviceRedirection.SerialPorts == false - - edit_cap_actual.UserGroups | length == 2 - - edit_cap_actual.UserGroups[0] == "Users@BUILTIN" - - edit_cap_actual.UserGroups[1] == "Guests@BUILTIN" - - edit_cap_actual.ComputerGroups | length == 1 - - edit_cap_actual.ComputerGroups[0] == "Administrators@BUILTIN" - -- name: test remove all computer groups of CAP - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - computer_groups: [] - register: remove_computer_groups_cap - -- name: get result of remove all computer groups of CAP - win_shell: | - Import-Module RemoteDesktopServices; - $cap_path = "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}" - Write-Host @(Get-ChildItem -Path "$cap_path\ComputerGroups" | Select -ExpandProperty Name).Count - register: remove_computer_groups_cap_actual - -- name: assert results of remove all computer groups of CAP - assert: - that: - - remove_computer_groups_cap.changed == true - - remove_computer_groups_cap_actual.stdout_lines[0] == "0" - -- name: test create a CAP in second position - win_rds_cap: - name: '{{ test_win_rds_cap_name }} Second' - user_groups: - - users@builtin - order: 2 - state: present - register: second_cap - -- name: get result of create a CAP in second position - win_shell: Import-Module RemoteDesktopServices; Write-Host (Get-Item "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }} Second\EvaluationOrder").CurrentValue - register: second_cap_actual - -- name: assert results of create a CAP in second position - assert: - that: - - second_cap.changed == true - - second_cap.warnings is not defined - - second_cap_actual.stdout_lines[0] == "2" - -- name: test create a CAP with order greater than existing CAP count - win_rds_cap: - name: '{{ test_win_rds_cap_name }} Last' - user_groups: - - users@builtin - order: 50 - state: present - register: cap_big_order - -- name: get result of create a CAP with order greater than existing CAP count - win_shell: Import-Module RemoteDesktopServices; Write-Host (Get-Item "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }} Last\EvaluationOrder").CurrentValue - register: cap_big_order_actual - -- name: assert results of create a CAP with order greater than existing CAP count - assert: - that: - - cap_big_order.changed == true - - cap_big_order.warnings | length == 1 - - cap_big_order_actual.stdout_lines[0] == "3" - -- name: test remove CAP (check mode) - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - state: absent - register: remove_cap_check - check_mode: yes - -- name: get result of remove CAP (check mode) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}") - register: remove_cap_actual_check - -- name: assert results of remove CAP (check mode) - assert: - that: - - remove_cap_check.changed == true - - remove_cap_actual_check.stdout_lines[0] == "True" - -- name: test remove CAP - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - state: absent - register: remove_cap_check - -- name: get result of remove CAP - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}") - register: remove_cap_actual_check - -- name: assert results of remove CAP - assert: - that: - - remove_cap_check.changed == true - - remove_cap_actual_check.stdout_lines[0] == "False" - -- name: test remove CAP (idempotent) - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - state: absent - register: remove_cap_check - -- name: get result of remove CAP (idempotent) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\CAP\{{ test_win_rds_cap_name }}") - register: remove_cap_actual_check - -- name: assert results of remove CAP (idempotent) - assert: - that: - - remove_cap_check.changed == false - - remove_cap_actual_check.stdout_lines[0] == "False" - -- name: fail when create a new CAP without user group - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - state: present - register: new_cap_without_group - check_mode: yes - failed_when: "new_cap_without_group.msg != 'User groups must be defined to create a new CAP.'" - -- name: fail when create a new CAP with an empty user group list - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - user_groups: [] - state: present - register: new_cap_empty_group_list - check_mode: yes - failed_when: "new_cap_empty_group_list.msg is not search('cannot be an empty list')" - -- name: fail when create a new CAP with an invalid user group - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - user_groups: - - fake_group - state: present - register: new_cap_invalid_user_group - check_mode: yes - failed_when: new_cap_invalid_user_group.changed != false or new_cap_invalid_user_group.msg is not search('is not a valid account') - -- name: fail when create a new CAP with an invalid computer group - win_rds_cap: - name: '{{ test_win_rds_cap_name }}' - computer_groups: - - fake_group - state: present - register: new_cap_invalid_computer_group - check_mode: yes - failed_when: new_cap_invalid_computer_group.changed != false or new_cap_invalid_computer_group.msg is not search('is not a valid account') diff --git a/test/integration/targets/win_rds/tasks/win_rds_rap.yml b/test/integration/targets/win_rds/tasks/win_rds_rap.yml deleted file mode 100644 index 561f6ead03..0000000000 --- a/test/integration/targets/win_rds/tasks/win_rds_rap.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: run tests with cleanup - block: - - name: run tests - include_tasks: win_rds_rap_tests.yml - - always: - - name: delete all RAPs - win_shell: Import-Module RemoteDesktopServices; Remove-Item -Path RDS:\GatewayServer\RAP\* -Recurse diff --git a/test/integration/targets/win_rds/tasks/win_rds_rap_tests.yml b/test/integration/targets/win_rds/tasks/win_rds_rap_tests.yml deleted file mode 100644 index a8645965b7..0000000000 --- a/test/integration/targets/win_rds/tasks/win_rds_rap_tests.yml +++ /dev/null @@ -1,254 +0,0 @@ ---- -- name: test create a new RAP (check mode) - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: - - administrators - - users@builtin - state: present - register: new_rap_check - check_mode: yes - -- name: get result of create a new RAP (check mode) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}") - register: new_rap_actual_check - -- name: assert results of create a new RAP (check mode) - assert: - that: - - new_rap_check.changed == true - - new_rap_actual_check.stdout_lines[0] == "False" - -- name: test create a new RAP - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: - - administrators - - users@builtin - state: present - register: new_rap - -- name: get result of create a new RAP - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}") - register: new_rap_actual - -- name: assert results of create a new RAP - assert: - that: - - new_rap.changed == true - - new_rap_actual.stdout_lines[0] == "True" - -- name: test create a new RAP (idempotent) - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: - - administrators - - users@builtin - state: present - register: new_rap_again - -- name: get result of create a new RAP (idempotent) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}") - register: new_rap_actual_again - -- name: assert results of create a new RAP (idempotent) - assert: - that: - - new_rap_again.changed == false - - new_rap_actual_again.stdout_lines[0] == "True" - -- name: test edit a RAP - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - description: 'Description of {{ test_win_rds_rap_name }}' - user_groups: - # Test with different group name formats - - users@builtin - - .\guests - computer_group_type: ad_network_resource_group - computer_group: administrators - allowed_ports: - - 3389 - - 3390 - - 3391 - state: disabled - register: edit_rap - -- name: get result of edit a RAP - win_shell: | - Import-Module RemoteDesktopServices; - $rap_path = "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}" - $rap = @{} - Get-ChildItem -Path "$rap_path" | foreach { $rap.Add($_.Name,$_.CurrentValue) } - $rap.UserGroups = @(Get-ChildItem -Path "$rap_path\UserGroups" | Select -ExpandProperty Name) - $rap | ConvertTo-Json - register: edit_rap_actual_json - -- name: parse result of edit a RAP. - set_fact: - edit_rap_actual: '{{ edit_rap_actual_json.stdout | from_json }}' - -- name: assert results of edit a RAP - assert: - that: - - edit_rap.changed == true - - edit_rap_actual.Status == "0" - - edit_rap_actual.Description == "Description of {{ test_win_rds_rap_name }}" - - edit_rap_actual.PortNumbers == "3389,3390,3391" - - edit_rap_actual.UserGroups | length == 2 - - edit_rap_actual.UserGroups[0] == "Users@BUILTIN" - - edit_rap_actual.UserGroups[1] == "Guests@BUILTIN" - - edit_rap_actual.ComputerGroupType == "1" - - edit_rap_actual.ComputerGroup == "Administrators@BUILTIN" - -- name: test edit a RAP (indempotent) - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - description: 'Description of {{ test_win_rds_rap_name }}' - user_groups: - - users@builtin - - guests@builtin - computer_group_type: ad_network_resource_group - computer_group: Administrators@BUILTIN - allowed_ports: - - 3389 - - 3390 - - 3391 - state: disabled - register: edit_rap_again - -- name: assert results of edit a RAP (indempotent) - assert: - that: - - edit_rap_again.changed == false - -- name: test allow all ports - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - allowed_ports: any - register: edit_rap_allow_all_ports - -- name: get result of allow all ports - win_shell: Import-Module RemoteDesktopServices; Write-Host (Get-Item "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}\PortNumbers").CurrentValue - register: edit_rap_allow_all_ports_actual - -- name: assert results of allow all ports - assert: - that: - - edit_rap_allow_all_ports.changed == true - - edit_rap_allow_all_ports_actual.stdout_lines[0] == "*" - -- name: test remove RAP (check mode) - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - state: absent - register: remove_rap_check - check_mode: yes - -- name: get result of remove RAP (check mode) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}") - register: remove_rap_actual_check - -- name: assert results of remove RAP (check mode) - assert: - that: - - remove_rap_check.changed == true - - remove_rap_actual_check.stdout_lines[0] == "True" - -- name: test remove RAP - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - state: absent - register: remove_rap - -- name: get result of remove RAP - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}") - register: remove_rap_actual - -- name: assert results of remove RAP - assert: - that: - - remove_rap.changed == true - - remove_rap_actual.stdout_lines[0] == "False" - -- name: test remove RAP (idempotent) - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - state: absent - register: remove_rap_again - -- name: get result of remove RAP (idempotent) - win_shell: Import-Module RemoteDesktopServices; Write-Host (Test-Path "RDS:\GatewayServer\RAP\{{ test_win_rds_rap_name }}") - register: remove_rap_actual_again - -- name: assert results of remove RAP (idempotent) - assert: - that: - - remove_rap_again.changed == false - - remove_rap_actual_again.stdout_lines[0] == "False" - -- name: fail when create a new RAP without user group - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - state: present - register: new_rap_without_group - check_mode: yes - failed_when: "new_rap_without_group.msg != 'User groups must be defined to create a new RAP.'" - -- name: fail when create a new RAP with an empty user group list - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: [] - state: present - register: new_rap_empty_group_list - check_mode: yes - failed_when: "new_rap_empty_group_list.msg is not search('cannot be an empty list')" - -- name: fail when create a new RAP with an invalid user group - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: - - fake_group - state: present - register: new_rap_invalid_group - check_mode: yes - failed_when: new_rap_invalid_group.changed != false or new_rap_invalid_group.msg is not search('is not a valid account') - -- name: fail when create a new RAP with an invalid AD computer group - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: - - administrators - computer_group_type: ad_network_resource_group - computer_group: fake_ad_group - state: present - register: new_rap_invalid_ad_computer_group - check_mode: yes - failed_when: new_rap_invalid_ad_computer_group.changed != false or new_rap_invalid_ad_computer_group.msg is not search('is not a valid account') - -- name: fail when create a new RAP with an invalid gateway managed computer group - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: - - administrators - computer_group_type: rdg_group - computer_group: fake_rdg_group - state: present - register: new_rap_invalid_rdg_computer_group - check_mode: yes - failed_when: new_rap_invalid_rdg_computer_group.changed != false or new_rap_invalid_rdg_computer_group.msg is not search('is not a valid gateway managed computer group') - -- name: fail when create a new RAP with invalid port numbers - win_rds_rap: - name: '{{ test_win_rds_rap_name }}' - user_groups: - - administrators - allowed_ports: - - '{{ item }}' - state: present - loop: - - invalid_port_number - - 65536 - register: new_rap_invalid_port - check_mode: yes - failed_when: new_rap_invalid_port.changed != false or new_rap_invalid_port.msg is not search('is not a valid port number') diff --git a/test/integration/targets/win_rds/tasks/win_rds_settings.yml b/test/integration/targets/win_rds/tasks/win_rds_settings.yml deleted file mode 100644 index 08e291fbca..0000000000 --- a/test/integration/targets/win_rds/tasks/win_rds_settings.yml +++ /dev/null @@ -1,66 +0,0 @@ -- name: run tests with cleanup - block: - - name: gather facts - setup: - filter: ansible_hostname - - - name: ensure testing folders exists - win_file: - path: '{{test_win_rds_settings_path}}' - state: directory - - - name: deploy test artifacts - win_template: - src: '{{item}}.j2' - dest: '{{test_win_rds_settings_path}}\{{item | basename}}' - with_items: - - rds_base_cfg.xml - - - name: import RDS test configuration - win_shell: | - $ts = Get-WmiObject Win32_TSGatewayServer -namespace root\cimv2\TerminalServices - $import_xml = Get-Content {{test_win_rds_settings_path}}\rds_base_cfg.xml - $import_result = $ts.Import(45, $import_xml) - exit $import_result.ReturnValue - - - name: write certreq file - win_copy: - content: |- - [NewRequest] - Subject = "CN={{ rds_cert_suject }}" - KeyLength = 2048 - KeyAlgorithm = RSA - MachineKeySet = true - RequestType = Cert - KeyUsage = 0xA0 ; Digital Signature, Key Encipherment - [EnhancedKeyUsageExtension] - OID=1.3.6.1.5.5.7.3.1 ; Server Authentication - dest: '{{test_win_rds_settings_path}}\certreq.txt' - - - name: create self signed cert from certreq - win_command: certreq -new -machine {{test_win_rds_settings_path}}\certreq.txt {{test_win_rds_settings_path}}\certreqresp.txt - - - name: register certificate thumbprint - raw: '(gci Cert:\LocalMachine\my | ? {$_.subject -eq "CN={{ rds_cert_suject }}"})[0].Thumbprint' - register: rds_cert_thumbprint - - - name: run tests - include_tasks: win_rds_settings_tests.yml - - always: - - name: restore RDS base configuration - win_shell: | - $ts = Get-WmiObject Win32_TSGatewayServer -namespace root\cimv2\TerminalServices - $import_xml = Get-Content {{test_win_rds_settings_path}}\rds_base_cfg.xml - $import_result = $ts.Import(45, $import_xml) - exit $import_result.ReturnValue - - - name: remove certificate - raw: 'remove-item cert:\localmachine\my\{{ item }} -force -ea silentlycontinue' - with_items: - - "{{ rds_cert_thumbprint.stdout_lines[0] }}" - - - name: cleanup test artifacts - win_file: - path: '{{test_win_rds_settings_path}}' - state: absent diff --git a/test/integration/targets/win_rds/tasks/win_rds_settings_tests.yml b/test/integration/targets/win_rds/tasks/win_rds_settings_tests.yml deleted file mode 100644 index 63fa815003..0000000000 --- a/test/integration/targets/win_rds/tasks/win_rds_settings_tests.yml +++ /dev/null @@ -1,89 +0,0 @@ ---- -- name: test change RDS settings (check mode) - win_rds_settings: - max_connections: 50 - certificate_hash: '{{rds_cert_thumbprint.stdout_lines[0]}}' - ssl_bridging: https_https - enable_only_messaging_capable_clients: yes - register: configure_rds_check - check_mode: yes - -- name: get result of change RDS settings (check mode) - win_shell: | - Import-Module RemoteDesktopServices - (Get-Item RDS:\GatewayServer\MaxConnections).CurrentValue - (Get-Item RDS:\GatewayServer\SSLCertificate\Thumbprint).CurrentValue - (Get-Item RDS:\GatewayServer\SSLBridging).CurrentValue - (Get-Item RDS:\GatewayServer\EnableOnlyMessagingCapableClients).CurrentValue - register: configure_rds_actual_check - -- name: assert results of change RDS settings (check mode) - assert: - that: - - configure_rds_check.changed == true - - configure_rds_actual_check.stdout_lines[0] != "50" - - configure_rds_actual_check.stdout_lines[1] != rds_cert_thumbprint.stdout_lines[0] - - configure_rds_actual_check.stdout_lines[2] == "0" - - configure_rds_actual_check.stdout_lines[3] == "0" - -- name: test change RDS settings - win_rds_settings: - max_connections: 50 - certificate_hash: '{{rds_cert_thumbprint.stdout_lines[0]}}' - ssl_bridging: https_https - enable_only_messaging_capable_clients: yes - register: configure_rds - -- name: get result of change RDS settings - win_shell: | - Import-Module RemoteDesktopServices - (Get-Item RDS:\GatewayServer\MaxConnections).CurrentValue - (Get-Item RDS:\GatewayServer\SSLCertificate\Thumbprint).CurrentValue - (Get-Item RDS:\GatewayServer\SSLBridging).CurrentValue - (Get-Item RDS:\GatewayServer\EnableOnlyMessagingCapableClients).CurrentValue - register: configure_rds_actual - -- name: assert results of change RDS settings - assert: - that: - - configure_rds.changed == true - - configure_rds_actual.stdout_lines[0] == "50" - - configure_rds_actual.stdout_lines[1] == rds_cert_thumbprint.stdout_lines[0] - - configure_rds_actual.stdout_lines[2] == "2" - - configure_rds_actual.stdout_lines[3] == "1" - -- name: test change RDS settings (idempotent) - win_rds_settings: - max_connections: 50 - certificate_hash: '{{rds_cert_thumbprint.stdout_lines[0]}}' - ssl_bridging: https_https - enable_only_messaging_capable_clients: yes - register: configure_rds_again - -- name: assert results of change RDS settings (idempotent) - assert: - that: - - configure_rds_again.changed == false - -- name: test disable connection limit - win_rds_settings: - max_connections: -1 - register: disable_limit - -- name: get result of disable connection limit - win_shell: | - Import-Module RemoteDesktopServices - (Get-Item RDS:\GatewayServer\MaxConnections).CurrentValue -eq (Get-Item RDS:\GatewayServer\MaxConnectionsAllowed).CurrentValue - register: disable_limit_actual - -- name: assert results of disable connection limit - assert: - that: - - disable_limit.changed == true - - disable_limit_actual.stdout_lines[0] == "True" - -- name: fail with invalid certificate thumbprint - win_rds_settings: - certificate_hash: 72E8BD0216FA14100192A3E8B7B150C65B4B0817 - register: fail_invalid_cert - failed_when: fail_invalid_cert.msg is not search('Unable to locate certificate')
\ No newline at end of file diff --git a/test/integration/targets/win_rds/templates/rds_base_cfg.xml.j2 b/test/integration/targets/win_rds/templates/rds_base_cfg.xml.j2 deleted file mode 100644 index 5aa48ed84f..0000000000 --- a/test/integration/targets/win_rds/templates/rds_base_cfg.xml.j2 +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="UTF-16"?> -<?TSGateway version="1.0"?> -<TsgServer> - <ServerName>{{ ansible_hostname }}</ServerName> - <ServerSettings> - <MaxConnections>4294967295</MaxConnections> - <UnlimitedConnections>1</UnlimitedConnections> - <CentralCapEnabled>0</CentralCapEnabled> - <RequestSOH>0</RequestSOH> - <OnlyConsentCapableClients>0</OnlyConsentCapableClients> - <LogEvents> - <LogEvent> - <Name>LogChannelDisconnect</Name> - <Enabled>1</Enabled> - </LogEvent> - <LogEvent> - <Name>LogFailureChannelConnect</Name> - <Enabled>1</Enabled> - </LogEvent> - <LogEvent> - <Name>LogFailureConnectionAuthorizationCheck</Name> - <Enabled>1</Enabled> - </LogEvent> - <LogEvent> - <Name>LogFailureResourceAuthorizationCheck</Name> - <Enabled>1</Enabled> - </LogEvent> - <LogEvent> - <Name>LogSuccessfulChannelConnect</Name> - <Enabled>1</Enabled> - </LogEvent> - <LogEvent> - <Name>LogSuccessfulConnectionAuthorizationCheck</Name> - <Enabled>1</Enabled> - </LogEvent> - <LogEvent> - <Name>LogSuccessfulResourceAuthorizationCheck</Name> - <Enabled>1</Enabled> - </LogEvent> - </LogEvents> - <AuthenticationPlugin>native</AuthenticationPlugin> - <AuthorizationPlugin>native</AuthorizationPlugin> - <ConsentMessageText/> - <AdminMessageText/> - <AdminMsgStartDate/> - <AdminMsgEndDate/> - <SslBridging>0</SslBridging> - <HttpIPAddress>*</HttpIPAddress> - <UdpIPAddress>*</UdpIPAddress> - <HttpPort>443</HttpPort> - <UdpPort>3391</UdpPort> - <IsUdpEnabled>1</IsUdpEnabled> - <EnforceChannelBinding>1</EnforceChannelBinding> - </ServerSettings> - <Caps/> - <Raps/> - <ResourceGroups/> -</TsgServer>
\ No newline at end of file diff --git a/test/integration/targets/win_region/aliases b/test/integration/targets/win_region/aliases deleted file mode 100644 index 215e0b0692..0000000000 --- a/test/integration/targets/win_region/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group4 diff --git a/test/integration/targets/win_region/meta/main.yml b/test/integration/targets/win_region/meta/main.yml deleted file mode 100644 index d328716dfa..0000000000 --- a/test/integration/targets/win_region/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - prepare_win_tests diff --git a/test/integration/targets/win_region/tasks/main.yml b/test/integration/targets/win_region/tasks/main.yml deleted file mode 100644 index 5600d23d3a..0000000000 --- a/test/integration/targets/win_region/tasks/main.yml +++ /dev/null @@ -1,252 +0,0 @@ -# test code for the win_region module -# 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 <http://www.gnu.org/licenses/>. - -- name: expect failure when only setting copy_settings - win_region: - copy_settings: False - register: actual - failed_when: actual.msg != "An argument for 'format', 'location' or 'unicode_language' needs to be supplied" - -- name: expect failure when using invalid geo id for the location - win_region: - location: 111111 - register: actual - failed_when: actual.msg != "The argument location '111111' does not contain a valid Geo ID" - -- name: expect failure when using invalid culture for format - win_region: - format: ab-CD - register: actual - failed_when: actual.msg != "The argument format 'ab-CD' does not contain a valid Culture Name" - -- name: expect failure when using invalid culture for unicode_language - win_region: - unicode_language: ab-CD - register: actual - failed_when: actual.msg != "The argument unicode_language 'ab-CD' does not contain a valid Culture Name" - -- name: set settings all to English Australia before tests for a baseline - win_region: - location: 12 - format: en-AU - unicode_language: en-AU - -- name: reboot server to set properties - win_reboot: - -- name: check that changing location in check mode works - win_region: - location: 244 - register: check_location - check_mode: yes - -- name: get current location value - win_command: powershell (Get-ItemProperty -Path 'HKCU:\Control Panel\International\Geo').Nation - register: actual_location - -- name: check assertion about location change in check mode - assert: - that: - - "actual_location.stdout_lines[0] == '12'" # Corresponds to en-AU - - "check_location is changed" - - "check_location.restart_required == False" - -- name: set location to United States - win_region: - location: 244 - register: location - -- name: get current location value - win_command: powershell (Get-ItemProperty -Path 'HKCU:\Control Panel\International\Geo').Nation - register: actual_location - -- name: check assertion about location change - assert: - that: - - "actual_location.stdout_lines[0] == '244'" # Corresponds to en-US - - "location is changed" - - "location.restart_required == False" - -- name: set location to United States again - win_region: - location: 244 - register: location_again - -- name: check that the result did not change - assert: - that: - - "location_again is not changed" - - "location_again.restart_required == False" - -- name: set format to English United States in check mode - win_region: - format: en-US - register: check_format - check_mode: yes - -- name: get actual format value from check mode - win_command: powershell (Get-Culture).Name - register: actual_format - -- name: check assertion about location change in check mode - assert: - that: - - "actual_format.stdout_lines[0] == 'en-AU'" - - "check_format is changed" - - "check_format.restart_required == False" - -- name: set format to English United States - win_region: - format: en-US - register: format - -- name: get actual format value - win_command: powershell (Get-Culture).Name - register: actual_format - -- name: check assertion about format change - assert: - that: - - "actual_format.stdout_lines[0] == 'en-US'" - - "format is changed" - - "format.restart_required == False" - -- name: set format to English United States again - win_region: - format: en-US - register: format_again - -- name: check that the result did not change - assert: - that: - - "format_again is not changed" - - "format_again.restart_required == False" - -- name: set unicode_language to English United States in check mode - win_region: - unicode_language: en-US - register: check_unicode - check_mode: yes - -- name: get actual unicode values - win_command: powershell (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\Language').Default - register: actual_unicode - -- name: check assertion about unicode language change in check mode - assert: - that: - - "actual_unicode.stdout_lines[0] == '0c09'" - - "check_unicode is changed" - - "check_unicode.restart_required == True" - -- name: set unicode_language to English United States - win_region: - unicode_language: en-US - register: unicode - -- name: reboot the server after changing unicode language - action: win_reboot - when: unicode.restart_required - -- name: get actual unicode value - win_command: powershell (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Nls\Language').Default - register: actual_unicode - -- name: check assertion about unicode language change - assert: - that: - - "actual_unicode.stdout_lines[0] == '0409'" # corresponds to en-US - - "unicode is changed" - - "unicode.restart_required == True" - -- name: set unicode_language to English United States again - win_region: - unicode_language: en-US - register: unicode_again - -- name: check that the result did not change - assert: - that: - - "unicode_again is not changed" - - "unicode_again.restart_required == False" - -- name: copy settings when setting to the same format check mode - win_region: - format: en-US - copy_settings: True - register: check_copy_same - check_mode: yes - -- name: check that the result did not change in check mode - assert: - that: - - "check_copy_same is not changed" - - "check_copy_same.restart_required == False" - -- name: copy settings when setting to the same format - win_region: - format: en-US - copy_settings: True - register: copy_same - -- name: check that the result did not change - assert: - that: - - "copy_same is not changed" - - "copy_same.restart_required == False" - -- name: copy setting when setting to a different format - win_region: - format: en-GB - copy_settings: True - register: copy - -- name: get actual format value after copy_settings - win_command: powershell (Get-Culture).Name - register: actual_copy - -- name: get locale name for local service registry hive - win_command: powershell "New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS | Out-Null; (Get-ItemProperty 'HKU:\S-1-5-19\Control Panel\International').LocaleName" - register: actual_local - -- name: get locale name for network service registry hive - win_command: powershell "New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS | Out-Null; (Get-ItemProperty 'HKU:\S-1-5-20\Control Panel\International').LocaleName" - register: actual_network - -- name: load temp hive - win_command: reg load HKU\TEMP C:\Users\Default\NTUSER.DAT - -- name: get locale name for default registry hive - win_command: powershell "New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS | Out-Null; (Get-ItemProperty 'HKU:\TEMP\Control Panel\International').LocaleName" - register: actual_temp - -- name: unload temp hive - win_command: reg unload HKU\TEMP - -- name: get locale name for default registry hive - win_command: powershell "New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS | Out-Null; (Get-ItemProperty 'HKU:\.DEFAULT\Control Panel\International').LocaleName" - register: actual_default - -- name: check assertions about copy setting when setting to a different format - assert: - that: - - "actual_copy.stdout_lines[0] == 'en-GB'" - - "actual_local.stdout_lines[0] == 'en-GB'" - - "actual_network.stdout_lines[0] == 'en-GB'" - - "actual_temp.stdout_lines[0] == 'en-GB'" - - "actual_default.stdout_lines[0] == 'en-GB'" - - "copy is changed" - - "copy.restart_required == False" diff --git a/test/integration/targets/win_regmerge/aliases b/test/integration/targets/win_regmerge/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_regmerge/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_regmerge/files/settings1.reg b/test/integration/targets/win_regmerge/files/settings1.reg Binary files differdeleted file mode 100644 index baec75b2af..0000000000 --- a/test/integration/targets/win_regmerge/files/settings1.reg +++ /dev/null diff --git a/test/integration/targets/win_regmerge/files/settings2.reg b/test/integration/targets/win_regmerge/files/settings2.reg Binary files differdeleted file mode 100644 index fc2612cb8a..0000000000 --- a/test/integration/targets/win_regmerge/files/settings2.reg +++ /dev/null diff --git a/test/integration/targets/win_regmerge/files/settings3.reg b/test/integration/targets/win_regmerge/files/settings3.reg Binary files differdeleted file mode 100644 index fbe7411c95..0000000000 --- a/test/integration/targets/win_regmerge/files/settings3.reg +++ /dev/null diff --git a/test/integration/targets/win_regmerge/meta/main.yml b/test/integration/targets/win_regmerge/meta/main.yml deleted file mode 100644 index d328716dfa..0000000000 --- a/test/integration/targets/win_regmerge/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - prepare_win_tests diff --git a/test/integration/targets/win_regmerge/tasks/main.yml b/test/integration/targets/win_regmerge/tasks/main.yml deleted file mode 100644 index 15c754de6d..0000000000 --- a/test/integration/targets/win_regmerge/tasks/main.yml +++ /dev/null @@ -1,133 +0,0 @@ -# test code for the win_regmerge module -# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com> - -# 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 <http://www.gnu.org/licenses/>. - -# clear the area of the registry we are using for tests -- name: remove setting - win_regedit: - key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp' - state: absent - -# copy over some registry files to work with -- name: copy over some registry files to work with - win_copy: src={{item}} dest={{win_output_dir}}\\{{item}} - with_items: - - settings1.reg - - settings2.reg - - settings3.reg - -# test 1 - basic test of changed behaviour -# merge in REG_SZ -- name: test 1 merge in a setting - win_regmerge: - path: "{{win_output_dir}}\\settings1.reg" - register: merge11_result - -- assert: - that: - - "merge11_result.changed == true" - -# re run the merge -- name: test 1 merge in the setting again - win_regmerge: - path: "{{win_output_dir}}\\settings1.reg" - register: merge12_result - -# without a compare to key, should always report changed -- assert: - that: - - "merge12_result.changed == true" -# assert changed false - -# prune reg key -- name: test 1 remove setting - win_regedit: - key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp' - state: absent - -# -# test 2, observe behaviour when compare_to param is set -# -- name: test 2 merge in a setting - win_regmerge: - path: "{{win_output_dir}}\\settings1.reg" - compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moosic\ILikeToMooveIt' - register: merge21_result - -- assert: - that: - - "merge21_result.changed == true" - -# re run the merge -- name: test 2 merge in the setting again but with compare_key - win_regmerge: - path: "{{win_output_dir}}\\settings1.reg" - compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moosic\ILikeToMooveIt' - register: merge22_result - -# with a compare to key, should now report not changed -- assert: - that: - - "merge22_result.changed == false" -# assert changed false - -# prune the contents of the registry from the parent of the compare key downwards -- name: test 2 clean up remove setting - win_regedit: - key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp' - state: absent - -# test 3 merge in more complex settings -- name: test 3 merge in a setting - win_regmerge: - path: "{{win_output_dir}}\\settings3.reg" - compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moo Monitor' - register: merge31_result - -- assert: - that: - - "merge31_result.changed == true" - -# re run the merge -- name: test 3 merge in the setting again but with compare_key check - win_regmerge: - path: "{{win_output_dir}}\\settings3.reg" - compare_to: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp\Moo Monitor' - register: merge32_result - -# with a compare to key, should now report not changed -- assert: - that: - - "merge32_result.changed == false" -# assert changed false - -# prune the contents of the registry from the compare key downwards -- name: test 3 clean up remove setting - win_regedit: - key: 'HKLM:\SOFTWARE\Wow6432Node\Cow Corp' - state: absent - -# clean up registry files - -- name: clean up registry files - win_file: path={{win_output_dir}}\\{{item}} state=absent - with_items: - - settings1.reg - - settings2.reg - - settings3.reg - -# END OF win_regmerge tests diff --git a/test/integration/targets/win_regmerge/templates/win_line_ending.j2 b/test/integration/targets/win_regmerge/templates/win_line_ending.j2 deleted file mode 100644 index d0cefd76f4..0000000000 --- a/test/integration/targets/win_regmerge/templates/win_line_ending.j2 +++ /dev/null @@ -1,4 +0,0 @@ -#jinja2: newline_sequence:'\r\n' -{{ templated_var }}
-{{ templated_var }}
-{{ templated_var }}
diff --git a/test/integration/targets/win_regmerge/vars/main.yml b/test/integration/targets/win_regmerge/vars/main.yml deleted file mode 100644 index 1e8f64ccf4..0000000000 --- a/test/integration/targets/win_regmerge/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ -templated_var: templated_var_loaded diff --git a/test/integration/targets/win_route/aliases b/test/integration/targets/win_route/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_route/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_route/defaults/main.yml b/test/integration/targets/win_route/defaults/main.yml deleted file mode 100644 index a77ebc16cb..0000000000 --- a/test/integration/targets/win_route/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -default_gateway: 192.168.1.1 -destination_ip_address: 192.168.2.10 diff --git a/test/integration/targets/win_route/tasks/main.yml b/test/integration/targets/win_route/tasks/main.yml deleted file mode 100644 index b0f40dd06c..0000000000 --- a/test/integration/targets/win_route/tasks/main.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- -# test code for the win_psmodule module when using winrm connection -# (c) 2017, Daniele Lazzari <lazzari@mailup.com> - -# 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 <http://www.gnu.org/licenses/>. - - -- name: get os info - win_shell: '[Environment]::OSVersion.Version -ge [Version]"6.3"' - register: os - -- name: Perform with os Windows 2012R2 or newer - when: os.stdout_lines[0] == "True" - block: - - name: run all tasks - include: tests.yml diff --git a/test/integration/targets/win_route/tasks/tests.yml b/test/integration/targets/win_route/tasks/tests.yml deleted file mode 100644 index 0c365bef54..0000000000 --- a/test/integration/targets/win_route/tasks/tests.yml +++ /dev/null @@ -1,79 +0,0 @@ ---- -- name: add a static route - win_route: - destination: "{{ destination_ip_address }}/32" - gateway: "{{ default_gateway }}" - metric: 1 - state: present - register: route - -- name: check if route successfully added - win_shell: (Get-CimInstance win32_ip4PersistedrouteTable -Filter "Destination = '{{ destination_ip_address }}'").Caption - register: route_added - -- name: check route default gateway - win_shell: (Get-CimInstance win32_ip4PersistedrouteTable -Filter "Destination = '{{ destination_ip_address }}'").NextHop - register: route_gateway - -- name: test if route successfully added - assert: - that: - - route is changed - - route_added.stdout_lines[0] == "{{ destination_ip_address }}" - - route_gateway.stdout_lines[0] == "{{ default_gateway }}" - -- name: add a static route to test idempotency - win_route: - destination: "{{ destination_ip_address }}/32" - gateway: "{{ default_gateway }}" - metric: 1 - state: present - register: idempotent_route - -- name: test idempotency - assert: - that: - - idempotent_route is not changed - - idempotent_route.output == "Static route already exists" - -- name: remove route - win_route: - destination: "{{ destination_ip_address }}/32" - state: absent - register: route_removed - -- name: check route is removed - win_shell: Get-CimInstance win32_ip4PersistedrouteTable -Filter "Destination = '{{ destination_ip_address }}'" - register: check_route_removed - -- name: test route is removed - assert: - that: - - route_removed is changed - - check_route_removed.stdout == '' - -- name: remove static route to test idempotency - win_route: - destination: "{{ destination_ip_address }}/32" - state: absent - register: idempotent_route_removed - -- name: test idempotency - assert: - that: - - idempotent_route_removed is not changed - - idempotent_route_removed.output == "No route to remove" - -- name: add route to wrong ip address - win_route: - destination: "715.18.0.0/32" - gateway: "{{ default_gateway }}" - metric: 1 - state: present - ignore_errors: yes - register: wrong_ip - -- name: test route to wrong ip address - assert: - that: - - wrong_ip is failed diff --git a/test/integration/targets/win_say/aliases b/test/integration/targets/win_say/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_say/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_say/tasks/main.yml b/test/integration/targets/win_say/tasks/main.yml deleted file mode 100644 index 71c9435cdb..0000000000 --- a/test/integration/targets/win_say/tasks/main.yml +++ /dev/null @@ -1,44 +0,0 @@ -# CI hosts don't have a valid Speech package so we rely on check mode for basic -# sanity tests ---- -- name: Warn of impending deployment - win_say: - msg: Warning, deployment commencing in 5 minutes, please log out. - check_mode: "{{ win_say_check_mode |default('yes') }}" - -- name: Using a specified voice and a start sound - win_say: - msg: Warning, deployment commencing in 5 minutes, please log out. - start_sound_path: C:\Windows\Media\ding.wav - voice: Microsoft Hazel Desktop - check_mode: "{{ win_say_check_mode |default('yes') }}" - -- name: Example with start and end sound - win_say: - msg: New software installed - start_sound_path: C:\Windows\Media\Windows Balloon.wav - end_sound_path: C:\Windows\Media\chimes.wav - check_mode: "{{ win_say_check_mode |default('yes') }}" - -- name: Create message file - win_copy: - content: Stay calm and carry on - dest: C:\Windows\Temp\win_say_message.txt - -- name: Text from file example - win_say: - msg_file: C:\Windows\Temp\win_say_message.txt - start_sound_path: C:\Windows\Media\Windows Balloon.wav - end_sound_path: C:\Windows\Media\chimes.wav - check_mode: "{{ win_say_check_mode |default('yes') }}" - -- name: Remove message file - win_file: - path: C:\Windows\Temp\win_say_message.txt - state: absent - -- name: Different speech speed - win_say: - speech_speed: 5 - msg: Stay calm and proceed to the closest fire exit. - check_mode: "{{ win_say_check_mode |default('yes') }}" diff --git a/test/integration/targets/win_scheduled_task/aliases b/test/integration/targets/win_scheduled_task/aliases deleted file mode 100644 index 6036e173f1..0000000000 --- a/test/integration/targets/win_scheduled_task/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group7 diff --git a/test/integration/targets/win_scheduled_task/defaults/main.yml b/test/integration/targets/win_scheduled_task/defaults/main.yml deleted file mode 100644 index f501c72fc5..0000000000 --- a/test/integration/targets/win_scheduled_task/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -test_scheduled_task_name: Ansible Test -test_scheduled_task_path: \Ansible Test Folder -test_scheduled_task_user: MooCow -test_scheduled_task_pass: Password01 diff --git a/test/integration/targets/win_scheduled_task/tasks/clean.yml b/test/integration/targets/win_scheduled_task/tasks/clean.yml deleted file mode 100644 index 635339bf34..0000000000 --- a/test/integration/targets/win_scheduled_task/tasks/clean.yml +++ /dev/null @@ -1,16 +0,0 @@ -# cleans up each test to ensure a blank slate ---- -- win_scheduled_task: - name: '{{item.name}}' - path: '{{item.path|default(omit)}}' - state: absent - with_items: - - name: Task # old tests - path: \Path - - name: '{{test_scheduled_task_name}}' - - name: '{{test_scheduled_task_name}}' - path: '{{test_scheduled_task_path}}' - -- win_user: - name: '{{test_scheduled_task_user}}' - state: absent diff --git a/test/integration/targets/win_scheduled_task/tasks/failures.yml b/test/integration/targets/win_scheduled_task/tasks/failures.yml deleted file mode 100644 index 0642437436..0000000000 --- a/test/integration/targets/win_scheduled_task/tasks/failures.yml +++ /dev/null @@ -1,149 +0,0 @@ -# test out the known failure cases to ensure we have decent error messages ---- -- name: fail create task without an action - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - register: fail_create_without_action - failed_when: fail_create_without_action.msg != 'cannot create a task with no actions, set at least one action with a path to an executable' - -- name: fail both username and group are set - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{ansible_user}}' - group: '{{ansible_user}}' - register: fail_username_and_group - failed_when: fail_username_and_group.msg != 'username and group can not be set at the same time' - -- name: fail logon type s4u but no password set - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - logon_type: s4u - register: fail_lt_s4u_not_set - failed_when: fail_lt_s4u_not_set.msg != 'password must be set when logon_type=s4u' - -- name: fail logon type group but no group set - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - logon_type: group - register: fail_lt_group_not_set - failed_when: fail_lt_group_not_set.msg != 'group must be set when logon_type=group' - -- name: fail logon type service but non service user set - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - logon_type: service_account - username: '{{ansible_user}}' - register: fail_lt_service_invalid_user - failed_when: fail_lt_service_invalid_user.msg != 'username must be SYSTEM, LOCAL SERVICE or NETWORK SERVICE when logon_type=service_account' - -- name: fail trigger with no type - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - delay: test - register: fail_trigger_no_type - failed_when: fail_trigger_no_type.msg != "a trigger entry must contain a key 'type' with a value of 'event', 'time', 'daily', 'weekly', 'monthly', 'monthlydow', 'idle', 'registration', 'boot', 'logon', 'session_state_change'" - -- name: fail trigger with datetime in incorrect format - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: time - start_boundary: fake - register: fail_trigger_invalid_datetime - failed_when: fail_trigger_invalid_datetime.msg != "trigger option 'start_boundary' must be in the format 'YYYY-MM-DDThh:mm:ss' format but was 'fake'" - -- name: fail trigger with duration in incorrect format - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: boot - execution_time_limit: fake - register: fail_trigger_invalid_duration - failed_when: fail_trigger_invalid_duration.msg != "trigger option 'execution_time_limit' must be in the XML duration format but was 'fake'" - -- name: fail trigger option invalid day of the week - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: weekly - start_boundary: '2000-01-01T00:00:01' - days_of_week: fakeday - register: fail_trigger_invalid_day_of_week - failed_when: fail_trigger_invalid_day_of_week.msg != "invalid day of week 'fakeday', check the spelling matches the full day name" - -- name: fail trigger option invalid day of the month - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: monthly - start_boundary: '2000-01-01T00:00:01' - days_of_month: 35 - register: fail_trigger_invalid_day_of_month - failed_when: fail_trigger_invalid_day_of_month.msg != "invalid day of month '35', please specify numbers from 1-31" - -- name: fail trigger option invalid week of the month - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: monthlydow - start_boundary: '2000-01-01T00:00:01' - weeks_of_month: 5 - register: fail_trigger_invalid_week_of_month - failed_when: fail_trigger_invalid_week_of_month.msg != "invalid week of month '5', please specify weeks from 1-4" - -- name: fail trigger option invalid month of the year - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: monthlydow - start_boundary: '2000-01-01T00:00:01' - months_of_year: fakemonth - register: fail_trigger_invalid_month_of_year - failed_when: fail_trigger_invalid_month_of_year.msg != "invalid month name 'fakemonth', please specify full month name" - -- name: fail trigger repetition with duration in incorrect format - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: boot - repetition: - - duration: fake - register: fail_trigger_repetition_invalid_duration - failed_when: fail_trigger_repetition_invalid_duration.msg != "trigger option 'duration' must be in the XML duration format but was 'fake'" - -- name: fail trigger repetition with interval in incorrect format - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: boot - repetition: - - interval: fake - register: fail_trigger_repetition_invalid_interval - failed_when: fail_trigger_repetition_invalid_interval.msg != "trigger option 'interval' must be in the XML duration format but was 'fake'" - -- name: fail trigger repetition option interval greater than duration - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - triggers: - - type: boot - repetition: - - interval: PT5M - duration: PT1M - register: fail_trigger_repetition_interval_greater_than_duration - failed_when: fail_trigger_repetition_interval_greater_than_duration.msg != "trigger repetition option 'interval' value 'PT5M' must be less than or equal to 'duration' value 'PT1M'" diff --git a/test/integration/targets/win_scheduled_task/tasks/main.yml b/test/integration/targets/win_scheduled_task/tasks/main.yml deleted file mode 100644 index 53b062c0b0..0000000000 --- a/test/integration/targets/win_scheduled_task/tasks/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -- name: remove test tasks before test - include_tasks: clean.yml - -- block: - - name: Test failure scenarios - include_tasks: failures.yml - - - name: Test normal scenarios - include_tasks: tests.yml - - - include_tasks: clean.yml - - - name: Test principals - include_tasks: principals.yml - - - include_tasks: clean.yml - - - name: Test triggers - include_tasks: triggers.yml - - always: - - name: remove test tasks after test - include_tasks: clean.yml diff --git a/test/integration/targets/win_scheduled_task/tasks/principals.yml b/test/integration/targets/win_scheduled_task/tasks/principals.yml deleted file mode 100644 index bc0b9e88ce..0000000000 --- a/test/integration/targets/win_scheduled_task/tasks/principals.yml +++ /dev/null @@ -1,436 +0,0 @@ ---- -- name: create test user - win_user: - name: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - state: present - groups: - - Administrators - -- name: task with password principal (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - logon_type: password - update_password: no - actions: - - path: cmd.exe - register: task_with_password_check - check_mode: yes - -- name: get result of task with password principal (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_password_result_check - -- name: assert results of task with password principal (check mode) - assert: - that: - - task_with_password_check is changed - - task_with_password_result_check.task_exists == False - -- name: task with password principal - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - logon_type: password - update_password: no - actions: - - path: cmd.exe - register: task_with_password - -- name: get result of task with password principal - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_password_result - -- name: assert results of task with password principal - assert: - that: - - task_with_password is changed - - task_with_password_result.task_exists == True - - task_with_password_result.principal.group_id == None - - task_with_password_result.principal.logon_type == "TASK_LOGON_PASSWORD" - - task_with_password_result.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_password_result.principal.user_id.endswith(test_scheduled_task_user) - -- name: task with password principal (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - logon_type: password - update_password: no - actions: - - path: cmd.exe - register: task_with_password_again - -- name: assert results of task with password principal (idempotent) - assert: - that: - - task_with_password_again is not changed - -- name: task with password principal force pass change - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - logon_type: password - update_password: yes - actions: - - path: cmd.exe - register: task_with_password_force_update - -- name: assert results of task with password principal force pass change - assert: - that: - - task_with_password_force_update is changed - -- name: task with s4u principal (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - logon_type: s4u - update_password: no - actions: - - path: cmd.exe - register: task_with_s4u_check - check_mode: yes - -- name: get result of task with s4u principal (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_s4u_result_check - -- name: assert results of task with s4u principal (check mode) - assert: - that: - - task_with_s4u_check is changed - - task_with_s4u_result_check.task_exists == True - - task_with_s4u_result_check.principal.group_id == None - - task_with_s4u_result_check.principal.logon_type == "TASK_LOGON_PASSWORD" - - task_with_s4u_result_check.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_s4u_result_check.principal.user_id.endswith(test_scheduled_task_user) - -- name: task with s4u principal - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - logon_type: s4u - update_password: no - actions: - - path: cmd.exe - register: task_with_s4u - -- name: get result of task with s4u principal - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_s4u_result - -- name: assert results of task with s4u principal - assert: - that: - - task_with_s4u is changed - - task_with_s4u_result.task_exists == True - - task_with_s4u_result.principal.group_id == None - - task_with_s4u_result.principal.logon_type == "TASK_LOGON_S4U" - - task_with_s4u_result.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_s4u_result.principal.user_id.endswith(test_scheduled_task_user) - -- name: task with s4u principal (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - password: '{{test_scheduled_task_pass}}' - logon_type: s4u - update_password: no - actions: - - path: cmd.exe - register: task_with_s4u_again - -- name: assert results of task with s4u principal (idempotent) - assert: - that: - - task_with_s4u_again is not changed - -- name: task with interactive principal (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - logon_type: interactive_token - actions: - - path: cmd.exe - register: task_with_interactive_check - check_mode: yes - -- name: get result of task with interactive principal (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_interactive_result_check - -- name: assert results of task with interactive principal (check mode) - assert: - that: - - task_with_interactive_check is changed - - task_with_interactive_result_check.task_exists == True - - task_with_interactive_result_check.principal.group_id == None - - task_with_interactive_result_check.principal.logon_type == "TASK_LOGON_S4U" - - task_with_interactive_result_check.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_interactive_result_check.principal.user_id.endswith(test_scheduled_task_user) - -- name: task with interactive principal - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - logon_type: interactive_token - actions: - - path: cmd.exe - register: task_with_interactive - -- name: get result of task with interactive principal - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_interactive_result - -- name: assert results of task with interactive principal - assert: - that: - - task_with_interactive is changed - - task_with_interactive_result.task_exists == True - - task_with_interactive_result.principal.group_id == None - - task_with_interactive_result.principal.logon_type == "TASK_LOGON_INTERACTIVE_TOKEN" - - task_with_interactive_result.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_interactive_result.principal.user_id.endswith(test_scheduled_task_user) - -- name: task with interactive principal (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: '{{test_scheduled_task_user}}' - logon_type: interactive_token - actions: - - path: cmd.exe - register: task_with_interactive_again - -- name: assert results of task with interactive principal (idempotent) - assert: - that: - - task_with_interactive_again is not changed - -- name: task with group principal (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - group: Administrators - logon_type: group - actions: - - path: cmd.exe - register: task_with_group_check - check_mode: yes - -- name: get result of task with group principal (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_group_result_check - -- name: assert results of task with group principal (check mode) - assert: - that: - - task_with_group_check is changed - - task_with_group_result_check.task_exists == True - - task_with_group_result_check.principal.group_id == None - - task_with_group_result_check.principal.logon_type == "TASK_LOGON_INTERACTIVE_TOKEN" - - task_with_group_result_check.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_group_result_check.principal.user_id.endswith(test_scheduled_task_user) - -- name: task with group principal - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - group: Administrators - logon_type: group - actions: - - path: cmd.exe - register: task_with_group - -- name: get result of task with group principal - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_group_result - -- name: assert results of task with group principal - assert: - that: - - task_with_group is changed - - task_with_group_result.task_exists == True - - task_with_group_result.principal.group_id == "BUILTIN\\Administrators" - - task_with_group_result.principal.logon_type == "TASK_LOGON_GROUP" - - task_with_group_result.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_group_result.principal.user_id == None - -- name: task with group principal (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - group: Administrators - logon_type: group - actions: - - path: cmd.exe - register: task_with_group_again - -- name: assert results of task with group principal (idempotent) - assert: - that: - - task_with_group_again is not changed - -- name: task with service account principal (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: System - logon_type: service_account - action: - - path: cmd.exe - register: task_with_service_check - check_mode: yes - -- name: get result of task with service account principal (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_service_result_check - -- name: assert results of task with service account principal (check mode) - assert: - that: - - task_with_service_check is changed - - task_with_service_result_check.task_exists == True - - task_with_service_result_check.principal.group_id == "BUILTIN\\Administrators" - - task_with_service_result_check.principal.logon_type == "TASK_LOGON_GROUP" - - task_with_service_result_check.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_service_result_check.principal.user_id == None - -- name: task with service account principal - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: System - logon_type: service_account - action: - - path: cmd.exe - register: task_with_service - -- name: get result of task with service account principal - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_service_result - -- name: assert results of task with service account principal - assert: - that: - - task_with_service is changed - - task_with_service_result.task_exists == True - - task_with_service_result.principal.group_id == None - - task_with_service_result.principal.logon_type == "TASK_LOGON_SERVICE_ACCOUNT" - - task_with_service_result.principal.run_level == "TASK_RUNLEVEL_LUA" - - task_with_service_result.principal.user_id == "NT AUTHORITY\\SYSTEM" - -- name: task with service account principal (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - username: System - logon_type: service_account - action: - - path: cmd.exe - register: task_with_service_again - -- name: assert results of task with service account principal (idempotent) - assert: - that: - - task_with_service_again is not changed - -- name: task with highest privilege (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - run_level: highest - username: System - logon_type: service_account - action: - - path: cmd.exe - register: task_with_highest_privilege_check - check_mode: yes - -- name: get result of task with highest privilege (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_highest_privilege_result_check - -- name: assert results of task with highest privilege (check mode) - assert: - that: - - task_with_highest_privilege_check is changed - - task_with_highest_privilege_result_check.principal.run_level == "TASK_RUNLEVEL_LUA" - -- name: task with highest privilege - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - run_level: highest - username: System - logon_type: service_account - action: - - path: cmd.exe - register: task_with_highest_privilege - -- name: get result of task with highest privilege - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: task_with_highest_privilege_result - -- name: assert results of task with highest privilege - assert: - that: - - task_with_highest_privilege is changed - - task_with_highest_privilege_result.principal.run_level == "TASK_RUNLEVEL_HIGHEST" - -- name: task with highest privilege (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - run_level: highest - username: System - logon_type: service_account - action: - - path: cmd.exe - register: task_with_highest_privilege_again - -- name: assert results of task with highest privilege (idempotent) - assert: - that: - - task_with_highest_privilege_again is not changed diff --git a/test/integration/targets/win_scheduled_task/tasks/tests.yml b/test/integration/targets/win_scheduled_task/tasks/tests.yml deleted file mode 100644 index b4ed29e49f..0000000000 --- a/test/integration/targets/win_scheduled_task/tasks/tests.yml +++ /dev/null @@ -1,440 +0,0 @@ ---- -- name: create task (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - arguments: /c echo hi - description: Original Description - register: create_task_check - check_mode: yes - -- name: get result of create task (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: create_task_result_check - -- name: assert results of create task (check mode) - assert: - that: - - create_task_check is changed - - create_task_result_check.task_exists == False - -- name: create task - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - arguments: /c echo hi - description: Original Description - register: create_task - -- name: get result of create task - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: create_task_result - -- name: assert results of create task - assert: - that: - - create_task is changed - - create_task_result.task_exists == True - - create_task_result.actions|count == 1 - - create_task_result.actions[0].path == "cmd.exe" - - create_task_result.actions[0].arguments == "/c echo hi" - - create_task_result.actions[0].working_directory == None - - create_task_result.registration_info.description == "Original Description" - - create_task_result.triggers|count == 0 - -- name: create task (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - arguments: /c echo hi - description: Original Description - register: create_task_again - -- name: assert results of create task (idempotent) - assert: - that: - - create_task_again is not changed - -- name: change task (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - author: Cow Inc. - description: Test for Ansible - allow_demand_start: no - restart_count: 5 - restart_interval: PT2H5M - register: change_task_check - check_mode: yes - -- name: get result of change task (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: change_task_result_check - -- name: assert results of change task (check mode) - assert: - that: - - change_task_check is changed - - change_task_result_check.actions|count == 1 - - change_task_result_check.registration_info.author == None - - change_task_result_check.registration_info.description == "Original Description" - - change_task_result_check.settings.allow_demand_start == true - - change_task_result_check.settings.restart_count == 0 - - change_task_result_check.settings.restart_interval == None - -- name: change task - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - author: Cow Inc. - description: Test for Ansible - allow_demand_start: no - restart_count: 5 - restart_interval: PT1M - register: change_task - -- name: get result of change task - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: change_task_result - -- name: assert results of change task - assert: - that: - - change_task is changed - - change_task_result.actions|count == 1 - - change_task_result.registration_info.author == "Cow Inc." - - change_task_result.registration_info.description == "Test for Ansible" - - change_task_result.settings.allow_demand_start == false - - change_task_result.settings.restart_count == 5 - - change_task_result.settings.restart_interval == "PT1M" - -- name: change task (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - author: Cow Inc. - description: Test for Ansible - allow_demand_start: no - restart_count: 5 - restart_interval: PT1M - register: change_task_again - -- name: assert results of change task (idempotent) - assert: - that: - - change_task_again is not changed - -- name: add task action (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - arguments: /c echo hi - - path: powershell.exe - arguments: -File C:\ansible\script.ps1 - working_directory: C:\ansible - register: add_task_action_check - check_mode: yes - -- name: get result of add task action (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: add_task_action_result_check - -- name: assert results of add task action (check mode) - assert: - that: - - add_task_action_check is changed - - add_task_action_result_check.actions|count == 1 - - add_task_action_result_check.actions[0].path == "cmd.exe" - - add_task_action_result_check.actions[0].arguments == "/c echo hi" - - add_task_action_result_check.actions[0].working_directory == None - -- name: add task action - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - arguments: /c echo hi - - path: powershell.exe - arguments: -File C:\ansible\script.ps1 - working_directory: C:\ansible - register: add_task_action - -- name: get result of add task action - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: add_task_action_result - -- name: assert results of add task action - assert: - that: - - add_task_action is changed - - add_task_action_result.actions|count == 2 - - add_task_action_result.actions[0].path == "cmd.exe" - - add_task_action_result.actions[0].arguments == "/c echo hi" - - add_task_action_result.actions[0].working_directory == None - - add_task_action_result.actions[1].path == "powershell.exe" - - add_task_action_result.actions[1].arguments == "-File C:\\ansible\\script.ps1" - - add_task_action_result.actions[1].working_directory == "C:\\ansible" - -- name: add task action (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - arguments: /c echo hi - - path: powershell.exe - arguments: -File C:\ansible\script.ps1 - working_directory: C:\ansible - register: add_task_action_again - -- name: assert results of add task action (idempotent) - assert: - that: - - add_task_action_again is not changed - -- name: remove task action (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: powershell.exe - arguments: -File C:\ansible\script.ps1 - working_directory: C:\ansible - register: remove_task_action_check - check_mode: yes - -- name: get result of remove task action (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_task_action_result_check - -- name: assert results of remove task action (check mode) - assert: - that: - - remove_task_action_check is changed - - remove_task_action_result_check.actions|count == 2 - - remove_task_action_result_check.actions[0].path == "cmd.exe" - - remove_task_action_result_check.actions[0].arguments == "/c echo hi" - - remove_task_action_result_check.actions[0].working_directory == None - - remove_task_action_result_check.actions[1].path == "powershell.exe" - - remove_task_action_result_check.actions[1].arguments == "-File C:\\ansible\\script.ps1" - - remove_task_action_result_check.actions[1].working_directory == "C:\\ansible" - -- name: remove task action - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: powershell.exe - arguments: -File C:\ansible\script.ps1 - working_directory: C:\ansible - register: remove_task_action - -- name: get result of remove task action - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_task_action_result - -- name: assert results of remove task action - assert: - that: - - remove_task_action is changed - - remove_task_action_result.actions|count == 1 - - remove_task_action_result.actions[0].path == "powershell.exe" - - remove_task_action_result.actions[0].arguments == "-File C:\\ansible\\script.ps1" - - remove_task_action_result.actions[0].working_directory == "C:\\ansible" - -- name: remove task action (idempontent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: powershell.exe - arguments: -File C:\ansible\script.ps1 - working_directory: C:\ansible - register: remove_task_action_again - -- name: assert results of remove task action (idempotent) - assert: - that: - - remove_task_action_again is not changed - -- name: remove task (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: absent - register: remove_task_check - check_mode: yes - -- name: get result of remove task (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_task_result_check - -- name: assert results of remove task (check mode) - assert: - that: - - remove_task_check is changed - - remove_task_result_check.task_exists == True - -- name: remove task - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: absent - register: remove_task - -- name: get result of remove task - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_task_result - -- name: assert results of remove task - assert: - that: - - remove_task is changed - - remove_task_result.task_exists == False - -- name: remove task (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: absent - register: remove_task_again - -- name: assert results of remove task (idempotent) - assert: - that: - - remove_task_again is not changed - -- name: create sole task in folder (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - path: '{{test_scheduled_task_path}}' - actions: - - path: cmd.exe - register: create_sole_task_check - check_mode: yes - -- name: get result of create sole task in folder (check mode) - win_scheduled_task_stat: - path: '{{test_scheduled_task_path}}' - name: '{{test_scheduled_task_name}}' - register: create_sole_task_result_check - -- name: assert results of create sole task in folder (check mode) - assert: - that: - - create_sole_task_check is changed - - create_sole_task_result_check.folder_exists == False - - create_sole_task_result_check.task_exists == False - -- name: create sole task in folder - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - path: '{{test_scheduled_task_path}}' - actions: - - path: cmd.exe - register: create_sole_task - -- name: get result of create sole task in folder - win_scheduled_task_stat: - path: '{{test_scheduled_task_path}}' - name: '{{test_scheduled_task_name}}' - register: create_sole_task_result - -- name: assert results of create sole task in folder - assert: - that: - - create_sole_task is changed - - create_sole_task_result.folder_exists == True - - create_sole_task_result.task_exists == True - -- name: create sole task in folder (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - path: '{{test_scheduled_task_path}}' - actions: - - path: cmd.exe - register: create_sole_task_again - -- name: assert results of create sole task in folder (idempotent) - assert: - that: - - create_sole_task_again is not changed - -- name: remove sole task in folder (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - path: '{{test_scheduled_task_path}}' - state: absent - register: remove_sole_task_check - check_mode: yes - -- name: get result of remove sole task in folder (check mode) - win_scheduled_task_stat: - path: '{{test_scheduled_task_path}}' - name: '{{test_scheduled_task_name}}' - register: remove_sole_task_result_check - -- name: assert results of remove sole task in folder (check mode) - assert: - that: - - remove_sole_task_check is changed - - remove_sole_task_result_check.folder_exists == True - - remove_sole_task_result_check.task_exists == True - -- name: remove sole task in folder - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - path: '{{test_scheduled_task_path}}' - state: absent - register: remove_sole_task - -- name: get result of remove sole task in folder - win_scheduled_task_stat: - path: '{{test_scheduled_task_path}}' - name: '{{test_scheduled_task_name}}' - register: remove_sole_task_result - -- name: assert results of remove sole task in folder - assert: - that: - - remove_sole_task is changed - - remove_sole_task_result.folder_exists == False - - remove_sole_task_result.task_exists == False - -- name: remove sole task in folder (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - path: '{{test_scheduled_task_path}}' - state: absent - register: remove_sole_task_again - -- name: assert results of remove sole task in folder (idempotent) - assert: - that: - - remove_sole_task_again is not changed diff --git a/test/integration/targets/win_scheduled_task/tasks/triggers.yml b/test/integration/targets/win_scheduled_task/tasks/triggers.yml deleted file mode 100644 index 15b274aede..0000000000 --- a/test/integration/targets/win_scheduled_task/tasks/triggers.yml +++ /dev/null @@ -1,818 +0,0 @@ ---- -- name: create boot trigger (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: boot - register: trigger_boot_check - check_mode: yes - -- name: get result of create boot trigger (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_boot_result_check - -- name: assert results of create boot trigger (check mode) - assert: - that: - - trigger_boot_check is changed - - trigger_boot_result_check.task_exists == False - -- name: create boot trigger - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: boot - register: trigger_boot - -- name: get result of create boot trigger - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_boot_result - -- name: assert results of create boot trigger - assert: - that: - - trigger_boot is changed - - trigger_boot_result.task_exists == True - - trigger_boot_result.triggers|count == 1 - - trigger_boot_result.triggers[0].type == "TASK_TRIGGER_BOOT" - - trigger_boot_result.triggers[0].enabled == True - - trigger_boot_result.triggers[0].start_boundary == None - - trigger_boot_result.triggers[0].end_boundary == None - -- name: create boot trigger (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: boot - register: trigger_boot_again - -- name: assert results of create boot trigger (idempotent) - assert: - that: - - trigger_boot_again is not changed - -- name: create daily trigger (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: daily - start_boundary: '2000-01-01T00:00:01' - register: trigger_daily_check - check_mode: yes - -- name: get result of create daily trigger (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_daily_result_check - -- name: assert results of create daily trigger (check mode) - assert: - that: - - trigger_daily_check is changed - - trigger_daily_result_check.task_exists == True - - trigger_daily_result_check.triggers|count == 1 - - trigger_daily_result_check.triggers[0].type == "TASK_TRIGGER_BOOT" - - trigger_daily_result_check.triggers[0].enabled == True - - trigger_daily_result_check.triggers[0].start_boundary == None - - trigger_daily_result_check.triggers[0].end_boundary == None - -- name: create daily trigger - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: daily - start_boundary: '2000-01-01T00:00:01' - register: trigger_daily - -- name: get result of create daily trigger - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_daily_result - -- name: assert results of create daily trigger - assert: - that: - - trigger_daily is changed - - trigger_daily_result.task_exists == True - - trigger_daily_result.triggers|count == 1 - - trigger_daily_result.triggers[0].type == "TASK_TRIGGER_DAILY" - - trigger_daily_result.triggers[0].enabled == True - - trigger_daily_result.triggers[0].start_boundary == "2000-01-01T00:00:01" - - trigger_daily_result.triggers[0].end_boundary == None - -- name: create daily trigger (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: daily - start_boundary: '2000-01-01T00:00:01' - register: trigger_daily_again - -- name: assert results of create daily trigger (idempotent) - assert: - that: - - trigger_daily_again is not changed - -- name: create logon trigger (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: logon - register: trigger_logon_check - check_mode: yes - -- name: get result of create logon trigger (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_logon_result_check - -- name: assert results of create logon trigger - assert: - that: - - trigger_logon_check is changed - - trigger_logon_result_check.task_exists == True - - trigger_logon_result_check.triggers|count == 1 - - trigger_logon_result_check.triggers[0].type == "TASK_TRIGGER_DAILY" - - trigger_logon_result_check.triggers[0].enabled == True - - trigger_logon_result_check.triggers[0].start_boundary == "2000-01-01T00:00:01" - - trigger_logon_result_check.triggers[0].end_boundary == None - -- name: create logon trigger - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: logon - register: trigger_logon - -- name: get result of create logon trigger - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_logon_result - -- name: assert results of create logon trigger - assert: - that: - - trigger_logon is changed - - trigger_logon_result.task_exists == True - - trigger_logon_result.triggers|count == 1 - - trigger_logon_result.triggers[0].type == "TASK_TRIGGER_LOGON" - - trigger_logon_result.triggers[0].enabled == True - - trigger_logon_result.triggers[0].start_boundary == None - - trigger_logon_result.triggers[0].end_boundary == None - -- name: create logon trigger (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: logon - register: trigger_logon_again - -- name: assert results of create logon trigger (idempotent) - assert: - that: - - trigger_logon_again is not changed - -- name: create monthly dow trigger (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: monthlydow - start_boundary: '2000-01-01T00:00:01' - weeks_of_month: 1,2 - days_of_week: [ "monday", "wednesday" ] - register: trigger_monthlydow_check - check_mode: yes - -- name: get result of create monthly dow trigger (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_monthlydow_result_check - -- name: assert results of create monthly dow trigger (check mode) - assert: - that: - - trigger_monthlydow_check is changed - - trigger_monthlydow_result_check.task_exists == True - - trigger_monthlydow_result_check.triggers|count == 1 - - trigger_monthlydow_result_check.triggers[0].type == "TASK_TRIGGER_LOGON" - - trigger_monthlydow_result_check.triggers[0].enabled == True - - trigger_monthlydow_result_check.triggers[0].start_boundary == None - - trigger_monthlydow_result_check.triggers[0].end_boundary == None - -- name: create monthly dow trigger - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: monthlydow - start_boundary: '2000-01-01T00:00:01+03:00' - weeks_of_month: 1,2 - days_of_week: [ "monday", "wednesday" ] - register: trigger_monthlydow - -- name: get result of create monthly dow trigger - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: trigger_monthlydow_result - -- name: assert results of create monthly dow trigger - assert: - that: - - trigger_monthlydow is changed - - trigger_monthlydow_result.task_exists == True - - trigger_monthlydow_result.triggers|count == 1 - - trigger_monthlydow_result.triggers[0].type == "TASK_TRIGGER_MONTHLYDOW" - - trigger_monthlydow_result.triggers[0].enabled == True - - trigger_monthlydow_result.triggers[0].start_boundary == "1999-12-31T21:00:01+00:00" - - trigger_monthlydow_result.triggers[0].end_boundary == None - - trigger_monthlydow_result.triggers[0].weeks_of_month == "1,2" - - trigger_monthlydow_result.triggers[0].days_of_week == "monday,wednesday" - -- name: create monthly dow trigger (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: monthlydow - start_boundary: '2000-01-01T00:00:01+03:00' - weeks_of_month: 1,2 - days_of_week: [ "monday", "wednesday" ] - register: trigger_monthlydow_again - -- name: assert results of create monthly dow trigger (idempotent) - assert: - that: - - trigger_monthlydow_again is not changed - -- name: create trigger repetition (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - repetition: - # TODO: change to dict in 2.12 as a list format is deprecated - - interval: PT1M - duration: PT5M - stop_at_duration_end: yes - register: create_trigger_repetition_check - check_mode: yes - -- name: get result of create trigger repetition (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: create_trigger_repetition_result_check - -- name: assert results of create trigger repetition (check mode) - assert: - that: - - create_trigger_repetition_check is changed - - create_trigger_repetition_check.deprecations|count == 1 - - create_trigger_repetition_check.deprecations[0].version == "2.12" - - create_trigger_repetition_check.deprecations[0].msg == "repetition is a list, should be defined as a dict" - - create_trigger_repetition_result_check.task_exists == True - - create_trigger_repetition_result_check.triggers|count == 1 - - create_trigger_repetition_result_check.triggers[0].type == "TASK_TRIGGER_MONTHLYDOW" - - create_trigger_repetition_result_check.triggers[0].enabled == True - - create_trigger_repetition_result_check.triggers[0].start_boundary == "1999-12-31T21:00:01+00:00" - - create_trigger_repetition_result_check.triggers[0].end_boundary == None - - create_trigger_repetition_result_check.triggers[0].weeks_of_month == "1,2" - - create_trigger_repetition_result_check.triggers[0].days_of_week == "monday,wednesday" - - create_trigger_repetition_result_check.triggers[0].repetition.interval == None - - create_trigger_repetition_result_check.triggers[0].repetition.duration == None - - create_trigger_repetition_result_check.triggers[0].repetition.stop_at_duration_end == False - -- name: create trigger repetition - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - repetition: - interval: PT1M - duration: PT5M - stop_at_duration_end: yes - register: create_trigger_repetition - -- name: get result of create trigger repetition - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: create_trigger_repetition_result - -- name: assert results of create trigger repetition - assert: - that: - - create_trigger_repetition is changed - - create_trigger_repetition_result.task_exists == True - - create_trigger_repetition_result.triggers|count == 1 - - create_trigger_repetition_result.triggers[0].type == "TASK_TRIGGER_REGISTRATION" - - create_trigger_repetition_result.triggers[0].enabled == True - - create_trigger_repetition_result.triggers[0].start_boundary == None - - create_trigger_repetition_result.triggers[0].end_boundary == None - - create_trigger_repetition_result.triggers[0].repetition.interval == "PT1M" - - create_trigger_repetition_result.triggers[0].repetition.duration == "PT5M" - - create_trigger_repetition_result.triggers[0].repetition.stop_at_duration_end == True - -- name: create trigger repetition (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - repetition: - interval: PT1M - duration: PT5M - stop_at_duration_end: yes - register: create_trigger_repetition_again - -- name: assert results of create trigger repetition (idempotent) - assert: - that: - - create_trigger_repetition_again is not changed - -- name: change trigger repetition (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - repetition: - interval: PT10M - duration: PT20M - stop_at_duration_end: no - register: change_trigger_repetition_check - check_mode: yes - -- name: get result of change trigger repetition (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: change_trigger_repetition_result_check - -- name: assert results of change trigger repetition (check mode) - assert: - that: - - change_trigger_repetition_check is changed - - change_trigger_repetition_result_check.task_exists == True - - change_trigger_repetition_result_check.triggers|count == 1 - - change_trigger_repetition_result_check.triggers[0].type == "TASK_TRIGGER_REGISTRATION" - - change_trigger_repetition_result_check.triggers[0].enabled == True - - change_trigger_repetition_result_check.triggers[0].start_boundary == None - - change_trigger_repetition_result_check.triggers[0].end_boundary == None - - change_trigger_repetition_result_check.triggers[0].repetition.interval == "PT1M" - - change_trigger_repetition_result_check.triggers[0].repetition.duration == "PT5M" - - change_trigger_repetition_result_check.triggers[0].repetition.stop_at_duration_end == True - -- name: change trigger repetition - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - repetition: - interval: PT10M - duration: PT20M - stop_at_duration_end: no - register: change_trigger_repetition - -- name: get result of change trigger repetition - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: change_trigger_repetition_result - -- name: assert results of change trigger repetition - assert: - that: - - change_trigger_repetition is changed - - change_trigger_repetition_result.task_exists == True - - change_trigger_repetition_result.triggers|count == 1 - - change_trigger_repetition_result.triggers[0].type == "TASK_TRIGGER_REGISTRATION" - - change_trigger_repetition_result.triggers[0].enabled == True - - change_trigger_repetition_result.triggers[0].start_boundary == None - - change_trigger_repetition_result.triggers[0].end_boundary == None - - change_trigger_repetition_result.triggers[0].repetition.interval == "PT10M" - - change_trigger_repetition_result.triggers[0].repetition.duration == "PT20M" - - change_trigger_repetition_result.triggers[0].repetition.stop_at_duration_end == False - -- name: change trigger repetition (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - repetition: - interval: PT10M - duration: PT20M - stop_at_duration_end: no - register: change_trigger_repetition_again - -- name: assert results of change trigger repetition (idempotent) - assert: - that: - - change_trigger_repetition_again is not changed - -- name: create task with multiple triggers (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: monthly - days_of_month: 1,5,10,15,20,25,30 - run_on_last_day_of_month: true - start_boundary: '2000-01-01T00:00:01' - months_of_year: - - march - - may - - july - - type: time - start_boundary: '2000-01-01T00:00:01' - random_delay: PT10M5S - register: create_multiple_triggers_check - check_mode: yes - -- name: get result of create task with multiple triggers (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: create_multiple_triggers_result_check - -- name: assert results of create task with multiple triggers (check mode) - assert: - that: - - create_multiple_triggers_check is changed - - create_multiple_triggers_result_check.task_exists == True - - create_multiple_triggers_result_check.triggers|count == 1 - - create_multiple_triggers_result_check.triggers[0].type == "TASK_TRIGGER_REGISTRATION" - - create_multiple_triggers_result_check.triggers[0].enabled == True - - create_multiple_triggers_result_check.triggers[0].start_boundary == None - - create_multiple_triggers_result_check.triggers[0].end_boundary == None - - create_multiple_triggers_result_check.triggers[0].repetition.interval == "PT10M" - - create_multiple_triggers_result_check.triggers[0].repetition.duration == "PT20M" - - create_multiple_triggers_result_check.triggers[0].repetition.stop_at_duration_end == False - -- name: create task with multiple triggers - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: monthly - days_of_month: 1,5,10,15,20,25,30 - run_on_last_day_of_month: true - start_boundary: '2000-01-01T00:00:01' - months_of_year: - - march - - may - - july - - type: time - start_boundary: '2000-01-01T00:00:01' - random_delay: PT10M5S - register: create_multiple_triggers - -- name: get result of create task with multiple triggers - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: create_multiple_triggers_result - -- name: assert results of create task with multiple triggers - assert: - that: - - create_multiple_triggers is changed - - create_multiple_triggers_result.task_exists == True - - create_multiple_triggers_result.triggers|count == 2 - - create_multiple_triggers_result.triggers[0].type == "TASK_TRIGGER_MONTHLY" - - create_multiple_triggers_result.triggers[0].enabled == True - - create_multiple_triggers_result.triggers[0].start_boundary == "2000-01-01T00:00:01" - - create_multiple_triggers_result.triggers[0].end_boundary == None - - create_multiple_triggers_result.triggers[0].days_of_month == "1,5,10,15,20,25,30" - - create_multiple_triggers_result.triggers[0].months_of_year == "march,may,july" - - create_multiple_triggers_result.triggers[0].run_on_last_day_of_month == True - - create_multiple_triggers_result.triggers[1].type == "TASK_TRIGGER_TIME" - - create_multiple_triggers_result.triggers[1].enabled == True - - create_multiple_triggers_result.triggers[1].start_boundary == "2000-01-01T00:00:01" - - create_multiple_triggers_result.triggers[1].end_boundary == None - - create_multiple_triggers_result.triggers[1].random_delay == "PT10M5S" - -- name: create task with multiple triggers (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: monthly - days_of_month: 1,5,10,15,20,25,30 - run_on_last_day_of_month: true - start_boundary: '2000-01-01T00:00:01' - months_of_year: - - march - - may - - july - - type: time - start_boundary: '2000-01-01T00:00:01' - random_delay: PT10M5S - register: create_multiple_triggers_again - -- name: assert results of create task with multiple triggers (idempotent) - assert: - that: - - create_multiple_triggers_again is not changed - -- name: change task with multiple triggers (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: weekly - days_of_week: tuesday,friday - start_boundary: '2000-01-01T00:00:01' - - type: registration - enabled: no - register: change_multiple_triggers_check - check_mode: yes - -- name: get result of change task with multiple triggers (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: change_multiple_triggers_result_check - -- name: assert results of change task with multiple triggers (check mode) - assert: - that: - - change_multiple_triggers_check is changed - - change_multiple_triggers_result_check.task_exists == True - - change_multiple_triggers_result_check.triggers|count == 2 - - change_multiple_triggers_result_check.triggers[0].type == "TASK_TRIGGER_MONTHLY" - - change_multiple_triggers_result_check.triggers[0].enabled == True - - change_multiple_triggers_result_check.triggers[0].start_boundary == "2000-01-01T00:00:01" - - change_multiple_triggers_result_check.triggers[0].end_boundary == None - - change_multiple_triggers_result_check.triggers[0].days_of_month == "1,5,10,15,20,25,30" - - change_multiple_triggers_result_check.triggers[0].months_of_year == "march,may,july" - - change_multiple_triggers_result_check.triggers[0].run_on_last_day_of_month == True - - change_multiple_triggers_result_check.triggers[1].type == "TASK_TRIGGER_TIME" - - change_multiple_triggers_result_check.triggers[1].enabled == True - - change_multiple_triggers_result_check.triggers[1].start_boundary == "2000-01-01T00:00:01" - - change_multiple_triggers_result_check.triggers[1].end_boundary == None - - change_multiple_triggers_result_check.triggers[1].random_delay == "PT10M5S" - -- name: change task with multiple triggers - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: weekly - days_of_week: tuesday,friday - start_boundary: '2000-01-01T00:00:01' - - type: registration - enabled: no - register: change_multiple_triggers - -- name: get result of change task with multiple triggers - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: change_multiple_triggers_result - -- name: assert results of change task with multiple triggers - assert: - that: - - change_multiple_triggers is changed - - change_multiple_triggers_result.task_exists == True - - change_multiple_triggers_result.triggers|count == 2 - - change_multiple_triggers_result.triggers[0].type == "TASK_TRIGGER_WEEKLY" - - change_multiple_triggers_result.triggers[0].enabled == True - - change_multiple_triggers_result.triggers[0].start_boundary == "2000-01-01T00:00:01" - - change_multiple_triggers_result.triggers[0].end_boundary == None - - change_multiple_triggers_result.triggers[0].days_of_week == "tuesday,friday" - - change_multiple_triggers_result.triggers[1].type == "TASK_TRIGGER_REGISTRATION" - - change_multiple_triggers_result.triggers[1].enabled == False - - change_multiple_triggers_result.triggers[1].start_boundary == None - - change_multiple_triggers_result.triggers[1].end_boundary == None - -- name: change task with multiple triggers (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: weekly - days_of_week: tuesday,friday - start_boundary: '2000-01-01T00:00:01' - - type: registration - enabled: no - register: change_multiple_triggers_again - -- name: assert results of change task with multiple triggers (idempotent) - assert: - that: - - change_multiple_triggers_again is not changed - -- name: remove trigger from multiple triggers (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - enabled: no - register: remove_single_trigger_check - check_mode: yes - -- name: get result of remove trigger from multiple triggers (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_single_trigger_result_check - -- name: assert results of remove trigger from multiple triggers (check mode) - assert: - that: - - remove_single_trigger_check is changed - - remove_single_trigger_result_check.task_exists == True - - remove_single_trigger_result_check.triggers|count == 2 - - remove_single_trigger_result_check.triggers[0].type == "TASK_TRIGGER_WEEKLY" - - remove_single_trigger_result_check.triggers[0].enabled == True - - remove_single_trigger_result_check.triggers[0].start_boundary == "2000-01-01T00:00:01" - - remove_single_trigger_result_check.triggers[0].end_boundary == None - - remove_single_trigger_result_check.triggers[0].days_of_week == "tuesday,friday" - - remove_single_trigger_result_check.triggers[1].type == "TASK_TRIGGER_REGISTRATION" - - remove_single_trigger_result_check.triggers[1].enabled == False - - remove_single_trigger_result_check.triggers[1].start_boundary == None - - remove_single_trigger_result_check.triggers[1].end_boundary == None - -- name: remove trigger from multiple triggers - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - enabled: no - register: remove_single_trigger - -- name: get result of remove trigger from multiple triggers - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_single_trigger_result - -- name: assert results of remove trigger from multiple triggers - assert: - that: - - remove_single_trigger is changed - - remove_single_trigger_result.task_exists == True - - remove_single_trigger_result.triggers|count == 1 - - remove_single_trigger_result.triggers[0].type == "TASK_TRIGGER_REGISTRATION" - - remove_single_trigger_result.triggers[0].enabled == False - - remove_single_trigger_result.triggers[0].start_boundary == None - - remove_single_trigger_result.triggers[0].end_boundary == None - -- name: remove trigger from multiple triggers (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: - - type: registration - enabled: no - register: remove_single_trigger_again - -- name: assert results of remove trigger from multiple triggers (idempotent) - assert: - that: - - remove_single_trigger_again is not changed - -- name: remove all triggers (check mode) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: [] - register: remove_triggers_check - check_mode: yes - -- name: get result of remove all triggers (check mode) - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_triggers_result_check - -- name: assert results of remove all triggers (check mode) - assert: - that: - - remove_triggers_check is changed - - remove_triggers_result_check.task_exists == True - - remove_triggers_result_check.triggers|count == 1 - - remove_triggers_result_check.triggers[0].type == "TASK_TRIGGER_REGISTRATION" - - remove_triggers_result_check.triggers[0].enabled == False - - remove_triggers_result_check.triggers[0].start_boundary == None - - remove_triggers_result_check.triggers[0].end_boundary == None - -- name: remove all triggers - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: [] - register: remove_triggers - -- name: get result of remove all triggers - win_scheduled_task_stat: - path: \ - name: '{{test_scheduled_task_name}}' - register: remove_triggers_result - -- name: assert results of remove all triggers - assert: - that: - - remove_triggers is changed - - remove_triggers_result.task_exists == True - - remove_triggers_result.triggers|count == 0 - -- name: remove all triggers (idempotent) - win_scheduled_task: - name: '{{test_scheduled_task_name}}' - state: present - actions: - - path: cmd.exe - triggers: [] - register: remove_triggers_again - -- name: assert results of remove all triggers (idempotent) - assert: - that: - - remove_triggers_again is not changed diff --git a/test/integration/targets/win_scheduled_task_stat/aliases b/test/integration/targets/win_scheduled_task_stat/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_scheduled_task_stat/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_scheduled_task_stat/defaults/main.yml b/test/integration/targets/win_scheduled_task_stat/defaults/main.yml deleted file mode 100644 index 24efaf0de7..0000000000 --- a/test/integration/targets/win_scheduled_task_stat/defaults/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -test_scheduled_task_stat_name: Test Task -test_scheduled_task_stat_path: \test path diff --git a/test/integration/targets/win_scheduled_task_stat/tasks/main.yml b/test/integration/targets/win_scheduled_task_stat/tasks/main.yml deleted file mode 100644 index ee78abb0c0..0000000000 --- a/test/integration/targets/win_scheduled_task_stat/tasks/main.yml +++ /dev/null @@ -1,176 +0,0 @@ ---- -- name: Look up built-in Administrator account name (-500 user whose domain == computer name) - raw: $machine_sid = (Get-CimInstance Win32_UserAccount -Filter "Domain='$env:COMPUTERNAME'")[0].SID -replace '(S-1-5-21-\d+-\d+-\d+)-\d+', '$1'; (Get-CimInstance Win32_UserAccount -Filter "SID='$machine_sid-500'").Name - check_mode: no - register: admin_account_result - -- set_fact: - admin_account_name: "{{ admin_account_result.stdout_lines[0] }}" - -- name: ensure task is deleted before test - win_scheduled_task: - name: '{{test_scheduled_task_stat_name}}' - path: '{{test_scheduled_task_stat_path}}' - state: absent - -# folder stat tests -- name: get stat of a folder that is missing - win_scheduled_task_stat: - path: '{{test_scheduled_task_stat_path}}' - register: stat_folder_missing - -- name: assert get stat of a folder that is missing - assert: - that: - - stat_folder_missing.folder_exists == False - -- name: get stat of existing folder - win_scheduled_task_stat: - path: \ - register: stat_folder_present - -- name: assert get stat of existing folder - assert: - that: - - stat_folder_present.folder_exists == True - - stat_folder_present.folder_task_count is defined - - stat_folder_present.folder_task_names is defined - -- name: create scheduled task in folder - win_scheduled_task: - path: '{{test_scheduled_task_stat_path}}' - name: '{{test_scheduled_task_stat_name}}' - state: present - logon_type: interactive_token - username: '{{ admin_account_name }}' - author: Ansible Author - description: Fake description - execution_time_limit: PT23H - disallow_start_if_on_batteries: false - restart_count: 3 - restart_interval: PT15M - actions: - - path: cmd.exe - - path: C:\temp\some.exe - arguments: --help - working_directory: C:\temp - triggers: - - type: boot - delay: PT15M - - type: monthly - days_of_month: 5,15,30 - months_of_year: june,december - run_on_last_day_of_month: true - start_boundary: '2017-09-20T03:44:38' - -- name: get stat of existing folder with task - win_scheduled_task_stat: - path: '{{test_scheduled_task_stat_path}}' - register: stat_folder_with_task - -- name: assert get stat of existing folder with task - assert: - that: - - stat_folder_with_task.folder_exists == True - - stat_folder_with_task.folder_task_count == 1 - - stat_folder_with_task.folder_task_names[0] == "Test Task" - - stat_folder_with_task.task_exists is not defined - -# task stat tests -- name: get stat of missing task with invalid folder - win_scheduled_task_stat: - path: fake path - name: fake task - register: stat_task_missing_folder - -- name: assert get stat of missing task with invalid folder - assert: - that: - - stat_task_missing_folder.folder_exists == False - - stat_task_missing_folder.task_exists == False - -- name: get stat of missing task - win_scheduled_task_stat: - path: '{{test_scheduled_task_stat_path}}' - name: fake task - register: stat_task_missing - -- name: assert get stat of missing task - assert: - that: - - stat_task_missing.task_exists == False - -- name: get stat of existing task - win_scheduled_task_stat: - path: '{{test_scheduled_task_stat_path}}' - name: '{{test_scheduled_task_stat_name}}' - register: stat_task_present - -- name: assert get stat of existing task - assert: - that: - - stat_task_present.task_exists == True - - stat_task_present.actions|count == 2 - - stat_task_present.actions[0].path == "cmd.exe" - - stat_task_present.actions[0].type == "TASK_ACTION_EXEC" - - stat_task_present.actions[0].working_directory == None - - stat_task_present.actions[1].arguments == "--help" - - stat_task_present.actions[1].path == "C:\\temp\some.exe" - - stat_task_present.actions[1].type == "TASK_ACTION_EXEC" - - stat_task_present.actions[1].working_directory == "C:\\temp" - - stat_task_present.principal.display_name == None - - stat_task_present.principal.group_id == None - - stat_task_present.principal.logon_type == "TASK_LOGON_INTERACTIVE_TOKEN" - - stat_task_present.principal.run_level == "TASK_RUNLEVEL_LUA" - - stat_task_present.principal.user_id.endswith(admin_account_name) - - stat_task_present.registration_info.author == "Ansible Author" - - stat_task_present.registration_info.date is defined - - stat_task_present.registration_info.description == "Fake description" - - stat_task_present.settings.disallow_start_if_on_batteries == False - - stat_task_present.settings.execution_time_limit == "PT23H" - - stat_task_present.settings.restart_count == 3 - - stat_task_present.settings.restart_interval == "PT15M" - - stat_task_present.state.status == "TASK_STATE_READY" - - stat_task_present.triggers|count == 2 - - stat_task_present.triggers[0].delay == "PT15M" - - stat_task_present.triggers[0].type == "TASK_TRIGGER_BOOT" - - stat_task_present.triggers[0].repetition.stop_at_duration_end == False - - stat_task_present.triggers[0].repetition.duration == None - - stat_task_present.triggers[0].repetition.interval == None - - stat_task_present.triggers[1].days_of_month == "5,15,30" - - stat_task_present.triggers[1].months_of_year == "june,december" - - stat_task_present.triggers[1].run_on_last_day_of_month == True - - stat_task_present.triggers[1].start_boundary == "2017-09-20T03:44:38" - - stat_task_present.triggers[1].type == "TASK_TRIGGER_MONTHLY" - - stat_task_present.triggers[1].repetition.stop_at_duration_end == False - - stat_task_present.triggers[1].repetition.duration == None - - stat_task_present.triggers[1].repetition.interval == None - -- name: change principal to system account so it will run in the next step - win_scheduled_task: - name: '{{test_scheduled_task_stat_name}}' - path: '{{test_scheduled_task_stat_path}}' - username: SYSTEM - -- name: start the scheduled task - win_command: schtasks.exe /Run /TN "{{test_scheduled_task_stat_path}}\{{test_scheduled_task_stat_name}}" - -- name: get stat of running task - win_scheduled_task_stat: - path: '{{test_scheduled_task_stat_path}}' - name: '{{test_scheduled_task_stat_name}}' - register: stat_task_running - -- name: assert stat of running task - assert: - that: - - stat_task_running.state.status == "TASK_STATE_RUNNING" - -- name: stop the scheduled task - win_command: schtasks.exe /End /TN "{{test_scheduled_task_stat_path}}\{{test_scheduled_task_stat_name}}" - -- name: ensure task is delete after test - win_scheduled_task: - name: '{{test_scheduled_task_stat_name}}' - path: '{{test_scheduled_task_stat_path}}' - state: absent diff --git a/test/integration/targets/win_security_policy/aliases b/test/integration/targets/win_security_policy/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_security_policy/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_security_policy/library/test_win_security_policy.ps1 b/test/integration/targets/win_security_policy/library/test_win_security_policy.ps1 deleted file mode 100644 index 5c83c1b5d0..0000000000 --- a/test/integration/targets/win_security_policy/library/test_win_security_policy.ps1 +++ /dev/null @@ -1,53 +0,0 @@ -#!powershell - -# WANT_JSON -# POWERSHELL_COMMON - -# basic script to get the lsit of users in a particular right -# this is quite complex to put as a simple script so this is -# just a simple module - -$ErrorActionPreference = 'Stop' - -$params = Parse-Args $args -supports_check_mode $false -$section = Get-AnsibleParam -obj $params -name "section" -type "str" -failifempty $true -$key = Get-AnsibleParam -obj $params -name "key" -type "str" -failifempty $true - -$result = @{ - changed = $false -} - -Function ConvertFrom-Ini($file_path) { - $ini = @{} - switch -Regex -File $file_path { - "^\[(.+)\]" { - $section = $matches[1] - $ini.$section = @{} - } - "(.+?)\s*=(.*)" { - $name = $matches[1].Trim() - $value = $matches[2].Trim() - if ($value -match "^\d+$") { - $value = [int]$value - } elseif ($value.StartsWith('"') -and $value.EndsWith('"')) { - $value = $value.Substring(1, $value.Length - 2) - } - - $ini.$section.$name = $value - } - } - - $ini -} - -$secedit_ini_path = [IO.Path]::GetTempFileName() -&SecEdit.exe /export /cfg $secedit_ini_path /quiet -$secedit_ini = ConvertFrom-Ini -file_path $secedit_ini_path - -if ($secedit_ini.ContainsKey($section)) { - $result.value = $secedit_ini.$section.$key -} else { - $result.value = $null -} - -Exit-Json $result diff --git a/test/integration/targets/win_security_policy/tasks/main.yml b/test/integration/targets/win_security_policy/tasks/main.yml deleted file mode 100644 index 28fdb5ea09..0000000000 --- a/test/integration/targets/win_security_policy/tasks/main.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -- name: get current entry for audit - test_win_security_policy: - section: Event Audit - key: AuditSystemEvents - register: before_value_audit - -- name: get current entry for guest - test_win_security_policy: - section: System Access - key: NewGuestName - register: before_value_guest - -- block: - - name: set AuditSystemEvents entry before tests - win_security_policy: - section: Event Audit - key: AuditSystemEvents - value: 0 - - - name: set NewGuestName entry before tests - win_security_policy: - section: System Access - key: NewGuestName - value: Guest - - - name: run tests - include_tasks: tests.yml - - always: - - name: reset entries for AuditSystemEvents - win_security_policy: - section: Event Audit - key: AuditSystemEvents - value: "{{before_value_audit.value}}" - - - name: reset entries for NewGuestName - win_security_policy: - section: System Access - key: NewGuestName - value: "{{before_value_guest.value}}" diff --git a/test/integration/targets/win_security_policy/tasks/tests.yml b/test/integration/targets/win_security_policy/tasks/tests.yml deleted file mode 100644 index 724b6010a3..0000000000 --- a/test/integration/targets/win_security_policy/tasks/tests.yml +++ /dev/null @@ -1,186 +0,0 @@ ---- -- name: fail with invalid section name - win_security_policy: - section: This is not a valid section - key: KeyName - value: 0 - register: fail_invalid_section - failed_when: fail_invalid_section.msg != "The section 'This is not a valid section' does not exist in SecEdit.exe output ini" - -- name: fail with invalid key name - win_security_policy: - section: System Access - key: InvalidKey - value: 0 - register: fail_invalid_key - failed_when: fail_invalid_key.msg != "The key 'InvalidKey' in section 'System Access' is not a valid key, cannot set this value" - -- name: change existing key check - win_security_policy: - section: Event Audit - key: AuditSystemEvents - value: 1 - register: change_existing_check - check_mode: yes - -- name: get actual change existing key check - test_win_security_policy: - section: Event Audit - key: AuditSystemEvents - register: change_existing_actual_check - -- name: assert change existing key check - assert: - that: - - change_existing_check is changed - - change_existing_actual_check.value == 0 - -- name: change existing key - win_security_policy: - section: Event Audit - key: AuditSystemEvents - value: 1 - register: change_existing - -- name: get actual change existing key - test_win_security_policy: - section: Event Audit - key: AuditSystemEvents - register: change_existing_actual - -- name: assert change existing key - assert: - that: - - change_existing is changed - - change_existing_actual.value == 1 - -- name: change existing key again - win_security_policy: - section: Event Audit - key: AuditSystemEvents - value: 1 - register: change_existing_again - -- name: assert change existing key again - assert: - that: - - change_existing_again is not changed - - change_existing_again.value == 1 - -- name: change existing key with string type - win_security_policy: - section: Event Audit - key: AuditSystemEvents - value: "1" - register: change_existing_key_with_type - -- name: assert change existing key with string type - assert: - that: - - change_existing_key_with_type is not changed - - change_existing_key_with_type.value == "1" - -- name: change existing string key check - win_security_policy: - section: System Access - key: NewGuestName - value: New Guest - register: change_existing_string_check - check_mode: yes - -- name: get actual change existing string key check - test_win_security_policy: - section: System Access - key: NewGuestName - register: change_existing_string_actual_check - -- name: assert change existing string key check - assert: - that: - - change_existing_string_check is changed - - change_existing_string_actual_check.value == "Guest" - -- name: change existing string key - win_security_policy: - section: System Access - key: NewGuestName - value: New Guest - register: change_existing_string - -- name: get actual change existing string key - test_win_security_policy: - section: System Access - key: NewGuestName - register: change_existing_string_actual - -- name: assert change existing string key - assert: - that: - - change_existing_string is changed - - change_existing_string_actual.value == "New Guest" - -- name: change existing string key again - win_security_policy: - section: System Access - key: NewGuestName - value: New Guest - register: change_existing_string_again - -- name: assert change existing string key again - assert: - that: - - change_existing_string_again is not changed - - change_existing_string_again.value == "New Guest" - -- name: add policy setting - win_security_policy: - section: Privilege Rights - # following key is empty by default - key: SeCreateTokenPrivilege - # add Guests - value: '*S-1-5-32-546' - -- name: get actual policy setting - test_win_security_policy: - section: Privilege Rights - key: SeCreateTokenPrivilege - register: add_policy_setting_actual - -- name: assert add policy setting - assert: - that: - - add_policy_setting_actual.value == '*S-1-5-32-546' - -- name: remove policy setting - win_security_policy: - section: Privilege Rights - key: SeCreateTokenPrivilege - value: '' - diff: yes - register: remove_policy_setting - -- name: get actual policy setting - test_win_security_policy: - section: Privilege Rights - key: SeCreateTokenPrivilege - register: remove_policy_setting_actual - -- name: assert remove policy setting - assert: - that: - - remove_policy_setting is changed - - remove_policy_setting.diff.prepared == "[Privilege Rights]\n-SeCreateTokenPrivilege = *S-1-5-32-546\n+SeCreateTokenPrivilege = " - - remove_policy_setting_actual.value is none - -- name: remove policy setting again - win_security_policy: - section: Privilege Rights - key: SeCreateTokenPrivilege - value: '' - register: remove_policy_setting_again - -- name: assert remove policy setting again - assert: - that: - - remove_policy_setting_again is not changed - - remove_policy_setting_again.value == '' diff --git a/test/integration/targets/win_shortcut/aliases b/test/integration/targets/win_shortcut/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_shortcut/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_shortcut/tasks/clean.yml b/test/integration/targets/win_shortcut/tasks/clean.yml deleted file mode 100644 index 5fa892186b..0000000000 --- a/test/integration/targets/win_shortcut/tasks/clean.yml +++ /dev/null @@ -1,37 +0,0 @@ -# Test code for the file module. -# (c) 2017, Dag Wieers <dag@wieers.com> - -# 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 <http://www.gnu.org/licenses/>. - -- name: Clean up Ansible website link - win_file: - path: '%UserProfile%\Desktop\Ansible website.url' - state: absent - -- name: Clean up Registry Editor shortcut - win_file: - path: '%Public%\Desktop\Registry Editor.lnk' - state: absent - -- name: Clean up Shell path shortcut - win_file: - path: '%Public%\bin.lnk' - state: absent - -- name: Clean up Executable shortcut - win_file: - path: '%Public%\Desktop\cmd.lnk' - state: absent diff --git a/test/integration/targets/win_shortcut/tasks/main.yml b/test/integration/targets/win_shortcut/tasks/main.yml deleted file mode 100644 index cf04ea3b5b..0000000000 --- a/test/integration/targets/win_shortcut/tasks/main.yml +++ /dev/null @@ -1,34 +0,0 @@ -# Test code for the file module. -# (c) 2017, Dag Wieers <dag@wieers.com> - -# 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 <http://www.gnu.org/licenses/>. - -- name: Clean slate - import_tasks: clean.yml - -- name: Test in normal mode - import_tasks: tests.yml - vars: - in_check_mode: no - -- name: Clean slate - import_tasks: clean.yml - -- name: Test in check-mode - import_tasks: tests.yml - vars: - in_check_mode: yes - check_mode: yes diff --git a/test/integration/targets/win_shortcut/tasks/tests.yml b/test/integration/targets/win_shortcut/tasks/tests.yml deleted file mode 100644 index 2797598b43..0000000000 --- a/test/integration/targets/win_shortcut/tasks/tests.yml +++ /dev/null @@ -1,367 +0,0 @@ -# Test code for the file module. -# (c) 2017, Dag Wieers <dag@wieers.com> - -# 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 <http://www.gnu.org/licenses/>. - -- name: get current user profile location - raw: $env:USERPROFILE - check_mode: no - register: profile_result - -- set_fact: - profile_dir: '{{ profile_result.stdout_lines[0] }}' - -- name: Add Ansible website link on the desktop - win_shortcut: - src: https://ansible.com/ - dest: '%UserProfile%\Desktop\Ansible website.url' - state: present - register: ansible_website_link_add - -- name: Check there was a change - assert: - that: - - ansible_website_link_add.changed == true - - ansible_website_link_add.dest == profile_dir + '\Desktop\Ansible website.url' - - ansible_website_link_add.src == 'https://ansible.com/' - -- name: Add Ansible website link on the desktop again - win_shortcut: - src: https://ansible.com/ - dest: '%UserProfile%\Desktop\Ansible website.url' - state: present - register: ansible_website_link_add_again - -- name: Check there was no change (normal mode) - assert: - that: - - ansible_website_link_add_again.changed == false - - ansible_website_link_add_again.dest == profile_dir + '\Desktop\Ansible website.url' - - ansible_website_link_add_again.src == 'https://ansible.com/' - when: not in_check_mode - -- name: Check there was a change (check-mode) - assert: - that: - - ansible_website_link_add_again.changed == true - - ansible_website_link_add_again.dest == profile_dir + '\Desktop\Ansible website.url' - - ansible_website_link_add_again.src == 'https://ansible.com/' - when: in_check_mode - -- name: Remove link - win_shortcut: - dest: '%UserProfile%\Desktop\Ansible website.url' - state: absent - register: ansible_website_link_remove - -- name: Check there was a change (normal mode) - assert: - that: - - ansible_website_link_remove.changed == true - - ansible_website_link_remove.dest == profile_dir + '\Desktop\Ansible website.url' - when: not in_check_mode - -- name: Check there was no change (check-mode) - assert: - that: - - ansible_website_link_remove.changed == false - - ansible_website_link_remove.dest == profile_dir + '\Desktop\Ansible website.url' - when: in_check_mode - -- name: Remove link again - win_shortcut: - dest: '%UserProfile%\Desktop\Ansible website.url' - state: absent - register: ansible_website_link_remove_again - -- name: Check there was no change - assert: - that: - - ansible_website_link_remove_again.changed == false - - ansible_website_link_remove_again.dest == profile_dir + '\Desktop\Ansible website.url' - -- name: Add a regedit shortcut on the desktop - win_shortcut: - description: "Registry Editor" - src: regedit.exe - dest: '%Public%\Desktop\Registry Editor.lnk' - state: present - register: regedit_shortcut_add - -- name: Check there was a change - assert: - that: - - regedit_shortcut_add.changed == true - - regedit_shortcut_add.description == 'Registry Editor' - - regedit_shortcut_add.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_add.src == 'C:\\Windows\\regedit.exe' - -- name: Add a regedit shortcut on the desktop again - win_shortcut: - description: "Registry Editor" - src: regedit.exe - dest: '%Public%\Desktop\Registry Editor.lnk' - state: present - register: regedit_shortcut_add_again - -- name: Check there was no change (normal mode) - assert: - that: - - regedit_shortcut_add_again.changed == false - - regedit_shortcut_add_again.description == 'Registry Editor' - - regedit_shortcut_add_again.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_add_again.src == 'C:\\Windows\\regedit.exe' - when: not in_check_mode - -- name: Check there was a change (check-mode) - assert: - that: - - regedit_shortcut_add_again.changed == true - - regedit_shortcut_add_again.description == 'Registry Editor' - - regedit_shortcut_add_again.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_add_again.src == 'C:\\Windows\\regedit.exe' - when: in_check_mode - -- name: Update a regedit shortcut on the desktop - win_shortcut: - description: "Registry Editor" - src: C:\BogusPath\regedit.exe - dest: '%Public%\Desktop\Registry Editor.lnk' - state: present - register: regedit_shortcut_update - -- name: Check there was a change - assert: - that: - - regedit_shortcut_update.changed == true - - regedit_shortcut_update.description == 'Registry Editor' - - regedit_shortcut_update.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_update.src == 'C:\\BogusPath\\regedit.exe' - -- name: Update a regedit shortcut on the desktop again - win_shortcut: - description: "Registry Editor" - src: C:\BogusPath\regedit.exe - dest: '%Public%\Desktop\Registry Editor.lnk' - state: present - register: regedit_shortcut_update_again - -- name: Check there was no change (normal mode) - assert: - that: - - regedit_shortcut_update_again.changed == false - - regedit_shortcut_update_again.description == 'Registry Editor' - - regedit_shortcut_update_again.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_update_again.src == 'C:\\BogusPath\\regedit.exe' - when: not in_check_mode - -- name: Check there was a change (check-mode) - assert: - that: - - regedit_shortcut_update_again.changed == true - - regedit_shortcut_update_again.description == 'Registry Editor' - - regedit_shortcut_update_again.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_update_again.src == 'C:\\BogusPath\\regedit.exe' - when: in_check_mode - -- name: Add an (explicit) icon - win_shortcut: - description: "Registry Editor" - src: C:\Windows\regedit.exe - dest: '%Public%\Desktop\Registry Editor.lnk' - icon: 'C:\Windows\regedit.exe,0' - state: present - register: regedit_shortcut_add_icon - -- name: Check there was a change - assert: - that: - - regedit_shortcut_add_icon.changed == true - - regedit_shortcut_add_icon.description == 'Registry Editor' - - regedit_shortcut_add_icon.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_add_icon.icon == 'C:\\Windows\\regedit.exe,0' - - regedit_shortcut_add_icon.src == 'C:\\Windows\\regedit.exe' - -- name: Add an (explicit) icon again - win_shortcut: - description: "Registry Editor" - src: C:\Windows\regedit.exe - dest: '%Public%\Desktop\Registry Editor.lnk' - icon: 'C:\Windows\regedit.exe,0' - state: present - register: regedit_shortcut_add_icon_again - -- name: Check there was no change (normal mode) - assert: - that: - - regedit_shortcut_add_icon_again.changed == false - - regedit_shortcut_add_icon_again.description == 'Registry Editor' - - regedit_shortcut_add_icon_again.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_add_icon_again.icon == 'C:\\Windows\\regedit.exe,0' - - regedit_shortcut_add_icon_again.src == 'C:\\Windows\\regedit.exe' - when: not in_check_mode - -- name: Check there was a change (check-mode) - assert: - that: - - regedit_shortcut_add_icon_again.changed == true - - regedit_shortcut_add_icon_again.description == 'Registry Editor' - - regedit_shortcut_add_icon_again.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - - regedit_shortcut_add_icon_again.icon == 'C:\\Windows\\regedit.exe,0' - - regedit_shortcut_add_icon_again.src == 'C:\\Windows\\regedit.exe' - when: in_check_mode - -- name: Remove shortcut - win_shortcut: - dest: '%Public%\Desktop\Registry Editor.lnk' - state: absent - register: regedit_shortcut_remove - -- name: Check there was a change (normal mode) - assert: - that: - - regedit_shortcut_remove.changed == true - - regedit_shortcut_remove.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - when: not in_check_mode - -- name: Check there was no change (check-mode) - assert: - that: - - regedit_shortcut_remove.changed == false - - regedit_shortcut_remove.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - when: in_check_mode - -- name: Remove shortcut again - win_shortcut: - dest: '%Public%\Desktop\Registry Editor.lnk' - state: absent - register: regedit_shortcut_remove_again - -- name: Check there was no change - assert: - that: - - regedit_shortcut_remove_again.changed == false - - regedit_shortcut_remove_again.dest == 'C:\\Users\\Public\\Desktop\\Registry Editor.lnk' - -- name: Create shortcut to shell path - win_shortcut: - dest: '%Public%\bin.lnk' - src: shell:RecycleBinFolder - state: present - register: shell_add - -- name: Check there was a change - assert: - that: - - shell_add is changed - - shell_add.dest == 'C:\\Users\\Public\\bin.lnk' - - shell_add.src == 'shell:RecycleBinFolder' - -- name: Create shortcut to shell path again - win_shortcut: - dest: '%Public%\bin.lnk' - src: shell:RecycleBinFolder - state: present - register: shell_add_again - -- name: Check there was no change (normal mode) - assert: - that: - - not shell_add_again is changed - - shell_add_again.src == 'shell:RecycleBinFolder' - when: not in_check_mode - -- name: Check there was a change (check-mode) - assert: - that: - - shell_add_again is changed - when: in_check_mode - -- name: Change shortcut to another shell path - win_shortcut: - dest: '%Public%\bin.lnk' - src: shell:Start Menu - state: present - register: shell_change - -- name: Check there was a change - assert: - that: - - shell_change is changed - - shell_change.src == 'shell:Start Menu' - -- name: Create shortcut to an executable without run as admin - win_shortcut: - dest: '%Public%\Desktop\cmd.lnk' - src: '%SystemRoot%\System32\cmd.exe' - state: present - register: shell_exe_limited - -- name: Get run as admin flag state - win_shell: | - $shortcut = "$env:Public\Desktop\cmd.lnk" - $flags = [System.BitConverter]::ToUInt32([System.IO.FIle]::ReadAllBytes($shortcut), 20) - ($flags -band 0x00002000) -eq 0x00002000 - register: shell_exe_limited_actual - -- name: Check that run as admin flag wasn't set (normal mode) - assert: - that: - - shell_exe_limited is changed - - not shell_exe_limited_actual.stdout_lines[0]|bool - when: not in_check_mode - -- name: Check that exe shortcut results in a change (check-mode) - assert: - that: - - shell_exe_limited is changed - when: in_check_mode - -- name: Set shortcut to run as admin - win_shortcut: - dest: '%Public%\Desktop\cmd.lnk' - src: '%SystemRoot%\System32\cmd.exe' - run_as_admin: True - state: present - register: shell_exe_admin - -- name: Get run as admin flag state - win_shell: | - $shortcut = "$env:Public\Desktop\cmd.lnk" - $flags = [System.BitConverter]::ToUInt32([System.IO.FIle]::ReadAllBytes($shortcut), 20) - ($flags -band 0x00002000) -eq 0x00002000 - register: shell_exe_admin_actual - -- name: Check that run as admin flag was set (normal mode) - assert: - that: - - shell_exe_admin is changed - - shell_exe_admin_actual.stdout_lines[0]|bool - when: not in_check_mode - -- name: Set shortcut to run as admin again - win_shortcut: - dest: '%Public%\Desktop\cmd.lnk' - src: '%SystemRoot%\System32\cmd.exe' - run_as_admin: True - state: present - register: shell_exe_admin_again - -- name: Check that set run as admin wasn't changed (normal mode) - assert: - that: - - not shell_exe_admin_again is changed - when: not in_check_mode diff --git a/test/integration/targets/win_snmp/aliases b/test/integration/targets/win_snmp/aliases deleted file mode 100644 index 219895f4bc..0000000000 --- a/test/integration/targets/win_snmp/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group2 -skip/windows/2016 # Host takes a while to run and module isn't OS dependent diff --git a/test/integration/targets/win_snmp/tasks/cleanup.yml b/test/integration/targets/win_snmp/tasks/cleanup.yml deleted file mode 100644 index 28d98debea..0000000000 --- a/test/integration/targets/win_snmp/tasks/cleanup.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- - - name: Make sure there are no existing SNMP configuration settings - win_regedit: - path: "{{ item }}" - state: absent - loop: - - "{{ permitted_managers_key }}" - - "{{ valid_communities_key }}" - - - name: Create skeleton registry keys for SNMP - win_regedit: - path: "{{ item }}" - state: present - loop: - - "{{ permitted_managers_key }}" - - "{{ valid_communities_key }}" diff --git a/test/integration/targets/win_snmp/tasks/cleanup_using_module.yml b/test/integration/targets/win_snmp/tasks/cleanup_using_module.yml deleted file mode 100644 index 290de7fc1f..0000000000 --- a/test/integration/targets/win_snmp/tasks/cleanup_using_module.yml +++ /dev/null @@ -1,26 +0,0 @@ ---- - - name: Set no SNMP community or SNMP manager - register: snmp_cleanup - win_snmp: - action: set - community_strings: [] - permitted_managers: [] - - - name: Check registry for no SNMP community - register: snmp_cleanup_reg_community - win_reg_stat: - path: "{{ valid_communities_key }}" - name: snmp-cleanup - - - name: Check registry for no SNMP manager - register: snmp_cleanup_reg_manager - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 1 - - - name: Asset SNMP set operation results in no remaining SNMP details - assert: - that: - - snmp_cleanup.changed - - snmp_cleanup_reg_community.exists == false - - snmp_cleanup_reg_manager.exists == false diff --git a/test/integration/targets/win_snmp/tasks/main.yml b/test/integration/targets/win_snmp/tasks/main.yml deleted file mode 100644 index 09000d6e90..0000000000 --- a/test/integration/targets/win_snmp/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - - include_tasks: cleanup.yml - - include_tasks: snmp_community.yml - - include_tasks: cleanup.yml - - include_tasks: snmp_managers.yml - - include_tasks: output_only.yml - - include_tasks: cleanup_using_module.yml - - include_tasks: cleanup.yml diff --git a/test/integration/targets/win_snmp/tasks/output_only.yml b/test/integration/targets/win_snmp/tasks/output_only.yml deleted file mode 100644 index 7115da45d2..0000000000 --- a/test/integration/targets/win_snmp/tasks/output_only.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- - # Already tested - - name: Add an SNMP manager and an SNMP community - win_snmp: - action: add - community_strings: - - snmp-cleanup - permitted_managers: - - 192.168.1.1 - - - name: Run without options - register: snmp_no_options - win_snmp: - - - name: Assert no changes occurred when no options provided - assert: - that: - - not snmp_no_options.changed - - - name: Assert community strings and permitted managers are correctly returned - assert: - that: - - "'snmp-cleanup' in snmp_no_options.community_strings" - - "'192.168.1.1' in snmp_no_options.permitted_managers" diff --git a/test/integration/targets/win_snmp/tasks/snmp_community.yml b/test/integration/targets/win_snmp/tasks/snmp_community.yml deleted file mode 100644 index 47a06297f2..0000000000 --- a/test/integration/targets/win_snmp/tasks/snmp_community.yml +++ /dev/null @@ -1,165 +0,0 @@ ---- - - name: Add initial SNMP community - register: snmp_community - win_snmp: - action: add - community_strings: - - ansible-ro-test - - - name: Check initial SNMP community exists in registry - register: snmp_community_reg - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test - - - name: Assert initial SNMP community is correct - assert: - that: - - snmp_community is changed - - snmp_community_reg.exists - - snmp_community_reg.type == 'REG_DWORD' - - snmp_community_reg.value == 4 - - - name: Add initial SNMP community again - register: snmp_community_again - win_snmp: - action: add - community_strings: - - ansible-ro-test - - - name: Check no change occurred when adding SNMP community again - assert: - that: - - snmp_community_again is not changed - - - name: Add next SNMP community - register: snmp_community_next - win_snmp: - action: add - community_strings: - - ansible-ro-test-next - - - name: Check initial SNMP community still exists in registry - register: snmp_community_reg_orig - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test - - - name: Check next SNMP community exists in registry - register: snmp_community_reg_next - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test-next - - - name: Assert initial SNMP community still exists - assert: - that: - - snmp_community_reg_orig.exists - - snmp_community_reg_orig.type == 'REG_DWORD' - - snmp_community_reg_orig.value == 4 - - - name: Assert next SNMP community exists - assert: - that: - - snmp_community_next is changed - - snmp_community_reg_next.exists - - snmp_community_reg_next.type == 'REG_DWORD' - - snmp_community_reg_next.value == 4 - - - name: Replace SNMP community - register: snmp_community_replace - win_snmp: - action: set - community_strings: - - ansible-ro-test-replace - - - name: Check initial SNMP community does not exist in registry - register: snmp_community_reg_orig_replace - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test - - - name: Check next SNMP community does not exist in registry - register: snmp_community_reg_next_replace - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test-next - - - name: Check replace SNMP community exists in registry - register: snmp_community_reg_replace - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test-replace - - - name: Assert replace SNMP community exists and others are replaced - assert: - that: - - snmp_community_replace is changed - - snmp_community_reg_orig_replace.exists == false - - snmp_community_reg_next_replace.exists == false - - snmp_community_reg_replace.exists - - snmp_community_reg_replace.type == 'REG_DWORD' - - snmp_community_reg_replace.value == 4 - - # This task has already been tested - - name: Add another SNMP community before testing removal - win_snmp: - action: add - community_strings: - - ansible-ro-remove-add - - - name: Remove the replaced SNMP community - register: snmp_community_remove - win_snmp: - action: remove - community_strings: - - ansible-ro-test-replace - - - name: Check replace SNMP community is removed in registry - register: snmp_community_reg_remove - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test-replace - - - name: Check SNMP community that was added for testing removal exists in registry - register: snmp_community_reg_remove_add - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-remove-add - - - name: Assert removal of SNMP community succeeded and next SNMP community remains - assert: - that: - - snmp_community_remove is changed - - snmp_community_reg_remove.exists == false - - snmp_community_reg_remove_add.exists - - snmp_community_reg_remove_add.type == 'REG_DWORD' - - snmp_community_reg_remove_add.value == 4 - - - name: Remove the replaced SNMP community (again) - register: snmp_community_remove - win_snmp: - action: remove - community_strings: - - ansible-ro-test-replace - - - name: Check replace SNMP community is removed in registry (again) - register: snmp_community_reg_remove - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-test-replace - - - name: Check SNMP community that was added for testing removal exists in registry (again) - register: snmp_community_reg_remove_add - win_reg_stat: - path: "{{ valid_communities_key }}" - name: ansible-ro-remove-add - - - name: Assert removal of SNMP community succeeded and next SNMP community remains (again) - assert: - that: - - snmp_community_remove is not changed - - snmp_community_reg_remove.exists == false - - snmp_community_reg_remove_add.exists - - snmp_community_reg_remove_add.type == 'REG_DWORD' - - snmp_community_reg_remove_add.value == 4 diff --git a/test/integration/targets/win_snmp/tasks/snmp_managers.yml b/test/integration/targets/win_snmp/tasks/snmp_managers.yml deleted file mode 100644 index dedd0767f1..0000000000 --- a/test/integration/targets/win_snmp/tasks/snmp_managers.yml +++ /dev/null @@ -1,158 +0,0 @@ ---- - - name: Add initial SNMP manager - register: snmp_manager - win_snmp: - action: add - permitted_managers: - - 192.168.1.1 - - - name: Check initial SNMP manager exists in registry - register: snmp_manager_reg - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 1 - - - name: Assert initial SNMP manager is correct - assert: - that: - - snmp_manager is changed - - snmp_manager_reg.exists - - snmp_manager_reg.type == 'REG_SZ' - - snmp_manager_reg.value == '192.168.1.1' - - - name: Add initial SNMP manager again - register: snmp_manager_again - win_snmp: - action: add - permitted_managers: - - 192.168.1.1 - - - name: Check no change occurred when adding SNMP manager again - assert: - that: - - snmp_manager_again is not changed - - - name: Add next SNMP manager - register: snmp_manager_next - win_snmp: - action: add - permitted_managers: - - 192.168.1.2 - - - name: Check initial SNMP manager still exists in registry - register: snmp_manager_reg_orig - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 1 - - - name: Check next SNMP manager exists in registry - register: snmp_manager_reg_next - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 2 - - - name: Assert initial SNMP manager still exists - assert: - that: - - snmp_manager_reg_orig.exists - - snmp_manager_reg_orig.type == 'REG_SZ' - - snmp_manager_reg_orig.value == '192.168.1.1' - - - name: Assert next SNMP manager exists - assert: - that: - - snmp_manager_next is changed - - snmp_manager_reg_next.exists - - snmp_manager_reg_next.type == 'REG_SZ' - - snmp_manager_reg_next.value == '192.168.1.2' - - - name: Replace SNMP manager - register: snmp_manager_replace - win_snmp: - action: set - permitted_managers: - - 192.168.1.10 - - - name: Check next SNMP manager does not exist in registry - register: snmp_manager_reg_next_replace - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 2 - - - name: Check replace SNMP manager exists in registry (overrides original slot) - register: snmp_manager_reg_replace - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 1 - - - name: Assert replace SNMP manager exists and others are replaced - assert: - that: - - snmp_manager_replace is changed - - snmp_manager_reg_next_replace.exists == false - - snmp_manager_reg_replace.exists - - snmp_manager_reg_replace.type == 'REG_SZ' - - snmp_manager_reg_replace.value == '192.168.1.10' - - # This task has already been tested - - name: Add another SNMP manager before testing removal - win_snmp: - action: add - permitted_managers: - - 192.168.1.20 - - - name: Remove the replaced SNMP manager - register: snmp_manager_remove - win_snmp: - action: remove - permitted_managers: - - 192.168.1.10 - - - name: Check replace SNMP manager is removed in registry - register: snmp_manager_reg_remove - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 1 - - - name: Check SNMP manager that was added for testing removal exists in registry - register: snmp_manager_reg_remove_add - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 2 - - - name: Assert removal of SNMP manager succeeded and next SNMP manager remains - assert: - that: - - snmp_manager_remove is changed - - snmp_manager_reg_remove.exists == false - - snmp_manager_reg_remove_add.exists - - snmp_manager_reg_remove_add.type == 'REG_SZ' - - snmp_manager_reg_remove_add.value == '192.168.1.20' - - - name: Remove the replaced SNMP manager (again) - register: snmp_manager_remove - win_snmp: - action: remove - permitted_managers: - - 192.168.1.10 - - - name: Check replace SNMP manager is removed in registry (again) - register: snmp_manager_reg_remove - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 1 - - - name: Check SNMP manager that was added for testing removal exists in registry (again) - register: snmp_manager_reg_remove_add - win_reg_stat: - path: "{{ permitted_managers_key }}" - name: 2 - - - name: Assert removal of SNMP manager succeeded and next SNMP manager remains (again) - assert: - that: - - snmp_manager_remove is not changed - - snmp_manager_reg_remove.exists == false - - snmp_manager_reg_remove_add.exists - - snmp_manager_reg_remove_add.type == 'REG_SZ' - - snmp_manager_reg_remove_add.value == '192.168.1.20' diff --git a/test/integration/targets/win_snmp/vars/main.yml b/test/integration/targets/win_snmp/vars/main.yml deleted file mode 100644 index 610be839fc..0000000000 --- a/test/integration/targets/win_snmp/vars/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - permitted_managers_key: 'HKLM:\System\CurrentControlSet\services\SNMP\Parameters\PermittedManagers' - valid_communities_key: 'HKLM:\System\CurrentControlSet\services\SNMP\Parameters\ValidCommunities' diff --git a/test/integration/targets/win_timezone/aliases b/test/integration/targets/win_timezone/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_timezone/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_timezone/tasks/main.yml b/test/integration/targets/win_timezone/tasks/main.yml deleted file mode 100644 index b7cd0c5624..0000000000 --- a/test/integration/targets/win_timezone/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ -- name: Determine if server has tzutil.exe installed - win_command: tzutil.exe /l - register: tzutil - ignore_errors: yes - -- name: Only run tests if tzutil.exe is installed - when: tzutil.rc == 0 - block: - - - name: Test in normal mode - import_tasks: tests.yml - vars: - in_check_mode: no - - - name: Test in check-mode - import_tasks: tests.yml - vars: - in_check_mode: yes - check_mode: yes diff --git a/test/integration/targets/win_timezone/tasks/tests.yml b/test/integration/targets/win_timezone/tasks/tests.yml deleted file mode 100644 index da5109f7f5..0000000000 --- a/test/integration/targets/win_timezone/tasks/tests.yml +++ /dev/null @@ -1,100 +0,0 @@ -# NOTE: Set to a known starting value, store original -- name: Change starting timezone to GMT - win_timezone: - timezone: GMT Standard Time - register: original - -# NOTE: We don't know if it changed, we don't care -- name: Test GMT timezone - assert: - that: - - original.timezone == 'GMT Standard Time' - -- name: Change timezone to GMT+1 - win_timezone: - timezone: Romance Standard Time - register: romance - -- name: Test GMT+1 timezone - assert: - that: - - romance is changed - - romance.previous_timezone == 'GMT Standard Time' - - romance.timezone == 'Romance Standard Time' - when: not in_check_mode - -- name: Test GMT+1 timezone - assert: - that: - - romance is changed - - romance.previous_timezone == original.timezone - - romance.timezone == 'Romance Standard Time' - when: in_check_mode - -- name: Change timezone to GMT+1 again - win_timezone: - timezone: Romance Standard Time - register: romance - -- name: Test GMT+1 timezone - assert: - that: - - romance is not changed - - romance.previous_timezone == 'Romance Standard Time' - - romance.timezone == 'Romance Standard Time' - when: not in_check_mode - -- name: Test GMT+1 timezone - assert: - that: - - romance is changed - - romance.previous_timezone == original.timezone - - romance.timezone == 'Romance Standard Time' - when: in_check_mode - -- name: Change timezone to GMT+6 - win_timezone: - timezone: Central Standard Time - register: central - -- name: Test GMT-6 timezone - assert: - that: - - central is changed - - central.previous_timezone == 'Romance Standard Time' - - central.timezone == 'Central Standard Time' - when: not in_check_mode - -- name: Test GMT+1 timezone - assert: - that: - - central is changed - - central.previous_timezone == original.timezone - - central.timezone == 'Central Standard Time' - when: in_check_mode - -- name: Change timezone to dstoff - win_timezone: - timezone: Eastern Standard Time_dstoff - register: dstoff_result - -- name: Test dstoff timezone - assert: - that: - - dstoff_result is changed - - dstoff_result.timezone == 'Eastern Standard Time_dstoff' - -- name: Change timezone to GMT+666 - win_timezone: - timezone: Dag's Standard Time - register: dag - ignore_errors: yes - -- name: Test GMT+666 timezone - assert: - that: - - dag is failed - -- name: Restore original timezone - win_timezone: - timezone: '{{ original.timezone }}' diff --git a/test/integration/targets/win_toast/aliases b/test/integration/targets/win_toast/aliases deleted file mode 100644 index ebd7be7463..0000000000 --- a/test/integration/targets/win_toast/aliases +++ /dev/null @@ -1,2 +0,0 @@ -shippable/windows/group1 -disabled diff --git a/test/integration/targets/win_toast/tasks/main.yml b/test/integration/targets/win_toast/tasks/main.yml deleted file mode 100644 index 735d55b1a9..0000000000 --- a/test/integration/targets/win_toast/tasks/main.yml +++ /dev/null @@ -1,13 +0,0 @@ -- name: Set up tests - import_tasks: setup.yml - -- name: Test in normal mode - import_tasks: tests.yml - vars: - in_check_mode: no - -- name: Test in check mode - import_tasks: tests.yml - vars: - in_check_mode: yes - check_mode: yes diff --git a/test/integration/targets/win_toast/tasks/setup.yml b/test/integration/targets/win_toast/tasks/setup.yml deleted file mode 100644 index 1fe3a22da1..0000000000 --- a/test/integration/targets/win_toast/tasks/setup.yml +++ /dev/null @@ -1,27 +0,0 @@ -- name: Get OS version - win_shell: '[Environment]::OSVersion.Version.Major' - register: os_version - -- name: Get logged in user count (using explorer exe as a proxy) - win_shell: (get-process -name explorer -EA silentlyContinue).Count - register: user_count - -- name: debug os_version - debug: - var: os_version - verbosity: 2 - -- name: debug user_count - debug: - var: user_count - verbosity: 2 - -- name: Set fact if toast cannot be made - set_fact: - can_toast: False - when: os_version.stdout|int < 10 - -- name: Set fact if toast can be made - set_fact: - can_toast: True - when: os_version.stdout|int >= 10 diff --git a/test/integration/targets/win_toast/tasks/tests.yml b/test/integration/targets/win_toast/tasks/tests.yml deleted file mode 100644 index d1d4ece107..0000000000 --- a/test/integration/targets/win_toast/tasks/tests.yml +++ /dev/null @@ -1,106 +0,0 @@ -- name: Warn user - win_toast: - expire: 10 - msg: Keep calm and carry on. - register: msg_result - ignore_errors: True - -- name: Test msg_result when can_toast is true (normal mode, users) - assert: - that: - - msg_result is not failed - - msg_result.time_taken > 10 - when: - - can_toast == True - - in_check_mode == False - - user_count.stdout|int > 0 - -- name: Test msg_result when can_toast is true (normal mode, no users) - assert: - that: - - msg_result is not failed - - msg_result.time_taken > 0.1 - - msg_result.toast_sent == False - when: - - can_toast == True - - in_check_mode == False - - user_count.stdout|int == 0 - -- name: Test msg_result when can_toast is true (check mode, users) - assert: - that: - - msg_result is not failed - - msg_result.time_taken > 0.1 - when: - - can_toast == True - - in_check_mode == True - -- name: Test msg_result when can_toast is true (check mode, no users) - assert: - that: - - msg_result is not failed - - msg_result.time_taken > 0.1 - - msg_result.toast_sent == False - when: - - can_toast == True - - in_check_mode == True - - user_count.stdout|int == 0 - -- name: Test msg_result when can_toast is false - assert: - that: - - msg_result is failed - when: can_toast == False - -- name: Warn user again - win_toast: - expire: 10 - msg: Keep calm and carry on. - register: msg_result2 - ignore_errors: True - -- name: Test msg_result2 when can_toast is true (normal mode, users) - assert: - that: - - msg_result2 is not failed - - msg_result2.time_taken > 10 - when: - - can_toast == True - - in_check_mode == False - - user_count.stdout|int > 0 - -- name: Test msg_result2 when can_toast is true (normal mode, no users) - assert: - that: - - msg_result2 is not failed - - msg_result2.time_taken > 0.1 - when: - - can_toast == True - - in_check_mode == False - - user_count.stdout|int == 0 - -- name: Test msg_result2 when can_toast is true (check mode, users) - assert: - that: - - msg_result2 is not failed - - msg_result2.time_taken > 0.1 - when: - - can_toast == True - - in_check_mode == False - - user_count.stdout|int > 0 - -- name: Test msg_result2 when can_toast is true (check mode, no users) - assert: - that: - - msg_result2 is not failed - - msg_result2.time_taken > 0.1 - when: - - can_toast == True - - in_check_mode == False - - user_count.stdout|int == 0 - -- name: Test msg_result2 when can_toast is false - assert: - that: - - msg_result2 is failed - when: can_toast == False diff --git a/test/integration/targets/win_unzip/aliases b/test/integration/targets/win_unzip/aliases deleted file mode 100644 index 423ce39108..0000000000 --- a/test/integration/targets/win_unzip/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group2 diff --git a/test/integration/targets/win_unzip/defaults/main.yml b/test/integration/targets/win_unzip/defaults/main.yml deleted file mode 100644 index 52d808d88c..0000000000 --- a/test/integration/targets/win_unzip/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ -win_unzip_dir: '{{ remote_tmp_dir }}\win_unzip .ÅÑŚÌβŁÈ [$!@^&test(;)]' diff --git a/test/integration/targets/win_unzip/files/create_crafty_zip_files.py b/test/integration/targets/win_unzip/files/create_crafty_zip_files.py deleted file mode 100644 index 8845b48629..0000000000 --- a/test/integration/targets/win_unzip/files/create_crafty_zip_files.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Copyright (c) 2020 Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - -import os -import shutil -import sys -import zipfile - -# Each key is a zip file and the vaule is the list of files that will be created -# and placed in the archive -zip_files = { - 'hat1': [r'hat/..\rabbit.txt'], - 'hat2': [r'hat/..\..\rabbit.txt'], - 'handcuffs': [r'..\..\houidini.txt'], - 'prison': [r'..\houidini.txt'], -} - -# Accept an argument of where to create the files, defaulting to -# the current working directory. -try: - output_dir = sys.argv[1] -except IndexError: - output_dir = os.getcwd() - -if not os.path.isdir(output_dir): - os.mkdir(output_dir) - -os.chdir(output_dir) - -for name, files in zip_files.items(): - # Create the files to go in the zip archive - for entry in files: - dirname = os.path.dirname(entry) - if dirname: - if os.path.isdir(dirname): - shutil.rmtree(dirname) - os.mkdir(dirname) - - with open(entry, 'w') as e: - e.write('escape!\n') - - # Create the zip archive with the files - filename = '%s.zip' % name - if os.path.isfile(filename): - os.unlink(filename) - - with zipfile.ZipFile(filename, 'w') as zf: - for entry in files: - zf.write(entry) - - # Cleanup - if dirname: - shutil.rmtree(dirname) - - for entry in files: - try: - os.unlink(entry) - except OSError: - pass diff --git a/test/integration/targets/win_unzip/files/create_zip.py b/test/integration/targets/win_unzip/files/create_zip.py deleted file mode 100644 index 41b6ff068b..0000000000 --- a/test/integration/targets/win_unzip/files/create_zip.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Copyright: (c) 2019, Ansible Project -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import sys -import tempfile -import zipfile - - -def main(): - filename = b"caf\xc3\xa9.txt" - - with tempfile.NamedTemporaryFile() as temp: - with open(temp.name, mode="wb") as fd: - fd.write(filename) - - with open(sys.argv[1], mode="wb") as fd: - with zipfile.ZipFile(fd, "w") as zip: - zip.write(temp.name, filename.decode('utf-8')) - - -if __name__ == '__main__': - main() diff --git a/test/integration/targets/win_unzip/meta/main.yml b/test/integration/targets/win_unzip/meta/main.yml deleted file mode 100644 index 9f37e96cd9..0000000000 --- a/test/integration/targets/win_unzip/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: -- setup_remote_tmp_dir diff --git a/test/integration/targets/win_unzip/tasks/main.yml b/test/integration/targets/win_unzip/tasks/main.yml deleted file mode 100644 index a9b8f1ca22..0000000000 --- a/test/integration/targets/win_unzip/tasks/main.yml +++ /dev/null @@ -1,171 +0,0 @@ -- name: create test directory - win_file: - path: '{{ win_unzip_dir }}\output' - state: directory - -- name: create local zip file with non-ascii chars - script: create_zip.py {{ output_dir + '/win_unzip.zip' | quote }} - delegate_to: localhost - -- name: copy across zip to Windows host - win_copy: - src: '{{ output_dir }}/win_unzip.zip' - dest: '{{ win_unzip_dir }}\win_unzip.zip' - -- name: unarchive zip (check) - win_unzip: - src: '{{ win_unzip_dir }}\win_unzip.zip' - dest: '{{ win_unzip_dir }}\output' - register: unzip_check - check_mode: yes - -- name: get result of unarchive zip (check) - win_stat: - path: '{{ win_unzip_dir }}\output\café.txt' - register: unzip_actual_check - -- name: assert result of unarchive zip (check) - assert: - that: - - unzip_check is changed - - not unzip_check.removed - - not unzip_actual_check.stat.exists - -- name: unarchive zip - win_unzip: - src: '{{ win_unzip_dir }}\win_unzip.zip' - dest: '{{ win_unzip_dir }}\output' - register: unzip - -- name: get result of unarchive zip - slurp: - path: '{{ win_unzip_dir }}\output\café.txt' - register: unzip_actual - -- name: assert result of unarchive zip - assert: - that: - - unzip is changed - - not unzip.removed - - unzip_actual.content | b64decode == 'café.txt' - -# Module is not idempotent, will always change without creates -- name: unarchive zip again without creates - win_unzip: - src: '{{ win_unzip_dir }}\win_unzip.zip' - dest: '{{ win_unzip_dir }}\output' - register: unzip_again - -- name: assert unarchive zip again without creates - assert: - that: - - unzip_again is changed - - not unzip_again.removed - -- name: unarchive zip with creates - win_unzip: - src: '{{ win_unzip_dir }}\win_unzip.zip' - dest: '{{ win_unzip_dir }}\outout' - creates: '{{ win_unzip_dir }}\output\café.txt' - register: unzip_again_creates - -- name: assert unarchive zip with creates - assert: - that: - - not unzip_again_creates is changed - - not unzip_again_creates.removed - -- name: unarchive zip with delete (check) - win_unzip: - src: '{{ win_unzip_dir }}\win_unzip.zip' - dest: '{{ win_unzip_dir }}\output' - delete_archive: yes - register: unzip_delete_check - check_mode: yes - -- name: get result of unarchive zip with delete (check) - win_stat: - path: '{{ win_unzip_dir }}\win_unzip.zip' - register: unzip_delete_actual_check - -- name: assert unarchive zip with delete (check) - assert: - that: - - unzip_delete_check is changed - - unzip_delete_check.removed - - unzip_delete_actual_check.stat.exists - -- name: unarchive zip with delete - win_unzip: - src: '{{ win_unzip_dir }}\win_unzip.zip' - dest: '{{ win_unzip_dir }}\output' - delete_archive: yes - register: unzip_delete - -- name: get result of unarchive zip with delete - win_stat: - path: '{{ win_unzip_dir }}\win_unzip.zip' - register: unzip_delete_actual - -- name: assert unarchive zip with delete - assert: - that: - - unzip_delete is changed - - unzip_delete.removed - - not unzip_delete_actual.stat.exists - -# Path traversal tests (CVE-2020-1737) -- name: Create zip files - script: create_crafty_zip_files.py {{ output_dir }} - delegate_to: localhost - -- name: Copy zip files to Windows host - win_copy: - src: "{{ output_dir }}/{{ item }}.zip" - dest: "{{ win_unzip_dir }}/" - loop: - - hat1 - - hat2 - - handcuffs - - prison - -- name: Perform first trick - win_unzip: - src: '{{ win_unzip_dir }}\hat1.zip' - dest: '{{ win_unzip_dir }}\output' - register: hat_trick1 - -- name: Check for file - win_stat: - path: '{{ win_unzip_dir }}\output\rabbit.txt' - register: rabbit - -- name: Perform next tricks (which should all fail) - win_unzip: - src: '{{ win_unzip_dir }}\{{ item }}.zip' - dest: '{{ win_unzip_dir }}\output' - ignore_errors: yes - register: escape - loop: - - hat2 - - handcuffs - - prison - -- name: Search for files - win_find: - recurse: yes - paths: - - '{{ win_unzip_dir }}' - patterns: - - '*houdini.txt' - - '*rabbit.txt' - register: files - -- name: Check results - assert: - that: - - rabbit.stat.exists - - hat_trick1 is success - - escape.results | map(attribute='failed') | unique | list == [True] - - files.matched == 1 - - files.files[0]['filename'] == 'rabbit.txt' diff --git a/test/integration/targets/win_user_profile/aliases b/test/integration/targets/win_user_profile/aliases deleted file mode 100644 index 4f4664b685..0000000000 --- a/test/integration/targets/win_user_profile/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group5 diff --git a/test/integration/targets/win_user_profile/tasks/main.yml b/test/integration/targets/win_user_profile/tasks/main.yml deleted file mode 100644 index c37d219df3..0000000000 --- a/test/integration/targets/win_user_profile/tasks/main.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- name: set custom user facts - set_fact: - test_username: ansible_test - test_password: '{{ "password123!" + lookup("password", "/dev/null chars=ascii_letters,digits length=9") }}' - -- name: create test account - win_user: - name: '{{ test_username }}' - password: '{{ test_password }}' - state: present - register: test_username_info - -- block: - - name: check if profile exists - win_stat: - path: C:\temp\{{ test_username }} - register: profile_path - - - name: assert that profile doesn't exist before the test - assert: - that: - - not profile_path.stat.exists - - - name: run tests - include_tasks: tests.yml - - always: - - name: remove test account - win_user: - name: '{{ test_username }}' - state: absent - - - name: remove test account profile - win_user_profile: - name: '{{ item }}' - state: absent - remove_multiple: True - with_items: - - '{{ test_username }}' - - '{{ test_username }}.000' - - test_username_profile diff --git a/test/integration/targets/win_user_profile/tasks/tests.yml b/test/integration/targets/win_user_profile/tasks/tests.yml deleted file mode 100644 index 3c787f3217..0000000000 --- a/test/integration/targets/win_user_profile/tasks/tests.yml +++ /dev/null @@ -1,374 +0,0 @@ ---- -- name: create profile (check mode) - win_user_profile: - username: '{{ test_username }}' - state: present - register: create_profile_check - check_mode: True - -- name: check if profile was created (check mode) - win_stat: - path: C:\Users\{{ test_username }} - register: create_profile_actual_check - -- name: assert create profile (check mode) - assert: - that: - - create_profile_check is changed - - create_profile_check.path|lower == "c:\\users\\" + test_username - - not create_profile_actual_check.stat.exists - -- name: create profile - win_user_profile: - username: '{{ test_username }}' - state: present - register: create_profile - -- name: check if profile was created - win_stat: - path: C:\Users\{{ test_username }} - register: create_profile_actual - -- name: assert create profile - assert: - that: - - create_profile is changed - - create_profile.path|lower == "c:\\users\\" + test_username - - create_profile_actual.stat.exists - -- name: create profile (idempotent) - win_user_profile: - username: '{{ test_username }}' - state: present - register: create_profile_again - -- name: assert create profile (idempotent) - assert: - that: - - not create_profile_again is changed - - create_profile_again.path|lower == "c:\\users\\" + test_username - -- name: remove profile (check mode) - win_user_profile: - username: '{{ test_username }}' - state: absent - register: remove_profile_check - check_mode: True - -- name: check if profile was removed (check mode) - win_stat: - path: C:\Users\{{ test_username }} - register: remove_profile_actual_check - -- name: assert remove profile (check mode) - assert: - that: - - remove_profile_check is changed - - remove_profile_check.path|lower == "c:\\users\\" + test_username - - remove_profile_actual_check.stat.exists - -- name: remove profile - win_user_profile: - username: '{{ test_username }}' - state: absent - register: remove_profile - -- name: check if profile was removed - win_stat: - path: C:\Users\{{ test_username }} - register: remove_profile_actual - -- name: assert remove profile - assert: - that: - - remove_profile is changed - - remove_profile.path|lower == "c:\\users\\" + test_username - - not remove_profile_actual.stat.exists - -- name: remove profile (idempotent) - win_user_profile: - username: '{{ test_username }}' - state: absent - register: remove_profile_again - -- name: assert remove profile (idempotent) - assert: - that: - - not remove_profile_again is changed - - remove_profile_again.path == None - -- name: create profile with specific base path - win_user_profile: - username: '{{ test_username }}' - name: test_username_profile - state: present - register: create_profile_basename - -- name: check if profile with specific base path was created - win_stat: - path: C:\Users\test_username_profile - register: create_profile_basename_actual - -- name: assert create profile with specific base path - assert: - that: - - create_profile_basename is changed - - create_profile_basename.path|lower == "c:\\users\\test_username_profile" - - create_profile_basename_actual.stat.exists - -- name: remove profile with specific base path - win_user_profile: - username: '{{ test_username }}' - state: absent - register: remove_profile_basename - -- name: check if profile with specific base path was removed - win_stat: - path: C:\Users\test_username_profile - register: remove_profile_basename_actual - -- name: assert remove profile with specific base path - assert: - that: - - remove_profile_basename is changed - - remove_profile_basename.path|lower == "c:\\users\\test_username_profile" - - not remove_profile_basename_actual.stat.exists - -- name: create dummy profile folder - win_file: - path: C:\Users\{{ test_username }} - state: directory - -- block: - - name: create profile folder with conflict (check mode) - win_user_profile: - username: '{{ test_username }}' - state: present - register: create_profile_conflict_check - check_mode: True - - - name: get result of create profile folder with conflict (check mode) - win_stat: - path: C:\Users\{{ test_username }}.000 - register: create_profile_conflict_actual_check - - - name: assert create profile folder with conflict (check mode) - assert: - that: - - create_profile_conflict_check is changed - # The check mode path calc is dumb, doesn't check for conflicts - - create_profile_conflict_check.path|lower == "c:\\users\\" + test_username - - not create_profile_conflict_actual_check.stat.exists - - - name: create profile folder with conflict - win_user_profile: - username: '{{ test_username }}' - state: present - register: create_profile_conflict - - - name: get result of create profile with conflict - win_stat: - path: C:\Users\{{ test_username }}.000 - register: create_profile_conflict_actual - - - name: assert create profile folder with conflict - assert: - that: - - create_profile_conflict is changed - - create_profile_conflict.path|lower == "c:\\users\\" + test_username + ".000" - - create_profile_conflict_actual.stat.exists - - - name: remove profile with conflict - win_user_profile: - username: '{{ test_username }}' - state: absent - register: remove_profile_conflict - - - name: get result of profile folder after remove - win_stat: - path: C:\Users\{{ test_username }}.000 - register: remove_profile_conflict_actual - - - name: get result of dummy folder after remove - win_stat: - path: C:\Users\{{ test_username }} - register: remove_profile_conflict_dummy - - - name: assert remove profile with conflict - assert: - that: - - remove_profile_conflict is changed - - remove_profile_conflict.path|lower == "c:\\users\\" + test_username + ".000" - - not remove_profile_conflict_actual.stat.exists - - remove_profile_conflict_dummy.stat.exists - - always: - - name: remove dummy profile folder - win_file: - path: C:\Users\{{ test_username }} - state: absent - -- name: create profile for deleted user by sid test - win_user_profile: - username: '{{ test_username_info.sid }}' - state: present - -- name: delete user for deleted user with sid test - win_user: - name: '{{ test_username }}' - state: absent - -- name: remove profile for remove profile by sid test - win_user_profile: - username: '{{ test_username_info.sid }}' - state: absent - register: remove_profile_deleted_sid - -- name: check if profile was deleted for deleted user using a SID - win_stat: - path: C:\Users\{{ test_username }} - register: remove_profile_deleted_sid_actual - -- name: assert remove profile for deleted user using a SID - assert: - that: - - remove_profile_deleted_sid is changed - - remove_profile_deleted_sid.path|lower == "c:\\users\\" + test_username - - not remove_profile_deleted_sid_actual.stat.exists - -- name: recreate user for deleted user by name test - win_user: - name: '{{ test_username }}' - password: '{{ test_password }}' - state: present - register: test_orphan_user1 - -- name: create profile for deleted user by name test - win_user_profile: - username: '{{ test_username }}' - state: present - -- name: delete user for remove profile by name test - win_user: - name: '{{ test_username }}' - state: absent - -- name: remove profile for deleted user using a name - win_user_profile: - name: '{{ test_username }}' - state: absent - register: remove_profile_deleted_name - -- name: check if profile was deleted for deleted user using a name - win_stat: - path: C:\Users\{{ test_username }} - register: remove_profile_deleted_name_actual - -- name: assert remove profile for deleted user using a name - assert: - that: - - remove_profile_deleted_name is changed - - remove_profile_deleted_name.path|lower == "c:\\users\\" + test_username - - not remove_profile_deleted_name_actual.stat.exists - -- name: remove profile for deleted user using a name (idempotent) - win_user_profile: - name: '{{ test_username }}' - state: absent - register: remove_profile_deleted_name_again - -- name: assert remove profile for deleted user using a name (idempotent) - assert: - that: - - not remove_profile_deleted_name_again is changed - -- name: recreate user for remove multiple user test - win_user: - name: '{{ test_username }}' - password: '{{ test_password }}' - state: present - register: test_orphan_user1 - -- name: create new profile for remove multiple user test - win_user_profile: - username: '{{ test_username }}' - state: present - register: orphan_user1_profile - -- name: remove user 1 for remove multiple user test - win_user: - name: '{{ test_username }}' - state: absent - -# win_file has issues with paths exceeding MAX_PATH, need to use rmdir instead -- name: remove profile folder for user 1 - win_shell: rmdir /S /Q {{ orphan_user1_profile.path}} - args: - executable: cmd.exe - -- name: create user 2 for remove multiple user test - win_user: - name: '{{ test_username }}' - password: '{{ test_password }}' - state: present - register: test_orphan_user2 - -- name: create new profile for orphan user 2 - win_user_profile: - username: '{{ test_username }}' - state: present - register: orphan_user2_profile - -- name: remove orphan user 2 for remove multiple user test - win_user: - name: '{{ test_username }}' - state: present - -- name: fail to remove multiple profiles without flag - win_user_profile: - name: '{{ test_username }}' - state: absent - register: fail_remove_multiple - ignore_errors: True - -- name: check if profile was removed - win_stat: - path: C:\Users\{{ test_username }} - register: fail_remove_multiple_actual - -- name: assert that profile was not actually deleted - assert: - that: - - fail_remove_multiple.msg == "Found multiple profiles matching the path 'C:\\Users\\" + test_username + "', set 'remove_multiple=True' to remove all the profiles for this match" - - fail_remove_multiple_actual.stat.exists - -- name: remove multiple profiles - win_user_profile: - name: '{{ test_username }}' - state: absent - remove_multiple: True - register: remove_multiple - -- name: get result of remove multiple profiles - win_stat: - path: C:\Users\{{ test_username }} - register: remove_multiple_actual - -- name: check that orphan user 1 reg profile has been removed - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\{{ test_orphan_user1.sid }} - register: remove_orphan1_actual - -- name: check that orphan user 2 reg profile has been removed - win_reg_stat: - path: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\{{ test_orphan_user2.sid }} - register: remove_orphan2_actual - -- name: assert remove multiple profiles - assert: - that: - - remove_multiple is changed - - remove_multiple.path|lower == "c:\\users\\" + test_username - - not remove_multiple_actual.stat.exists - - not remove_orphan1_actual.exists - - not remove_orphan2_actual.exists diff --git a/test/integration/targets/win_wait_for_process/aliases b/test/integration/targets/win_wait_for_process/aliases deleted file mode 100644 index 215e0b0692..0000000000 --- a/test/integration/targets/win_wait_for_process/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group4 diff --git a/test/integration/targets/win_wait_for_process/tasks/main.yml b/test/integration/targets/win_wait_for_process/tasks/main.yml deleted file mode 100644 index c775001b8d..0000000000 --- a/test/integration/targets/win_wait_for_process/tasks/main.yml +++ /dev/null @@ -1,200 +0,0 @@ ---- -- name: Get powershell version - win_shell: $PSVersionTable.PSVersion.Major - register: powershell_version - -- name: Ensure Spooler service is started - win_service: - name: Spooler - state: started - -- name: Wait for non-existing process to not exist - win_wait_for_process: - process_name_exact: - - ansible_foobar - timeout: 30 - state: absent - register: absent_nonexisting_process - -- assert: - that: - - absent_nonexisting_process is success - - absent_nonexisting_process is not changed - - absent_nonexisting_process.elapsed > 0 - - absent_nonexisting_process.elapsed < 30 - - absent_nonexisting_process.matched_processes|length == 0 - -- name: Wait for non-existing process until timeout - win_wait_for_process: - process_name_exact: ansible_foobar - timeout: 30 - state: present - ignore_errors: yes - register: present_nonexisting_process - -- assert: - that: - - present_nonexisting_process is failed - - present_nonexisting_process is not changed - - present_nonexisting_process.elapsed > 30 - - present_nonexisting_process.msg == 'Timed out while waiting for process(es) to start' - - present_nonexisting_process.matched_processes|length == 0 - -- name: Wait for existing process to exist - win_wait_for_process: - process_name_exact: spoolsv - timeout: 30 - state: present - register: present_existing_process - -- assert: - that: - - present_existing_process is success - - present_existing_process is not changed - - present_existing_process.elapsed > 0 - - present_existing_process.elapsed < 30 - - present_existing_process.matched_processes|length > 0 - -- name: Wait for existing process until timeout - win_wait_for_process: - process_name_exact: - - spoolsv - timeout: 30 - state: absent - ignore_errors: yes - register: absent_existing_process - -- assert: - that: - - absent_existing_process is failed - - absent_existing_process is not changed - - absent_existing_process.elapsed > 30 - - absent_existing_process.matched_processes|length > 0 - - absent_existing_process.msg == 'Timeout while waiting for process(es) to stop' - -- name: Wait for existing process to exist (using owner) - win_wait_for_process: - process_name_exact: spoolsv - owner: SYSTEM - timeout: 30 - state: present - ignore_errors: yes - register: present_existing_owner_process - -- assert: - that: - - present_existing_owner_process is success - - present_existing_owner_process is not changed - - present_existing_owner_process.elapsed > 0 - - present_existing_owner_process.elapsed < 30 - - present_existing_owner_process.matched_processes|length > 0 - when: powershell_version.stdout_lines[0]|int >= 4 - -- assert: - that: - - present_existing_owner_process is failed - - present_existing_owner_process is not changed - - present_existing_owner_process.elapsed == 0 - - present_existing_owner_process.matched_processes|length == 0 - - present_existing_owner_process.msg == "This version of Powershell does not support filtering processes by 'owner'." - when: powershell_version.stdout_lines[0]|int < 4 - -- name: Wait for Spooler service to stop - win_wait_for_process: - process_name_exact: - - spoolsv - timeout: 60 - state: absent - async: 30 - poll: 0 - register: spoolsv_process - -- name: Stop the Spooler service - win_service: - name: Spooler - force_dependent_services: yes - state: stopped - -- name: Check on async task - async_status: - jid: '{{ spoolsv_process.ansible_job_id }}' - until: absent_spoolsv_process is finished - retries: 20 - register: absent_spoolsv_process - -- assert: - that: - - absent_spoolsv_process is success - - absent_spoolsv_process is not changed - - absent_spoolsv_process is finished - - absent_spoolsv_process.elapsed > 0 - - absent_spoolsv_process.elapsed < 30 - - absent_spoolsv_process.matched_processes|length == 1 - -- name: Wait for Spooler service to start - win_wait_for_process: - process_name_exact: spoolsv - timeout: 60 - state: present - async: 60 - poll: 0 - register: spoolsv_process - -- name: Start the spooler service - win_service: - name: Spooler - force_dependent_services: yes - state: started - -- name: Check on async task - async_status: - jid: '{{ spoolsv_process.ansible_job_id }}' - until: present_spoolsv_process is finished - retries: 10 - register: present_spoolsv_process - -- assert: - that: - - present_spoolsv_process is success - - present_spoolsv_process is not changed - - present_spoolsv_process is finished - - present_spoolsv_process.elapsed > 0 - - present_spoolsv_process.elapsed < 60 - - present_spoolsv_process.matched_processes|length == 1 - -- name: Start a new long-running process - win_shell: | - Start-Sleep -Seconds 15 - async: 40 - poll: 0 - register: sleep_pid - -- name: Wait for PID to start - win_wait_for_process: - pid: '{{ sleep_pid.ansible_async_watchdog_pid }}' - timeout: 20 - state: present - register: present_sleep_pid - -- assert: - that: - - present_sleep_pid is success - - present_sleep_pid is not changed - - present_sleep_pid.elapsed > 0 - - present_sleep_pid.elapsed < 15 - - present_sleep_pid.matched_processes|length == 1 - -- name: Wait for PID to stop - win_wait_for_process: - pid: '{{ sleep_pid.ansible_async_watchdog_pid }}' - timeout: 20 - state: absent - register: absent_sleep_pid - -- assert: - that: - - absent_sleep_pid is success - - absent_sleep_pid is not changed - - absent_sleep_pid.elapsed > 0 - - absent_sleep_pid.elapsed < 15 - - absent_sleep_pid.matched_processes|length == 1 diff --git a/test/integration/targets/win_wakeonlan/aliases b/test/integration/targets/win_wakeonlan/aliases deleted file mode 100644 index 3cf5b97e80..0000000000 --- a/test/integration/targets/win_wakeonlan/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group3 diff --git a/test/integration/targets/win_wakeonlan/tasks/main.yml b/test/integration/targets/win_wakeonlan/tasks/main.yml deleted file mode 100644 index 169362b002..0000000000 --- a/test/integration/targets/win_wakeonlan/tasks/main.yml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Send a magic Wake-on-LAN packet to 00:00:5E:00:53:66 - win_wakeonlan: - mac: 00:00:5E:00:53:66 - broadcast: 192.0.2.255 - -- name: Send a magic Wake-On-LAN packet on port 9 to 00-00-5E-00-53-66 - win_wakeonlan: - mac: 00-00-5E-00-53-66 - port: 9 diff --git a/test/integration/targets/win_xml/aliases b/test/integration/targets/win_xml/aliases deleted file mode 100644 index 4cd27b3cb2..0000000000 --- a/test/integration/targets/win_xml/aliases +++ /dev/null @@ -1 +0,0 @@ -shippable/windows/group1 diff --git a/test/integration/targets/win_xml/files/books.xml b/test/integration/targets/win_xml/files/books.xml deleted file mode 100644 index e38ee15d4e..0000000000 --- a/test/integration/targets/win_xml/files/books.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<books> - <works lang="en"> - <title lang="en" isbn13="123412341234X">A Great Book</title> - <title lang="en" isbn13="1234109823400">Best Book Ever</title> - <title lang="en" isbn13="123412121234X">Worst Book Ever</title> - <title lang="en" isbn13="423412341234X">Another Book</title> - <title lang="en" isbn13="523412341234X">Worst Book Ever Two</title> - </works> -</books> diff --git a/test/integration/targets/win_xml/files/config.xml b/test/integration/targets/win_xml/files/config.xml deleted file mode 100644 index 68a6cdca47..0000000000 --- a/test/integration/targets/win_xml/files/config.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<config> - <string key="foo">bar</string> -</config> diff --git a/test/integration/targets/win_xml/files/log4j.xml b/test/integration/targets/win_xml/files/log4j.xml deleted file mode 100644 index 54b76cf7f2..0000000000 --- a/test/integration/targets/win_xml/files/log4j.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> -<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> - <appender name="stdout" class="org.apache.log4j.ConsoleAppender" > - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="[%d{dd/MM/yy hh:mm:ss:sss z}] %5p %c{2}: %m%n"/> - </layout> - </appender> - - <appender name="file" class="org.apache.log4j.DailyRollingFileAppender"> - <param name="append" value="true" /> - <param name="encoding" value="UTF-8" /> - <param name="file" value="mylogfile.log" /> - <param name="DatePattern" value="'.'yyyy-MM-dd" /> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="[%-25d{ISO8601}] %-5p %x %C{1} -- %m\n" /> - </layout> - </appender> - - <logger name="org.springframework.security.web.FilterChainProxy" additivity="false"> - <level value="error"/> - <appender-ref ref="file" /> - </logger> - - <logger name="org.springframework.security.web.context.HttpSessionSecurityContextRepository" additivity="false"> - <level value="error"/> - <appender-ref ref="file" /> - </logger> - - <logger name="org.springframework.security.web.context.SecurityContextPersistenceFilter" additivity="false"> - <level value="error"/> - <appender-ref ref="file" /> - </logger> - - <logger name="org.springframework.security.web.access.intercept" additivity="false"> - <level value="error"/> - <appender-ref ref="stdout" /> - </logger> - - <logger name="org.apache.commons.digester" additivity="false"> - <level value="info"/> - <appender-ref ref="stdout" /> - </logger> - - <root> - <priority value="debug"/> - <appender-ref ref="stdout"/> - </root> -</log4j:configuration> diff --git a/test/integration/targets/win_xml/files/plane.zip b/test/integration/targets/win_xml/files/plane.zip Binary files differdeleted file mode 100644 index 8157182aac..0000000000 --- a/test/integration/targets/win_xml/files/plane.zip +++ /dev/null diff --git a/test/integration/targets/win_xml/meta/main.yml b/test/integration/targets/win_xml/meta/main.yml deleted file mode 100644 index d328716dfa..0000000000 --- a/test/integration/targets/win_xml/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - prepare_win_tests diff --git a/test/integration/targets/win_xml/tasks/main.yml b/test/integration/targets/win_xml/tasks/main.yml deleted file mode 100644 index d3d98693ff..0000000000 --- a/test/integration/targets/win_xml/tasks/main.yml +++ /dev/null @@ -1,307 +0,0 @@ -# test code for the Windows xml module -# (c) 2017, Richard Levenberg <richard.levenberg@cosocloud.com> - -# 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 <http://www.gnu.org/licenses/>. - -- name: copy a test .xml file - win_copy: - src: config.xml - dest: "{{ win_output_dir }}\\config.xml" - -- name: add an element that only has a text child node - win_xml: - path: "{{ win_output_dir }}\\config.xml" - fragment: '<string key="answer">42</string>' - xpath: '/config' - register: element_add_result - -- name: check element add result - assert: - that: - - element_add_result is changed - -- name: try to add the element that only has a text child node again - win_xml: - path: "{{ win_output_dir }}\\config.xml" - fragment: '<string key="answer">42</string>' - xpath: '/config' - register: element_add_result_second - -- name: check element add result - assert: - that: - - not element_add_result_second is changed - -- name: copy a test log4j.xml - win_copy: - src: log4j.xml - dest: "{{ win_output_dir }}\\log4j.xml" - -- name: change an attribute to fatal logging - win_xml: - path: "{{ win_output_dir }}\\log4j.xml" - xpath: '/log4j:configuration/logger[@name="org.apache.commons.digester"]/level' - type: attribute - attribute: 'value' - fragment: 'FATAL' - -- name: try to change the attribute again - win_xml: - path: "{{ win_output_dir }}\\log4j.xml" - xpath: '/log4j:configuration/logger[@name="org.apache.commons.digester"]/level' - type: attribute - attribute: 'value' - fragment: 'FATAL' - register: attribute_changed_result - -- name: check attribute change result - assert: - that: - - attribute_changed_result is not changed - -# This testing is for https://github.com/ansible/ansible/issues/48471 -# The issue was that an .xml with no encoding declaration, but a UTF8 BOM -# with some UTF-8 characters was being written out with garbage characters. -# The characters added by win_xml were not UTF-8 characters. - -- name: copy test files (https://github.com/ansible/ansible/issues/48471) - win_copy: - src: plane.zip - dest: "{{ win_output_dir }}\\plane.zip" - -- name: unarchive the test files - win_unzip: - src: "{{ win_output_dir }}\\plane.zip" - dest: "{{ win_output_dir }}\\" - -- name: change a text value in a file with UTF8 BOM and armenian characters in the description - win_xml: - path: "{{ win_output_dir }}\\plane-utf8-bom-armenian-characters.xml" - xpath: '/plane/year' - type: text - fragment: '1988' - -- name: register the sha1 of the new file - win_stat: - path: "{{ win_output_dir }}\\plane-utf8-bom-armenian-characters.xml" - get_checksum: yes - register: sha1_checksum - -- name: verify the checksum - assert: - that: - - sha1_checksum.stat.checksum == 'e3e18c3066e1bfce9a5cf87c81353fa174440944' - -- name: change a text value in a file with UTF8 BOM and armenian characters in the description - win_xml: - path: "{{ win_output_dir }}\\plane-utf8-bom-armenian-characters.xml" - xpath: '/plane/year' - type: text - fragment: '1989' - backup: yes - register: test_backup - -- name: check backup_file - win_stat: - path: '{{ test_backup.backup_file }}' - register: backup_file - -- name: Check backup_file - assert: - that: - - test_backup is changed - - backup_file.stat.exists == true - -- name: change a text value in a file with UTF-16 BE BOM and Chinese characters in the description - win_xml: - path: "{{ win_output_dir }}\\plane-utf16be-bom-chinese-characters.xml" - xpath: '/plane/year' - type: text - fragment: '1988' - -- name: register the sha1 of the new file - win_stat: - path: "{{ win_output_dir}}\\plane-utf16be-bom-chinese-characters.xml" - get_checksum: yes - register: sha1_checksum - -- name: verify the checksum - assert: - that: - - sha1_checksum.stat.checksum == 'de86f79b409383447cf4cf112b20af8ffffcfdbf' - -# features added ansible 2.8 -# count - -- name: count logger nodes in log4j.xml - win_xml: - path: "{{ win_output_dir }}\\log4j.xml" - xpath: //logger - count: yes - register: logger_node_count - -- name: verify node count - assert: - that: - - logger_node_count.count == 5 - -# multiple attribute change -- name: ensure //logger/level value attributes are set to debug - win_xml: - path: "{{ win_output_dir }}\\log4j.xml" - xpath: '//logger/level[@value="error"]' - type: attribute - attribute: value - fragment: debug - count: yes - register: logger_level_value_attrs - -- name: verify //logger/level value attributes - assert: - that: - - logger_level_value_attrs.count == 4 - - logger_level_value_attrs.changed == true - - logger_level_value_attrs.msg == 'attribute changed' - -- name: ensure //logger/level value attributes are set to debug (idempotency) - win_xml: - path: "{{ win_output_dir }}\\log4j.xml" - xpath: '//logger/level[@value="error"]' - type: attribute - attribute: value - fragment: debug - count: yes - register: logger_level_value_attrs_again - -- name: verify //logger/level value attributes again (idempotency) - assert: - that: - - logger_level_value_attrs_again.count == 0 - - logger_level_value_attrs_again.changed == false - - logger_level_value_attrs_again.msg == 'The supplied xpath did not match any nodes. If this is unexpected, check your xpath is valid for the xml file at supplied path.' - -# multiple text nodes -- name: ensure test books.xml is present - win_copy: - src: books.xml - dest: '{{ win_output_dir }}\books.xml' - -- name: demonstrate multi text replace by replacing all title text elements - win_xml: - path: '{{ win_output_dir }}\books.xml' - xpath: //works/title - type: text - fragment: _TITLE_TEXT_REMOVED_BY_WIN_XML_MODULE_ - count: yes - register: multi_text - -- name: verify multi text change - assert: - that: - - multi_text.changed == true - - multi_text.count == 5 - - multi_text.msg == 'text changed' - -- name: demonstrate multi text replace by replacing all title text elements again (idempotency) - win_xml: - path: '{{ win_output_dir }}\books.xml' - xpath: //works/title - type: text - fragment: _TITLE_TEXT_REMOVED_BY_WIN_XML_MODULE_ - count: yes - register: multi_text_again - -- name: verify multi text again change (idempotency) - assert: - that: - - multi_text_again.changed == false - - multi_text_again.count == 5 - - multi_text_again.msg == 'not changed' - -# multiple element - -#- name: ensure a fresh test books.xml is present -# win_copy: -# src: books.xml -# dest: '{{ win_output_dir }}\books.xml' - -- name: demonstrate multi element should append new information element from fragment - win_xml: - path: '{{ win_output_dir }}\books.xml' - xpath: //works/title - type: element - fragment: <information>This element added by ansible</information> - count: yes - register: multi_element - -- name: verify multi element - assert: - that: - - multi_element.changed == true - - multi_element.count == 5 - - multi_element.msg == 'element changed' - -- name: demonstrate multi element unchanged (idempotency) - win_xml: - path: '{{ win_output_dir }}\books.xml' - xpath: //works/title - type: element - fragment: <information>This element added by ansible</information> - count: yes - register: multi_element_again - -- name: verify multi element again (idempotency) - assert: - that: - - multi_element_again.changed == false - - multi_element_again.count == 5 - - multi_element_again.msg == 'not changed' - -# multiple attributes on differing parent nodes - -- name: ensure all attribute lang=nl - win_xml: - path: '{{ win_output_dir }}\books.xml' - xpath: //@lang - type: attribute - attribute: lang - fragment: nl - count: yes - register: multi_attr - -- name: verify multi attribute - assert: - that: - - multi_attr.changed == true - - multi_attr.count == 6 - - multi_attr.msg == 'attribute changed' - -- name: ensure all attribute lang=nl (idempotency) - win_xml: - path: '{{ win_output_dir }}\books.xml' - xpath: //@lang - type: attribute - attribute: lang - fragment: nl - count: yes - register: multi_attr_again - -- name: verify multi attribute (idempotency) - assert: - that: - - multi_attr_again.changed == false - - multi_attr_again.count == 6 - - multi_attr_again.msg == 'not changed' diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index a290c597a1..37c3182fdf 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -3967,19 +3967,9 @@ lib/ansible/modules/web_infrastructure/ansible_tower/tower_workflow_template.py lib/ansible/modules/windows/async_status.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/setup.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_acl_inheritance.ps1 pslint:PSAvoidTrailingWhitespace -lib/ansible/modules/windows/win_audit_rule.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_certificate_store.ps1 validate-modules:parameter-type-not-in-doc -lib/ansible/modules/windows/win_chocolatey.ps1 validate-modules:doc-elements-mismatch -lib/ansible/modules/windows/win_chocolatey_config.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_chocolatey_facts.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_chocolatey_source.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_copy.ps1 pslint:PSUseApprovedVerbs -lib/ansible/modules/windows/win_credential.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_credential.ps1 validate-modules:doc-elements-mismatch -lib/ansible/modules/windows/win_credential.ps1 validate-modules:parameter-type-not-in-doc -lib/ansible/modules/windows/win_defrag.ps1 validate-modules:parameter-list-no-elements lib/ansible/modules/windows/win_dns_client.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_dns_record.ps1 validate-modules:doc-elements-mismatch lib/ansible/modules/windows/win_domain.ps1 pslint:PSAvoidUsingEmptyCatchBlock # Keep lib/ansible/modules/windows/win_domain.ps1 pslint:PSUseApprovedVerbs lib/ansible/modules/windows/win_domain_controller.ps1 pslint:PSAvoidGlobalVars # New PR @@ -3988,65 +3978,18 @@ lib/ansible/modules/windows/win_domain_controller.ps1 pslint:PSUseApprovedVerbs lib/ansible/modules/windows/win_domain_membership.ps1 pslint:PSAvoidGlobalVars # New PR lib/ansible/modules/windows/win_domain_membership.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_domain_membership.ps1 pslint:PSUseApprovedVerbs -lib/ansible/modules/windows/win_dotnet_ngen.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_dsc.ps1 pslint:PSAvoidUsingEmptyCatchBlock # Keep lib/ansible/modules/windows/win_dsc.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_eventlog.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_feature.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_file_version.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_find.ps1 pslint:PSAvoidUsingEmptyCatchBlock # Keep lib/ansible/modules/windows/win_find.ps1 validate-modules:doc-elements-mismatch -lib/ansible/modules/windows/win_firewall_rule.ps1 pslint:PSUseApprovedVerbs -lib/ansible/modules/windows/win_hosts.ps1 validate-modules:doc-elements-mismatch -lib/ansible/modules/windows/win_hotfix.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_hotfix.ps1 pslint:PSUseApprovedVerbs -lib/ansible/modules/windows/win_http_proxy.ps1 validate-modules:parameter-list-no-elements -lib/ansible/modules/windows/win_http_proxy.ps1 validate-modules:parameter-type-not-in-doc -lib/ansible/modules/windows/win_iis_virtualdirectory.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_iis_webapplication.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_iis_webapppool.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_iis_webbinding.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_iis_webbinding.ps1 pslint:PSUseApprovedVerbs -lib/ansible/modules/windows/win_iis_website.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_inet_proxy.ps1 validate-modules:parameter-list-no-elements -lib/ansible/modules/windows/win_inet_proxy.ps1 validate-modules:parameter-type-not-in-doc -lib/ansible/modules/windows/win_lineinfile.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_mapped_drive.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_netbios.ps1 validate-modules:parameter-list-no-elements lib/ansible/modules/windows/win_optional_feature.ps1 validate-modules:parameter-list-no-elements -lib/ansible/modules/windows/win_pagefile.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_pagefile.ps1 pslint:PSUseDeclaredVarsMoreThanAssignments # New PR - bug test_path should be testPath -lib/ansible/modules/windows/win_pagefile.ps1 pslint:PSUseSupportsShouldProcess -lib/ansible/modules/windows/win_pester.ps1 validate-modules:doc-elements-mismatch -lib/ansible/modules/windows/win_product_facts.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_psexec.ps1 validate-modules:parameter-list-no-elements -lib/ansible/modules/windows/win_psexec.ps1 validate-modules:parameter-type-not-in-doc -lib/ansible/modules/windows/win_rabbitmq_plugin.ps1 pslint:PSAvoidUsingInvokeExpression -lib/ansible/modules/windows/win_rabbitmq_plugin.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_rds_cap.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_rds_rap.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_rds_settings.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_regedit.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_region.ps1 pslint:PSAvoidUsingEmptyCatchBlock # Keep -lib/ansible/modules/windows/win_region.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_regmerge.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_robocopy.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_say.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_security_policy.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_security_policy.ps1 pslint:PSUseApprovedVerbs lib/ansible/modules/windows/win_share.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_shell.ps1 pslint:PSUseApprovedVerbs -lib/ansible/modules/windows/win_shortcut.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_snmp.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_unzip.ps1 pslint:PSUseApprovedVerbs lib/ansible/modules/windows/win_updates.ps1 pslint:PSCustomUseLiteralPath lib/ansible/modules/windows/win_uri.ps1 pslint:PSAvoidUsingEmptyCatchBlock # Keep -lib/ansible/modules/windows/win_user_profile.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_user_profile.ps1 validate-modules:parameter-type-not-in-doc lib/ansible/modules/windows/win_wait_for.ps1 pslint:PSCustomUseLiteralPath -lib/ansible/modules/windows/win_wait_for_process.ps1 validate-modules:parameter-list-no-elements -lib/ansible/modules/windows/win_webpicmd.ps1 pslint:PSAvoidUsingInvokeExpression -lib/ansible/modules/windows/win_xml.ps1 pslint:PSCustomUseLiteralPath lib/ansible/parsing/vault/__init__.py pylint:blacklisted-name lib/ansible/playbook/base.py pylint:blacklisted-name lib/ansible/playbook/collectionsearch.py required-and-default-attributes # https://github.com/ansible/ansible/issues/61460 @@ -4248,24 +4191,16 @@ test/integration/targets/wait_for/files/testserver.py future-import-boilerplate test/integration/targets/wait_for/files/testserver.py metaclass-boilerplate test/integration/targets/want_json_modules_posix/library/helloworld.py future-import-boilerplate test/integration/targets/want_json_modules_posix/library/helloworld.py metaclass-boilerplate -test/integration/targets/win_audit_rule/library/test_get_audit_rule.ps1 pslint:PSCustomUseLiteralPath -test/integration/targets/win_chocolatey/files/tools/chocolateyUninstall.ps1 pslint:PSCustomUseLiteralPath -test/integration/targets/win_chocolatey_source/library/choco_source.ps1 pslint:PSCustomUseLiteralPath test/integration/targets/win_dsc/files/xTestDsc/1.0.0/DSCResources/ANSIBLE_xSetReboot/ANSIBLE_xSetReboot.psm1 pslint!skip test/integration/targets/win_dsc/files/xTestDsc/1.0.0/DSCResources/ANSIBLE_xTestResource/ANSIBLE_xTestResource.psm1 pslint!skip test/integration/targets/win_dsc/files/xTestDsc/1.0.0/xTestDsc.psd1 pslint!skip test/integration/targets/win_dsc/files/xTestDsc/1.0.1/DSCResources/ANSIBLE_xTestResource/ANSIBLE_xTestResource.psm1 pslint!skip test/integration/targets/win_dsc/files/xTestDsc/1.0.1/xTestDsc.psd1 pslint!skip test/integration/targets/win_exec_wrapper/library/test_fail.ps1 pslint:PSCustomUseLiteralPath -test/integration/targets/win_iis_webbinding/library/test_get_webbindings.ps1 pslint:PSUseApprovedVerbs test/integration/targets/win_module_utils/library/legacy_only_new_way_win_line_ending.ps1 line-endings # Explicitly tests that we still work with Windows line endings test/integration/targets/win_module_utils/library/legacy_only_old_way_win_line_ending.ps1 line-endings # Explicitly tests that we still work with Windows line endings test/integration/targets/win_ping/library/win_ping_syntax_error.ps1 pslint!skip -test/integration/targets/win_psmodule/files/module/template.psd1 pslint!skip -test/integration/targets/win_psmodule/files/module/template.psm1 pslint!skip -test/integration/targets/win_psmodule/files/setup_modules.ps1 pslint:PSCustomUseLiteralPath test/integration/targets/win_reboot/templates/post_reboot.ps1 pslint:PSCustomUseLiteralPath -test/integration/targets/win_regmerge/templates/win_line_ending.j2 line-endings test/integration/targets/win_script/files/test_script.ps1 pslint:PSAvoidUsingWriteHost # Keep test/integration/targets/win_script/files/test_script_creates_file.ps1 pslint:PSAvoidUsingCmdletAliases test/integration/targets/win_script/files/test_script_removes_file.ps1 pslint:PSCustomUseLiteralPath diff --git a/test/units/plugins/lookup/test_laps_password.py b/test/units/plugins/lookup/test_laps_password.py deleted file mode 100644 index af0664e6a6..0000000000 --- a/test/units/plugins/lookup/test_laps_password.py +++ /dev/null @@ -1,519 +0,0 @@ -# -*- coding: utf-8 -*- -# (c) 2019, Jordan Borean <jborean@redhat.com> -# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - -# Make coding more python3-ish -from __future__ import (absolute_import, division, print_function) -__metaclass__ = type - -import os -import platform -import pytest -import sys - -from units.compat.mock import MagicMock - -from ansible.errors import AnsibleLookupError -from ansible.plugins.loader import lookup_loader - - -class FakeLDAPError(Exception): - pass - - -class FakeLDAPAuthUnknownError(Exception): - pass - - -class FakeLdap(object): - SASL_AVAIL = 1 - TLS_AVAIL = 1 - - SCOPE_SUBTREE = 2 - - OPT_PROTOCOL_VERSION = 17 - OPT_REFERRALS = 8 - - OPT_X_TLS_NEVER = 0 - OPT_X_TLS_DEMAND = 2 - OPT_X_TLS_ALLOW = 3 - OPT_X_TLS_TRY = 4 - - OPT_X_TLS_CACERTFILE = 24578 - OPT_X_TLS_REQUIRE_CERT = 24582 - - LDAPError = FakeLDAPError - AUTH_UNKNOWN = FakeLDAPAuthUnknownError - - @staticmethod - def initialize(uri, bytes_mode=None, **kwargs): - return MagicMock() - - @staticmethod - def set_option(option, invalue): - pass - - -class FakeLdapUrl(object): - - def __init__(self, ldapUrl=None, urlscheme='ldap', hostport='', **kwargs): - url = ldapUrl if ldapUrl else "%s://%s" % (urlscheme, hostport) - self.urlscheme = url.split('://', 2)[0].lower() - self._url = url - - def initializeUrl(self): - return self._url - - -def fake_is_ldap_url(s): - s_lower = s.lower() - return s_lower.startswith("ldap://") or s_lower.startswith("ldaps://") or s_lower.startswith("ldapi://") - - -@pytest.fixture(autouse=True) -def laps_password(): - """Imports and the laps_password lookup with a mocks laps module for testing""" - - # Build the fake ldap and ldapurl Python modules - fake_ldap_obj = FakeLdap() - fake_ldap_url_obj = MagicMock() - fake_ldap_url_obj.isLDAPUrl.side_effect = fake_is_ldap_url - fake_ldap_url_obj.LDAPUrl.side_effect = FakeLdapUrl - - # Take a snapshot of sys.modules before we manipulate it - orig_modules = sys.modules.copy() - try: - sys.modules["ldap"] = fake_ldap_obj - sys.modules["ldapurl"] = fake_ldap_url_obj - - from ansible.plugins.lookup import laps_password - - # ensure the changes to these globals aren't persisted after each test - orig_has_ldap = laps_password.HAS_LDAP - orig_ldap_imp_err = laps_password.LDAP_IMP_ERR - - yield laps_password - - laps_password.HAS_LDAP = orig_has_ldap - laps_password.LDAP_IMP_ERR = orig_ldap_imp_err - finally: - # Restore sys.modules back to our pre-shenanigans - sys.modules = orig_modules - - -def test_missing_ldap(laps_password): - laps_password.HAS_LDAP = False - laps_password.LDAP_IMP_ERR = "no import for you!" - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="test") - - assert str(err.value).startswith( - "Failed to import the required Python library (python-ldap) on %s's Python %s. See " - "https://pypi.org/project/python-ldap/ for more info. Please " - % (platform.node(), sys.executable) - ) - assert str(err.value).endswith(". Import Error: no import for you!") - - -def test_invalid_cert_mapping(): - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="test", validate_certs="incorrect") - - assert str(err.value) == "Invalid validate_certs value 'incorrect': valid values are 'allow', 'demand', " \ - "'never', 'try'" - - -def test_invalid_auth(): - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="test", auth="fail") - - assert str(err.value) == "Invalid auth value 'fail': expecting either 'gssapi', or 'simple'" - - -def test_gssapi_without_sasl(monkeypatch, ): - monkeypatch.setattr("ldap.SASL_AVAIL", 0) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="test") - - assert str(err.value) == "Cannot use auth=gssapi when SASL is not configured with the local LDAP install" - - -def test_simple_auth_without_credentials(): - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="test", auth="simple") - - assert str(err.value) == "The username and password values are required when auth=simple" - - -def test_gssapi_auth_with_credentials(): - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="test", auth="gssapi", username="u", password="p") - - assert str(err.value) == "Explicit credentials are not supported when auth='gssapi'. Call kinit outside of Ansible" - - -def test_not_encrypted_without_override(): - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="dc01", auth="simple", username="test", password="test") - - assert str(err.value) == "Current configuration will result in plaintext traffic exposing credentials. Set " \ - "auth=gssapi, scheme=ldaps, start_tls=True, or allow_plaintext=True to continue" - - -def test_ldaps_without_tls(monkeypatch, ): - monkeypatch.setattr("ldap.TLS_AVAIL", 0) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="dc01", scheme="ldaps") - - assert str(err.value) == "Cannot use TLS as the local LDAP installed has not been configured to support it" - - -def test_start_tls_without_tls(monkeypatch, ): - monkeypatch.setattr("ldap.TLS_AVAIL", 0) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run(["host"], domain="dc01", start_tls=True) - - assert str(err.value) == "Cannot use TLS as the local LDAP installed has not been configured to support it" - - -def test_normal_run(monkeypatch, laps_password): - def get_laps_password(conn, cn, search_base): - return "CN=%s,%s" % (cn, search_base) - - mock_ldap = MagicMock() - mock_ldap.return_value.read_rootdse_s.return_value = {"defaultNamingContext": ["DC=domain,DC=com"]} - monkeypatch.setattr("ldap.initialize", mock_ldap) - - mock_get_laps_password = MagicMock(side_effect=get_laps_password) - monkeypatch.setattr(laps_password, "get_laps_password", mock_get_laps_password) - - actual = lookup_loader.get('laps_password').run(["host1", "host2"], domain="dc01") - assert actual == ["CN=host1,DC=domain,DC=com", "CN=host2,DC=domain,DC=com"] - - # Verify the call count to get_laps_password - assert mock_get_laps_password.call_count == 2 - - # Verify the initialize() method call - assert mock_ldap.call_count == 1 - assert mock_ldap.call_args[0] == ("ldap://dc01:389",) - assert mock_ldap.call_args[1] == {"bytes_mode": False} - - # Verify the number of calls made to the mocked LDAP object - assert mock_ldap.mock_calls[1][0] == "().set_option" - assert mock_ldap.mock_calls[1][1] == (FakeLdap.OPT_PROTOCOL_VERSION, 3) - - assert mock_ldap.mock_calls[2][0] == "().set_option" - assert mock_ldap.mock_calls[2][1] == (FakeLdap.OPT_REFERRALS, 0) - - assert mock_ldap.mock_calls[3][0] == '().sasl_gssapi_bind_s' - assert mock_ldap.mock_calls[3][1] == () - - assert mock_ldap.mock_calls[4][0] == "().read_rootdse_s" - assert mock_ldap.mock_calls[4][1] == () - - assert mock_ldap.mock_calls[5][0] == "().unbind_s" - assert mock_ldap.mock_calls[5][1] == () - - -def test_run_with_simple_auth_and_search_base(monkeypatch, laps_password): - def get_laps_password(conn, cn, search_base): - return "CN=%s,%s" % (cn, search_base) - - mock_ldap = MagicMock() - monkeypatch.setattr("ldap.initialize", mock_ldap) - - mock_get_laps_password = MagicMock(side_effect=get_laps_password) - monkeypatch.setattr(laps_password, "get_laps_password", mock_get_laps_password) - - actual = lookup_loader.get('laps_password').run(["host1", "host2"], domain="dc01", auth="simple", username="user", - password="pass", allow_plaintext=True, - search_base="OU=Workstations,DC=domain,DC=com") - assert actual == ["CN=host1,OU=Workstations,DC=domain,DC=com", "CN=host2,OU=Workstations,DC=domain,DC=com"] - - # Verify the call count to get_laps_password - assert mock_get_laps_password.call_count == 2 - - # Verify the initialize() method call - assert mock_ldap.call_count == 1 - assert mock_ldap.call_args[0] == ("ldap://dc01:389",) - assert mock_ldap.call_args[1] == {"bytes_mode": False} - - # Verify the number of calls made to the mocked LDAP object - assert mock_ldap.mock_calls[1][0] == "().set_option" - assert mock_ldap.mock_calls[1][1] == (FakeLdap.OPT_PROTOCOL_VERSION, 3) - - assert mock_ldap.mock_calls[2][0] == "().set_option" - assert mock_ldap.mock_calls[2][1] == (FakeLdap.OPT_REFERRALS, 0) - - assert mock_ldap.mock_calls[3][0] == '().bind_s' - assert mock_ldap.mock_calls[3][1] == (u"user", u"pass") - - assert mock_ldap.mock_calls[4][0] == "().unbind_s" - assert mock_ldap.mock_calls[4][1] == () - - -@pytest.mark.parametrize("kwargs, expected", [ - [{"domain": "dc01"}, "ldap://dc01:389"], - [{"domain": "dc02", "port": 1234}, "ldap://dc02:1234"], - [{"domain": "dc03", "scheme": "ldaps"}, "ldaps://dc03:636"], - # Verifies that an explicit URI ignores port and scheme - [{"domain": "ldap://dc04", "port": 1234, "scheme": "ldaps"}, "ldap://dc04"], -]) -def test_uri_options(monkeypatch, kwargs, expected): - mock_ldap = MagicMock() - monkeypatch.setattr("ldap.initialize", mock_ldap) - - lookup_loader.get('laps_password').run([], **kwargs) - - assert mock_ldap.call_count == 1 - assert mock_ldap.call_args[0] == (expected,) - assert mock_ldap.call_args[1] == {"bytes_mode": False} - - -@pytest.mark.parametrize("validate, expected", [ - ["never", FakeLdap.OPT_X_TLS_NEVER], - ["allow", FakeLdap.OPT_X_TLS_ALLOW], - ["try", FakeLdap.OPT_X_TLS_TRY], - ["demand", FakeLdap.OPT_X_TLS_DEMAND], -]) -def test_certificate_validation(monkeypatch, validate, expected): - mock_ldap_option = MagicMock() - monkeypatch.setattr(FakeLdap, "set_option", mock_ldap_option) - - mock_ldap = MagicMock() - monkeypatch.setattr("ldap.initialize", mock_ldap) - - lookup_loader.get('laps_password').run([], domain="dc01", start_tls=True, validate_certs=validate) - - assert mock_ldap_option.mock_calls[0][1] == (FakeLdap.OPT_X_TLS_REQUIRE_CERT, expected) - - assert mock_ldap.mock_calls[3][0] == "().start_tls_s" - assert mock_ldap.mock_calls[3][1] == () - - assert mock_ldap.mock_calls[4][0] == "().sasl_gssapi_bind_s" - assert mock_ldap.mock_calls[4][1] == () - - -def test_certificate_validate_with_custom_cacert(monkeypatch): - mock_ldap_option = MagicMock() - monkeypatch.setattr(FakeLdap, "set_option", mock_ldap_option) - - mock_ldap = MagicMock() - monkeypatch.setattr("ldap.initialize", mock_ldap) - monkeypatch.setattr(os.path, 'exists', lambda x: True) - - lookup_loader.get('laps_password').run([], domain="dc01", scheme="ldaps", cacert_file="cacert.pem") - - assert mock_ldap_option.mock_calls[0][1] == (FakeLdap.OPT_X_TLS_REQUIRE_CERT, FakeLdap.OPT_X_TLS_DEMAND) - assert mock_ldap_option.mock_calls[1][1] == (FakeLdap.OPT_X_TLS_CACERTFILE, u"cacert.pem") - - assert mock_ldap.mock_calls[3][0] == "().sasl_gssapi_bind_s" - assert mock_ldap.mock_calls[3][1] == () - - -def test_certificate_validate_with_custom_cacert_fail(monkeypatch): - def set_option(self, key, value): - if key == FakeLdap.OPT_X_TLS_CACERTFILE: - raise ValueError("set_option() failed") - - monkeypatch.setattr(FakeLdap, "set_option", set_option) - monkeypatch.setattr(os.path, 'exists', lambda x: True) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run([], domain="dc01", scheme="ldaps", cacert_file="cacert.pem") - - assert str(err.value) == "Failed to set path to cacert file, this is a known issue with older OpenLDAP " \ - "libraries on the host. Update OpenLDAP and reinstall python-ldap to continue" - - -@pytest.mark.parametrize("path", [ - "cacert.pem", - "~/.certs/cacert.pem", - "~/.certs/$USER/cacert.pem", -]) -def test_certificate_invalid_path(monkeypatch, path): - monkeypatch.setattr(os.path, 'exists', lambda x: False) - expected_path = os.path.expanduser(os.path.expandvars(path)) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run([], domain="dc01", scheme="ldaps", cacert_file=path) - - assert str(err.value) == "The cacert_file specified '%s' does not exist" % expected_path - - -def test_simple_auth_with_ldaps(monkeypatch): - mock_ldap_option = MagicMock() - monkeypatch.setattr(FakeLdap, "set_option", mock_ldap_option) - - mock_ldap = MagicMock() - monkeypatch.setattr("ldap.initialize", mock_ldap) - - lookup_loader.get('laps_password').run([], domain="dc01", scheme="ldaps", auth="simple", username="user", - password="pass") - - assert mock_ldap_option.mock_calls[0][1] == (FakeLdap.OPT_X_TLS_REQUIRE_CERT, FakeLdap.OPT_X_TLS_DEMAND) - - assert mock_ldap.mock_calls[3][0] == '().bind_s' - assert mock_ldap.mock_calls[3][1] == (u"user", u"pass") - - assert mock_ldap.mock_calls[4][0] == "().read_rootdse_s" - assert mock_ldap.mock_calls[4][1] == () - - -def test_simple_auth_with_start_tls(monkeypatch): - mock_ldap_option = MagicMock() - monkeypatch.setattr(FakeLdap, "set_option", mock_ldap_option) - - mock_ldap = MagicMock() - monkeypatch.setattr("ldap.initialize", mock_ldap) - - lookup_loader.get('laps_password').run([], domain="dc01", start_tls=True, auth="simple", username="user", - password="pass") - - assert mock_ldap_option.mock_calls[0][1] == (FakeLdap.OPT_X_TLS_REQUIRE_CERT, FakeLdap.OPT_X_TLS_DEMAND) - - assert mock_ldap.mock_calls[3][0] == "().start_tls_s" - assert mock_ldap.mock_calls[3][1] == () - - assert mock_ldap.mock_calls[4][0] == '().bind_s' - assert mock_ldap.mock_calls[4][1] == (u"user", u"pass") - - assert mock_ldap.mock_calls[5][0] == "().read_rootdse_s" - assert mock_ldap.mock_calls[5][1] == () - - -def test_start_tls_ldap_error(monkeypatch): - mock_ldap = MagicMock() - mock_ldap.return_value.start_tls_s.side_effect = FakeLDAPError("fake error") - monkeypatch.setattr("ldap.initialize", mock_ldap) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run([], domain="dc01", start_tls=True) - - assert str(err.value) == "Failed to send StartTLS to LDAP host 'ldap://dc01:389': fake error" - - -def test_simple_bind_ldap_error(monkeypatch): - mock_ldap = MagicMock() - mock_ldap.return_value.bind_s.side_effect = FakeLDAPError("fake error") - monkeypatch.setattr("ldap.initialize", mock_ldap) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run([], domain="dc01", auth="simple", username="user", password="pass", - allow_plaintext=True) - - assert str(err.value) == "Failed to simple bind against LDAP host 'ldap://dc01:389': fake error" - - -def test_sasl_bind_ldap_error(monkeypatch): - mock_ldap = MagicMock() - mock_ldap.return_value.sasl_gssapi_bind_s.side_effect = FakeLDAPError("fake error") - monkeypatch.setattr("ldap.initialize", mock_ldap) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run([], domain="dc01") - - assert str(err.value) == "Failed to do a sasl bind against LDAP host 'ldap://dc01:389': fake error" - - -def test_sasl_bind_ldap_no_mechs_error(monkeypatch): - mock_ldap = MagicMock() - mock_ldap.return_value.sasl_gssapi_bind_s.side_effect = FakeLDAPAuthUnknownError("no mechs") - monkeypatch.setattr("ldap.initialize", mock_ldap) - - with pytest.raises(AnsibleLookupError) as err: - lookup_loader.get('laps_password').run([], domain="dc01") - - assert str(err.value) == "Failed to do a sasl bind against LDAP host 'ldap://dc01:389', the GSSAPI mech is " \ - "not installed: no mechs" - - -def test_get_password_valid(laps_password): - mock_conn = MagicMock() - mock_conn.search_s.return_value = [ - ("CN=server,DC=domain,DC=local", - {"ms-Mcs-AdmPwd": ["pass"], "distinguishedName": ["CN=server,DC=domain,DC=local"]}), - # Replicates the 3 extra entries AD returns that aren't server objects - (None, ["ldap://ForestDnsZones.domain.com/DC=ForestDnsZones,DC=domain,DC=com"]), - (None, ["ldap://DomainDnsZones.domain.com/DC=DomainDnsZones,DC=domain,DC=com"]), - (None, ["ldap://domain.com/CN=Configuration,DC=domain,DC=com"]), - ] - - actual = laps_password.get_laps_password(mock_conn, "server", "DC=domain,DC=local") - assert actual == "pass" - - assert len(mock_conn.method_calls) == 1 - assert mock_conn.method_calls[0][0] == "search_s" - assert mock_conn.method_calls[0][1] == ("DC=domain,DC=local", FakeLdap.SCOPE_SUBTREE, - "(&(objectClass=computer)(CN=server))") - assert mock_conn.method_calls[0][2] == {"attrlist": ["distinguishedName", "ms-Mcs-AdmPwd"]} - - -def test_get_password_laps_not_configured(laps_password): - mock_conn = MagicMock() - mock_conn.search_s.return_value = [ - ("CN=server,DC=domain,DC=local", {"distinguishedName": ["CN=server,DC=domain,DC=local"]}), - (None, ["ldap://ForestDnsZones.domain.com/DC=ForestDnsZones,DC=domain,DC=com"]), - (None, ["ldap://DomainDnsZones.domain.com/DC=DomainDnsZones,DC=domain,DC=com"]), - (None, ["ldap://domain.com/CN=Configuration,DC=domain,DC=com"]), - ] - - with pytest.raises(AnsibleLookupError) as err: - laps_password.get_laps_password(mock_conn, "server2", "DC=test,DC=local") - assert str(err.value) == \ - "The server 'CN=server,DC=domain,DC=local' did not have the LAPS attribute 'ms-Mcs-AdmPwd'" - - assert len(mock_conn.method_calls) == 1 - assert mock_conn.method_calls[0][0] == "search_s" - assert mock_conn.method_calls[0][1] == ("DC=test,DC=local", FakeLdap.SCOPE_SUBTREE, - "(&(objectClass=computer)(CN=server2))") - assert mock_conn.method_calls[0][2] == {"attrlist": ["distinguishedName", "ms-Mcs-AdmPwd"]} - - -def test_get_password_no_results(laps_password): - mock_conn = MagicMock() - mock_conn.search_s.return_value = [ - (None, ["ldap://ForestDnsZones.domain.com/DC=ForestDnsZones,DC=domain,DC=com"]), - (None, ["ldap://DomainDnsZones.domain.com/DC=DomainDnsZones,DC=domain,DC=com"]), - (None, ["ldap://domain.com/CN=Configuration,DC=domain,DC=com"]), - ] - - with pytest.raises(AnsibleLookupError) as err: - laps_password.get_laps_password(mock_conn, "server", "DC=domain,DC=local") - assert str(err.value) == "Failed to find the server 'server' in the base 'DC=domain,DC=local'" - - assert len(mock_conn.method_calls) == 1 - assert mock_conn.method_calls[0][0] == "search_s" - assert mock_conn.method_calls[0][1] == ("DC=domain,DC=local", FakeLdap.SCOPE_SUBTREE, - "(&(objectClass=computer)(CN=server))") - assert mock_conn.method_calls[0][2] == {"attrlist": ["distinguishedName", "ms-Mcs-AdmPwd"]} - - -def test_get_password_multiple_results(laps_password): - mock_conn = MagicMock() - mock_conn.search_s.return_value = [ - ("CN=server,OU=Workstations,DC=domain,DC=local", - {"ms-Mcs-AdmPwd": ["pass"], "distinguishedName": ["CN=server,OU=Workstations,DC=domain,DC=local"]}), - ("CN=server,OU=Servers,DC=domain,DC=local", - {"ms-Mcs-AdmPwd": ["pass"], "distinguishedName": ["CN=server,OU=Servers,DC=domain,DC=local"]}), - (None, ["ldap://ForestDnsZones.domain.com/DC=ForestDnsZones,DC=domain,DC=com"]), - (None, ["ldap://DomainDnsZones.domain.com/DC=DomainDnsZones,DC=domain,DC=com"]), - (None, ["ldap://domain.com/CN=Configuration,DC=domain,DC=com"]), - ] - - with pytest.raises(AnsibleLookupError) as err: - laps_password.get_laps_password(mock_conn, "server", "DC=domain,DC=local") - assert str(err.value) == \ - "Found too many results for the server 'server' in the base 'DC=domain,DC=local'. Specify a more explicit " \ - "search base for the server required. Found servers 'CN=server,OU=Workstations,DC=domain,DC=local', " \ - "'CN=server,OU=Servers,DC=domain,DC=local'" - - assert len(mock_conn.method_calls) == 1 - assert mock_conn.method_calls[0][0] == "search_s" - assert mock_conn.method_calls[0][1] == ("DC=domain,DC=local", FakeLdap.SCOPE_SUBTREE, - "(&(objectClass=computer)(CN=server))") - assert mock_conn.method_calls[0][2] == {"attrlist": ["distinguishedName", "ms-Mcs-AdmPwd"]} |