Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 85bf5d5

Browse files
authored
Get response as string instead of bytes (GoogleCloudPlatform#4063)
* Get response as string instead of bytes * Mock the correct property for string * Typo * Missed fixing a mock response check
1 parent b90c7b2 commit 85bf5d5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

functions/security/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
def calling_function(request):
3333
# Fetch the token
3434
token_response = requests.get(token_full_url, headers=token_headers)
35-
jwt = token_response.content
35+
jwt = token_response.text
3636

3737
# Provide the token in the request to the receiving function
3838
function_headers = {'Authorization': f'bearer {jwt}'}
3939
function_response = requests.get(function_url, headers=function_headers)
4040

41-
return function_response.content
41+
return function_response.text
4242
# [END functions_bearer_token]

functions/security/main_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020

2121
class Response(object):
22-
def __init__(self, content=u''):
23-
self.content = content
22+
def __init__(self, text=u''):
23+
self.text = text
2424

2525

2626
@mock.patch("main.requests")

0 commit comments

Comments
 (0)