U
    [eQ                     @   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m	Z	 G dd de
ZG dd	 d	eeZG d
d deZG dd dee	ZG dd deZdS )    N)	HTTPretty)	urlencode)AuthForbidden)
OAuth1Test
OAuth2Testc                   @   s   e Zd ZdZdZdZeddddiddidd	idd
iddiddiddidddddddZedddddddddiiddddddddiiddgd Z	d!S )"BitbucketOAuthMixinz"https://api.bitbucket.org/2.0/userfoobarz)https://api.bitbucket.org/2.0/user/emailsz2012-03-29T18:07:38+00:00zFoo Barhrefz/https://bitbucket.org/account/foobar/avatar/32/z4https://api.bitbucket.org/2.0/users/foobar/followersz4https://api.bitbucket.org/2.0/users/foobar/followingz0https://api.bitbucket.org/2.0/users/foobar/hookszhttps://bitbucket.org/foobarz1https://api.bitbucket.org/2.0/repositories/foobarz*https://api.bitbucket.org/2.0/users/foobar)ZavatarZ	followersZ	followinghookshtmlZrepositoriesselfzFooville, Baruserz&{397621dc-0f78-329f-8d6d-727396248e3f}zhttp://foobar.com)Z
created_onZdisplay_namelinkslocationtypeusernameuuidZwebsite   
      foo@bar.comTr   5https://api.bitbucket.org/2.0/user/emails/foo@bar.comemailr   Zis_confirmedZ
is_primaryr   r   znot@confirme.comFz;https://api.bitbucket.org/2.0/user/emails/not@confirmed.compageZpagelensizevaluesN)
__name__
__module____qualname__Zuser_data_urlZexpected_usernamebb_api_user_emailsjsondumpsZuser_data_bodyemails_body r%   r%   f/var/www/html/services/stratfitenv/lib/python3.8/site-packages/social/tests/backends/test_bitbucket.pyr   
   sL   

r   c                   @   s@   e Zd ZdZeddddZedddZdd	 Z	d
d Z
dS )BitbucketOAuth1Testz(social.backends.bitbucket.BitbucketOAuthzfoobar-secretr   true)Zoauth_token_secretZoauth_tokenZoauth_callback_confirmedbearer)access_token
token_typec                 C   s$   t jt j| jd| jd |   d S N   )statusbodyr   register_uriGETr!   r$   Zdo_loginr   r%   r%   r&   
test_loginF   s     zBitbucketOAuth1Test.test_loginc                 C   s$   t jt j| jd| jd |   d S r,   r   r1   r2   r!   r$   Zdo_partial_pipeliner3   r%   r%   r&   test_partial_pipelineL   s     z)BitbucketOAuth1Test.test_partial_pipelineN)r   r   r    backend_pathr   Zrequest_token_bodyr"   r#   access_token_bodyr4   r6   r%   r%   r%   r&   r'   8   s   r'   c                       sR   e Zd Zedddddddddiid	d
gdZ fddZ fddZ  ZS )BitbucketOAuth1FailTestr   r   r   FTr   r	   r   r   r   r   c              	      s8   | j ddi | t tt|   W 5 Q R X d S NZ*SOCIAL_AUTH_BITBUCKET_VERIFIED_EMAILS_ONLYT)strategyset_settingsassertRaisesr   superr9   r4   r3   	__class__r%   r&   r4   c   s     z"BitbucketOAuth1FailTest.test_loginc              	      s8   | j ddi | t tt|   W 5 Q R X d S r:   )r;   r<   r=   r   r>   r9   r6   r3   r?   r%   r&   r6   j   s     z-BitbucketOAuth1FailTest.test_partial_pipeline	r   r   r    r"   r#   r$   r4   r6   __classcell__r%   r%   r?   r&   r9   S   s   
r9   c                   @   s6   e Zd ZdZeddddddZdd	 Zd
d ZdS )BitbucketOAuth2Testz)social.backends.bitbucket.BitbucketOAuth2Zfoobar_accessZ	foo_scopei  Zfoobar_refreshr)   )r*   ZscopesZ
expires_inZrefresh_tokenr+   c                 C   s$   t jt j| jd| jd |   d S r,   r0   r3   r%   r%   r&   r4   }   s     zBitbucketOAuth2Test.test_loginc                 C   s$   t jt j| jd| jd |   d S r,   r5   r3   r%   r%   r&   r6      s     z)BitbucketOAuth2Test.test_partial_pipelineN)	r   r   r    r7   r"   r#   r8   r4   r6   r%   r%   r%   r&   rC   r   s   rC   c                       sR   e Zd Zedddddddddiid	d
gdZ fddZ fddZ  ZS )BitbucketOAuth2FailTestr   r   r   FTr   r	   r   r   r   r   c              	      s8   | j ddi | t tt|   W 5 Q R X d S NZ1SOCIAL_AUTH_BITBUCKET_OAUTH2_VERIFIED_EMAILS_ONLYT)r;   r<   r=   r   r>   rD   r4   r3   r?   r%   r&   r4      s     z"BitbucketOAuth2FailTest.test_loginc              	      s8   | j ddi | t tt|   W 5 Q R X d S rE   )r;   r<   r=   r   r>   rD   r6   r3   r?   r%   r&   r6      s     z-BitbucketOAuth2FailTest.test_partial_pipelinerA   r%   r%   r?   r&   rD      s   
rD   )r"   Z	httprettyr   Z	social.p3r   Zsocial.exceptionsr   Zsocial.tests.backends.oauthr   r   objectr   r'   r9   rC   rD   r%   r%   r%   r&   <module>   s   .