mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
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:
parent
e1dd10be70
commit
aa34a80997
@ -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
|
||||
|
3
tests/integration/files/file/base/issue-46672-a.sls
Normal file
3
tests/integration/files/file/base/issue-46672-a.sls
Normal file
@ -0,0 +1,3 @@
|
||||
echo1:
|
||||
cmd.run:
|
||||
- name: "echo 'This is Æ test!'"
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user