-
Notifications
You must be signed in to change notification settings - Fork 26
User LDAP #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User LDAP #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| from .base import BaseTestCase | ||
|
|
||
|
|
||
| class TestUserLDAP(BaseTestCase): | ||
|
|
||
| SUCCESS_CODE = 200 | ||
|
|
||
| def setUp(self): | ||
| super(TestUserLDAP, self).setUp() | ||
| self.nxc.enable_app('user_ldap') | ||
|
|
||
| def test_crud_ldap_config(self): | ||
| res = self.nxc.create_ldap_config() | ||
| assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE | ||
| config_id = res['ocs']['data']['configID'] | ||
|
|
||
| # test get config by id | ||
| res = self.nxc.get_ldap_config(config_id) | ||
| assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE | ||
| config_data = res['ocs']['data'] | ||
|
|
||
| # test edit config | ||
| param_to_change = "ldapPagingSize" | ||
| old_param_value = config_data[param_to_change] | ||
| new_param_value = 777 | ||
| assert old_param_value != new_param_value | ||
| res = self.nxc.edit_ldap_config(config_id, data={param_to_change: new_param_value}) | ||
| assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE | ||
| new_config_data = self.nxc.get_ldap_config(config_id)['ocs']['data'] | ||
| assert str(new_config_data[param_to_change]) == str(new_param_value) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's interesting, what is the point of the conversion? You treat
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You right, didn't notice that at first it was integer. |
||
|
|
||
| # test showPassword param | ||
| ldap_password_param = "ldapAgentPassword" | ||
| ldap_password_value = "test_password" | ||
| self.nxc.edit_ldap_config(config_id, {ldap_password_param: ldap_password_value}) | ||
| config_data_without_password = self.nxc.get_ldap_config(config_id)['ocs']['data'] | ||
| assert config_data_without_password[ldap_password_param] == "***" | ||
| config_data_with_password = self.nxc.get_ldap_config(config_id, show_password=1)['ocs']['data'] | ||
| assert config_data_with_password[ldap_password_param] == ldap_password_value | ||
|
|
||
| # test delete config | ||
| res = self.nxc.delete_ldap_config(config_id) | ||
| assert res['ocs']['meta']['statuscode'] == self.SUCCESS_CODE | ||
| res = self.nxc.get_ldap_config(config_id) | ||
| assert res['ocs']['meta']['statuscode'] == self.NOT_FOUND_CODE | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to provide methods for configuration s.a.
edit_ldap_passwordandget_ldap_passwordinstead of theedit_ldap_configaccepting a opcode argument. It is possible to go the manual way of reading the documentation and creating those methods by hand, or if they are very similar, it may be worth considering to define a list of e.g.(name_stem, argname, docstring)tuples in the module, and creating those methods dynamically in the class constructor usingsetattr.Think about that, it is not a requirement for this PR to be merged, it can be added later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, thanks! I've added it as a
TODOcomment below to refactor it like this later.