コード例 #1
0
    def test_empty_claims(self):
        settings = dict(**TOKEN_AUTH_SETTINGS)
        LocationFactory.create(slug='amsterdam')
        settings.update(assertion_mapping={
            'email': 'mail',
            'remote_id': 'nameId',
            'location.slug': 'location',
        })

        with self.settings(TOKEN_AUTH=settings):

            request = self._request('get',
                                    '/sso/redirect',
                                    HTTP_HOST='www.stuff.com')
            auth_backend = SAMLAuthentication(request)

            result = auth_backend.parse_user({
                'nameId': ['1234325'],
                'location': ['amsterdam']
            })
            self.assertEqual(result['location.slug'], 'amsterdam')

            result = auth_backend.parse_user({
                'nameId': ['4573457'],
                'location': []
            })
            self.assertEqual(result['location.slug'], '')
コード例 #2
0
    def test_parse_user(self):
        settings = dict(**TOKEN_AUTH_SETTINGS)
        settings.update(
            assertion_mapping={
                'email': 'mail',
                'remote_id': 'nameId',
                'segment.team': ['team', 'team_name']
            })

        with self.settings(TOKEN_AUTH=settings):

            request = self._request('get',
                                    '/sso/redirect',
                                    HTTP_HOST='www.stuff.com')
            auth_backend = SAMLAuthentication(request)

            result = auth_backend.parse_user({
                'team': ['Marketing'],
                'team_name': ['Online Marketing'],
                'mail': ['*****@*****.**'],
                'nameId': ['1234325']
            })
            self.assertEqual(result['remote_id'], '1234325')
            self.assertEqual(result['email'], '*****@*****.**')
            self.assertEqual(result['segment.team'],
                             ['Marketing', 'Online Marketing'])