File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,24 @@ def test_str(self):
312312 )
313313 self .assertEqual (expected , req .__str__ ())
314314
315+ def test_str_excludes_authorization_header (self ):
316+ req = Request (
317+ method = "POST" ,
318+ url = "https://api.twilio.com/2010-04-01/Accounts.json" ,
319+ params = {"PageSize" : "1" },
320+ data = {"FriendlyName" : "My New Account" },
321+ headers = {
322+ "Authorization" : "Bearer secret-token" ,
323+ "X-Custom-Header" : "Value"
324+ },
325+ )
326+ expected = (
327+ "POST https://api.twilio.com/2010-04-01/Accounts.json?PageSize=1\n "
328+ ' -d "FriendlyName=My New Account"\n '
329+ ' -H "X-Custom-Header: Value"'
330+ )
331+ self .assertEqual (expected , req .__str__ ())
332+
315333
316334class MyVersion (Version ):
317335 def __init__ (self , domain ):
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ def __str__(self) -> str:
7171 headers = ""
7272 if self .headers and self .headers != Match .ANY :
7373 headers = "\n {}" .format (
74- "\n " .join (' -H "{}: {}"' .format (k , v ) for k , v in self .headers .items ())
74+ "\n " .join (' -H "{}: {}"' .format (k , v ) for k , v in self .headers .items () if k . lower () != "authorization" )
7575 )
7676
7777 return "{method} {url}{params}{data}{headers}" .format (
You can’t perform that action at this time.
0 commit comments