"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "keystone/tests/unit/test_backend_ldap.py" between
keystone-15.0.0.tar.gz and keystone-15.0.1.tar.gz

About: OpenStack Keystone (Core Service: Identity) provides an authentication and authorization service for other OpenStack services. Provides a catalog of endpoints for all OpenStack services.
The "Stein" series (maintained release).

test_backend_ldap.py  (keystone-15.0.0):test_backend_ldap.py  (keystone-15.0.1)
skipping to change at line 1814 skipping to change at line 1814
driver = PROVIDERS.identity_api._select_identity_driver( driver = PROVIDERS.identity_api._select_identity_driver(
CONF.identity.default_domain_id) CONF.identity.default_domain_id)
driver.user.id_attr = 'mail' driver.user.id_attr = 'mail'
user_ref = PROVIDERS.identity_api.get_user(self.user_foo['email']) user_ref = PROVIDERS.identity_api.get_user(self.user_foo['email'])
# the user_id_attribute map should be honored, which means # the user_id_attribute map should be honored, which means
# user_ref['id'] should contains the email attribute # user_ref['id'] should contains the email attribute
self.assertEqual(self.user_foo['email'], user_ref['id']) self.assertEqual(self.user_foo['email'], user_ref['id'])
@mock.patch.object(common_ldap.BaseLdap, '_ldap_get') @mock.patch.object(common_ldap.BaseLdap, '_ldap_get')
def test_get_id_from_dn_for_multivalued_attribute_id(self, mock_ldap_get): def test_get_multivalued_attribute_id_from_dn(self,
mock_ldap_get):
driver = PROVIDERS.identity_api._select_identity_driver(
CONF.identity.default_domain_id)
driver.user.id_attr = 'mail'
# make 'email' multivalued so we can test the error condition
email1 = uuid.uuid4().hex
email2 = uuid.uuid4().hex
# Mock the ldap search results to return user entries with
# user_name_attribute('sn') value has emptyspaces, emptystring
# and attibute itself is not set.
mock_ldap_get.return_value = (
'cn=users,dc=example,dc=com',
{
'mail': [email1, email2],
}
)
# This is not a valid scenario, since we do not support multiple value
# attribute id on DN.
self.assertRaises(exception.NotFound,
PROVIDERS.identity_api.get_user, email1)
@mock.patch.object(common_ldap.BaseLdap, '_ldap_get')
def test_raise_not_found_dn_for_multivalued_attribute_id(self,
mock_ldap_get):
driver = PROVIDERS.identity_api._select_identity_driver( driver = PROVIDERS.identity_api._select_identity_driver(
CONF.identity.default_domain_id) CONF.identity.default_domain_id)
driver.user.id_attr = 'mail' driver.user.id_attr = 'mail'
# make 'email' multivalued so we can test the error condition # make 'email' multivalued so we can test the error condition
email1 = uuid.uuid4().hex email1 = uuid.uuid4().hex
email2 = uuid.uuid4().hex email2 = uuid.uuid4().hex
mock_ldap_get.return_value = ( mock_ldap_get.return_value = (
'cn=nobodycares,dc=example,dc=com', 'cn=nobodycares,dc=example,dc=com',
{ {
'sn': [uuid.uuid4().hex], 'sn': [uuid.uuid4().hex],
'mail': [email1, email2], 'mail': [email1, email2],
'cn': 'nobodycares' 'cn': 'nobodycares'
} }
) )
user_ref = PROVIDERS.identity_api.get_user(email1) # This is not a valid scenario, since we do not support multiple value
# make sure we get the ID from DN (old behavior) if the ID attribute # attribute id on DN.
# has multiple values self.assertRaises(exception.NotFound,
self.assertEqual('nobodycares', user_ref['id']) PROVIDERS.identity_api.get_user, email1)
@mock.patch.object(common_ldap.BaseLdap, '_ldap_get')
def test_get_id_not_in_dn(self,
mock_ldap_get):
driver = PROVIDERS.identity_api._select_identity_driver(
CONF.identity.default_domain_id)
driver.user.id_attr = 'sAMAccountName'
user_id = uuid.uuid4().hex
mock_ldap_get.return_value = (
'cn=someuser,dc=example,dc=com',
{
'cn': 'someuser',
'sn': [uuid.uuid4().hex],
'sAMAccountName': [user_id],
}
)
user_ref = PROVIDERS.identity_api.get_user(user_id)
self.assertEqual(user_id, user_ref['id'])
@mock.patch.object(common_ldap.BaseLdap, '_ldap_get') @mock.patch.object(common_ldap.BaseLdap, '_ldap_get')
def test_id_attribute_not_found(self, mock_ldap_get): def test_id_attribute_not_found(self, mock_ldap_get):
mock_ldap_get.return_value = ( mock_ldap_get.return_value = (
'cn=nobodycares,dc=example,dc=com', 'cn=nobodycares,dc=example,dc=com',
{ {
'sn': [uuid.uuid4().hex], 'sn': [uuid.uuid4().hex],
} }
) )
 End of changes. 2 change blocks. 
5 lines changed or deleted 50 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)