Always trasfer bytes from fileserver roots

Fixes a state test on windows (py3) where utf-8 data was getting
improperly decoded before fileserver sends the data to a client.
This commit is contained in:
Daniel A Wozniak 2018-07-23 16:39:28 +00:00 committed by Daniel A. Wozniak
parent e1dd10be70
commit aa34a80997
No known key found for this signature in database
GPG Key ID: 166B9D2C06C82D61
3 changed files with 17 additions and 2 deletions

View File

@ -129,8 +129,6 @@ def serve_file(load, fnd):
with salt.utils.files.fopen(fpath, 'rb') as fp_:
fp_.seek(load['loc'])
data = fp_.read(__opts__['file_buffer_size'])
if data and six.PY3 and not salt.utils.files.is_binary(fpath):
data = data.decode(__salt_system_encoding__)
if gzip and data:
data = salt.utils.gzip_util.compress(data, gzip)
ret['gzip'] = gzip

View File

@ -0,0 +1,3 @@
echo1:
cmd.run:
- name: "echo 'This is Æ test!'"

View File

@ -1942,6 +1942,20 @@ class StateModuleTest(ModuleCase, SaltReturnAssertsMixin):
_expected = "cmd_|-echo1_|-echo 'This is Æ test!'_|-run"
self.assertIn(_expected, ret)
def test_state_sls_unicode_characters_cmd_output(self):
'''
test the output from running and echo command with non-ascii
characters.
'''
ret = self.run_function('state.sls', ['issue-46672-a'])
key = list(ret.keys())[0]
log.debug('== ret %s ==', type(ret))
_expected = 'This is Æ test!'
if salt.utils.platform.is_windows():
# Windows cmd.exe will mangle the output using cmd's codepage.
_expected = "'This is test!'"
self.assertEqual(_expected, ret[key]['changes']['stdout'])
def tearDown(self):
nonbase_file = os.path.join(TMP, 'nonbase_env')
if os.path.isfile(nonbase_file):