From 398c4b89903c57638a09ae75980a1ba89f707873 Mon Sep 17 00:00:00 2001 From: hiranya911 Date: Mon, 13 Jul 2020 18:33:13 -0700 Subject: [PATCH] fix: Updates for latest version of google-auth --- firebase_admin/db.py | 13 ++----------- tests/test_token_gen.py | 4 ++-- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/firebase_admin/db.py b/firebase_admin/db.py index d42370317..1a91635d5 100644 --- a/firebase_admin/db.py +++ b/firebase_admin/db.py @@ -27,7 +27,7 @@ import threading from urllib import parse -import google.auth +from google.auth import credentials import requests import firebase_admin @@ -802,7 +802,7 @@ def get_client(self, db_url=None): credential = self._credential.get_credential() else: # Emulator base_url. Use fake credentials and specify ?ns=foo in query params. - credential = _EmulatorAdminCredentials() + credential = credentials.AnonymousCredentials() params = {'ns': namespace} if self._auth_override: params['auth_variable_override'] = self._auth_override @@ -978,12 +978,3 @@ def _extract_error_message(cls, response): message = 'Unexpected response from database: {0}'.format(response.content.decode()) return message - - -class _EmulatorAdminCredentials(google.auth.credentials.Credentials): - def __init__(self): - google.auth.credentials.Credentials.__init__(self) - self.token = 'owner' - - def refresh(self, request): - pass diff --git a/tests/test_token_gen.py b/tests/test_token_gen.py index f88c87ff4..8ee4b4b71 100644 --- a/tests/test_token_gen.py +++ b/tests/test_token_gen.py @@ -221,7 +221,7 @@ def test_sign_with_iam(self): testutils.MockCredential(), name='iam-signer-app', options=options) try: signature = base64.b64encode(b'test').decode() - iam_resp = '{{"signature": "{0}"}}'.format(signature) + iam_resp = '{{"signedBlob": "{0}"}}'.format(signature) _overwrite_iam_request(app, testutils.MockRequest(200, iam_resp)) custom_token = auth.create_custom_token(MOCK_UID, app=app).decode() assert custom_token.endswith('.' + signature.rstrip('=')) @@ -259,7 +259,7 @@ def test_sign_with_discovered_service_account(self): # Now invoke the IAM signer. signature = base64.b64encode(b'test').decode() request.response = testutils.MockResponse( - 200, '{{"signature": "{0}"}}'.format(signature)) + 200, '{{"signedBlob": "{0}"}}'.format(signature)) custom_token = auth.create_custom_token(MOCK_UID, app=app).decode() assert custom_token.endswith('.' + signature.rstrip('=')) self._verify_signer(custom_token, 'discovered-service-account') pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy