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:
50
50
user_set_active_password_path = "/v1/mgmt/user/password/set/active"
51
51
user_expire_password_path = "/v1/mgmt/user/password/expire"
52
52
user_remove_all_passkeys_path = "/v1/mgmt/user/passkeys/delete"
53
+ user_remove_totp_seed_path = "/v1/mgmt/user/totp/delete"
53
54
user_add_tenant_path = "/v1/mgmt/user/update/tenant/add"
54
55
user_remove_tenant_path = "/v1/mgmt/user/update/tenant/remove"
55
56
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(
1506
1506
)
1507
1507
return
1508
1508
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
+
1509
1531
def generate_otp_for_test_user (
1510
1532
self ,
1511
1533
method : DeliveryMethod ,
Original file line number Diff line number Diff line change @@ -2181,6 +2181,39 @@ def test_user_remove_all_passkeys(self):
2181
2181
timeout = DEFAULT_TIMEOUT_SECONDS ,
2182
2182
)
2183
2183
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
+
2184
2217
def test_generate_magic_link_for_test_user (self ):
2185
2218
# Test failed flows
2186
2219
with patch ("requests.post" ) as mock_post :
You can’t perform that action at this time.
0 commit comments