def test_ldap_save_settings(self): self.log_user() params = self._enable_plugins( 'kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap' ) params.update({ 'auth_ldap_host': u'dc.example.com', 'auth_ldap_port': '999', 'auth_ldap_tls_kind': 'PLAIN', 'auth_ldap_tls_reqcert': 'NEVER', 'auth_ldap_cacertdir': '', 'auth_ldap_dn_user': '******', 'auth_ldap_dn_pass': '******', 'auth_ldap_base_dn': 'test_base_dn', 'auth_ldap_filter': 'test_filter', 'auth_ldap_search_scope': 'BASE', 'auth_ldap_attr_login': '******', 'auth_ldap_attr_firstname': 'ima', 'auth_ldap_attr_lastname': 'tester', 'auth_ldap_attr_email': '*****@*****.**' }) test_url = url(controller='admin/auth_settings', action='auth_settings') response = self.app.post(url=test_url, params=params) self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() assert new_settings[ 'auth_ldap_host'] == u'dc.example.com', 'fail db write compare'
def test_ldap_save_settings(self): self.log_user() params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap') params.update({'auth_ldap_host': u'dc.example.com', 'auth_ldap_port': '999', 'auth_ldap_tls_kind': 'PLAIN', 'auth_ldap_tls_reqcert': 'NEVER', 'auth_ldap_cacertdir': '', 'auth_ldap_dn_user': '******', 'auth_ldap_dn_pass': '******', 'auth_ldap_base_dn': 'test_base_dn', 'auth_ldap_filter': 'test_filter', 'auth_ldap_search_scope': 'BASE', 'auth_ldap_attr_login': '******', 'auth_ldap_attr_firstname': 'ima', 'auth_ldap_attr_lastname': 'tester', 'auth_ldap_attr_email': '*****@*****.**'}) test_url = url(controller='admin/auth_settings', action='auth_settings') response = self.app.post(url=test_url, params=params) self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() assert new_settings['auth_ldap_host'] == u'dc.example.com', 'fail db write compare'
def test_pam_save_settings(self): self.log_user() params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_pam') params.update({'auth_pam_service': 'kallithea', 'auth_pam_gecos': '^foo-.*'}) test_url = url(controller='admin/auth_settings', action='auth_settings') response = self.app.post(url=test_url, params=params) self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() assert new_settings['auth_pam_service'] == u'kallithea', 'fail db write compare'
def test_crowd_save_settings(self): self.log_user() params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_crowd') params.update({'auth_crowd_host': ' hostname ', 'auth_crowd_app_password': '******', 'auth_crowd_admin_groups': 'mygroup', 'auth_crowd_port': '123', 'auth_crowd_app_name': 'xyzzy'}) test_url = url(controller='admin/auth_settings', action='auth_settings') response = self.app.post(url=test_url, params=params) self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() assert new_settings['auth_crowd_host'] == u'hostname', 'fail db write compare'
def index(self, defaults=None, errors=None, prefix_error=False): self.__load_defaults() _defaults = {} # default plugins loaded formglobals = { "auth_plugins": ["kallithea.lib.auth_modules.auth_internal"] } formglobals.update(Setting.get_auth_settings()) formglobals["plugin_settings"] = {} formglobals["auth_plugins_shortnames"] = {} _defaults["auth_plugins"] = formglobals["auth_plugins"] for module in formglobals["auth_plugins"]: plugin = auth_modules.loadplugin(module) plugin_name = plugin.name formglobals["auth_plugins_shortnames"][module] = plugin_name formglobals["plugin_settings"][module] = plugin.plugin_settings() for v in formglobals["plugin_settings"][module]: fullname = ("auth_" + plugin_name + "_" + v["name"]) if "default" in v: _defaults[fullname] = v["default"] # Current values will be the default on the form, if there are any setting = Setting.get_by_name(fullname) if setting: _defaults[fullname] = setting.app_settings_value # we want to show , separated list of enabled plugins _defaults['auth_plugins'] = ','.join(_defaults['auth_plugins']) if defaults: _defaults.update(defaults) formglobals["defaults"] = _defaults # set template context variables for k, v in formglobals.iteritems(): setattr(c, k, v) log.debug(pprint.pformat(formglobals, indent=4)) log.debug(formatted_json(defaults)) return formencode.htmlfill.render( render('admin/auth/auth_settings.html'), defaults=_defaults, errors=errors, prefix_error=prefix_error, encoding="UTF-8", force_defaults=False)
def test_pam_save_settings(self): self.log_user() params = self._enable_plugins( 'kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_pam' ) params.update({ 'auth_pam_service': 'kallithea', 'auth_pam_gecos': '^foo-.*' }) test_url = url(controller='admin/auth_settings', action='auth_settings') response = self.app.post(url=test_url, params=params) self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() assert new_settings[ 'auth_pam_service'] == u'kallithea', 'fail db write compare'
def test_crowd_save_settings(self): self.log_user() params = self._enable_plugins( 'kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_crowd' ) params.update({ 'auth_crowd_host': ' hostname ', 'auth_crowd_app_password': '******', 'auth_crowd_admin_groups': 'mygroup', 'auth_crowd_port': '123', 'auth_crowd_app_name': 'xyzzy' }) test_url = url(controller='admin/auth_settings', action='auth_settings') response = self.app.post(url=test_url, params=params) self.checkSessionFlash(response, 'Auth settings updated successfully') new_settings = Setting.get_auth_settings() assert new_settings[ 'auth_crowd_host'] == u'hostname', 'fail db write compare'