New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WinRM/PSRP: Ensure shell returns UTF-8 output #47404
Conversation
2ecf0d9
to
14c38f2
Compare
Hi @dagwieers, thank you for submitting this pull-request! |
14c38f2
to
8b91ac7
Compare
8b91ac7
to
0d863fa
Compare
This PR makes UTF-8 output work in PSRP shells.
0d863fa
to
8ddad23
Compare
Local tests seem to be fine, now we have a psrp only testing location are you able to add a win_shell or win_command test with unicode characters to https://github.com/ansible/ansible/blob/devel/test/integration/targets/connection_psrp/tests.yml. This will test that we don't loose the unicode chars end to end. |
This comment has been minimized.
This comment has been minimized.
c2103ae
to
8f302e3
Compare
351c820
to
12dbd83
Compare
12dbd83
to
a72be25
Compare
@@ -59,3 +59,42 @@ | |||
assert: | |||
that: | |||
- async_out.stdout_lines == ["abc"] | |||
|
|||
- name: Output unicode characters from Powershell using PSRP | |||
raw: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, this is tested above
- raw_unicode_output.stderr == '' | ||
|
||
- name: Output unicode characters from Powershell using PSRP | ||
win_command: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do win_command: "powershell.exe -ExecutionPolicy ByPass -Command \"Write-Host '\U0001F4A9'\""
. Due to the PyYAML issue you can't put unicode characters that are a surrogate pair in YAML files.
that: | ||
- command_unicode_output is changed | ||
- command_unicode_output.rc == 0 | ||
- command_unicode_output.stdout == '💩' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"command_unicode_output.stdout == '\U0001F4A9\n'"
. Need to use the \U
form and add \n
to the end.
that: | ||
- shell_unicode_output is changed | ||
- shell_unicode_output.rc == 0 | ||
- shell_unicode_output.stdout == '💩' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"shell_unicode_output.stdout == '\U0001F4A9\n'"
. Need to use the \U
form and add \n
to the end.
- command_unicode_output.stderr == '' | ||
|
||
- name: Output unicode characters from Powershell using PSRP | ||
win_shell: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do win_shell: "Write-Host '\U0001F4A9'"
@dagwieers you also need to indent the new tests to it lines up with the other tasks. |
d3c4e6a
to
3cee841
Compare
3cee841
to
72f2b3e
Compare
72f2b3e
to
216fe32
Compare
that: | ||
- command_unicode_output is changed | ||
- command_unicode_output.rc == 0 | ||
- command_unicode_output.stdout == "\U0001F4A9\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully this is the last one, you need to quote this entire line for the \U
to take effect, e.g. "command_unicode_output.stdout == '\U0001F4A9\n'"
. Same as the win_shell assertion below.
* WinRM/PSRP: Ensure shell returns UTF-8 output This PR makes UTF-8 output work in PSRP shells. * Add win_command and win_shell integration tests * Fix tests * more test fixes (cherry picked from commit 691ff4b)
@dagwieers I've cherry-picked this commit to #47530 so they will be merged together. |
* WinRM/PSRP: Ensure shell returns UTF-8 output This PR makes UTF-8 output work in PSRP shells. * Add win_command and win_shell integration tests * Fix tests * more test fixes (cherry picked from commit 691ff4b)
@jborean93 Thanks ! |
* WinRM/PSRP: Ensure shell returns UTF-8 output This PR makes UTF-8 output work in PSRP shells. * Add win_command and win_shell integration tests * Fix tests * more test fixes
SUMMARY
This PR makes UTF-8 output work in PSRP shells.
This relates to #46998
ISSUE TYPE
COMPONENT NAME
WinRM/PSRP
ANSIBLE VERSION
v2.8