'Test varius mapping options and how users are identified.
This test calls mapped.setup_username() for propagating user object.
Test plan:
- Check if the user has proper domain (\'federated\') set
- Check if the user has proper type set (\'ephemeral\')
- Check if display_name is properly set from the assertion
- Check if unique_id is properly set and equal to value hardcoded
in the mapping
This test does two iterations with different assertions used as input
for the Mapping Engine.  Different assertions will be matched with
different rules in the ruleset, effectively issuing different user_id
(hardcoded values). In the first iteration, the hardcoded user_id is
not url-safe and we expect Keystone to make it url safe. In the latter
iteration, provided user_id is already url-safe and we expect server
not to change it.'

def test_user_identification_id_and_name(self):

    request = webob.Request.blank('/')
    testcases = [(mapping_fixtures.CUSTOMER_ASSERTION, 'bwilliams'), (mapping_fixtures.EMPLOYEE_ASSERTION, 'tbo')]
    for (assertion, exp_user_name) in testcases:
        mapping = mapping_fixtures.MAPPING_USER_IDS
        rp = mapping_utils.RuleProcessor(FAKE_MAPPING_ID, mapping['rules'])
        mapped_properties = rp.process(assertion)
        self.assertIsNotNone(mapped_properties)
        self.assertValidMappedUserObject(mapped_properties)
        (unique_id, display_name) = mapped.get_user_unique_id_and_display_name(request, mapped_properties)
        self.assertEqual(exp_user_name, display_name)
        self.assertEqual('abc123%40example.com', unique_id)
