Esempio n. 1
0
    def setUp(self):
        def set_user(request):
            request.user = mock.MagicMock()
            request.client = mock.MagicMock()
            request.client.client_id = 'mocked_client_id'
            return True

        self.mock_validator = mock.MagicMock()
        self.mock_validator.authenticate_client.side_effect = set_user
        self.addCleanup(setattr, self, 'mock_validator', mock.MagicMock())
        auth_code = grant_types.AuthorizationCodeGrant(
            request_validator=self.mock_validator)
        password = grant_types.ResourceOwnerPasswordCredentialsGrant(
            request_validator=self.mock_validator)
        client = grant_types.ClientCredentialsGrant(
            request_validator=self.mock_validator)
        supported_types = {
            'authorization_code': auth_code,
            'password': password,
            'client_credentials': client,
        }
        token = tokens.BearerToken(self.mock_validator)
        self.endpoint = draft25.TokenEndpoint('authorization_code',
                                              default_token_type=token,
                                              grant_types=supported_types)
Esempio n. 2
0
 def __init__(self,
              default_grant_type=None,
              default_token_type=None,
              grant_types=None):
     self._grant_types = grant_types or {}
     self._default_token_type = default_token_type or tokens.BearerToken()
     self._default_grant_type = default_grant_type
Esempio n. 3
0
 def __init__(self,
              default_response_type=None,
              default_token=None,
              response_types=None):
     self._response_types = response_types or {}
     self._default_response_type = default_response_type
     self._default_token = default_token or tokens.BearerToken()
Esempio n. 4
0
 def __init__(self, request_validator, *args, **kwargs):
     auth_grant = grant_types.AuthorizationCodeGrant(request_validator)
     bearer = tokens.BearerToken(request_validator)
     AuthorizationEndpoint.__init__(self,
                                    default_response_type='code',
                                    response_types={'code': auth_grant})
     TokenEndpoint.__init__(self,
                            default_grant_type='authorization_code',
                            grant_types={'authorization_code': auth_grant},
                            default_token_type=bearer)
     ResourceEndpoint.__init__(self,
                               default_token='Bearer',
                               token_types={'Bearer': bearer})
Esempio n. 5
0
    def setUp(self):
        self.mock_validator = mock.MagicMock()
        self.addCleanup(setattr, self, 'mock_validator', mock.MagicMock())
        auth_code = grant_types.AuthorizationCodeGrant(
            request_validator=self.mock_validator)
        auth_code.save_authorization_code = mock.MagicMock()
        implicit = grant_types.ImplicitGrant(
            request_validator=self.mock_validator)
        implicit.save_token = mock.MagicMock()
        response_types = {
            'code': auth_code,
            'token': implicit,
        }

        token = tokens.BearerToken(self.mock_validator)
        self.endpoint = draft25.AuthorizationEndpoint(
            default_response_type='code',
            default_token_type=token,
            response_types=response_types)
Esempio n. 6
0
 def setUp(self):
     self.mock_validator = mock.MagicMock()
     self.addCleanup(setattr, self, 'mock_validator', mock.MagicMock())
     token = tokens.BearerToken(request_validator=self.mock_validator)
     self.endpoint = draft25.ResourceEndpoint(default_token='Bearer',
                                              token_types={'Bearer': token})
Esempio n. 7
0
 def __init__(self, default_token=None, token_types=None):
     self._tokens = token_types or {'Bearer': tokens.BearerToken()}
     self._default_token = default_token
Esempio n. 8
0
 def __init__(self, token_types=None):
     self._tokens = token_types or {'Bearer': tokens.BearerToken()}