@@ -69,6 +69,26 @@ def test_update_jwt(self):
6969 timeout = DEFAULT_TIMEOUT_SECONDS ,
7070 )
7171
72+ resp = client .mgmt .jwt .update_jwt ("test" , {"k1" : "v1" })
73+ self .assertEqual (resp , "response" )
74+ expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .update_jwt_path } "
75+ mock_post .assert_called_with (
76+ expected_uri ,
77+ headers = {
78+ ** common .default_headers ,
79+ "Authorization" : f"Bearer { self .dummy_project_id } :{ self .dummy_management_key } " ,
80+ },
81+ json = {
82+ "jwt" : "test" ,
83+ "customClaims" : {"k1" : "v1" },
84+ "refreshDuration" : 0 ,
85+ },
86+ allow_redirects = False ,
87+ verify = True ,
88+ params = None ,
89+ timeout = DEFAULT_TIMEOUT_SECONDS ,
90+ )
91+
7292 def test_impersonate (self ):
7393 client = DescopeClient (
7494 self .dummy_project_id ,
@@ -145,7 +165,7 @@ def test_sign_in(self):
145165 network_resp .json .return_value = json .loads ("""{"jwt": "response"}""" )
146166 mock_post .return_value = network_resp
147167 client .mgmt .jwt .sign_in ("loginId" )
148- expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .mgmt_sign_in } "
168+ expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .mgmt_sign_in_path } "
149169 mock_post .assert_called_with (
150170 expected_uri ,
151171 headers = {
@@ -184,7 +204,7 @@ def test_sign_up(self):
184204 network_resp .json .return_value = json .loads ("""{"jwt": "response"}""" )
185205 mock_post .return_value = network_resp
186206 client .mgmt .jwt .sign_up ("loginId" )
187- expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .mgmt_sign_up } "
207+ expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .mgmt_sign_up_path } "
188208 mock_post .assert_called_with (
189209 expected_uri ,
190210 headers = {
@@ -233,7 +253,7 @@ def test_sign_up_or_in(self):
233253 network_resp .json .return_value = json .loads ("""{"jwt": "response"}""" )
234254 mock_post .return_value = network_resp
235255 client .mgmt .jwt .sign_up_or_in ("loginId" )
236- expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .mgmt_sign_up_or_in } "
256+ expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .mgmt_sign_up_or_in_path } "
237257 mock_post .assert_called_with (
238258 expected_uri ,
239259 headers = {
@@ -263,3 +283,32 @@ def test_sign_up_or_in(self):
263283 params = None ,
264284 timeout = DEFAULT_TIMEOUT_SECONDS ,
265285 )
286+
287+ def test_anonymous (self ):
288+ client = DescopeClient (
289+ self .dummy_project_id ,
290+ self .public_key_dict ,
291+ False ,
292+ self .dummy_management_key ,
293+ )
294+
295+ # Test success flow
296+ with patch ("requests.post" ) as mock_post :
297+ network_resp = mock .Mock ()
298+ network_resp .ok = True
299+ network_resp .json .return_value = json .loads ("""{"jwt": "response"}""" )
300+ mock_post .return_value = network_resp
301+ client .mgmt .jwt .anonymous ({"k1" : "v1" }, "id" )
302+ expected_uri = f"{ common .DEFAULT_BASE_URL } { MgmtV1 .anonymous_path } "
303+ mock_post .assert_called_with (
304+ expected_uri ,
305+ headers = {
306+ ** common .default_headers ,
307+ "Authorization" : f"Bearer { self .dummy_project_id } :{ self .dummy_management_key } " ,
308+ },
309+ json = {"customClaims" : {"k1" : "v1" }, "selectedTenant" : "id" },
310+ allow_redirects = False ,
311+ verify = True ,
312+ params = None ,
313+ timeout = DEFAULT_TIMEOUT_SECONDS ,
314+ )
0 commit comments