U
    [e(                     @   s   d dl Z 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mZ d dlmZmZ G dd	 d	eZG d
d deZG dd deZe j  dZG dd deZG dd deZG dd deeZdS )    N)	HTTPretty)	urlencode)do_disconnect)User)
OAuth1Test
OAuth2Test)
OpenIdTestOpenIdConnectTestMixinc                   @   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gdddddiddddddddd dd!d"gdd#d$gd%d&d'd&d(gd)d*Z	d+d, Z
d-d. Zd/d0 Zd1S )2GoogleOAuth2Testz#social.backends.google.GoogleOAuth2z,https://www.googleapis.com/plus/v1/people/meZfoofoobarbearerZaccess_token
token_typezAbout me textr   )ZleftImageOffsetZtopImageOffsetiu  \https://lh5.googleusercontent.com/-ui-GqpNh5Ms/AAAAAAAAAAI/AAAAAAAAAZw/a7puhHMO_fg/photo.jpgi  )heighturlwidthZbanner)Z	coverInfoZ
coverPhotoZlayoutFoo Baraccountfoo@bar.com)typevaluez"e-tag string"male101010101010101010101r   Tzplus#personenBarFoo)Z
familyNameZ	givenNameZpersonzSoftware developerzOrg nameschool)nameprimaryr   ZAnyplace)r   r   -https://plus.google.com/101010101010101010101zhttp://foobar.comZotherProfile)labelr   r   F)ZaboutMeZcoverZdisplayNameZemailsetaggenderidimageZ
isPlusUserkindlanguager   Z
objectTypeZ
occupationZorganizationsZplacesLivedr   urlsZverifiedc                 C   s   |    d S Ndo_loginself r.   c/var/www/html/services/stratfitenv/lib/python3.8/site-packages/social/tests/backends/test_google.py
test_loginL   s    zGoogleOAuth2Test.test_loginc                 C   s   |    d S r)   do_partial_pipeliner,   r.   r.   r/   test_partial_pipelineO   s    z&GoogleOAuth2Test.test_partial_pipelinec                 C   s   | j ddi |   d S )N,SOCIAL_AUTH_GOOGLE_OAUTH2_USE_UNIQUE_USER_IDTstrategyset_settingsr+   r,   r.   r.   r/   test_with_unique_user_idR   s
     z)GoogleOAuth2Test.test_with_unique_user_idN)__name__
__module____qualname__backend_pathuser_data_urlexpected_usernamejsondumpsaccess_token_bodyuser_data_bodyr0   r3   r8   r.   r.   r.   r/   r
      sj    6r
   c                   @   sJ   e Zd ZdZedddddddd	d
dddZdd Zdd Zdd Z	dS )GoogleOAuth2DeprecatedAPITestz-https://www.googleapis.com/oauth2/v1/userinfor   r   r   r   r   r   z
0000-01-22r    r   r   T)Zfamily_namer   Zpicturelocaler#   emailbirthdaylinkZ
given_namer$   Zverified_emailc                 C   s   | j ddi |   d S N,SOCIAL_AUTH_GOOGLE_OAUTH2_USE_DEPRECATED_APITr5   r,   r.   r.   r/   r0   j   s
     z(GoogleOAuth2DeprecatedAPITest.test_loginc                 C   s   | j ddi |   d S rH   )r6   r7   r2   r,   r.   r.   r/   r3   p   s
     z3GoogleOAuth2DeprecatedAPITest.test_partial_pipelinec                 C   s   | j ddd |   d S )NT)r4   rI   r5   r,   r.   r.   r/   r8   v   s
    z6GoogleOAuth2DeprecatedAPITest.test_with_unique_user_idN)
r9   r:   r;   r=   r?   r@   rB   r0   r3   r8   r.   r.   r.   r/   rC   Y   s"   rC   c                   @   sh   e Zd ZdZdZdZedddZe	ddddZ
e	d	dd
dZdd Zdd Zdd Zdd ZdS )GoogleOAuth1Testz"social.backends.google.GoogleOAuthz)https://www.googleapis.com/userinfo/emailr   r   r   zfoobar-secrettrue)Zoauth_token_secretZoauth_tokenZoauth_callback_confirmedzfoobar@gmail.comr   )rE   Z
isVerifiedr$   c                 C   s   |    d S r)   r*   r,   r.   r.   r/   r0      s    zGoogleOAuth1Test.test_loginc                 C   s   |    d S r)   r1   r,   r.   r.   r/   r3      s    z&GoogleOAuth1Test.test_partial_pipelinec                 C   s   | j ddi |   d S )NZ+SOCIAL_AUTH_GOOGLE_OAUTH_USE_UNIQUE_USER_IDTr5   r,   r.   r.   r/   r8      s
     z)GoogleOAuth1Test.test_with_unique_user_idc                 C   s   | j d d d |   d S )N)ZSOCIAL_AUTH_GOOGLE_OAUTH_KEYZSOCIAL_AUTH_GOOGLE_OAUTH_SECRETr5   r,   r.   r.   r/   "test_with_anonymous_key_and_secret   s
    z3GoogleOAuth1Test.test_with_anonymous_key_and_secretN)r9   r:   r;   r<   r=   r>   r?   r@   rA   r   Zrequest_token_bodyrB   r0   r3   r8   rL   r.   r.   r.   r/   rJ   ~   s*   rJ   z%Y-%m-%dT%H:%M:%SZc                1   @   s   e Zd ZdZdZ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d	d
