2018-10-23 19:37:05 +00:00
|
|
|
---
|
|
|
|
# these are extra tests for psrp that aren't covered under test/integration/targets/connection/*
|
|
|
|
- name: test out psrp specific tests
|
|
|
|
hosts: winrm
|
|
|
|
serial: 1
|
|
|
|
gather_facts: no
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: test complex objects in raw output
|
|
|
|
# until PyYAML is upgraded to 4.x we need to use the \U escape for a unicode codepoint
|
|
|
|
# and enclose in a quote to it translates the \U
|
|
|
|
raw: "
|
|
|
|
[PSCustomObject]@{string = 'string'};
|
|
|
|
[PSCustomObject]@{unicode = 'poo - \U0001F4A9'};
|
|
|
|
[PSCustomObject]@{integer = 1};
|
|
|
|
[PSCustomObject]@{list = @(1, 2)};
|
|
|
|
Get-Service -Name winrm;
|
|
|
|
Write-Output -InputObject 'string - \U0001F4A9';"
|
|
|
|
register: raw_out
|
|
|
|
|
|
|
|
- name: assert complex objects in raw output
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- raw_out.stdout_lines|count == 6
|
|
|
|
- "raw_out.stdout_lines[0] == 'string: string'"
|
|
|
|
- "raw_out.stdout_lines[1] == 'unicode: poo - \U0001F4A9'"
|
|
|
|
- "raw_out.stdout_lines[2] == 'integer: 1'"
|
|
|
|
- "raw_out.stdout_lines[3] == \"list: [1, 2]\""
|
|
|
|
- raw_out.stdout_lines[4] == "winrm"
|
|
|
|
- raw_out.stdout_lines[5] == "string - \U0001F4A9"
|
|
|
|
|
|
|
|
# Become only works on Server 2008 when running with basic auth, skip this host for now as it is too complicated to
|
|
|
|
# override the auth protocol in the tests.
|
|
|
|
- name: check if we running on Server 2008
|
|
|
|
win_shell: '[System.Environment]::OSVersion.Version -ge [Version]"6.1"'
|
|
|
|
register: os_version
|
|
|
|
|
|
|
|
- name: test out become with psrp
|
|
|
|
win_whoami:
|
|
|
|
when: os_version|bool
|
|
|
|
register: whoami_out
|
|
|
|
become: yes
|
|
|
|
become_method: runas
|
|
|
|
become_user: SYSTEM
|
|
|
|
|
|
|
|
- name: assert test out become with psrp
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- whoami_out.account.sid == "S-1-5-18"
|
|
|
|
when: os_version|bool
|
|
|
|
|
|
|
|
- name: test out async with psrp
|
|
|
|
win_shell: Start-Sleep -Seconds 2; Write-Output abc
|
2019-04-10 03:56:27 +00:00
|
|
|
async: 10
|
2018-10-23 19:37:05 +00:00
|
|
|
poll: 1
|
|
|
|
register: async_out
|
|
|
|
|
|
|
|
- name: assert est out async with psrp
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- async_out.stdout_lines == ["abc"]
|
2018-10-24 00:40:54 +00:00
|
|
|
|
|
|
|
- name: Output unicode characters from Powershell using PSRP
|
|
|
|
win_command: "powershell.exe -ExecutionPolicy ByPass -Command \"Write-Host '\U0001F4A9'\""
|
|
|
|
register: command_unicode_output
|
|
|
|
|
|
|
|
- name: Assert unicode output
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- command_unicode_output is changed
|
|
|
|
- command_unicode_output.rc == 0
|
|
|
|
- "command_unicode_output.stdout == '\U0001F4A9\n'"
|
|
|
|
- command_unicode_output.stderr == ''
|
|
|
|
|
|
|
|
- name: Output unicode characters from Powershell using PSRP
|
|
|
|
win_shell: "Write-Host '\U0001F4A9'"
|
|
|
|
register: shell_unicode_output
|
|
|
|
|
|
|
|
- name: Assert unicode output
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- shell_unicode_output is changed
|
|
|
|
- shell_unicode_output.rc == 0
|
|
|
|
- "shell_unicode_output.stdout == '\U0001F4A9\n'"
|
|
|
|
- shell_unicode_output.stderr == ''
|