* More fixes raised during tests

This commit is contained in:
Adolfo Gómez García 2014-10-30 07:25:33 +01:00
parent 6fbe86b218
commit 063f433696
4 changed files with 19 additions and 13 deletions

View File

@ -39,7 +39,7 @@ from uds.core.util import log
from uds.REST.model import ModelHandler
from uds.REST import RequestError, ResponseError
from uds.core.ui.UserInterface import gui
from user_services import AssignedService, CachedService, Groups, Transports, Publications
from uds.REST.methods.user_services import AssignedService, CachedService, Groups, Transports, Publications
import logging
@ -165,11 +165,11 @@ class ServicesPools(ModelHandler):
fields['osmanager'] = osmanager
del fields['osmanager_id']
if serviceType.usesCache == False:
if serviceType.usesCache is False:
for k in ('initial_srvs', 'cache_l1_srvs', 'cache_l2_srvs', 'max_srvs'):
fields[k] = 0
except:
except Exception:
raise RequestError(ugettext('This service requires an os manager'))
except (RequestError, ResponseError):

View File

@ -126,7 +126,7 @@ class MarshallerProcessor(ContentProcessor):
try:
if len(self._request.body) == 0:
return self.processGetParameters()
logger.debug('Body: >>{}<< {}'.format(self._request.body, len(self._request.body)))
# logger.debug('Body: >>{}<< {}'.format(self._request.body, len(self._request.body)))
res = self.marshaller.loads(self._request.body)
logger.debug("Unmarshalled content: {}".format(res))
return res

View File

@ -108,7 +108,7 @@ class InternalDBAuth(Authenticator):
except Exception:
return False
if usr.parent is not None and self.parent != '': # Direct auth not allowed for "derived" users
if usr.parent is not None and usr.parent != '': # Direct auth not allowed for "derived" users
return False
# Internal Db Auth has its own groups, and if it active it is valid

View File

@ -42,8 +42,9 @@ from uds.core.auths.Exceptions import AuthenticatorException
import ldap
import logging
import six
__updated__ = '2014-09-11'
__updated__ = '2014-10-30'
logger = logging.getLogger(__name__)
@ -84,7 +85,7 @@ class SimpleLDAPAuthenticator(Authenticator):
def __init__(self, dbAuth, environment, values=None):
super(SimpleLDAPAuthenticator, self).__init__(dbAuth, environment, values)
if values != None:
if values is not None:
self._host = values['host']
self._port = values['port']
self._ssl = gui.strToBool(values['ssl'])
@ -142,6 +143,10 @@ class SimpleLDAPAuthenticator(Authenticator):
def __connection(self, username=None, password=None):
if self._connection is None or username is not None: # We want this method also to check credentials
if isinstance(username, six.text_type):
username = username.encode('utf8')
if isinstance(password, six.text_type):
password = password.encode('utf8')
l = None
cache = False
try:
@ -214,7 +219,7 @@ class SimpleLDAPAuthenticator(Authenticator):
con = self.__connection()
filter_ = '(&(objectClass=%s)(|(%s=%s)(%s=%s)))' % (self._groupClass, self._memberAttr, usr['_id'], self._memberAttr, usr['dn'])
logger.debug('Filter: {0}'.format(filter_))
res = con.search_ext_s(base=self._ldapBase, scope=ldap.SCOPE_SUBTREE, filterstr=filter_, attrlist=[self._groupIdAttr],
res = con.search_ext_s(base=self._ldapBase, scope=ldap.SCOPE_SUBTREE, filterstr=filter_, attrlist=[self._groupIdAttr.encode('utf8')],
sizelimit=LDAP_RESULT_LIMIT)
groups = {}
for g in res:
@ -227,6 +232,7 @@ class SimpleLDAPAuthenticator(Authenticator):
return groups
except Exception:
logger.exception('Exception at __getGroups')
return {}
def __getUserRealName(self, usr):