Skip to content
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

Merged
merged 4 commits into from Oct 24, 2018

Conversation

dagwieers
Copy link
Contributor

@dagwieers dagwieers commented Oct 22, 2018

SUMMARY

This PR makes UTF-8 output work in PSRP shells.

This relates to #46998

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

WinRM/PSRP

ANSIBLE VERSION

v2.8

@ansibot
Copy link
Contributor

ansibot commented Oct 22, 2018

Hi @dagwieers, thank you for submitting this pull-request!

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 22, 2018

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. labels Oct 22, 2018
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. community_review In order to be merged, this PR must follow the community review workflow. labels Oct 23, 2018
This PR makes UTF-8 output work in PSRP shells.
@jborean93
Copy link
Contributor

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.

@ansibot

This comment has been minimized.

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Oct 23, 2018
@ansibot
Copy link
Contributor

ansibot commented Oct 23, 2018

@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed ci_verified Changes made in this PR are causing tests to fail. labels Oct 23, 2018
@dagwieers dagwieers force-pushed the psrp-shell-utf8 branch 2 times, most recently from 351c820 to 12dbd83 Compare October 23, 2018 20:52
@ansibot ansibot removed the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Oct 23, 2018
@@ -59,3 +59,42 @@
assert:
that:
- async_out.stdout_lines == ["abc"]

- name: Output unicode characters from Powershell using PSRP
raw: |
Copy link
Contributor

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: |
Copy link
Contributor

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 == '💩'
Copy link
Contributor

@jborean93 jborean93 Oct 23, 2018

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 == '💩'
Copy link
Contributor

@jborean93 jborean93 Oct 23, 2018

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: |
Copy link
Contributor

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'"

@jborean93
Copy link
Contributor

@dagwieers you also need to indent the new tests to it lines up with the other tasks.

@dagwieers dagwieers force-pushed the psrp-shell-utf8 branch 2 times, most recently from d3c4e6a to 3cee841 Compare October 23, 2018 23:10
@ansibot ansibot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Oct 23, 2018
@ansibot ansibot removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Oct 23, 2018
that:
- command_unicode_output is changed
- command_unicode_output.rc == 0
- command_unicode_output.stdout == "\U0001F4A9\n"
Copy link
Contributor

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.

@jborean93 jborean93 merged commit 691ff4b into ansible:devel Oct 24, 2018
jborean93 pushed a commit to jborean93/ansible that referenced this pull request Oct 24, 2018
* 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
Copy link
Contributor

@dagwieers I've cherry-picked this commit to #47530 so they will be merged together.

abadger pushed a commit that referenced this pull request Oct 24, 2018
* 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
Copy link
Contributor Author

@jborean93 Thanks !

Tomorrow9 pushed a commit to Tomorrow9/ansible that referenced this pull request Dec 4, 2018
* 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
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. windows Windows community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants