o
    "4gb	                     @   s\   d dl Z d dlmZ e jdddgdd Zdd	 Zd
d Ze jdddgdd ZdS )    N)Authenticatoremail_verifiedFTc                 C   s   |  |d}|r.|jdksJ | }t|d d dks J t|d d dks,J d S |jdks5J | dd	d
dgdksDJ d S )Nheadless:mfa:manage_totpi  metasecret    totp_url   i  zYYou cannot activate two-factor authentication until you have verified your email address.unverified_email)messagecode)statuserrors)getstatus_codejsonlen)auth_clientuserheadless_reverser   respdata r   m/var/www/html/authentication-server/venv/lib/python3.10/site-packages/allauth/headless/mfa/tests/test_totp.pytest_get_totp_not_active   s   r   c                 C   sR   |  |d}|jdksJ | }|d d dksJ t|d d ts'J d S )Nr      r   typetotp
created_at)r   r   r   
isinstancefloat)r   user_with_totpr   r   r   r   r   r   test_get_totp   s
   r"   c                 C   s\   |  |  |d}W d    n1 sw   Y  |jdks!J tjj|d r,J d S )Nr   r   )r   )deleter   r   objectsfilterexists)r   r!   r   reauthentication_bypassr   r   r   r   test_deactivate_totp'   s
   r(   c           	   	   C   s   | ' |  | j |dddidd}W d    n1 sw   Y  W d    n1 s-w   Y  |rn|jdks;J tjj|tjjd sIJ | }|d d	 d
ksWJ t	|d d t
sbJ |d d d u slJ d S |jdksuJ d S )Nr   r   42zapplication/json)r   content_typer   )r   r   r   r   r   r   last_used_ati  )postr   r   r$   r%   TypeTOTPr&   r   r   r    )	r   r   r   r'   settingstotp_validation_bypassr   r   r   r   r   r   test_activate_totp3   s,   
r1   )	pytestallauth.mfa.modelsr   markparametrizer   r"   r(   r1   r   r   r   r   <module>   s    
