def test_create(self): self.assertEqual(len(db_oauth_token.list_tokens()), 0) db_oauth_token.create( client_id=self.oauth_client["client_id"], access_token="Test Access Token", refresh_token="Test Refresh Token", expires=datetime.now() + timedelta(seconds=200), user_id=self.user.id, scopes=None, ) self.assertEqual(len(db_oauth_token.list_tokens()), 1)
def test_list(self): db_oauth_token.create( client_id=self.oauth_client["client_id"], access_token="Test Access Token", refresh_token="Test Refresh Token", expires=datetime.now() + timedelta(seconds=200), user_id=self.user.id, scopes=None, ) self.assertEqual(len(db_oauth_token.list_tokens(client_id=self.oauth_client["client_id"])), 1) self.assertEqual(len(db_oauth_token.list_tokens(refresh_token="Test Refresh Token")), 1)
def fetch_access_token(access_token): tokens = db_oauth_token.list_tokens(access_token=access_token) return tokens[0] if tokens else None
def fetch_token(client_id, refresh_token): tokens = db_oauth_token.list_tokens(client_id=client_id, refresh_token=refresh_token) return tokens[0] if tokens else None
def fetch_access_token(access_token): token = db_oauth_token.list_tokens(access_token=access_token)[0] return token
def fetch_token(client_id, refresh_token): token = db_oauth_token.list_tokens(client_id=client_id, refresh_token=refresh_token)[0] return token