ó
¨œž[c           @` sç  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l m Z m Z m	 Z	 m
 Z
 m Z m Z m 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 d  d
 l m Z d  d l m Z m  Z  m! Z! m" Z" y d  d l m# Z# Wn e$ k
 r3e% Z# n Xd e e f d „  ƒ  YZ& d e e f d „  ƒ  YZ' d e f d „  ƒ  YZ( d e e	 f d „  ƒ  YZ) d e e	 f d „  ƒ  YZ* d e* f d „  ƒ  YZ+ d e e	 f d „  ƒ  YZ, d e f d „  ƒ  YZ- d e f d „  ƒ  YZ. d e e
 f d  „  ƒ  YZ/ d! e e f d" „  ƒ  YZ0 d# e f d$ „  ƒ  YZ1 d% e f d& „  ƒ  YZ2 d' e e f d( „  ƒ  YZ3 d) e3 f d* „  ƒ  YZ4 d+ e3 f d, „  ƒ  YZ5 d- e3 f d. „  ƒ  YZ6 d/ e3 f d0 „  ƒ  YZ7 d1 e3 f d2 „  ƒ  YZ8 d3 e3 f d4 „  ƒ  YZ9 d5 e3 f d6 „  ƒ  YZ: d7 e f d8 „  ƒ  YZ; d9 e f d: „  ƒ  YZ< d; e f d< „  ƒ  YZ= d= e f d> „  ƒ  YZ> d? e e f d@ „  ƒ  YZ? dA e f dB „  ƒ  YZ@ dC e f dD „  ƒ  YZA dE e f dF „  ƒ  YZB dG e f dH „  ƒ  YZC d S(I   i    (   t   absolute_importt   divisiont   print_functionN(   t	   AuthErrort   OpenIdMixint
   OAuthMixint   OAuth2Mixint   GoogleOAuth2Mixint   FacebookGraphMixint   TwitterMixin(   t   Future(   t   json_decode(   t   gen(   t
   url_concat(   t   gen_logt   app_log(   t   AsyncHTTPTestCaset	   ExpectLog(   t   ignore_deprecation(   t   RequestHandlert   Applicationt   asynchronoust	   HTTPError(   t   mockt   OpenIdClientLoginHandlerLegacyc           B` s9   e  Z d  „  Z e ƒ   e d „  ƒ Z Wd QXd „  Z RS(   c         C` s   | j  d ƒ |  _ d  S(   Ns   /openid/server/authenticate(   t   get_urlt   _OPENID_ENDPOINT(   t   selft   test(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt
   initialize    s    c      	   C` s   |  j  d d  ƒ rY t j ƒ  6 t j d t ƒ |  j |  j d |  j d ƒd  SWd  QXn  |  j	 ƒ  } t
 | t ƒ sz t ‚ | j ƒ  sŒ t ‚ d  S(   Ns   openid.modet   ignoret   http_client(   t   get_argumentt   Nonet   warningst   catch_warningst   simplefiltert   DeprecationWarningt   get_authenticated_usert   on_usert   settingst   authenticate_redirectt
   isinstanceR
   t   AssertionErrort   done(   R   t   res(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   get$   s    Nc         C` s,   | d  k r t d ƒ ‚ n  |  j | ƒ d  S(   Ns   user is None(   R!   t	   Exceptiont   finish(   R   t   user(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR'   0   s    (   t   __name__t
   __module__R   R   R   R.   R'   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR      s   	
t   OpenIdClientLoginHandlerc           B` s#   e  Z d  „  Z e j d „  ƒ Z RS(   c         C` s   | j  d ƒ |  _ d  S(   Ns   /openid/server/authenticate(   R   R   (   R   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   7   s    c         c` s   |  j  d d  ƒ rX |  j d |  j d ƒ V} | d  k rG t d ƒ ‚ n  |  j | ƒ d  S|  j ƒ  } t | t ƒ sy t	 ‚ | j
 ƒ  s‹ t	 ‚ d  S(   Ns   openid.modeR   s   user is None(   R    R!   R&   R(   R/   R0   R)   R*   R
   R+   R,   (   R   R1   R-   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   :   s    (   R2   R3   R   R   t	   coroutineR.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR4   6   s   	t   OpenIdServerAuthenticateHandlerc           B` s   e  Z d  „  Z RS(   c         C` s5   |  j  d ƒ d k r$ t d ƒ ‚ n  |  j d ƒ d  S(   Ns   openid.modet   check_authentications   incorrect openid.mode %rs   is_valid:true(   R    R/   t   write(   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   postH   s    (   R2   R3   R9   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR6   G   s   t   OAuth1ClientLoginHandlerLegacyc           B` sK   e  Z d  „  Z d „  Z e ƒ   e d „  ƒ Z Wd QXd „  Z d „  Z RS(   c         C` sC   | |  _  | j d ƒ |  _ | j d ƒ |  _ | j d ƒ |  _ d  S(   Ns   /oauth1/server/request_tokens   /oauth1/server/authorizes   /oauth1/server/access_token(   t   _OAUTH_VERSIONR   t   _OAUTH_REQUEST_TOKEN_URLt   _OAUTH_AUTHORIZE_URLt   _OAUTH_ACCESS_TOKEN_URL(   R   R   t   version(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   O   s    	c         C` s   t  d d d d ƒ S(   Nt   keyt   asdft   secrett   qwer(   t   dict(   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   _oauth_consumer_tokenU   s    c      	   C` sˆ   |  j  d d  ƒ rV t j ƒ  2 t j d t ƒ |  j |  j d |  j d ƒWd  QXd  S|  j	 d |  j d ƒ } t
 | t ƒ s„ t ‚ d  S(   Nt   oauth_tokenR   R   (   R    R!   R"   R#   R$   R%   R&   R'   R(   t   authorize_redirectR*   R
   R+   (   R   R-   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   Y   s    Nc         C` s,   | d  k r t d ƒ ‚ n  |  j | ƒ d  S(   Ns   user is None(   R!   R/   R0   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR'   d   s    c         C` sf   |  j  d d  ƒ r! t d ƒ ‚ n  | t d d d d ƒ k rO t d | ƒ ‚ n  | t d d	 ƒ ƒ d  S(
   Nt   fail_in_get_users   failing in get_userR@   t   uiopRB   t   5678s   incorrect access token %rt   emails   foo@example.com(   R    R!   R/   RD   (   R   t   access_tokent   callback(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   _oauth_get_useri   s
    (	   R2   R3   R   RE   R   R   R.   R'   RN   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR:   N   s   		
	t   OAuth1ClientLoginHandlerc           B` s>   e  Z d  „  Z d „  Z e j d „  ƒ Z e j d „  ƒ Z RS(   c         C` sC   | |  _  | j d ƒ |  _ | j d ƒ |  _ | j d ƒ |  _ d  S(   Ns   /oauth1/server/request_tokens   /oauth1/server/authorizes   /oauth1/server/access_token(   R;   R   R<   R=   R>   (   R   R   R?   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   r   s    	c         C` s   t  d d d d ƒ S(   NR@   RA   RB   RC   (   RD   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRE   x   s    c         c` st   |  j  d d  ƒ rX |  j d |  j d ƒ V} | d  k rG t d ƒ ‚ n  |  j | ƒ d  S|  j d |  j d ƒ Vd  S(   NRF   R   s   user is None(   R    R!   R&   R(   R/   R0   RG   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   {   s    c         C` s\   |  j  d d  ƒ r! t d ƒ ‚ n  | t d d d d ƒ k rO t d | ƒ ‚ n  t d d	 ƒ S(
   NRH   s   failing in get_userR@   RI   RB   RJ   s   incorrect access token %rRK   s   foo@example.com(   R    R!   R/   RD   (   R   RL   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   _oauth_get_user_future…   s
    (   R2   R3   R   RE   R   R5   R.   RP   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRO   q   s   		
t!   OAuth1ClientLoginCoroutineHandlerc           B` s    e  Z d  Z e j d „  ƒ Z RS(   sD   Replaces OAuth1ClientLoginCoroutineHandler's get() with a coroutine.c         c` sg   |  j  d d  ƒ rX y |  j ƒ  VWqc t k
 rT } |  j d ƒ |  j d | ƒ qc Xn |  j ƒ  Vd  S(   NRF   i÷  s   got exception: %s(   R    R!   R&   R/   t
   set_statusR8   RG   (   R   t   e(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.      s    (   R2   R3   t   __doc__R   R5   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRQ   Ž   s   t$   OAuth1ClientRequestParametersHandlerc           B` s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C` s   | |  _  d  S(   N(   R;   (   R   R?   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   Ÿ   s    c         C` s   t  d d d d ƒ S(   NR@   RA   RB   RC   (   RD   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRE   ¢   s    c         C` sA   |  j  d t d d d d ƒ d t d d ƒ ƒ} |  j | ƒ d  S(	   Ns   http://www.example.com/api/asdfR@   RI   RB   RJ   t
   parameterst   foot   bar(   t   _oauth_request_parametersRD   R8   (   R   t   params(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   ¥   s
    (   R2   R3   R   RE   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRU   ž   s   		t   OAuth1ServerRequestTokenHandlerc           B` s   e  Z d  „  Z RS(   c         C` s   |  j  d ƒ d  S(   Ns(   oauth_token=zxcv&oauth_token_secret=1234(   R8   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   ®   s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR[   ­   s   t   OAuth1ServerAccessTokenHandlerc           B` s   e  Z d  „  Z RS(   c         C` s   |  j  d ƒ d  S(   Ns(   oauth_token=uiop&oauth_token_secret=5678(   R8   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   ³   s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR\   ²   s   t   OAuth2ClientLoginHandlerc           B` s   e  Z d  „  Z d „  Z RS(   c         C` s   | j  d ƒ |  _ d  S(   Ns   /oauth2/server/authorize(   R   R=   (   R   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   ¸   s    c         C` s7   |  j  ƒ  } t | t ƒ s! t ‚ | j ƒ  s3 t ‚ d  S(   N(   RG   R*   R
   R+   R,   (   R   R-   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   »   s    (   R2   R3   R   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR]   ·   s   	t   FacebookClientLoginHandlerc           B` s#   e  Z d  „  Z e j d „  ƒ Z RS(   c         C` s:   | j  d ƒ |  _ | j  d ƒ |  _ | j  d ƒ |  _ d  S(   Ns   /facebook/server/authorizes   /facebook/server/access_tokens   /facebook/server(   R   R=   R>   t   _FACEBOOK_BASE_URL(   R   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   Â   s    c      
   c` sŸ   |  j  d d  ƒ rg |  j d |  j j ƒ  d |  j d d |  j d d |  j  d ƒ ƒ V} |  j | ƒ n4 |  j d |  j j ƒ  d |  j d d i d d	 6ƒ Vd  S(
   Nt   codet   redirect_urit	   client_idt   facebook_api_keyt   client_secrett   facebook_secrett   extra_paramss   read_stream,offline_accesst   scope(   R    R!   R&   t   requestt   full_urlR(   R8   RG   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   Ç   s    		(   R2   R3   R   R   R5   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR^   Á   s   	t    FacebookServerAccessTokenHandlerc           B` s   e  Z d  „  Z RS(   c         C` s    |  j  t d d d d ƒ ƒ d  S(   NRL   RA   t
   expires_ini  (   R8   RD   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   Ø   s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRj   ×   s   t   FacebookServerMeHandlerc           B` s   e  Z d  „  Z RS(   c         C` s   |  j  d ƒ d  S(   Ns   {}(   R8   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   Ý   s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRl   Ü   s   t   TwitterClientHandlerc           B` s   e  Z d  „  Z d „  Z RS(   c         C` s^   | j  d ƒ |  _ | j  d ƒ |  _ | j  d ƒ |  _ | j  d ƒ |  _ | j  d ƒ |  _ d  S(   Ns   /oauth1/server/request_tokens   /twitter/server/access_tokens   /oauth1/server/authorizes   /twitter/server/authenticates   /twitter/api(   R   R<   R>   R=   t   _OAUTH_AUTHENTICATE_URLt   _TWITTER_BASE_URL(   R   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   â   s
    c         C` s   |  j  d S(   NR   (   R(   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   get_auth_http_clienté   s    (   R2   R3   R   Rp   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRm   á   s   	t   TwitterClientLoginHandlerLegacyc           B` s0   e  Z e ƒ   e d  „  ƒ Z Wd QXd „  Z RS(   c         C` s4   |  j  d d  ƒ r& |  j |  j ƒ d  S|  j ƒ  d  S(   NRF   (   R    R!   R&   R'   RG   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   ï   s    Nc         C` s,   | d  k r t d ƒ ‚ n  |  j | ƒ d  S(   Ns   user is None(   R!   R/   R0   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR'   ö   s    (   R2   R3   R   R   R.   R'   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRq   í   s   
t   TwitterClientLoginHandlerc           B` s   e  Z e j d  „  ƒ Z RS(   c         c` sZ   |  j  d d  ƒ rK |  j ƒ  V} | d  k r: t d ƒ ‚ n  |  j | ƒ d  S|  j ƒ  Vd  S(   NRF   s   user is None(   R    R!   R&   R/   R0   RG   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   ý   s    (   R2   R3   R   R5   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRr   ü   s   t    TwitterClientAuthenticateHandlerc           B` s   e  Z e j d  „  ƒ Z RS(   c         c` sZ   |  j  d d  ƒ rK |  j ƒ  V} | d  k r: t d ƒ ‚ n  |  j | ƒ d  S|  j ƒ  Vd  S(   NRF   s   user is None(   R    R!   R&   R/   R0   R)   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.     s    (   R2   R3   R   R5   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRs     s   t"   TwitterClientLoginGenEngineHandlerc           B` s0   e  Z e ƒ   e e j d  „  ƒ ƒ Z Wd QXRS(   c         c` s=   |  j  d d  ƒ r/ |  j ƒ  V} |  j | ƒ n
 |  j ƒ  d  S(   NRF   (   R    R!   R&   R0   RG   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.     s    N(   R2   R3   R   R   R   t   engineR.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRt     s   
t%   TwitterClientLoginGenCoroutineHandlerc           B` s   e  Z e j d  „  ƒ Z RS(   c         c` s>   |  j  d d  ƒ r/ |  j ƒ  V} |  j | ƒ n |  j ƒ  Vd  S(   NRF   (   R    R!   R&   R0   RG   (   R   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   %  s    (   R2   R3   R   R5   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRv   $  s   t"   TwitterClientShowUserHandlerLegacyc           B` s0   e  Z e ƒ   e e j d  „  ƒ ƒ Z Wd QXRS(   c         c` s•   t  j ƒ  M t  j d t ƒ t j |  j d |  j d ƒ d t d d d d ƒ ƒV} Wd  QX| d  k r„ |  j
 d	 ƒ |  j d
 ƒ n |  j | ƒ d  S(   NR   s   /users/show/%st   nameRL   R@   t   hjklRB   t   vbnmiô  s   error from twitter request(   R"   R#   R$   R%   R   t   Taskt   twitter_requestR    RD   R!   RR   R0   (   R   t   response(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   2  s    N(   R2   R3   R   R   R   Ru   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRw   0  s   
t   TwitterClientShowUserHandlerc           B` s   e  Z e j d  „  ƒ Z RS(   c         c` su   y6 |  j  d |  j d ƒ d t d d d d ƒ ƒV} Wn+ t k
 rc |  j d ƒ |  j d	 ƒ n X|  j | ƒ d  S(
   Ns   /users/show/%sRx   RL   R@   Ry   RB   Rz   iô  s   error from twitter request(   R|   R    RD   R   RR   R0   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   D  s    (   R2   R3   R   R5   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR~   C  s   t   TwitterServerAccessTokenHandlerc           B` s   e  Z d  „  Z RS(   c         C` s   |  j  d ƒ d  S(   Ns8   oauth_token=hjkl&oauth_token_secret=vbnm&screen_name=foo(   R8   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   T  s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR   S  s   t   TwitterServerShowUserHandlerc           B` s   e  Z d  „  Z RS(   c         C` sõ   | d k r t  d ƒ ‚ n  d |  j j k s3 t ‚ d |  j j k sK t ‚ d |  j j k sc t ‚ |  j d ƒ d k s~ t ‚ |  j d ƒ d	 k s™ t ‚ |  j d
 ƒ d k s´ t ‚ |  j d ƒ d k sÏ t ‚ |  j t d | d | j ƒ  ƒ ƒ d  S(   Nt   erroriô  t   oauth_noncet   oauth_timestampt   oauth_signaturet   oauth_consumer_keyt   test_twitter_consumer_keyt   oauth_signature_methods	   HMAC-SHA1t   oauth_versions   1.0RF   Ry   t   screen_nameRx   (   R   Rh   t	   argumentsR+   R    R8   RD   t
   capitalize(   R   R‰   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   Y  s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR€   X  s   t%   TwitterServerVerifyCredentialsHandlerc           B` s   e  Z d  „  Z RS(   c         C` sÔ   d |  j  j k s t ‚ d |  j  j k s0 t ‚ d |  j  j k sH t ‚ |  j d ƒ d k sc t ‚ |  j d ƒ d k s~ t ‚ |  j d ƒ d	 k s™ t ‚ |  j d
 ƒ d k s´ t ‚ |  j t d d d d ƒ ƒ d  S(   NR‚   Rƒ   R„   R…   R†   R‡   s	   HMAC-SHA1Rˆ   s   1.0RF   Ry   R‰   RW   Rx   t   Foo(   Rh   RŠ   R+   R    R8   RD   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   g  s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRŒ   f  s   t   AuthTestc           B` s.  e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z e j e d k d ƒ d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# RS(    c         C` s  t  d t t d |  ƒ f d t t d |  ƒ f d t t d |  d d ƒ f d t t d |  d d ƒ f d t t d d ƒ f d	 t t d |  d d
 ƒ f d t t d |  d d
 ƒ f d t t d |  d d
 ƒ f d t t d d
 ƒ f d t t d |  ƒ f d t	 t d |  ƒ f d t
 t d |  ƒ f d t t d |  ƒ f d t t d |  ƒ f d t t d |  ƒ f d t t d |  ƒ f d t t d |  ƒ f d t t d |  ƒ f d t f d t f d t f d t f d t f d t f d t f d t f g d |  j d  d! d" d# d$ d% d& d' ƒS((   Ns   /legacy/openid/client/loginR   s   /openid/client/logins   /legacy/oauth10/client/loginR?   s   1.0s   /oauth10/client/logins   /oauth10/client/request_paramss   /legacy/oauth10a/client/logins   1.0as   /oauth10a/client/logins    /oauth10a/client/login_coroutines   /oauth10a/client/request_paramss   /oauth2/client/logins   /facebook/client/logins   /legacy/twitter/client/logins   /twitter/client/logins   /twitter/client/authenticates    /twitter/client/login_gen_engines#   /twitter/client/login_gen_coroutines    /legacy/twitter/client/show_users   /twitter/client/show_users   /openid/server/authenticates   /oauth1/server/request_tokens   /oauth1/server/access_tokens   /facebook/server/access_tokens   /facebook/server/mes   /twitter/server/access_tokens"   /twitter/api/users/show/(.*)\.jsons-   /twitter/api/account/verify_credentials\.jsonR   t   twitter_consumer_keyR†   t   twitter_consumer_secrett   test_twitter_consumer_secretRc   t   test_facebook_api_keyRe   t   test_facebook_secret(   R   R   RD   R4   R:   RO   RU   RQ   R]   R^   Rq   Rr   Rs   Rt   Rv   Rw   R~   R6   R[   R\   Rj   Rl   R   R€   RŒ   R   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   get_apps  s^    								c         C` sF   |  j  d d t ƒ} |  j | j d ƒ |  j d | j d k ƒ d  S(   Ns   /legacy/openid/client/logint   follow_redirectsi.  s   /openid/server/authenticate?t   Location(   t   fetcht   Falset   assertEqualR`   t
   assertTruet   headers(   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_openid_redirect_legacy¬  s    c         C` s@   |  j  d ƒ } | j ƒ  t | j ƒ } |  j | d d ƒ d  S(   Ns³   /legacy/openid/client/login?openid.mode=blah&openid.ns.ax=http://openid.net/srv/ax/1.0&openid.ax.type.email=http://axschema.org/contact/email&openid.ax.value.email=foo@example.comRK   s   foo@example.com(   R—   t   rethrowR   t   bodyR™   (   R   R}   t   parsed(    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_openid_get_user_legacy²  s    
c         C` sF   |  j  d d t ƒ} |  j | j d ƒ |  j d | j d k ƒ d  S(   Ns   /openid/client/loginR•   i.  s   /openid/server/authenticate?R–   (   R—   R˜   R™   R`   Rš   R›   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_openid_redirect»  s    c         C` s@   |  j  d ƒ } | j ƒ  t | j ƒ } |  j | d d ƒ d  S(   Ns¬   /openid/client/login?openid.mode=blah&openid.ns.ax=http://openid.net/srv/ax/1.0&openid.ax.type.email=http://axschema.org/contact/email&openid.ax.value.email=foo@example.comRK   s   foo@example.com(   R—   R   R   Rž   R™   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_openid_get_userÁ  s    
c         C` sm   |  j  d d t ƒ} |  j | j d ƒ |  j | j d j d ƒ ƒ |  j d | j d k | j d ƒ d  S(   Ns   /legacy/oauth10/client/loginR•   i.  R–   s)   /oauth1/server/authorize?oauth_token=zxcvs(   _oauth_request_token="enhjdg==|MTIzNA=="s
   Set-Cookie(   R—   R˜   R™   R`   Rš   R›   t   endswith(   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10_redirect_legacyÊ  s    
c         C` sm   |  j  d d t ƒ} |  j | j d ƒ |  j | j d j d ƒ ƒ |  j d | j d k | j d ƒ d  S(   Ns   /oauth10/client/loginR•   i.  R–   s)   /oauth1/server/authorize?oauth_token=zxcvs(   _oauth_request_token="enhjdg==|MTIzNA=="s
   Set-Cookie(   R—   R˜   R™   R`   Rš   R›   R£   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10_redirectÔ  s    
c      
   C` s€   t  ƒ  ! |  j d d i d d 6ƒ} Wd  QX| j ƒ  t | j ƒ } |  j | d d ƒ |  j | d t d d	 d
 d ƒ ƒ d  S(   Ns-   /legacy/oauth10/client/login?oauth_token=zxcvR›   s&   _oauth_request_token=enhjdg==|MTIzNA==t   CookieRK   s   foo@example.comRL   R@   RI   RB   RJ   (   R   R—   R   R   Rž   R™   RD   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10_get_user_legacyÞ  s    

c         C` sp   |  j  d d i d d 6ƒ} | j ƒ  t | j ƒ } |  j | d d ƒ |  j | d t d d	 d
 d ƒ ƒ d  S(   Ns&   /oauth10/client/login?oauth_token=zxcvR›   s&   _oauth_request_token=enhjdg==|MTIzNA==R¦   RK   s   foo@example.comRL   R@   RI   RB   RJ   (   R—   R   R   Rž   R™   RD   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10_get_userè  s    
c         C` sz   |  j  d ƒ } | j ƒ  t | j ƒ } |  j | d d ƒ |  j | d d ƒ |  j d | k ƒ |  j d | k ƒ d  S(   Ns   /oauth10/client/request_paramsR…   RA   RF   RI   R‚   R„   (   R—   R   R   Rž   R™   Rš   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10_request_parametersñ  s    
c         C` sm   |  j  d d t ƒ} |  j | j d ƒ |  j | j d j d ƒ ƒ |  j d | j d k | j d ƒ d  S(   Ns   /legacy/oauth10a/client/loginR•   i.  R–   s)   /oauth1/server/authorize?oauth_token=zxcvs(   _oauth_request_token="enhjdg==|MTIzNA=="s
   Set-Cookie(   R—   R˜   R™   R`   Rš   R›   R£   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10a_redirect_legacyú  s    
c      
   C` s€   t  ƒ  ! |  j d d i d d 6ƒ} Wd  QX| j ƒ  t | j ƒ } |  j | d d ƒ |  j | d t d d	 d
 d ƒ ƒ d  S(   Ns.   /legacy/oauth10a/client/login?oauth_token=zxcvR›   s&   _oauth_request_token=enhjdg==|MTIzNA==R¦   RK   s   foo@example.comRL   R@   RI   RB   RJ   (   R   R—   R   R   Rž   R™   RD   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10a_get_user_legacy  s    

c         C` sm   |  j  d d t ƒ} |  j | j d ƒ |  j | j d j d ƒ ƒ |  j d | j d k | j d ƒ d  S(   Ns   /oauth10a/client/loginR•   i.  R–   s)   /oauth1/server/authorize?oauth_token=zxcvs(   _oauth_request_token="enhjdg==|MTIzNA=="s
   Set-Cookie(   R—   R˜   R™   R`   Rš   R›   R£   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10a_redirect  s    
s   mock package not presentc         C` so   t  j j t d ƒ T } t d ƒ | _ t t d ƒ  |  j d d t	 ƒ} Wd  QX|  j
 | j d ƒ Wd  QXd  S(   NR.   t   booms   Uncaught exceptions   /oauth10a/client/loginR•   iô  (   R   t   patcht   objectR[   R/   t   side_effectR   R   R—   R˜   R™   R`   (   R   R.   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10a_redirect_error  s
    c         C` sp   |  j  d d i d d 6ƒ} | j ƒ  t | j ƒ } |  j | d d ƒ |  j | d t d d	 d
 d ƒ ƒ d  S(   Ns'   /oauth10a/client/login?oauth_token=zxcvR›   s&   _oauth_request_token=enhjdg==|MTIzNA==R¦   RK   s   foo@example.comRL   R@   RI   RB   RJ   (   R—   R   R   Rž   R™   RD   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth10a_get_user   s    
c         C` sz   |  j  d ƒ } | j ƒ  t | j ƒ } |  j | d d ƒ |  j | d d ƒ |  j d | k ƒ |  j d | k ƒ d  S(   Ns   /oauth10a/client/request_paramsR…   RA   RF   RI   R‚   R„   (   R—   R   R   Rž   R™   Rš   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt    test_oauth10a_request_parameters)  s    
c         C` s3   |  j  d d i d d 6ƒ} |  j | j d ƒ d  S(   NsG   /oauth10a/client/login_coroutine?oauth_token=zxcv&fail_in_get_user=trueR›   s&   _oauth_request_token=enhjdg==|MTIzNA==R¦   i÷  (   R—   R™   R`   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt*   test_oauth10a_get_user_coroutine_exception2  s    c         C` sF   |  j  d d t ƒ} |  j | j d ƒ |  j d | j d k ƒ d  S(   Ns   /oauth2/client/loginR•   i.  s   /oauth2/server/authorize?R–   (   R—   R˜   R™   R`   Rš   R›   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_oauth2_redirect8  s    c         C` s¥   |  j  d d t ƒ} |  j | j d ƒ |  j d | j d k ƒ |  j  d d t ƒ} |  j | j d ƒ t | j ƒ } |  j | d d	 ƒ |  j | d
 d ƒ d  S(   Ns   /facebook/client/loginR•   i.  s   /facebook/server/authorize?R–   s    /facebook/client/login?code=1234iÈ   RL   RA   t   session_expirest   3600(   R—   R˜   R™   R`   Rš   R›   R   Rž   (   R   R}   R1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_facebook_login=  s    c         C` sm   |  j  | d t ƒ} |  j | j d ƒ |  j | j d j d ƒ ƒ |  j d | j d k | j d ƒ d  S(   NR•   i.  R–   s)   /oauth1/server/authorize?oauth_token=zxcvs(   _oauth_request_token="enhjdg==|MTIzNA=="s
   Set-Cookie(   R—   R˜   R™   R`   Rš   R›   R£   (   R   t   urlR}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   base_twitter_redirectG  s    
c         C` s   |  j  d ƒ d  S(   Ns   /legacy/twitter/client/login(   Rº   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_twitter_redirect_legacyR  s    c         C` s   |  j  d ƒ d  S(   Ns   /twitter/client/login(   Rº   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_twitter_redirectU  s    c         C` s   |  j  d ƒ d  S(   Ns    /twitter/client/login_gen_engine(   Rº   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt    test_twitter_redirect_gen_engineX  s    c         C` s   |  j  d ƒ d  S(   Ns#   /twitter/client/login_gen_coroutine(   Rº   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt#   test_twitter_redirect_gen_coroutine[  s    c         C` sw   |  j  d d t ƒ} |  j | j d ƒ |  j | j d j d ƒ | j d ƒ |  j d | j d k | j d ƒ d  S(   Ns   /twitter/client/authenticateR•   i.  R–   s-   /twitter/server/authenticate?oauth_token=zxcvs(   _oauth_request_token="enhjdg==|MTIzNA=="s
   Set-Cookie(   R—   R˜   R™   R`   Rš   R›   R£   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt"   test_twitter_authenticate_redirect^  s    c         C` sz   |  j  d d i d d 6ƒ} | j ƒ  t | j ƒ } |  j | i i d d 6d d 6d	 d
 6d 6d d 6d d 6d d 6ƒ d  S(   Ns&   /twitter/client/login?oauth_token=zxcvR›   s&   _oauth_request_token=enhjdg==|MTIzNA==R¦   u   hjklu   keyu   foou   screen_nameu   vbnmu   secretu   access_tokenu   Foou   nameu   username(   R—   R   R   Rž   R™   (   R   R}   RŸ   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_twitter_get_userh  s    
	c         C` sD   |  j  d ƒ } | j ƒ  |  j t | j ƒ i d d 6d d 6ƒ d  S(   Ns.   /legacy/twitter/client/show_user?name=somebodyt   SomebodyRx   t   somebodyR‰   (   R—   R   R™   R   Rž   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_twitter_show_user_legacyv  s    
c         C` sO   t  t d ƒ  |  j d ƒ } Wd  QX|  j | j d ƒ |  j | j d ƒ d  S(   Ns   Error response HTTP 500s+   /legacy/twitter/client/show_user?name=erroriô  s   error from twitter request(   R   R   R—   R™   R`   Rž   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt#   test_twitter_show_user_error_legacy|  s    c         C` sD   |  j  d ƒ } | j ƒ  |  j t | j ƒ i d d 6d d 6ƒ d  S(   Ns'   /twitter/client/show_user?name=somebodyRÁ   Rx   RÂ   R‰   (   R—   R   R™   R   Rž   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_twitter_show_user‚  s    
c         C` s9   |  j  d ƒ } |  j | j d ƒ |  j | j d ƒ d  S(   Ns$   /twitter/client/show_user?name=erroriô  s   error from twitter request(   R—   R™   R`   Rž   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_twitter_show_user_errorˆ  s    N($   R2   R3   R”   Rœ   R    R¡   R¢   R¤   R¥   R§   R¨   R©   Rª   R«   R¬   t   unittestt   skipIfR   R!   R±   R²   R³   R´   Rµ   R¸   Rº   R»   R¼   R½   R¾   R¿   RÀ   RÃ   RÄ   RÅ   RÆ   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRŽ   r  s<   	9							
	
	
					
	
	
!							
						
				t   GoogleLoginHandlerc           B` s#   e  Z d  „  Z e j d „  ƒ Z RS(   c         C` sC   | |  _  | j d ƒ |  _ | j d ƒ |  _ | j d ƒ |  _ d  S(   Ns   /client/logins   /google/oauth2/authorizes   /google/oauth2/token(   R   R   t   _OAUTH_REDIRECT_URIR=   R>   (   R   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR     s    	c         c` sÑ   |  j  d d  ƒ } | d  k	 rx |  j |  j | ƒ V} |  j |  j j d ƒ d | d ƒV} | d | d <|  j | ƒ nU |  j d |  j d |  j	 d d d |  j	 d d	 d
 d d g d d d i d d 6ƒ Vd  S(   NR`   s   /google/oauth2/userinfoRL   Ra   Rb   t   google_oauthR@   Rd   RB   Rg   t   profileRK   t   response_typeRf   t   select_accountt   prompt(
   R    R!   R&   RÊ   t   oauth2_requestR   R   R8   RG   R(   (   R   R`   t   accessR1   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   •  s     
		(   R2   R3   R   R   R5   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRÉ   Ž  s   	t   GoogleOAuth2AuthorizeHandlerc           B` s   e  Z d  „  Z RS(   c         C` s2   d } |  j  t |  j d ƒ t d | ƒ ƒ ƒ d  S(   Ns   fake-authorization-codeRa   R`   (   t   redirectR   R    RD   (   R   R`   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   ­  s    (   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRÒ   ¬  s   t   GoogleOAuth2TokenHandlerc           B` s   e  Z d  „  Z RS(   c         C` s:   |  j  d ƒ d k s t ‚ |  j i d d 6d d 6ƒ d  S(   NR`   s   fake-authorization-codes   fake-access-tokenRL   s   never-expiresRk   (   R    R+   R0   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR9   µ  s    	(   R2   R3   R9   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRÔ   ´  s   t   GoogleOAuth2UserinfoHandlerc           B` s   e  Z d  „  Z RS(   c         C` s:   |  j  d ƒ d k s t ‚ |  j i d d 6d d 6ƒ d  S(   NRL   s   fake-access-tokenR   Rx   s   foo@example.comRK   (   R    R+   R0   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR.   ¿  s    	(   R2   R3   R.   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRÕ   ¾  s   t   GoogleOAuth2Testc           B` s   e  Z d  „  Z d „  Z RS(   c         C` sN   t  d t t d |  ƒ f d t f d t f d t f g d i d d 6d	 d
 6ƒS(   Ns   /client/loginR   s   /google/oauth2/authorizes   /google/oauth2/tokens   /google/oauth2/userinfoRË   t   fake_google_client_idR@   t   fake_google_client_secretRB   (   R   RÉ   RD   RÒ   RÔ   RÕ   (   R   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyR”   É  s    		c         C` sA   |  j  d ƒ } |  j i d d 6d d 6d d 6t | j ƒ ƒ d  S(   Ns   /client/loginu   Foou   nameu   foo@example.comu   emailu   fake-access-tokenu   access_token(   R—   t   assertDictEqualR   Rž   (   R   R}   (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   test_google_loginÙ  s    	(   R2   R3   R”   RÚ   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyRÖ   È  s   	(D   t
   __future__R    R   R   RÇ   R"   t   tornado.authR   R   R   R   R   R   R	   t   tornado.concurrentR
   t   tornado.escapeR   t   tornadoR   t   tornado.httputilR   t   tornado.logR   R   t   tornado.testingR   R   t   tornado.test.utilR   t   tornado.webR   R   R   R   R   t   ImportErrorR!   R   R4   R6   R:   RO   RQ   RU   R[   R\   R]   R^   Rj   Rl   Rm   Rq   Rr   Rs   Rt   Rv   Rw   R~   R   R€   RŒ   RŽ   RÉ   RÒ   RÔ   RÕ   RÖ   (    (    (    s5   lib/python2.7/site-packages/tornado/test/auth_test.pyt   <module>   s\   4"
#
ÿ 

