File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1313
1414class JWT (AuthBase ):
1515 def update_jwt (
16- self , jwt : str , custom_claims : dict , refresh_duration : Optional [int ]
16+ self , jwt : str , custom_claims : dict , refresh_duration : Optional [int ] = 0
1717 ) -> str :
1818 """
1919 Given a valid JWT, update it with custom claims, and update its authz claims as well
Original file line number Diff line number Diff line change @@ -69,6 +69,31 @@ def test_update_jwt(self):
6969 timeout = DEFAULT_TIMEOUT_SECONDS ,
7070 )
7171
72+ with patch ("requests.post" ) as mock_post :
73+ network_resp = mock .Mock ()
74+ network_resp .ok = True
75+ network_resp .json .return_value = json .loads ("""{"jwt": "response"}""" )
76+ mock_post .return_value = network_resp
77+ resp = client .mgmt .jwt .update_jwt ("test" , {"k1" : "v1" })
78+ self .assertEqual (resp , "response" )
79+ expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .update_jwt_path } "
80+ mock_post .assert_called_with (
81+ expected_uri ,
82+ headers = {
83+ ** common .default_headers ,
84+ "Authorization" : f"Bearer { self .dummy_project_id } :{ self .dummy_management_key } " ,
85+ },
86+ json = {
87+ "jwt" : "test" ,
88+ "customClaims" : {"k1" : "v1" },
89+ "refreshDuration" : 0 ,
90+ },
91+ allow_redirects = False ,
92+ verify = True ,
93+ params = None ,
94+ timeout = DEFAULT_TIMEOUT_SECONDS ,
95+ )
96+
7297 def test_impersonate (self ):
7398 client = DescopeClient (
7499 self .dummy_project_id ,
You can’t perform that action at this time.
0 commit comments