mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge branch '2019.2.1' into fix_test_winrepo
This commit is contained in:
commit
91da774089
@ -298,7 +298,9 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
||||
tmplstr = tmplstr.decode(SLS_ENCODING)
|
||||
|
||||
if tmplstr.endswith(os.linesep):
|
||||
newline = True
|
||||
newline = os.linesep
|
||||
elif tmplstr.endswith('\n'):
|
||||
newline = '\n'
|
||||
|
||||
if not saltenv:
|
||||
if tmplpath:
|
||||
@ -443,7 +445,7 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
|
||||
# Workaround a bug in Jinja that removes the final newline
|
||||
# (https://github.com/mitsuhiko/jinja2/issues/75)
|
||||
if newline:
|
||||
output += os.linesep
|
||||
output += newline
|
||||
|
||||
return output
|
||||
|
||||
|
@ -166,13 +166,45 @@ secrets:
|
||||
GPG_PILLAR_ENCRYPTED = {
|
||||
'secrets': {
|
||||
'vault': {
|
||||
'foo': '-----BEGIN PGP MESSAGE-----\n\nhQEMAw2B674HRhwSAQgAhTrN8NizwUv/VunVrqa4/X8t6EUulrnhKcSeb8sZS4th\nW1Qz3K2NjL4lkUHCQHKZVx/VoZY7zsddBIFvvoGGfj8+2wjkEDwFmFjGE4DEsS74\nZLRFIFJC1iB/O0AiQ+oU745skQkU6OEKxqavmKMrKo3rvJ8ZCXDC470+i2/Hqrp7\n+KWGmaDOO422JaSKRm5D9bQZr9oX7KqnrPG9I1+UbJyQSJdsdtquPWmeIpamEVHb\nVMDNQRjSezZ1yKC4kCWm3YQbBF76qTHzG1VlLF5qOzuGI9VkyvlMaLfMibriqY73\nzBbPzf6Bkp2+Y9qyzuveYMmwS4sEOuZL/PetqisWe9JGAWD/O+slQ2KRu9hNww06\nKMDPJRdyj5bRuBVE4hHkkP23KrYr7SuhW2vpe7O/MvWEJ9uDNegpMLhTWruGngJh\niFndxegN9w==\n=bAuo\n-----END PGP MESSAGE-----\n',
|
||||
'foo': '-----BEGIN PGP MESSAGE-----\n'
|
||||
'\n'
|
||||
'hQEMAw2B674HRhwSAQgAhTrN8NizwUv/VunVrqa4/X8t6EUulrnhKcSeb8sZS4th\n'
|
||||
'W1Qz3K2NjL4lkUHCQHKZVx/VoZY7zsddBIFvvoGGfj8+2wjkEDwFmFjGE4DEsS74\n'
|
||||
'ZLRFIFJC1iB/O0AiQ+oU745skQkU6OEKxqavmKMrKo3rvJ8ZCXDC470+i2/Hqrp7\n'
|
||||
'+KWGmaDOO422JaSKRm5D9bQZr9oX7KqnrPG9I1+UbJyQSJdsdtquPWmeIpamEVHb\n'
|
||||
'VMDNQRjSezZ1yKC4kCWm3YQbBF76qTHzG1VlLF5qOzuGI9VkyvlMaLfMibriqY73\n'
|
||||
'zBbPzf6Bkp2+Y9qyzuveYMmwS4sEOuZL/PetqisWe9JGAWD/O+slQ2KRu9hNww06\n'
|
||||
'KMDPJRdyj5bRuBVE4hHkkP23KrYr7SuhW2vpe7O/MvWEJ9uDNegpMLhTWruGngJh\n'
|
||||
'iFndxegN9w==\n'
|
||||
'=bAuo\n'
|
||||
'-----END PGP MESSAGE-----\n',
|
||||
'bar': 'this was unencrypted already',
|
||||
'baz': '-----BEGIN PGP MESSAGE-----\n\nhQEMAw2B674HRhwSAQf+Ne+IfsP2IcPDrUWct8sTJrga47jQvlPCmO+7zJjOVcqz\ngLjUKvMajrbI/jorBWxyAbF+5E7WdG9WHHVnuoywsyTB9rbmzuPqYCJCe+ZVyqWf\n9qgJ+oUjcvYIFmH3h7H68ldqbxaAUkAOQbTRHdr253wwaTIC91ZeX0SCj64HfTg7\nIzwk383CRWonEktXJpientApQFSUWNeLUWagEr/YPNFA3vzpPF5/Ia9X8/z/6oO2\nq+D5W5mVsns3i2HHbg2A8Y+pm4TWnH6mTSh/gdxPqssi9qIrzGQ6H1tEoFFOEq1V\nkJBe0izlfudqMq62XswzuRB4CYT5Iqw1c97T+1RqENJCASG0Wz8AGhinTdlU5iQl\nJkLKqBxcBz4L70LYWyHhYwYROJWjHgKAywX5T67ftq0wi8APuZl9olnOkwSK+wrY\n1OZi\n=7epf\n-----END PGP MESSAGE-----\n',
|
||||
'baz': '-----BEGIN PGP MESSAGE-----\n'
|
||||
'\n'
|
||||
'hQEMAw2B674HRhwSAQf+Ne+IfsP2IcPDrUWct8sTJrga47jQvlPCmO+7zJjOVcqz\n'
|
||||
'gLjUKvMajrbI/jorBWxyAbF+5E7WdG9WHHVnuoywsyTB9rbmzuPqYCJCe+ZVyqWf\n'
|
||||
'9qgJ+oUjcvYIFmH3h7H68ldqbxaAUkAOQbTRHdr253wwaTIC91ZeX0SCj64HfTg7\n'
|
||||
'Izwk383CRWonEktXJpientApQFSUWNeLUWagEr/YPNFA3vzpPF5/Ia9X8/z/6oO2\n'
|
||||
'q+D5W5mVsns3i2HHbg2A8Y+pm4TWnH6mTSh/gdxPqssi9qIrzGQ6H1tEoFFOEq1V\n'
|
||||
'kJBe0izlfudqMq62XswzuRB4CYT5Iqw1c97T+1RqENJCASG0Wz8AGhinTdlU5iQl\n'
|
||||
'JkLKqBxcBz4L70LYWyHhYwYROJWjHgKAywX5T67ftq0wi8APuZl9olnOkwSK+wrY\n'
|
||||
'1OZi\n'
|
||||
'=7epf\n'
|
||||
'-----END PGP MESSAGE-----\n',
|
||||
'qux': [
|
||||
'foo',
|
||||
'bar',
|
||||
'-----BEGIN PGP MESSAGE-----\n\nhQEMAw2B674HRhwSAQgAg1YCmokrweoOI1c9HO0BLamWBaFPTMblOaTo0WJLZoTS\nksbQ3OJAMkrkn3BnnM/djJc5C7vNs86ZfSJ+pvE8Sp1Rhtuxh25EKMqGOn/SBedI\ngR6N5vGUNiIpG5Tf3DuYAMNFDUqw8uY0MyDJI+ZW3o3xrMUABzTH0ew+Piz85FDA\nYrVgwZfqyL+9OQuu6T66jOIdwQNRX2NPFZqvon8liZUPus5VzD8E5cAL9OPxQ3sF\nf7/zE91YIXUTimrv3L7eCgU1dSxKhhfvA2bEUi+AskMWFXFuETYVrIhFJAKnkFmE\nuZx+O9R9hADW3hM5hWHKH9/CRtb0/cC84I9oCWIQPdI+AaPtICxtsD2N8Q98hhhd\n4M7I0sLZhV+4ZJqzpUsOnSpaGyfh1Zy/1d3ijJi99/l+uVHuvmMllsNmgR+ZTj0=\n=LrCQ\n-----END PGP MESSAGE-----\n'
|
||||
'-----BEGIN PGP MESSAGE-----\n'
|
||||
'\n'
|
||||
'hQEMAw2B674HRhwSAQgAg1YCmokrweoOI1c9HO0BLamWBaFPTMblOaTo0WJLZoTS\n'
|
||||
'ksbQ3OJAMkrkn3BnnM/djJc5C7vNs86ZfSJ+pvE8Sp1Rhtuxh25EKMqGOn/SBedI\n'
|
||||
'gR6N5vGUNiIpG5Tf3DuYAMNFDUqw8uY0MyDJI+ZW3o3xrMUABzTH0ew+Piz85FDA\n'
|
||||
'YrVgwZfqyL+9OQuu6T66jOIdwQNRX2NPFZqvon8liZUPus5VzD8E5cAL9OPxQ3sF\n'
|
||||
'f7/zE91YIXUTimrv3L7eCgU1dSxKhhfvA2bEUi+AskMWFXFuETYVrIhFJAKnkFmE\n'
|
||||
'uZx+O9R9hADW3hM5hWHKH9/CRtb0/cC84I9oCWIQPdI+AaPtICxtsD2N8Q98hhhd\n'
|
||||
'4M7I0sLZhV+4ZJqzpUsOnSpaGyfh1Zy/1d3ijJi99/l+uVHuvmMllsNmgR+ZTj0=\n'
|
||||
'=LrCQ\n'
|
||||
'-----END PGP MESSAGE-----\n'
|
||||
],
|
||||
},
|
||||
},
|
||||
@ -416,7 +448,15 @@ class DecryptGPGPillarTest(ModuleCase):
|
||||
'Failed to decrypt pillar key \'secrets:vault\': Decryption '
|
||||
'renderer \'asdf\' is not available'
|
||||
]
|
||||
self.assertEqual(ret, expected)
|
||||
self.assertEqual(ret['_errors'], expected['_errors'])
|
||||
self.assertEqual(ret['secrets']['vault']['foo'],
|
||||
expected['secrets']['vault']['foo'])
|
||||
self.assertEqual(ret['secrets']['vault']['bar'],
|
||||
expected['secrets']['vault']['bar'])
|
||||
self.assertEqual(ret['secrets']['vault']['baz'],
|
||||
expected['secrets']['vault']['baz'])
|
||||
self.assertEqual(ret['secrets']['vault']['qux'],
|
||||
expected['secrets']['vault']['qux'])
|
||||
|
||||
@requires_system_grains
|
||||
def test_decrypt_pillar_invalid_renderer(self, grains=None):
|
||||
@ -441,4 +481,12 @@ class DecryptGPGPillarTest(ModuleCase):
|
||||
'Failed to decrypt pillar key \'secrets:vault\': \'gpg\' is '
|
||||
'not a valid decryption renderer. Valid choices are: foo, bar'
|
||||
]
|
||||
self.assertEqual(ret, expected)
|
||||
self.assertEqual(ret['_errors'], expected['_errors'])
|
||||
self.assertEqual(ret['secrets']['vault']['foo'],
|
||||
expected['secrets']['vault']['foo'])
|
||||
self.assertEqual(ret['secrets']['vault']['bar'],
|
||||
expected['secrets']['vault']['bar'])
|
||||
self.assertEqual(ret['secrets']['vault']['baz'],
|
||||
expected['secrets']['vault']['baz'])
|
||||
self.assertEqual(ret['secrets']['vault']['qux'],
|
||||
expected['secrets']['vault']['qux'])
|
||||
|
@ -3,10 +3,12 @@
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
import textwrap
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import destructiveTest
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.files
|
||||
@ -16,6 +18,19 @@ import salt.utils.stringutils
|
||||
|
||||
class PyDSLRendererIncludeTestCase(ModuleCase):
|
||||
|
||||
def setUp(self):
|
||||
self.directory_created = False
|
||||
if salt.utils.platform.is_windows():
|
||||
if not os.path.isdir('\\tmp'):
|
||||
os.mkdir('\\tmp')
|
||||
self.directory_created = True
|
||||
|
||||
def tearDown(self):
|
||||
if salt.utils.platform.is_windows():
|
||||
if self.directory_created:
|
||||
shutil.rmtree('\\tmp')
|
||||
|
||||
@destructiveTest
|
||||
def test_rendering_includes(self):
|
||||
'''
|
||||
This test is currently hard-coded to /tmp to work-around a seeming
|
||||
@ -49,9 +64,10 @@ class PyDSLRendererIncludeTestCase(ModuleCase):
|
||||
'hello green 2 \r\n' \
|
||||
'hello blue 3 \r\n'
|
||||
|
||||
with salt.utils.files.fopen('/tmp/output', 'r') as f:
|
||||
ret = salt.utils.stringutils.to_unicode(f.read())
|
||||
|
||||
os.remove('/tmp/output')
|
||||
try:
|
||||
with salt.utils.files.fopen('/tmp/output', 'r') as f:
|
||||
ret = salt.utils.stringutils.to_unicode(f.read())
|
||||
finally:
|
||||
os.remove('/tmp/output')
|
||||
|
||||
self.assertEqual(sorted(ret), sorted(expected))
|
||||
|
Loading…
Reference in New Issue
Block a user