Skip to content

Commit

Permalink
Merge pull request #52615 from twangboy/gitfs_2019.2.1
Browse files Browse the repository at this point in the history
 Bring 51661 into 2019.2.1
  • Loading branch information
dwoz authored Apr 18, 2019
2 parents 8ee15a9 + d952674 commit c6b4986
Show file tree
Hide file tree
Showing 2 changed files with 182 additions and 1 deletion.
2 changes: 1 addition & 1 deletion salt/utils/gitfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3016,7 +3016,7 @@ def checkout(self):
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:
Expand Down
181 changes: 181 additions & 0 deletions tests/integration/pillar/test_git_pillar.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,33 @@ def test_all_saltenvs(self):
'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)
Expand Down Expand Up @@ -1742,6 +1769,103 @@ def test_all_saltenvs(self, grains):
''')
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')
Expand Down Expand Up @@ -2119,6 +2243,33 @@ def test_all_saltenvs(self):
'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')
Expand Down Expand Up @@ -2719,3 +2870,33 @@ def test_all_saltenvs(self):
'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}}}
)

0 comments on commit c6b4986

Please sign in to comment.