Skip to content

Commit

Permalink
fix: async certificate decoding
Browse files Browse the repository at this point in the history
The async `_cert_fetch` implementation was not properly decoding
certificates into a utf-8 string. This updates the code and tests to
decode the certificates into strings.

This resolves #1050.
  • Loading branch information
clundin25 committed Jul 21, 2022
1 parent 6f49d1f commit ea58c02
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion google/oauth2/_id_token_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def _fetch_certs(request, certs_url):

data = await response.data.read()

return json.loads(json.dumps(data))
return json.loads(data.decode("utf-8"))


async def verify_token(
Expand Down
Binary file modified system_tests/secrets.tar.enc
Binary file not shown.
5 changes: 4 additions & 1 deletion tests_async/oauth2/test_id_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os

import mock
Expand All @@ -32,7 +33,9 @@ def make_request(status, data=None):

if data is not None:
response.data = mock.AsyncMock(spec=["__call__", "read"])
response.data.read = mock.AsyncMock(spec=["__call__"], return_value=data)
response.data.read = mock.AsyncMock(
spec=["__call__"], return_value=json.dumps(data).encode("utf-8")
)

request = mock.AsyncMock(spec=["transport.Request"])
request.return_value = response
Expand Down

0 comments on commit ea58c02

Please sign in to comment.