o
    "4g                     @   sv   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d Zejd	d
dd Zdd Zdd ZdS )    )ANY)reverseN)assertTemplateUsed)"AUTHENTICATION_METHODS_SESSION_KEY)Authenticatorc                 C   s   |  td}|jdksJ |d tdsJ |  td}t|d tjj |tjjd}|	 
 d }| jtdd	|id
}|jdksIJ |  td}|jdksWJ t|d | jt }|d dd|jtddkspJ d S )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methods r)   j/var/www/html/authentication-server/venv/lib/python3.10/site-packages/allauth/mfa/base/tests/test_views.pytest_reauthentication   s,   


r+   url_name)mfa_activate_totp	mfa_indexmfa_deactivate_totpc                 C   s6   |  t|}|jdksJ |d tdsJ d S )Nr   r	   account_login)r   r   r   r   )clientr,   r%   r)   r)   r*   test_login_required_views%   s   	r2   c                 C   s    |  td}d|jv sJ d S )Nr.   authenticators)r   r   contextr#   user_with_totpr%   r)   r)   r*   
test_index3   s   r7   c                 C   sB   |  tdddd}|jdksJ |jd jddgiksJ d S )	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   r4   errorsr5   r)   r)   r*   test_add_email_not_allowed8   s   
r>   )unittest.mockr   django.urlsr   pytestpytest_django.assertsr   allauth.account.authenticationr   allauth.mfa.modelsr   r+   markparametrizer2   r7   r>   r)   r)   r)   r*   <module>   s    
