Example #1
0
class ResourceOwnerPasswordCredentialsGrantTest(TestCase):

    def setUp(self):
        mock_client = mock.MagicMock()
        mock_client.user.return_value = 'mocked user'
        self.request = Request('http://a.b/path')
        self.request.grant_type = 'password'
        self.request.username = '******'
        self.request.password = '******'
        self.request.client = mock_client
        self.request.scopes = ('mocked', 'scopes')
        self.mock_validator = mock.MagicMock()
        self.auth = ResourceOwnerPasswordCredentialsGrant(
                request_validator=self.mock_validator)

    def test_create_token_response(self):
        bearer = BearerToken(self.mock_validator)
        uri, headers, body, status_code = self.auth.create_token_response(
                self.request, bearer)
        token = json.loads(body)
        self.assertIn('access_token', token)
        self.assertIn('token_type', token)
        self.assertIn('expires_in', token)
        self.assertIn('refresh_token', token)

    def test_error_response(self):
        pass

    def test_scopes(self):
        pass
Example #2
0
class ResourceOwnerPasswordCredentialsGrantTest(TestCase):
    def setUp(self):
        self.request = Request('http://a.b/path')
        self.request.grant_type = 'password'
        self.request.username = '******'
        self.request.password = '******'
        self.request.client = 'mock authenticated'
        self.request.scopes = ('mocked', 'scopes')
        self.mock_validator = mock.MagicMock()
        self.auth = ResourceOwnerPasswordCredentialsGrant(
            request_validator=self.mock_validator)

    def test_create_token_response(self):
        bearer = BearerToken()
        bearer.save_token = mock.MagicMock()
        uri, headers, body = self.auth.create_token_response(
            self.request, bearer)
        token = json.loads(body)
        self.assertIn('access_token', token)
        self.assertIn('token_type', token)
        self.assertIn('expires_in', token)
        self.assertIn('refresh_token', token)

    def test_error_response(self):
        pass

    def test_scopes(self):
        pass