Exemplo n.º 1
0
    def test_user_identification_id_and_name(self):
        """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 user's name is properly mapped from the assertion
        - Check if user's id is properly set and 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.

        """
        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(mapping['rules'])
            mapped_properties = rp.process(assertion)
            context = {'environment': {}}
            self.assertIsNotNone(mapped_properties)
            self.assertValidMappedUserObject(mapped_properties)
            mapped.setup_username(context, mapped_properties)
            self.assertEqual(exp_user_name, mapped_properties['user']['name'])
            self.assertEqual('abc123%40example.com',
                             mapped_properties['user']['id'])
Exemplo n.º 2
0
    def test_user_identification_id_and_name(self):
        """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 user's name is properly mapped from the assertion
        - Check if user's id is properly set and 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.

        """
        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)
            context = {'environment': {}}
            self.assertIsNotNone(mapped_properties)
            self.assertValidMappedUserObject(mapped_properties)
            mapped.setup_username(context, mapped_properties)
            self.assertEqual(exp_user_name, mapped_properties['user']['name'])
            self.assertEqual('abc123%40example.com',
                             mapped_properties['user']['id'])
Exemplo n.º 3
0
    def test_user_identifications_name(self):
        """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 property type set ('ephemeral')
        - Check if user's name is properly mapped from the assertion
        - Check if user's id is properly set and equal to name, as it was not
        explicitly specified in the mapping.

        """
        mapping = mapping_fixtures.MAPPING_USER_IDS
        rp = mapping_utils.RuleProcessor(mapping['rules'])
        assertion = mapping_fixtures.CONTRACTOR_ASSERTION
        mapped_properties = rp.process(assertion)
        self.assertIsNotNone(mapped_properties)
        self.assertValidMappedUserObject(mapped_properties)
        mapped.setup_username({}, mapped_properties)
        self.assertEqual('jsmith', mapped_properties['user']['id'])
        self.assertEqual('jsmith', mapped_properties['user']['name'])
Exemplo n.º 4
0
    def test_user_identifications_name(self):
        """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 property type set ('ephemeral')
        - Check if user's name is properly mapped from the assertion
        - Check if user's id is properly set and equal to name, as it was not
        explicitly specified in the mapping.

        """
        mapping = mapping_fixtures.MAPPING_USER_IDS
        rp = mapping_utils.RuleProcessor(FAKE_MAPPING_ID, mapping['rules'])
        assertion = mapping_fixtures.CONTRACTOR_ASSERTION
        mapped_properties = rp.process(assertion)
        self.assertIsNotNone(mapped_properties)
        self.assertValidMappedUserObject(mapped_properties)
        mapped.setup_username({}, mapped_properties)
        self.assertEqual('jsmith', mapped_properties['user']['id'])
        self.assertEqual('jsmith', mapped_properties['user']['name'])
Exemplo n.º 5
0
    def test_user_identification_id(self):
        """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 propert type set ('ephemeral')
        - Check if user's id is properly mapped from the assertion
        - Check if user's name is properly set and equal to id, as it was not
        explicitely specified in the mapping.

        """
        mapping = mapping_fixtures.MAPPING_USER_IDS
        rp = mapping_utils.RuleProcessor(mapping['rules'])
        assertion = mapping_fixtures.ADMIN_ASSERTION
        mapped_properties = rp.process(assertion)
        context = {'environment': {}}
        self.assertIsNotNone(mapped_properties)
        self.assertValidMappedUserObject(mapped_properties)
        mapped.setup_username(context, mapped_properties)
        self.assertEqual('bob', mapped_properties['user']['name'])
        self.assertEqual('bob', mapped_properties['user']['id'])