'Illustrate the inconsistent handling of hyphens in keys.
To quote Morgan in bug 1526244:
the reason this is converted from "domain-id" to "domain_id" is
because of how we process/normalize data. The way we have to handle
specific data types for known columns requires avoiding "-" in the
actual python code since "-" is not valid for attributes in python
w/o significant use of "getattr" etc.
In short, historically we handle some things in conversions. The
use of "extras" has long been a poor design choice that leads to
odd/strange inconsistent behaviors because of other choices made in
handling data from within the body. (In many cases we convert from
"-" to "_" throughout openstack)
Source: https://bugs.launchpad.net/keystone/+bug/1526244/comments/9'

def test_user_management_normalized_keys(self):

    domain1 = unit.new_domain_ref()
    self.resource_api.create_domain(domain1['id'], domain1)
    domain2 = unit.new_domain_ref()
    self.resource_api.create_domain(domain2['id'], domain2)
    user = unit.new_user_ref(domain_id=domain1['id'])
    r = self.post('/users', body={'user': user})
    self.assertValidUserResponse(r, user)
    user['id'] = r.json['user']['id']
    r = self.get(('/users?domain-id=%s' % domain1['id']))
    self.assertValidUserListResponse(r, ref=self.user)
    self.assertNotEqual(domain1['id'], self.user['domain_id'])
    user = unit.new_user_ref(domain_id=domain1['id'])
    user['domain-id'] = user.pop('domain_id')
    r = self.post('/users', body={'user': user})
    self.assertNotIn('domain-id', r.json['user'])
    self.assertEqual(domain1['id'], r.json['user']['domain_id'])
    user['domain_id'] = user.pop('domain-id')
    self.assertValidUserResponse(r, user)
    user['id'] = r.json['user']['id']
    r = self.patch(('/users/%s' % user['id']), body={'user': {'domain-id': domain2['id']}})
    self.assertEqual(domain2['id'], r.json['user']['domain-id'])
    self.assertEqual(user['domain_id'], r.json['user']['domain_id'])
    self.assertNotEqual(domain2['id'], user['domain_id'])
    self.assertValidUserResponse(r, user)
