File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ class MgmtV1:
5050 user_set_active_password_path = "/v1/mgmt/user/password/set/active"
5151 user_expire_password_path = "/v1/mgmt/user/password/expire"
5252 user_remove_all_passkeys_path = "/v1/mgmt/user/passkeys/delete"
53+ user_remove_totp_seed_path = "/v1/mgmt/user/totp/delete"
5354 user_add_tenant_path = "/v1/mgmt/user/update/tenant/add"
5455 user_remove_tenant_path = "/v1/mgmt/user/update/tenant/remove"
5556 user_generate_otp_for_test_path = "/v1/mgmt/tests/generate/otp"
Original file line number Diff line number Diff line change @@ -1506,6 +1506,28 @@ def remove_all_passkeys(
15061506 )
15071507 return
15081508
1509+ def remove_totp_seed (
1510+ self ,
1511+ login_id : str ,
1512+ ) -> None :
1513+ """
1514+ Removes TOTP seed for the user with the given login ID.
1515+ Note: The user might not be able to login anymore if they have no other authentication
1516+ methods or a verified email/phone.
1517+
1518+ Args:
1519+ login_id (str): The login ID of the user to remove totp seed for.
1520+
1521+ Raise:
1522+ AuthException: raised if the operation fails
1523+ """
1524+ self ._auth .do_post (
1525+ MgmtV1 .user_remove_totp_seed_path ,
1526+ {"loginId" : login_id },
1527+ pswd = self ._auth .management_key ,
1528+ )
1529+ return
1530+
15091531 def generate_otp_for_test_user (
15101532 self ,
15111533 method : DeliveryMethod ,
Original file line number Diff line number Diff line change @@ -2181,6 +2181,39 @@ def test_user_remove_all_passkeys(self):
21812181 timeout = DEFAULT_TIMEOUT_SECONDS ,
21822182 )
21832183
2184+ def test_user_remove_totp_seed (self ):
2185+ # Test failed flows
2186+ with patch ("requests.post" ) as mock_post :
2187+ mock_post .return_value .ok = False
2188+ self .assertRaises (
2189+ AuthException ,
2190+ self .client .mgmt .user .remove_totp_seed ,
2191+ "login-id" ,
2192+ )
2193+
2194+ # Test success flow
2195+ with patch ("requests.post" ) as mock_post :
2196+ network_resp = mock .Mock ()
2197+ network_resp .ok = True
2198+ mock_post .return_value = network_resp
2199+ self .client .mgmt .user .remove_totp_seed (
2200+ "login-id" ,
2201+ )
2202+ mock_post .assert_called_with (
2203+ f"{ common .DEFAULT_BASE_URL } { MgmtV1 .user_remove_totp_seed_path } " ,
2204+ headers = {
2205+ ** common .default_headers ,
2206+ "Authorization" : f"Bearer { self .dummy_project_id } :{ self .dummy_management_key } " ,
2207+ },
2208+ params = None ,
2209+ json = {
2210+ "loginId" : "login-id" ,
2211+ },
2212+ allow_redirects = False ,
2213+ verify = True ,
2214+ timeout = DEFAULT_TIMEOUT_SECONDS ,
2215+ )
2216+
21842217 def test_generate_magic_link_for_test_user (self ):
21852218 # Test failed flows
21862219 with patch ("requests.post" ) as mock_post :
You can’t perform that action at this time.
0 commit comments