o
    "4g	                     @   s   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lmZ ejdd	d
dgfd
d
ddgfd
d	dgfgdd Zdd ZdS )    )ANY)reverseN)assertTemplateUsed)app_settings)get_adapter)"AUTHENTICATION_METHODS_SESSION_KEYz0with_totp,with_password,expected_method_urlnamesFTaccount_reauthenticatemfa_reauthenticatec           	      C   s   t js|rd S | ||rd ndd}| |ksJ || t |}t|t|ks.J tdd |D ttt	|ks@J dD ].}|dkrLt jsLqB|
t	|d }||v ra|jdks`J qB|jd	kshJ d
|d v spJ qBd S )N!)	with_totppasswordc                 S   s   g | ]}|d  qS )url ).0mr   r   t/var/www/html/authentication-server/venv/lib/python3.10/site-packages/allauth/account/tests/test_reauthentication.py
<listcomp>   s    z+test_user_with_mfa_only.<locals>.<listcomp>)r   r	   r	   z
?next=/foo   .  znext=%2Ffoolocation)allauth_settingsMFA_ENABLEDhas_usable_passwordforce_loginr   get_reauthentication_methodslensetmapr   getstatus_code)	user_factoryr   with_passwordexpected_method_urlnamesclientusermethodsurlnamerespr   r   r   test_user_with_mfa_only   s&   


r(   c                 C   s   d| _ |tdddd}|d tdsJ |td}t|d |jtdd	|id
}|jdks7J |tdddd}|d tdsMJ |jt }|d d	t	ddks^J d S )NTaccount_email zjohn3@example.org)
action_addemailr   r   zaccount/reauthenticate.htmlr   )datar   )methodatreauthenticated)
!ACCOUNT_REAUTHENTICATION_REQUIREDpostr   
startswithr   r   r   sessionr   r   )settingsauth_clientuser_passwordr'   r%   r   r   r   test_reauthentication-   s&   

r9   )unittest.mockr   django.urlsr   pytestpytest_django.assertsr   allauthr   r   allauth.account.adapterr   allauth.account.authenticationr   markparametrizer(   r9   r   r   r   r   <module>   s     


