o
    ˷e                     @   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-a9c1a697e6b7JohnDoezjdoe@example.comjohndoe)sub
given_namefamily_nameemailusername r   r   r   k/var/www/ideatree/venv/lib/python3.10/site-packages/allauth/socialaccount/providers/amazon_cognito/tests.py_get_mocked_claims   s   r   amazon_cognitoDOMAINz/https://domain.auth.us-east-1.amazoncognito.com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   status_codecontent)jsondumpsr   r   )selfmocked_payloadr   r   r   get_mocked_response#   s   z)AmazonCognitoTestCase.get_mocked_responser   r   c                 C   sH   |   }| jttjd | | W d    d S 1 sw   Y  d S )N)msg)r"   assertRaises
ValueErrorr   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 )	NTemail_verifiedr   r   r   )uid)user_idr   )r   r   r   r   r'   r   objectsgetr,   r   assertEqualr   
assertTrueverified)r    mocked_claimsr!   r(   r,   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_)r0   provider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   idprovider_idr"   r   r)   r4   r8   r   r   r   r   r      s    
r   )r   django.testr   allauth.account.modelsr   allauth.socialaccount.modelsr   7allauth.socialaccount.providers.amazon_cognito.providerr   4allauth.socialaccount.providers.amazon_cognito.viewsr   allauth.socialaccount.testsr   allauth.testsr   r	   r   r   r   r   r   r   <module>   s    
