@ -1,7 +1,5 @@
import json
from unittest import mock
from models . account import Account
from services . mfa_service import MFAService
@ -12,7 +10,7 @@ class TestMFASimpleIntegration:
""" Test MFA setup flow end-to-end. """
# Step 1: Check initial MFA status
response = test_client . get (
f " /console/api/account/mfa/status " ,
" /console/api/account/mfa/status " ,
headers = auth_header
)
assert response . status_code == 200
@ -21,7 +19,7 @@ class TestMFASimpleIntegration:
# Step 2: Initialize MFA setup
response = test_client . post (
f " /console/api/account/mfa/setup " ,
" /console/api/account/mfa/setup " ,
headers = auth_header
)
assert response . status_code == 200
@ -33,7 +31,7 @@ class TestMFASimpleIntegration:
# Step 3: Complete MFA setup with mocked TOTP
with mock . patch . object ( MFAService , ' verify_totp ' , return_value = True ) :
response = test_client . post (
f " /console/api/account/mfa/setup/complete " ,
" /console/api/account/mfa/setup/complete " ,
headers = auth_header ,
json = { " totp_token " : " 123456 " }
)
@ -44,7 +42,7 @@ class TestMFASimpleIntegration:
# Step 4: Verify MFA is now enabled
response = test_client . get (
f " /console/api/account/mfa/status " ,
" /console/api/account/mfa/status " ,
headers = auth_header
)
assert response . status_code == 200
@ -55,7 +53,7 @@ class TestMFASimpleIntegration:
""" Test MFA disable flow. """
# First check MFA status and disable if already enabled
response = test_client . get (
f " /console/api/account/mfa/status " ,
" /console/api/account/mfa/status " ,
headers = auth_header
)
assert response . status_code == 200
@ -65,7 +63,7 @@ class TestMFASimpleIntegration:
# MFA is already enabled, disable it first with mocked password verification
with mock . patch ( ' libs.password.compare_password ' , return_value = True ) :
response = test_client . post (
f " /console/api/account/mfa/disable " ,
" /console/api/account/mfa/disable " ,
headers = auth_header ,
json = { " password " : " any_password " } # Password doesn't matter, it's mocked
)
@ -75,14 +73,14 @@ class TestMFASimpleIntegration:
with mock . patch . object ( MFAService , ' verify_totp ' , return_value = True ) :
# Initialize setup
response = test_client . post (
f " /console/api/account/mfa/setup " ,
" /console/api/account/mfa/setup " ,
headers = auth_header
)
assert response . status_code == 200
# Complete setup
response = test_client . post (
f " /console/api/account/mfa/setup/complete " ,
" /console/api/account/mfa/setup/complete " ,
headers = auth_header ,
json = { " totp_token " : " 123456 " }
)
@ -91,7 +89,7 @@ class TestMFASimpleIntegration:
# Now disable MFA with mocked password verification
with mock . patch ( ' libs.password.compare_password ' , return_value = True ) :
response = test_client . post (
f " /console/api/account/mfa/disable " ,
" /console/api/account/mfa/disable " ,
headers = auth_header ,
json = { " password " : " any_password " } # Password doesn't matter, it's mocked
)
@ -101,7 +99,7 @@ class TestMFASimpleIntegration:
# Verify MFA is disabled
response = test_client . get (
f " /console/api/account/mfa/status " ,
" /console/api/account/mfa/status " ,
headers = auth_header
)
assert response . status_code == 200