def test_valid_user(self):
        user_id, app_id, _ = create_client()
        expiration = datetime.datetime(2014, 2, 23, 9, 0)
        access_code = AccessCode(
            code='1234',
            code_type='Bearer',
            expiration=expiration,
            scope=['scope1'],
            user_id=user_id,
            application_id=app_id,
        )
        with transaction.manager:
            Session.add(access_code)
            Session.flush()

        request = FakeRequest(headers={'Authorization': 'Bearer 1234'})

        user = verify_request(request, ['scope1'])
        self.assertEqual(user.id, user_id)
    def test_valid_user(self):
        user_id = self.db.users.insert({
            'username': '******',
        })

        expiration = datetime.datetime(2014, 2, 23, 9, 0, tzinfo=utc)
        self.db.access_codes.insert({
            'access_token': '1234',
            'type': 'Bearer',
            'expiration': expiration,
            'user_id': user_id,
            'scope': 'scope1',
            'client_id': 'client1',
        })
        request = testing.FakeRequest(headers={
            'Authorization': 'Bearer 1234',
        }, db=self.db)

        user = verify_request(request, ['scope1'])
        self.assertEqual(user['username'], 'user1')
예제 #3
0
 def wrapper(request):
     request.user = verify_request(request, scopes)
     return f(request)
예제 #4
0
 def wrapper(self):
     self.request.user = verify_request(self.request, scopes)
     return f(self)
예제 #5
0
 def wrapper(request):
     request.user = verify_request(request, scopes)
     return f(request)
예제 #6
0
 def wrapper(self):
     self.request.user = verify_request(self.request, scopes)
     return f(self)