ó
ŠwÛjc           @   s|   d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d e j f d „  ƒ  YZ d „  Z	 e
 d k rx e	 ƒ  n  d S(   iÿÿÿÿ(   t   run_unittestt   run_doctestt   check_warningsNt   CookieTestsc           B   st   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 RS(   c      	   C   sm  i d d 6i d d 6d d 6d 6d d	 6d
 d 6i d d 6i d d 6d 6d d	 6d d 6i d d 6i d d 6d 6d d	 6d d 6i d d 6i d d 6d d 6d d 6d d 6d 6d d	 6d j  d% ƒ d 6g } x£ | D]› } t j ƒ  } | j | d ƒ |  j t | ƒ | d	 ƒ |  j | j d$ d ƒ | d ƒ x; t | d j ƒ  ƒ D]# \ } } |  j | | j	 | ƒ q>WqÊ Wd  S(&   Ns   chips=ahoy; vienna=fingert   datat   ahoyt   chipst   fingert   viennat   dicts,   <SimpleCookie: chips='ahoy' vienna='finger'>t   reprs0   Set-Cookie: chips=ahoy
Set-Cookie: vienna=fingert   outputs)   keebler="E=mc2; L=\"Loves\"; fudge=\012;"s   E=mc2; L="Loves"; fudge=
;t   keeblers5   <SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\n;'>s5   Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;"s   keebler=E=mc2s   E=mc2s   <SimpleCookie: keebler='E=mc2'>s   Set-Cookie: keebler=E=mc2s   a=b; c=[; d=r; f=ht   bt   at   [t   ct   rt   dt   ht   fs'   <SimpleCookie: a='b' c='[' d='r' f='h'>s   
s   Set-Cookie: a=bs   Set-Cookie: c=[s   Set-Cookie: d=rs   Set-Cookie: f=ht   sep(   s   Set-Cookie: a=bs   Set-Cookie: c=[s   Set-Cookie: d=rs   Set-Cookie: f=h(
   t   joint   Cookiet   SimpleCookiet   loadt   assertEqualR
   R   t   sortedt	   iteritemst   value(   t   selft   casest   caset   Ct   kt   v(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt
   test_basic   s8    


#    #c         C   s  t  j ƒ  } | j d ƒ |  j | d j d ƒ |  j | d d d ƒ |  j | d d d ƒ |  j | j d g ƒ d ƒ |  j | j ƒ  d	 ƒ |  j | j d g ƒ d
 ƒ t  j ƒ  } | j d ƒ |  j | d d d ƒ t  j ƒ  } | j d ƒ |  j | d d d ƒ d  S(   Ns/   Customer="WILE_E_COYOTE"; Version=1; Path=/acmet   Customert   WILE_E_COYOTEt   versiont   1t   paths   /acmes0   Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acmesÆ   
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
        // end hiding -->
        </script>
        s»   
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
        // end hiding -->
        </script>
        s3   Customer="W"; expires=Wed, 01 Jan 2010 00:00:00 GMTt   expiress   Wed, 01 Jan 2010 00:00:00 GMTs1   Customer="W"; expires=Wed, 01 Jan 98 00:00:00 GMTs   Wed, 01 Jan 98 00:00:00 GMT(   R   R   R   R   R   R   t	   js_output(   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt	   test_load7   s&    c         C   s6   t  j ƒ  } d | d <|  j | j d g ƒ d ƒ d  S(   Ns   some,funky;stufft   vals(   Set-Cookie: val="some\054funky\073stuff"(   R   R   R   R   (   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   test_extended_encodeZ   s    
c         C   sE   t  j d ƒ } t | d d <t | d d <|  j | j ƒ  d ƒ d  S(   Ns   Customer="WILE_E_COYOTE"R%   t   securet   httponlys6   Set-Cookie: Customer="WILE_E_COYOTE"; httponly; secure(   R   R   t   TrueR   R   (   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   test_set_secure_httponly_attrsb   s
    c         C   sG   t  j ƒ  } | j d ƒ |  j | d d ƒ |  j | d d ƒ d  S(   Ns   eggs=scrambled; Path=/bacont   eggsR0   R/   (   R   R   R   t   assertFalse(   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt)   test_secure_httponly_false_if_not_presenti   s    c         C   sG   t  j ƒ  } | j d ƒ |  j | d d ƒ |  j | d d ƒ d  S(   Ns-   eggs=scrambled; httponly; secure; Path=/baconR3   R0   R/   (   R   R   R   t
   assertTrue(   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt$   test_secure_httponly_true_if_presento   s    c         C   sw   t  j ƒ  } | j d ƒ |  j | d d ƒ |  j | d d ƒ |  j | d d d ƒ |  j | d d d ƒ d  S(   Ns5   eggs=scrambled; httponly=foo; secure=bar; Path=/baconR3   R0   R/   t   foot   bar(   R   R   R   R6   R   (   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt'   test_secure_httponly_true_if_have_valuev   s    c         C   s3   t  j ƒ  } | j d ƒ |  j | j ƒ  d ƒ d  S(   Ns-   cookie=with; invalid; version; second=cookie;s2   Set-Cookie: cookie=with
Set-Cookie: second=cookie(   R   R   R   R   R   (   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   test_bad_attrs‚   s    c         C   s3   t  j ƒ  } | j d ƒ |  j | j ƒ  d ƒ d  S(   Ns=   eggs  =  scrambled  ;  secure  ;  path  =  bar   ; foo=foo   sA   Set-Cookie: eggs=scrambled; Path=bar; secure
Set-Cookie: foo=foo(   R   R   R   R   R   (   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   test_extra_spaces‰   s    c         C   sd   t  j ƒ  } | j d ƒ |  j | d j d ƒ |  j | d d d ƒ |  j | d d d ƒ d  S(   Ns3   Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"R%   R&   R'   R(   R)   s   /acme(   R   R   R   R   R   (   R   R!   (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   test_quoted_meta�   s
    c         C   sZ   t  j ƒ  } xG d D]? } | j | ƒ |  j t | ƒ i  ƒ |  j | j ƒ  d ƒ q Wd  S(   Ns   ]foo=xs   [foo=xs
   blah]foo=xs
   blah[foo=xt    (   s   ]foo=xs   [foo=xs
   blah]foo=xs
   blah[foo=x(   R   R   R   R   R	   R   (   R   R!   t   s(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   test_invalid_cookies—   s
    c         C   s•   d } d | } t  j ƒ  } | j | ƒ |  j | j ƒ  | ƒ xO t t j d ƒ D]: } t j t j	 | d | ƒƒ } |  j | j ƒ  | ƒ qS Wd  S(   Ns/   Customer="WILE_E_COYOTE"; Path=/acme; Version=1s   Set-Cookie: %si   t   protocol(
   R   R   R   R   R   t   ranget   picklet   HIGHEST_PROTOCOLt   loadst   dumps(   R   t   rawdatat   expected_outputR!   t   protot   C1(    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   test_pickleŸ   s    
(   t   __name__t
   __module__R$   R,   R.   R2   R5   R7   R:   R;   R<   R=   R@   RK   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyR   	   s   	,	#									c           C   sC   t  t ƒ t j d  k	 r? t d t f ƒ � t t ƒ Wd  QXn  d  S(   Ns)   .+Cookie class is insecure; do not use it(   R    R   R   t   __doc__t   NoneR   t   DeprecationWarningR   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt	   test_main¬   s
    
t   __main__(   t   test.test_supportR    R   R   t   unittestR   RC   t   TestCaseR   RQ   RL   (    (    (    s†   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_cookie.pyt   <module>   s   £	