U
    [e*                     @   s   d dl Z d dlmZ d dlmZ d dlmZ G dd deZG dd deZG d	d
 d
eZ	G dd deZ
G dd deZG dd deZdS )    N)	HTTPretty)
AuthFailed)
OAuth2Testc                   @   s   e Zd ZdZdZdZedddZeddddd	d
ddddddddddddddddddddddddZ	d d! Z
d"d# Zd$S )%GithubOAuth2Testz#social.backends.github.GithubOAuth2zhttps://api.github.com/userfoobarZbearer)Zaccess_token
token_type   0https://github.com/images/error/foobar_happy.gifsomehexcode#https://api.github.com/users/foobarmonalisa foobarGitHubhttps://github.com/blogSan Franciscofoo@bar.comFThere once was...      r   https://github.com/foobar2008-01-14T04:33:35ZUserd   Q   '     Medium  
   namespacecollaboratorsZprivate_reposloginidZ
avatar_urlZgravatar_idurlr   ZcompanyZbloglocationemailZhireableZbioZpublic_reposZpublic_gistsZ	followersZ	followingZhtml_urlZ
created_attypeZtotal_private_reposZowned_private_reposZprivate_gists
disk_usager!   Zplanc                 C   s   |    d S N)do_loginself r.   c/var/www/html/services/stratfitenv/lib/python3.8/site-packages/social/tests/backends/test_github.py
test_login3   s    zGithubOAuth2Test.test_loginc                 C   s   |    d S r*   do_partial_pipeliner,   r.   r.   r/   test_partial_pipeline6   s    z&GithubOAuth2Test.test_partial_pipelineN)__name__
__module____qualname__backend_pathZuser_data_urlZexpected_usernamejsondumpsZaccess_token_bodyuser_data_bodyr0   r3   r.   r.   r.   r/   r   
   sP   !r   c                   @   sl   e Zd Zeddddddddd	d
ddddddddddddddddddddZdd Zdd Zd d! Zd"S )#GithubOAuth2NoEmailTestr   r   r	   r
   r   r   r   r   r    Fr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   c                 C   s.   d}t jt j|dtdgdd |   d S )N"https://api.github.com/user/emails   r   application/jsonstatusbodycontent_typer   register_uriGETr8   r9   r+   r-   r%   r.   r.   r/   r0   \   s    
z"GithubOAuth2NoEmailTest.test_loginc                 C   s2   d}t jt j|dtddigdd |   d S )Nr=   r>   r'   r   r?   r@   rD   rG   r.   r.   r/   test_login_next_formatc   s    z.GithubOAuth2NoEmailTest.test_login_next_formatc                 C   s   |    d S r*   r1   r,   r.   r.   r/   r3   j   s    z-GithubOAuth2NoEmailTest.test_partial_pipelineN)	r4   r5   r6   r8   r9   r:   r0   rH   r3   r.   r.   r.   r/   r;   :   sD   !r;   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )GithubOrganizationOAuth2Test/social.backends.github.GithubOrganizationOAuth2c                    s(   d}t jt j|ddd tt| |S )N1https://api.github.com/orgs/foobar/members/foobar   r<   rA   rB   )r   rE   rF   superrI   auth_handlersr-   Z	start_urlr%   	__class__r.   r/   rO   q   s
    
z*GithubOrganizationOAuth2Test.auth_handlersc                 C   s   | j ddi |   d S NZSOCIAL_AUTH_GITHUB_ORG_NAMEr   strategyset_settingsr+   r,   r.   r.   r/   r0   x   s    z'GithubOrganizationOAuth2Test.test_loginc                 C   s   | j ddi |   d S rS   rU   rV   r2   r,   r.   r.   r/   r3   |   s    z2GithubOrganizationOAuth2Test.test_partial_pipeliner4   r5   r6   r7   rO   r0   r3   __classcell__r.   r.   rQ   r/   rI   n   s   rI   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS ) GithubOrganizationOAuth2FailTestrJ   c                    s*   d}t jt j|dddd tt| |S )NrK     {"message": "Not Found"}r?   r@   )r   rE   rF   rN   rZ   rO   rP   rQ   r.   r/   rO      s    
z.GithubOrganizationOAuth2FailTest.auth_handlersc              	   C   s2   | j ddi | t |   W 5 Q R X d S rS   rU   rV   assertRaisesr   r+   r,   r.   r.   r/   r0      s    z+GithubOrganizationOAuth2FailTest.test_loginc              	   C   s2   | j ddi | t |   W 5 Q R X d S rS   rU   rV   r^   r   r2   r,   r.   r.   r/   r3      s    z6GithubOrganizationOAuth2FailTest.test_partial_pipelinerX   r.   r.   rQ   r/   rZ      s   	rZ   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )GithubTeamOAuth2Test'social.backends.github.GithubTeamOAuth2c                    s(   d}t jt j|ddd tt| |S )N/https://api.github.com/teams/123/members/foobarrL   r<   rM   )r   rE   rF   rN   r`   rO   rP   rQ   r.   r/   rO      s
    
z"GithubTeamOAuth2Test.auth_handlersc                 C   s   | j ddi |   d S NZSOCIAL_AUTH_GITHUB_TEAM_IDZ123rT   r,   r.   r.   r/   r0      s    zGithubTeamOAuth2Test.test_loginc                 C   s   | j ddi |   d S rc   rW   r,   r.   r.   r/   r3      s    z*GithubTeamOAuth2Test.test_partial_pipelinerX   r.   r.   rQ   r/   r`      s   r`   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )GithubTeamOAuth2FailTestra   c                    s*   d}t jt j|dddd tt| |S )Nrb   r[   r\   r?   r@   )r   rE   rF   rN   rd   rO   rP   rQ   r.   r/   rO      s    
z&GithubTeamOAuth2FailTest.auth_handlersc              	   C   s2   | j ddi | t |   W 5 Q R X d S rc   r]   r,   r.   r.   r/   r0      s    z#GithubTeamOAuth2FailTest.test_loginc              	   C   s2   | j ddi | t |   W 5 Q R X d S rc   r_   r,   r.   r.   r/   r3      s    z.GithubTeamOAuth2FailTest.test_partial_pipelinerX   r.   r.   rQ   r/   rd      s   	rd   )r8   Z	httprettyr   Zsocial.exceptionsr   Zsocial.tests.backends.oauthr   r   r;   rI   rZ   r`   rd   r.   r.   r.   r/   <module>   s   04