|
1
|
|
|
from .base import BaseTestCase |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
class TestUserLDAP(BaseTestCase): |
|
5
|
|
|
|
|
6
|
|
|
SUCCESS_CODE = 200 |
|
7
|
|
|
|
|
8
|
|
|
def setUp(self): |
|
9
|
|
|
super(TestUserLDAP, self).setUp() |
|
10
|
|
|
self.nxc.enable_app('user_ldap') |
|
11
|
|
|
|
|
12
|
|
|
def test_crud_ldap_config(self): |
|
13
|
|
|
res = self.nxc.create_ldap_config() |
|
14
|
|
|
assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE |
|
15
|
|
|
config_id = res['ocs']['data']['configID'] |
|
16
|
|
|
|
|
17
|
|
|
# test get config by id |
|
18
|
|
|
res = self.nxc.get_ldap_config(config_id) |
|
19
|
|
|
assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE |
|
20
|
|
|
config_data = res['ocs']['data'] |
|
21
|
|
|
|
|
22
|
|
|
# test edit config |
|
23
|
|
|
param_to_change = "ldapPagingSize" |
|
24
|
|
|
old_param_value = config_data[param_to_change] |
|
25
|
|
|
new_param_value = 777 |
|
26
|
|
|
assert old_param_value != new_param_value |
|
27
|
|
|
res = self.nxc.edit_ldap_config(config_id, data={param_to_change: new_param_value}) |
|
28
|
|
|
assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE |
|
29
|
|
|
new_config_data = self.nxc.get_ldap_config(config_id)['ocs']['data'] |
|
30
|
|
|
assert str(new_config_data[param_to_change]) == str(new_param_value) |
|
31
|
|
|
|
|
32
|
|
|
# test showPassword param |
|
33
|
|
|
ldap_password_param = "ldapAgentPassword" |
|
34
|
|
|
ldap_password_value = "test_password" |
|
35
|
|
|
self.nxc.edit_ldap_config(config_id, {ldap_password_param: ldap_password_value}) |
|
36
|
|
|
config_data_without_password = self.nxc.get_ldap_config(config_id)['ocs']['data'] |
|
37
|
|
|
assert config_data_without_password[ldap_password_param] == "***" |
|
38
|
|
|
config_data_with_password = self.nxc.get_ldap_config(config_id, show_password=1)['ocs']['data'] |
|
39
|
|
|
assert config_data_with_password[ldap_password_param] == ldap_password_value |
|
40
|
|
|
|
|
41
|
|
|
# test delete config |
|
42
|
|
|
res = self.nxc.delete_ldap_config(config_id) |
|
43
|
|
|
assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE |
|
44
|
|
|
res = self.nxc.get_ldap_config(config_id) |
|
45
|
|
|
assert res['ocs']['meta']['statuscode'] == self.NOT_FOUND_CODE |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
|