Bring 51661 into 2019.2.1

This commit is contained in:
twangboy 2019-04-18 14:15:44 -06:00
parent e03aed58e8
commit 5a0464bdef
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB
2 changed files with 182 additions and 1 deletions

View file

@ -3016,7 +3016,7 @@ class GitPillar(GitBase):
if repo.branch == '__env__' and hasattr(repo, 'all_saltenvs'):
env = self.opts.get('pillarenv') \
or self.opts.get('saltenv') \
or self.opts.get('git_pillar_base')
or 'base'
elif repo.env:
env = repo.env
else:

View file

@ -488,6 +488,33 @@ class GitPythonMixin(object):
'nested_dict': {'dev': True}}}
)
def test_all_saltenvs_base(self):
'''
Test all_saltenvs parameter with base pillarenv.
'''
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: gitpython
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(
ret,
{'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}}}
)
@destructiveTest
@skipIf(NO_MOCK, NO_MOCK_REASON)
@ -1742,6 +1769,103 @@ class TestPygit2SSH(GitPillarSSHTestBase):
''')
self.assertEqual(ret, expected)
@requires_system_grains
def test_all_saltenvs_base(self, grains):
'''
Test all_saltenvs parameter.
'''
expected = {'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}
}
}
# Test with passphraseless key and global credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
git_pillar_pubkey: {pubkey_nopass}
git_pillar_privkey: {privkey_nopass}
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(ret, expected)
# Test with passphraseless key and per-repo credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- __env__ {url}:
- mountpoint: nowhere
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
''')
self.assertEqual(ret, expected)
if grains['os_family'] == 'Debian':
# passphrase-protected currently does not work here
return
# Test with passphrase-protected key and global credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
git_pillar_pubkey: {pubkey_withpass}
git_pillar_privkey: {privkey_withpass}
git_pillar_passphrase: {passphrase}
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(ret, expected)
# Test with passphrase-protected key and per-repo credential options
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- passphrase: {passphrase}
- __env__ {url}:
- mountpoint: nowhere
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- passphrase: {passphrase}
''')
self.assertEqual(ret, expected)
@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(_windows_or_mac(), 'minion is windows or mac')
@ -2119,6 +2243,33 @@ class TestPygit2HTTP(GitPillarHTTPTestBase):
'nested_dict': {'dev': True}}}
)
def test_all_saltenvs_base(self):
'''
Test all_saltenvs parameter with base pillarenv.
'''
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(
ret,
{'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}}}
)
@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(_windows_or_mac(), 'minion is windows or mac')
@ -2719,3 +2870,33 @@ class TestPygit2AuthenticatedHTTP(GitPillarHTTPTestBase):
'nested_list': ['dev'],
'nested_dict': {'dev': True}}}
)
def test_all_saltenvs_base(self):
'''
Test all_saltenvs parameter with base pillarenv.
'''
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
git_pillar_user: {user}
git_pillar_password: {password}
git_pillar_insecure_auth: True
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- __env__ {url_extra_repo}:
- all_saltenvs: master
- __env__ {url}:
- mountpoint: nowhere
''')
self.assertEqual(
ret,
{'branch': 'master',
'motd': 'The force will be with you. Always.',
'mylist': ['master'],
'mydict': {'master': True,
'nested_list': ['master'],
'nested_dict': {'master': True}}}
)