ddddddddd	d
ddddddg/Zeeddddddddd d!ddd"d#d$d%ed& d'e d(d)d*Z	d+d, Z
d-d. Zd/S )0GoogleOpenIdTestz#social.backends.google.GoogleOpenIdZFooBar z&<?xml version="1.0" encoding="UTF-8"?>z@<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">z<XRD>z<Service priority="0">z4<Type>http://specs.openid.net/auth/2.0/signon</Type>z)<Type>http://openid.net/srv/ax/1.0</Type>zA<Type>http://specs.openid.net/extensions/ui/1.0/mode/popup</Type>z;<Type>http://specs.openid.net/extensions/ui/1.0/icon</Type>z8<Type>http://specs.openid.net/extensions/pape/1.0</Type>z0<URI>https://www.google.com/accounts/o8/ud</URI>z
</Service>z<Service priority="10">z<<URI>https://www.google.com/accounts/o8/ud?source=mail</URI>zA<URI>https://www.google.com/accounts/o8/ud?source=gmail.com</URI>z<URI>z;https://www.google.com/accounts/o8/ud?source=googlemail.comz</URI>z@<URI>https://www.google.com/accounts/o8/ud?source=profiles</URI>z</XRD>z</xrds:XRDS>zassoc-handlez7https://www.google.com/accounts/o8/id?id=some-google-idfetch_responsez!http://axschema.org/contact/emailz$http://axschema.org/namePerson/firstz#http://axschema.org/namePerson/lastz&http://schema.openid.net/contact/emailr   r   r   Zid_resz http://specs.openid.net/auth/2.0zhttp://openid.net/srv/ax/1.0z%https://www.google.com/accounts/o8/udZby95cT34vX7p9gz0http://myapp.com/complete/google/?janrain_nonce=zbrT2kmu3eCzb1gQ1pbaXdnWioVM=zop_endpoint,claimed_id,identity,return_to,response_nonce,assoc_handle,ns.ext1,ext1.mode,ext1.type.old_email,ext1.value.old_email,ext1.type.first_name,ext1.value.first_name,ext1.type.last_name,ext1.value.last_name,ext1.type.email,ext1.value.email)Zjanrain_noncezopenid.assoc_handlezopenid.claimed_idzopenid.ext1.modezopenid.ext1.type.emailzopenid.ext1.type.first_namezopenid.ext1.type.last_namezopenid.ext1.type.old_emailzopenid.ext1.value.emailzopenid.ext1.value.first_namezopenid.ext1.value.last_namezopenid.ext1.value.old_emailzopenid.identityzopenid.modez	openid.nszopenid.ns.ext1zopenid.op_endpointzopenid.response_noncezopenid.return_toz
openid.sigzopenid.signedc                 C   s   |    d S r)   r*   r,   r.   r.   r/   r0      s    zGoogleOpenIdTest.test_loginc                 C   s   |    d S r)   r1   r,   r.   r.   r/   r3      s    z&GoogleOpenIdTest.test_partial_pipelineN)r9   r:   r;   r<   r>   joinZdiscovery_bodyr   JANRAIN_NONCEZserver_responser0   r3   r.   r.   r.   r/   rM      s   1 rM   c                   @   s   e Zd Zdd ZdS )GoogleRevokeTokenTestc                 C   sX   | j ddi |   t| j}d|_tj| 	| j
j| j
jdd t| j
| d S )NZ5SOCIAL_AUTH_GOOGLE_OAUTH2_REVOKE_TOKENS_ON_DISCONNECTTpassword   )status)r6   r7   r+   r   getr>   rS   r   Zregister_uri_methodbackendZREVOKE_TOKEN_METHODZREVOKE_TOKEN_URLr   )r-   userr.   r.   r/   test_revoke_token  s     z'GoogleRevokeTokenTest.test_revoke_tokenN)r9   r:   r;   rZ   r.   r.   r.   r/   rR     s   rR   c                   @   s   e Zd ZdZdZdZdS )GoogleOpenIdConnectTestz*social.backends.google.GoogleOpenIdConnectz:https://www.googleapis.com/plus/v1/people/me/openIdConnectzaccounts.google.comN)r9   r:   r;   r<   r=   Zissuerr.   r.   r.   r/   r[     s   r[   )datetimer?   Z	httprettyr   Z	social.p3r   Zsocial.actionsr   Zsocial.tests.modelsr   Zsocial.tests.backends.oauthr   r   Zsocial.tests.backends.open_idr   r	   r
   rC   rJ   nowstrftimerQ   rM   rR   r[   r.   r.   r.   r/   <module>   s   K%'[