mirror of https://github.com/ceph/ceph-ansible.git
Revert "library: exit on user creation failure"
This reverts commit 17884d9848
.
Signed-off-by: Teoman ONAY <tonay@ibm.com>
pull/7385/head
parent
971171d9e6
commit
ad4dd21d68
|
@ -20,10 +20,9 @@ try:
|
||||||
from ansible.module_utils.ca_common import generate_ceph_cmd, \
|
from ansible.module_utils.ca_common import generate_ceph_cmd, \
|
||||||
is_containerized, \
|
is_containerized, \
|
||||||
exec_command, \
|
exec_command, \
|
||||||
exit_module, \
|
exit_module
|
||||||
fatal
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from module_utils.ca_common import generate_ceph_cmd, is_containerized, exec_command, exit_module, fatal # noqa: E501
|
from module_utils.ca_common import generate_ceph_cmd, is_containerized, exec_command, exit_module # noqa: E501
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
@ -261,8 +260,6 @@ def run_module():
|
||||||
rc, cmd, out, err = exec_command(module, set_password(module, container_image=container_image), stdin=password) # noqa: E501
|
rc, cmd, out, err = exec_command(module, set_password(module, container_image=container_image), stdin=password) # noqa: E501
|
||||||
else:
|
else:
|
||||||
rc, cmd, out, err = exec_command(module, create_user(module, container_image=container_image), stdin=password) # noqa: E501
|
rc, cmd, out, err = exec_command(module, create_user(module, container_image=container_image), stdin=password) # noqa: E501
|
||||||
if rc != 0:
|
|
||||||
fatal(err, module)
|
|
||||||
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image)) # noqa: E501
|
rc, cmd, out, err = exec_command(module, set_roles(module, container_image=container_image)) # noqa: E501
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from mock.mock import MagicMock, patch
|
from mock.mock import MagicMock, patch
|
||||||
import pytest
|
|
||||||
import os
|
import os
|
||||||
import ca_test_common
|
|
||||||
import ceph_dashboard_user
|
import ceph_dashboard_user
|
||||||
|
|
||||||
fake_container_binary = 'podman'
|
fake_container_binary = 'podman'
|
||||||
|
@ -145,26 +143,3 @@ class TestCephDashboardUserModule(object):
|
||||||
]
|
]
|
||||||
|
|
||||||
assert ceph_dashboard_user.remove_user(self.fake_module) == expected_cmd
|
assert ceph_dashboard_user.remove_user(self.fake_module) == expected_cmd
|
||||||
|
|
||||||
@patch('ansible.module_utils.basic.AnsibleModule.fail_json')
|
|
||||||
@patch('ansible.module_utils.basic.AnsibleModule.run_command')
|
|
||||||
def test_create_user_fail_with_weak_password(self, m_run_command, m_fail_json):
|
|
||||||
ca_test_common.set_module_args(self.fake_module.params)
|
|
||||||
m_fail_json.side_effect = ca_test_common.fail_json
|
|
||||||
get_rc = 2
|
|
||||||
get_stderr = 'Error ENOENT: User {} does not exist.'.format(self.fake_user)
|
|
||||||
get_stdout = ''
|
|
||||||
create_rc = 22
|
|
||||||
create_stderr = 'Error EINVAL: Password is too weak.'
|
|
||||||
create_stdout = ''
|
|
||||||
m_run_command.side_effect = [
|
|
||||||
(get_rc, get_stdout, get_stderr),
|
|
||||||
(create_rc, create_stdout, create_stderr)
|
|
||||||
]
|
|
||||||
|
|
||||||
with pytest.raises(ca_test_common.AnsibleFailJson) as result:
|
|
||||||
ceph_dashboard_user.main()
|
|
||||||
|
|
||||||
result = result.value.args[0]
|
|
||||||
assert result['msg'] == create_stderr
|
|
||||||
assert result['rc'] == 1
|
|
||||||
|
|
Loading…
Reference in New Issue