mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
add unit test for failed login
This commit is contained in:
parent
0fc7989236
commit
af64632bf3
1 changed files with 20 additions and 0 deletions
|
@ -64,6 +64,26 @@ class DockerTestCase(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
docker_mod.__context__.pop('docker.client', None)
|
||||
|
||||
def test_failed_login(self):
|
||||
'''
|
||||
Check that when docker.login failed a retcode other then 0
|
||||
is part of the return.
|
||||
'''
|
||||
client = Mock()
|
||||
get_client_mock = MagicMock(return_value=client)
|
||||
ref_out = {
|
||||
'stdout': '',
|
||||
'stderr': 'login failed',
|
||||
'retcode': 1
|
||||
}
|
||||
with patch.dict(docker_mod.__pillar__, {'docker-registries': {'portus.example.com:5000':
|
||||
{'username': 'admin', 'password': 'linux12345', 'email': 'tux@example.com'}}}):
|
||||
with patch.object(docker_mod, '_get_client', get_client_mock):
|
||||
with patch.dict(docker_mod.__salt__, {'cmd.run_all': MagicMock(return_value=ref_out)}):
|
||||
ret = docker_mod.login('portus.example.com:5000')
|
||||
self.assertTrue('retcode' in ret)
|
||||
self.assertTrue(ret['retcode'] > 0)
|
||||
|
||||
def test_ps_with_host_true(self):
|
||||
'''
|
||||
Check that docker.ps called with host is ``True``,
|
||||
|
|
Loading…
Add table
Reference in a new issue