common.py (keystone-19.0.0) | : | common.py (keystone-19.0.1) | ||
---|---|---|---|---|
skipping to change at line 1374 | skipping to change at line 1374 | |||
if map_attr is None: | if map_attr is None: | |||
# Ignore attributes that are mapped to None. | # Ignore attributes that are mapped to None. | |||
continue | continue | |||
v = lower_res[map_attr.lower()] | v = lower_res[map_attr.lower()] | |||
except KeyError: # nosec | except KeyError: # nosec | |||
# Didn't find the attr, so don't add it. | # Didn't find the attr, so don't add it. | |||
pass | pass | |||
else: | else: | |||
try: | try: | |||
obj[k] = v[0] | value = v[0] | |||
except IndexError: | except IndexError: | |||
obj[k] = None | value = None | |||
# NOTE(xek): Some LDAP servers return bytes data type | ||||
# We convert it to string here, so that it is consistent with | ||||
# the other (SQL) backends. | ||||
# Bytes data type caused issues in the past, because it could | ||||
# be cached and then passed into str() method to be used as | ||||
# LDAP filters, which results in an unexpected b'...' prefix. | ||||
if isinstance(value, bytes): | ||||
try: | ||||
value = value.decode('utf-8') | ||||
except UnicodeDecodeError: | ||||
LOG.error("Error decoding value %r (object id %r).", | ||||
value, res[0]) | ||||
raise | ||||
obj[k] = value | ||||
return obj | return obj | |||
def affirm_unique(self, values): | def affirm_unique(self, values): | |||
if values.get('name') is not None: | if values.get('name') is not None: | |||
try: | try: | |||
self.get_by_name(values['name']) | self.get_by_name(values['name']) | |||
except exception.NotFound: # nosec | except exception.NotFound: # nosec | |||
# Didn't find it so it's unique, good. | # Didn't find it so it's unique, good. | |||
pass | pass | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 17 lines changed or added |