psrp - Fix raw and script tests for connection plugin (#55357)

* psrp - Fix raw and script tests for connection plugin

* Fix error propagation with raw in psrp

* uncomment test
This commit is contained in:
Jordan Borean
2019-04-17 09:01:28 +10:00
committed by GitHub
parent 49655a452d
commit fdf9df89f5
5 changed files with 52 additions and 22 deletions

View File

@@ -93,15 +93,30 @@
that:
- "raw_result.stdout_lines[0] == 'wwe=raw'"
# TODO: this test doesn't work anymore since we had to internally map Write-Host to Write-Output
- name: run a raw command with unicode chars and quoted args (from https://github.com/ansible/ansible-modules-core/issues/1929)
raw: Write-Host --% icacls D:\somedir\ /grant "! ЗАО. Руководство":F
register: raw_result2
- name: unicode tests for winrm
when: ansible_connection != 'psrp' # Write-Host does not work over PSRP
block:
- name: run a raw command with unicode chars and quoted args (from https://github.com/ansible/ansible-modules-core/issues/1929)
raw: Write-Host --% icacls D:\somedir\ /grant "! ЗАО. Руководство":F
register: raw_result2
- name: make sure raw passes command as-is and doesn't split/rejoin args
assert:
that:
- "raw_result2.stdout_lines[0] == '--% icacls D:\\\\somedir\\\\ /grant \"! ЗАО. Руководство\":F'"
- name: make sure raw passes command as-is and doesn't split/rejoin args
assert:
that:
- "raw_result2.stdout_lines[0] == '--% icacls D:\\\\somedir\\\\ /grant \"! ЗАО. Руководство\":F'"
- name: unicode tests for psrp
when: ansible_connection == 'psrp'
block:
# Cannot test unicode passed into separate exec as PSRP doesn't run with a preset CP of 65001 which reuslts in ? for unicode chars
- name: run a raw command with unicode chars
raw: Write-Output "! ЗАО. Руководство"
register: raw_result2
- name: make sure raw passes command as-is and doesn't split/rejoin args
assert:
that:
- "raw_result2.stdout_lines[0] == '! ЗАО. Руководство'"
# Assumes MaxShellsPerUser == 30 (the default)

View File

@@ -71,11 +71,22 @@
assert:
that:
- test_script_with_large_args_result.rc == 0
- test_script_with_large_args_result.stdout == long_string + "\r\n"
- not test_script_with_large_args_result.stderr
- test_script_with_large_args_result is not failed
- test_script_with_large_args_result is changed
- name: check that script ran and received arguments correctly with winrm output
assert:
that:
- test_script_with_large_args_result.stdout == long_string + "\r\n"
when: ansible_connection != 'psrp'
- name: check that script ran and received arguments correctly with psrp output
assert:
that:
- test_script_with_large_args_result.stdout == long_string
when: ansible_connection == 'psrp'
- name: run test script that takes parameters passed via splatting
script: test_script_with_splatting.ps1 @{ This = 'this'; That = '{{ test_win_script_value }}'; Other = 'other'}
register: test_script_with_splatting_result