
    g                         d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d Zej                  j                  dd	      d
        Zd Zd Zy)    )ANY)reverseN)assertTemplateUsed)"AUTHENTICATION_METHODS_SESSION_KEY)Authenticatorc                    | j                  t        d            }|j                  dk(  sJ |d   j                  t        d            sJ | j                  t        d            }t	        |d       t
        j                  j                  |t
        j                  j                        }|j                         j                         d   }| j                  t        d      d	|i
      }|j                  dk(  sJ | j                  t        d            }|j                  dk(  sJ t	        |d       | j                  t           }|d   dd|j                  t        ddk(  sJ y )Nmfa_view_recovery_codes.  locationaccount_reauthenticatemfa_reauthenticatezmfa/reauthenticate.html)usertyper   code)data   zmfa/recovery_codes/index.htmlmfarecovery_codesT)methodr   idatreauthenticated)getr   status_code
startswithr   r   objectsTypeRECOVERY_CODESwrapget_unused_codespostsessionr   pkr   )auth_clientuser_with_recovery_codesrespauthenticatorunused_codemethodss         ^/var/www/django_project/virt/lib/python3.12/site-packages/allauth/mfa/base/tests/test_views.pytest_reauthenticationr,      sZ   ??7#<=>Ds"""
&&w/G'HIII??7#789Dt67!))--%M,>,>,M,M . M  $$&779!<KG$89@UVDs"""??7#<=>Ds"""t<=!!"DEG2;        url_name)mfa_activate_totp	mfa_indexmfa_deactivate_totpc                     | j                  t        |            }|j                  dk(  sJ |d   j                  t        d            sJ y )Nr
   r   account_login)r   r   r   r   )clientr.   r'   s      r+   test_login_required_viewsr5   %   sI     ::gh'(Ds"""
&&w'?@@@r-   c                 X    | j                  t        d            }d|j                  v sJ y )Nr0   authenticators)r   r   contextr%   user_with_totpr'   s      r+   
test_indexr;   3   s'    ??7;/0Dt||+++r-   c                     | j                  t        d      ddd      }|j                  dk(  sJ |j                  d   j                  ddgik(  sJ y )	Naccount_email zchange-to@this.org)
action_addemailr   formr@   zUYou cannot add an email address to an account protected by two-factor authentication.)r"   r   r   r8   errorsr9   s      r+   test_add_email_not_allowedrC   8   sj     $89D s"""<<&&c
+   r-   )unittest.mockr   django.urlsr   pytestpytest_django.assertsr   allauth.account.authenticationr   allauth.mfa.modelsr   r,   markparametrizer5   r;   rC    r-   r+   <module>rM      sS       4 M ,2 AA,

r-   