U
    [eR'                     @   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 )%GithubEnterpriseOAuth2Testz8social.backends.github_enterprise.GithubEnterpriseOAuth2z#https://www.example.com/api/v3/userfoobarZbearer)Zaccess_token
token_type   5https://www.example.com/images/error/foobar_happy.gifsomehexcode+https://www.example.com/api/v3/users/foobarmonalisa foobarGitHubhttps://www.example.com/blogSan Franciscofoo@bar.comFThere once was...      r   https://www.example.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,   | j ddi | j ddi |   d S N!SOCIAL_AUTH_GITHUB_ENTERPRISE_URLhttps://www.example.com%SOCIAL_AUTH_GITHUB_ENTERPRISE_API_URLhttps://www.example.com/api/v3strategyset_settingsdo_loginself r5   n/var/www/html/services/stratfitenv/lib/python3.8/site-packages/social/tests/backends/test_github_enterprise.py
test_login3   s      z%GithubEnterpriseOAuth2Test.test_loginc                 C   s,   | j ddi | j ddi |   d S r*   r0   r1   do_partial_pipeliner3   r5   r5   r6   test_partial_pipeline:   s      z0GithubEnterpriseOAuth2Test.test_partial_pipelineN)__name__
__module____qualname__backend_pathZuser_data_urlZexpected_usernamejsondumpsZaccess_token_bodyuser_data_bodyr7   r:   r5   r5   r5   r6   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 )#!GithubEnterpriseOAuth2NoEmailTestr   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   sN   | j ddi | j ddi d}tjtj|dtdgdd	 |   d S )
Nr+   r,   r-   r.   *https://www.example.com/api/v3/user/emails   r   application/jsonstatusbodycontent_typer0   r1   r   register_uriGETr?   r@   r2   r4   r%   r5   r5   r6   r7   d   s      
z,GithubEnterpriseOAuth2NoEmailTest.test_loginc                 C   sR   | j ddi | j ddi d}tjtj|dtddigd	d
 |   d S )Nr+   r,   r-   r.   rD   rE   r'   r   rF   rG   rK   rN   r5   r5   r6   test_login_next_formato   s      z8GithubEnterpriseOAuth2NoEmailTest.test_login_next_formatc                 C   s,   | j ddi | j ddi |   d S r*   r8   r3   r5   r5   r6   r:   z   s      z7GithubEnterpriseOAuth2NoEmailTest.test_partial_pipelineN)	r;   r<   r=   r?   r@   rA   r7   rO   r:   r5   r5   r5   r6   rB   B   sD   !rB   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )&GithubEnterpriseOrganizationOAuth2TestDsocial.backends.github_enterprise.GithubEnterpriseOrganizationOAuth2c                    s(   d}t jt j|ddd tt| |S )N9https://www.example.com/api/v3/orgs/foobar/members/foobar   rC   rH   rI   )r   rL   rM   superrP   auth_handlersr4   Z	start_urlr%   	__class__r5   r6   rV      s
    
z4GithubEnterpriseOrganizationOAuth2Test.auth_handlersc                 C   s<   | j ddi | j ddi | j ddi |   d S NZ%SOCIAL_AUTH_GITHUB_ENTERPRISE_ORG_URLr,   Z)SOCIAL_AUTH_GITHUB_ENTERPRISE_ORG_API_URLr.   Z&SOCIAL_AUTH_GITHUB_ENTERPRISE_ORG_NAMEr   r/   r3   r5   r5   r6   r7      s      z1GithubEnterpriseOrganizationOAuth2Test.test_loginc                 C   s<   | j ddi | j ddi | j ddi |   d S rZ   r8   r3   r5   r5   r6   r:      s      z<GithubEnterpriseOrganizationOAuth2Test.test_partial_pipeliner;   r<   r=   r>   rV   r7   r:   __classcell__r5   r5   rX   r6   rP      s   rP   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )*GithubEnterpriseOrganizationOAuth2FailTestrQ   c                    s*   d}t jt j|dddd tt| |S )NrR     {"message": "Not Found"}rF   rG   )r   rL   rM   rU   r]   rV   rW   rX   r5   r6   rV      s    
z8GithubEnterpriseOrganizationOAuth2FailTest.auth_handlersc              	   C   sR   | j ddi | j ddi | j ddi | t |   W 5 Q R X d S rZ   r0   r1   assertRaisesr   r2   r3   r5   r5   r6   r7      s      z5GithubEnterpriseOrganizationOAuth2FailTest.test_loginc              	   C   sR   | j ddi | j ddi | j ddi | t |   W 5 Q R X d S rZ   r0   r1   ra   r   r9   r3   r5   r5   r6   r:      s      z@GithubEnterpriseOrganizationOAuth2FailTest.test_partial_pipeliner[   r5   r5   rX   r6   r]      s   		r]   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )GithubEnterpriseTeamOAuth2Test<social.backends.github_enterprise.GithubEnterpriseTeamOAuth2c                    s(   d}t jt j|ddd tt| |S )N7https://www.example.com/api/v3/teams/123/members/foobarrS   rC   rT   )r   rL   rM   rU   rc   rV   rW   rX   r5   r6   rV      s
    
z,GithubEnterpriseTeamOAuth2Test.auth_handlersc                 C   s<   | j ddi | j ddi | j ddi |   d S NZ&SOCIAL_AUTH_GITHUB_ENTERPRISE_TEAM_URLr,   Z*SOCIAL_AUTH_GITHUB_ENTERPRISE_TEAM_API_URLr.   Z%SOCIAL_AUTH_GITHUB_ENTERPRISE_TEAM_IDZ123r/   r3   r5   r5   r6   r7      s      z)GithubEnterpriseTeamOAuth2Test.test_loginc                 C   s<   | j ddi | j ddi | j ddi |   d S rf   r8   r3   r5   r5   r6   r:      s      z4GithubEnterpriseTeamOAuth2Test.test_partial_pipeliner[   r5   r5   rX   r6   rc      s   rc   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )"GithubEnterpriseTeamOAuth2FailTestrd   c                    s*   d}t jt j|dddd tt| |S )Nre   r^   r_   rF   rG   )r   rL   rM   rU   rg   rV   rW   rX   r5   r6   rV      s    
z0GithubEnterpriseTeamOAuth2FailTest.auth_handlersc              	   C   sR   | j ddi | j ddi | j ddi | t |   W 5 Q R X d S rf   r`   r3   r5   r5   r6   r7      s      z-GithubEnterpriseTeamOAuth2FailTest.test_loginc              	   C   sR   | j ddi | j ddi | j ddi | t |   W 5 Q R X d S rf   rb   r3   r5   r5   r6   r:      s      z8GithubEnterpriseTeamOAuth2FailTest.test_partial_pipeliner[   r5   r5   rX   r6   rg      s   		rg   )r?   Z	httprettyr   Zsocial.exceptionsr   Zsocial.tests.backends.oauthr   r   rB   rP   r]   rc   rg   r5   r5   r5   r6   <module>   s   8@