git_pillar: Add tests for mountpoint parameter

(cherry picked from commit 6e2f4e471d)
This commit is contained in:
Mathieu Parent 2018-11-08 04:10:49 +01:00
parent fce467e438
commit 12ea1cc01e
No known key found for this signature in database
GPG key ID: AE03980466681FA5
2 changed files with 181 additions and 0 deletions

View file

@ -413,6 +413,29 @@ class GitPythonMixin(object):
''')
self.assertEqual(ret, expected)
def test_mountpoint_parameter(self):
'''
Test mountpoint parameter
'''
expected = {
'included_pillar': True
}
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: gitpython
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- master {url}:
- mountpoint: mounted
- top_mounted {url}:
- env: base
''')
self.assertEqual(ret, expected)
@destructiveTest
@skipIf(NO_MOCK, NO_MOCK_REASON)
@ -1378,6 +1401,98 @@ class TestPygit2SSH(GitPillarSSHTestBase):
''')
self.assertEqual(ret, expected)
@requires_system_grains
def test_mountpoint_parameter(self, grains):
'''
Test mountpoint parameter
'''
expected = {
'included_pillar': 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:
- master {url}:
- mountpoint: mounted
- top_mounted {url}:
- env: base
''')
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:
- master {url}:
- mountpoint: mounted
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- top_mounted {url}:
- pubkey: {pubkey_nopass}
- privkey: {privkey_nopass}
- env: base
''')
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:
- master {url}:
- mountpoint: mounted
- top_mounted {url}:
- env: base
''')
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:
- master {url}:
- mountpoint: mounted
- pubkey: {pubkey_withpass}
- privkey: {privkey_withpass}
- passphrase: {passphrase}
- top_mounted {url}:
- pubkey: {pubkey_withpass}
- privkey: {privkey_withpass}
- passphrase: {passphrase}
- env: base
''')
self.assertEqual(ret, expected)
@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(_windows_or_mac(), 'minion is windows or mac')
@ -1680,6 +1795,29 @@ class TestPygit2HTTP(GitPillarHTTPTestBase):
''')
self.assertEqual(ret, expected)
def test_mountpoint_parameter(self):
'''
Test mountpoint parameter
'''
expected = {
'included_pillar': True
}
ret = self.get_pillar('''\
file_ignore_regex: []
file_ignore_glob: []
git_pillar_provider: pygit2
cachedir: {cachedir}
extension_modules: {extmods}
ext_pillar:
- git:
- master {url}:
- mountpoint: mounted
- top_mounted {url}:
- env: base
''')
self.assertEqual(ret, expected)
@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(_windows_or_mac(), 'minion is windows or mac')
@ -2049,6 +2187,32 @@ class TestPygit2AuthenticatedHTTP(GitPillarHTTPTestBase):
''')
self.assertEqual(ret, expected)
def test_mountpoint_parameter(self):
'''
Test mountpoint parameter
'''
expected = {
'included_pillar': True
}
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:
- master {url}:
- mountpoint: mounted
- top_mounted {url}:
- env: base
''')
self.assertEqual(ret, expected)
def test_root_parameter(self):
'''
Test root parameter

View file

@ -478,6 +478,23 @@ class GitPillarTestBase(GitTestBase, LoaderModuleMockMixin):
'''))
_push('top_only', 'add top_only branch')
# Create just another top file in a separate repo, to be mapped to the base
# env and including mounted.bar
self.run_function(
'git.checkout',
[self.admin_repo],
user=user,
opts='-b top_mounted')
# The top.sls should be the only file in this branch
with salt.utils.files.fopen(
os.path.join(self.admin_repo, 'top.sls'), 'w') as fp_:
fp_.write(textwrap.dedent('''\
base:
'*':
- mounted.bar
'''))
_push('top_mounted', 'add top_mounted branch')
def make_extra_repo(self, root_dir, user='root'):
self.bare_extra_repo = os.path.join(root_dir, 'extra_repo.git')
self.admin_extra_repo = os.path.join(root_dir, 'admin_extra')