a
    Qx_                     @   s   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZmZ d	d
 ZedddiidG dd deeZdS )    N)override_settings)EmailAddress)SocialAccount)AmazonCognitoProvider)AmazonCognitoOAuth2Adapter)OAuth2TestsMixin)MockedResponseTestCasec                   C   s   ddddddS )Nz$4993b410-8a1b-4c36-b843-a9c1a697e6b7ZJohnZDoezjdoe@example.comZjohndoe)subZ
given_nameZfamily_nameemailusername r   r   r   l/var/www/html/Ranjet/env/lib/python3.9/site-packages/allauth/socialaccount/providers/amazon_cognito/tests.py_get_mocked_claims   s    r   amazon_cognitoZDOMAINz/https://domain.auth.us-east-1.amazoncognito.comZSOCIALACCOUNT_PROVIDERSc                   @   s@   e Zd ZejZdd Zedi iddd Zdd Z	d	d
 Z
dS )AmazonCognitoTestCasec                 C   s   t t }td|dS )N   Zstatus_codecontent)jsondumpsr   r   )selfmocked_payloadr   r   r   get_mocked_response#   s    z)AmazonCognitoTestCase.get_mocked_responser   r   c                 C   sF   |   }| jttjd | | W d    n1 s80    Y  d S )N)msg)r   ZassertRaises
ValueErrorr   ZDOMAIN_KEY_MISSING_ERRORlogin)r   mocked_responser   r   r   8test_oauth2_adapter_raises_if_domain_settings_is_missing(   s    zNAmazonCognitoTestCase.test_oauth2_adapter_raises_if_domain_settings_is_missingc                 C   sr   t  }d|d< t|}td|d}| | tjj|d dj}t	jj|d}| 
|j|d  | |j d S )	NTZemail_verifiedr   r   r
   )uid)user_idr   )r   r   r   r   r   r   objectsgetr!   r   ZassertEqualr   
assertTrueZverified)r   Zmocked_claimsr   r   r!   Zemail_addressr   r   r   <test_saves_email_as_verified_if_email_is_verified_in_cognito4   s    

zRAmazonCognitoTestCase.test_saves_email_as_verified_if_email_is_verified_in_cognitoc                 C   s   |  d| j v d S )N_)r$   ZproviderZget_slug)r   r   r   r   4test_provider_slug_replaces_underscores_with_hyphensD   s    zJAmazonCognitoTestCase.test_provider_slug_replaces_underscores_with_hyphensN)__name__
__module____qualname__r   idZprovider_idr   r   r   r%   r'   r   r   r   r   r      s   
r   )r   Zdjango.testr   Zallauth.account.modelsr   Zallauth.socialaccount.modelsr   Z7allauth.socialaccount.providers.amazon_cognito.providerr   Z4allauth.socialaccount.providers.amazon_cognito.viewsr   Zallauth.socialaccount.testsr   Zallauth.testsr   r	   r   r   r   r   r   r   <module>   s   
