U
    ¶[ÖeG  ã                   @   sL   d dl mZmZ dZdZG dd„ deƒZG dd„ deƒZG dd	„ d	eƒZd
S )é    )ÚBaseStrategyÚBaseTemplateStrategyzhttp://myapp.comz	myapp.comc                   @   s   e Zd Zdd„ ZdS )ÚRedirectc                 C   s
   || _ d S ©N)Úurl©Úselfr   © r	   úW/var/www/html/services/stratfitenv/lib/python3.8/site-packages/social/tests/strategy.pyÚ__init__	   s    zRedirect.__init__N)Ú__name__Ú
__module__Ú__qualname__r   r	   r	   r	   r
   r      s   r   c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚTestTemplateStrategyc                 C   s   |S r   r	   )r   ÚtplÚcontextr	   r	   r
   Úrender_template   s    z$TestTemplateStrategy.render_templatec                 C   s   |S r   r	   )r   Úhtmlr   r	   r	   r
   Úrender_string   s    z"TestTemplateStrategy.render_stringN)r   r   r   r   r   r	   r	   r	   r
   r      s   r   c                       sÐ   e Zd ZeZd-‡ fdd„	Zdd„ Zdd„ Zdd	„ Zd.d
d„Z	d/dd„Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd0dd„Zdd„ Zdd „ Zd1d!d"„Zd#d$„ Zd%d&„ Zd'd(„ Z‡ fd)d*„Zd2d+d,„Z‡  ZS )3ÚTestStrategyNc                    s(   i | _ i | _i | _tt| ƒ ||¡ d S r   )Ú_request_dataÚ	_settingsÚ_sessionÚsuperr   r   )r   Ústorager   ©Ú	__class__r	   r
   r      s    zTestStrategy.__init__c                 C   s   t |ƒS r   )r   r   r	   r	   r
   Úredirect   s    zTestStrategy.redirectc                 C   s
   | j | S )z#Return value for given setting name)r   ©r   Únamer	   r	   r
   Úget_setting!   s    zTestStrategy.get_settingc                 C   s   |S )z'Return HTTP response with given contentr	   )r   Úcontentr	   r	   r
   r   %   s    zTestStrategy.htmlc                 C   s   |p|S )z4Render given template or raw html with given contextr	   )r   r   r   r   r	   r	   r
   Úrender_html)   s    zTestStrategy.render_htmlTc                 C   s   | j S )z)Return current request data (POST or GET))r   )r   Úmerger	   r	   r
   Úrequest_data-   s    zTestStrategy.request_datac                 C   s   t S )zReturn current host value)Ú	TEST_HOST©r   r	   r	   r
   Úrequest_host1   s    zTestStrategy.request_hostc                 C   s   dS )z Is the request using HTTPS? Fr	   r&   r	   r	   r
   Úrequest_is_secure5   s    zTestStrategy.request_is_securec                 C   s   dS )z path of the current request Ú r	   r&   r	   r	   r
   Úrequest_path9   s    zTestStrategy.request_pathc                 C   s   dS )z Port in use for this request éP   r	   r&   r	   r	   r
   Úrequest_port=   s    zTestStrategy.request_portc                 C   s
   | j  ¡ S )z Request GET data ©r   Úcopyr&   r	   r	   r
   Úrequest_getA   s    zTestStrategy.request_getc                 C   s
   | j  ¡ S )z Request POST data r-   r&   r	   r	   r
   Úrequest_postE   s    zTestStrategy.request_postc                 C   s   | j  ||¡S )z"Return session value for given key)r   Úget)r   r   Údefaultr	   r	   r
   Úsession_getI   s    zTestStrategy.session_getc                 C   s   || j |< dS )zSet session value for given keyN)r   )r   r   Úvaluer	   r	   r
   Úsession_setM   s    zTestStrategy.session_setc                 C   s   | j  |d¡S )zPop session value for given keyN)r   Úpopr   r	   r	   r
   Úsession_popQ   s    zTestStrategy.session_popc                 C   s(   |pd}|  d¡s|  d¡r |S t| S )z-Build absolute URI with given (optional) pathr)   zhttp://zhttps://)Ú
startswithÚTEST_URI)r   Úpathr	   r	   r
   Úbuild_absolute_uriU   s    zTestStrategy.build_absolute_uric                 C   s   | j  |¡ d S r   )r   Úupdate)r   Úvaluesr	   r	   r
   Úset_settings\   s    zTestStrategy.set_settingsc                 C   s   | j  |¡ | j |_d S r   )r   r<   Údata)r   r=   Úbackendr	   r	   r
   Úset_request_data_   s    zTestStrategy.set_request_datac                 C   s   | j  |d ¡ d S r   )r   r6   r   r	   r	   r
   Úremove_from_request_datac   s    z%TestStrategy.remove_from_request_datac                    s6   t t| ƒj||Ž}t|| jj ¡ ƒr2|  d|j¡ |S )NÚusername)	r   r   ÚauthenticateÚ
isinstancer   ÚuserZ
user_modelr5   rC   )r   ÚargsÚkwargsrF   r   r	   r
   rD   f   s    zTestStrategy.authenticatec                 C   s   |   dd¡S )NZPIPELINE)
z*social.pipeline.social_auth.social_detailsz&social.pipeline.social_auth.social_uidz(social.pipeline.social_auth.auth_allowedz'social.pipeline.social_auth.social_userz!social.pipeline.user.get_usernamez.social.pipeline.social_auth.associate_by_emailz social.pipeline.user.create_userz*social.pipeline.social_auth.associate_userz+social.pipeline.social_auth.load_extra_dataz!social.pipeline.user.user_details)Zsetting)r   r@   r	   r	   r
   Úget_pipelinel   s    zTestStrategy.get_pipeline)N)NNN)T)N)N)N)r   r   r   r   ZDEFAULT_TEMPLATE_STRATEGYr   r   r    r   r"   r$   r'   r(   r*   r,   r/   r0   r3   r5   r7   r;   r>   rA   rB   rD   rI   Ú__classcell__r	   r	   r   r
   r      s,   



r   N)	Zsocial.strategies.baser   r   r9   r%   Úobjectr   r   r   r	   r	   r	   r
   Ú<module>   s
   