ó {G_Tc@sdZddlZddlZddlZddlZddlmZddlmZdefd„ƒYZ defd„ƒYZ d fd „ƒYZ d „Z d „Z d „Zdefd„ƒYZdefd„ƒYZdefd„ƒYZed„ZedkredeƒndS(sTests for cookielib.py.iÿÿÿÿN(tTestCase(t test_supportt DateTimeTestscBs,eZd„Zd„Zd„Zd„ZRS(cCsÕddlm}d}d}|j||ƒdƒ|j|||ƒdƒ|j||d|ƒd ƒ|j||d |ƒd ƒ|ƒ}|d ƒ}x1||fD]#}|j|d d||fƒqªWdS(Niÿÿÿÿ(t time2isozix+ÀP-s1994-02-03 00:00:00Zs%s => '%s' (%s)(RRRRtlowertupper(RRRtteststtest_ttresulttexpectedts((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_http2time_formats/s.    %c Csoddlm}xXddddddd d d d g D]2}|j||ƒdkd |||ƒfƒq5WdS(Niÿÿÿÿ(RttGarbagesMandag 16. September 1996s 01-00-1980s 01-13-1980s 00-01-1980s 32-01-1980s01-01-1980 25:00:00s01-01-1980 00:61:00s01-01-1980 00:00:62s,http2time(%s) is not None http2time(test) %s(RRt assertTruetNone(RRttest((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_http2time_garbageSs (t__name__t __module__R RRR (((s//usr/local/lib/python2.7/test/test_cookielib.pyRs   $t HeaderTestscBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCsVddlm}d d d gg}x-d d gD]}|j||gƒ|ƒq/WdS(Niÿÿÿÿ(tparse_ns_headerstfootbartexpiresld9Wtversiont0s)foo=bar; expires=01 Jan 2040 22:23:32 GMTs+foo=bar; expires="01 Jan 2040 22:23:32 GMT"(sfooR&(sexpiresld9W(sversionR)(RR$R(RR$Rthdr((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_parse_ns_headers_expiresjs  cCsSddlm}d d gg}x-ddgD]}|j||gƒ|ƒq,WdS( Niÿÿÿÿ(R$R%R&R(t1sfoo=bar; version="1"sfoo=bar; Version="1"(sfoosbar(sversionR,(RR$R(RR$RR*((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_parse_ns_headers_versionus  cCsBddlm}d}dd gg}|j||gƒ|ƒdS( Niÿÿÿÿ(R$s expires=01 Jan 2040 22:23:32 GMTR's01 Jan 2040 22:23:32 GMTR(R)(sexpiress01 Jan 2040 22:23:32 GMT(sversionR)(RR$R(RR$R*R((s//usr/local/lib/python2.7/test/test_cookielib.pyt#test_parse_ns_headers_special_names€scCsRddlm}|dd ggƒ}|j|dƒ|j|ggƒdƒdS( Niÿÿÿÿ(tjoin_header_wordsR%R&tbazs foo; bar=bazR(sfooN(sbarR0(RR/RR(RR/tjoined((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_join_header_wordsŠsc Cs¥ddlm}ddggfddggfddggfddggfd dggfd d ggfd d!d"ggfd d#d$ggfdd%ggfdd&d'ggfdd(d)d*ggfdd+gd,gd-ggfdd.d/gd0gd1gd2ggfg }x•|D]\}}y||gƒ}WnKddl}ddl}|jƒ}|jd|ƒd|jƒ}nX|j||d|||fƒqWdS(3Niÿÿÿÿ(tsplit_header_wordsR%sfoo=barR&s foo s foo= Rs foo=s foo= ; s foo= ; bar= baz R0sfoo=bar bar=bazs foo= bar=bazsbar=bazsfoo=bar;bar=bazs foo bar bazsa, b, ctatbtcs(foo; bar=baz, spam=, foo="\,\;\"", bar= tspams,;"s (error -- traceback follows) %ss: When parsing: '%s' Expected: '%s' Got: '%s' (sfooN(sfoosbar(sfooN(sfooR(sfooR(sfooR(sfooR(sbarsbaz(sfoosbar(sbarsbaz(sfoosbar=baz(sfoosbar(sbarsbaz(sfooN(sbarN(sbazN(R4N(R5N(R6N(sfooN(sbarsbaz(sspamR(sfoos,;"(sbarR(RR3Rt tracebacktStringIOt print_exctgetvalueR( RR3RtargtexpectRR8R9tf((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_split_header_words’s4   cCsœddlm}m}ddddddd d!d"d#d$d%d&g }xR|D]J\}}||gƒ}||ƒ}|j||d||||fƒqJWdS('Niÿÿÿÿ(R3R/R%sfoo=bars foo sfoo=sfoo=""sfoo=bar bar=bazsfoo=bar; bar=bazsfoo=bar;bar=bazs foo bar bazs foo; bar; bazsfoo="\"" bar="\\"sfoo="\""; bar="\\"s foo,,,barsfoo, barsfoo=bar,bar=bazsfoo=bar, bar=bazstext/html; charset=iso-8859-1stext/html; charset="iso-8859-1"s)foo="bar"; port="80,81"; discard, bar=bazs'foo=bar; port="80,81"; discard, bar=bazsBasic realm="\"foo\\\\bar\""sBasic; realm="\"foo\\\\bar\""sM When parsing: '%s' Expected: '%s' Got: '%s' Input was: '%s' (sfoosfoo(sfoo=barsfoo=bar(s foo sfoo(sfoo=sfoo=""(sfoo=bar bar=bazsfoo=bar; bar=baz(sfoo=bar;bar=bazsfoo=bar; bar=baz(s foo bar bazs foo; bar; baz(sfoo="\"" bar="\\"sfoo="\""; bar="\\"(s foo,,,barsfoo, bar(sfoo=bar,bar=bazsfoo=bar, bar=baz(stext/html; charset=iso-8859-1stext/html; charset="iso-8859-1"(s)foo="bar"; port="80,81"; discard, bar=bazs'foo=bar; port="80,81"; discard, bar=baz(sBasic realm="\"foo\\\\bar\""sBasic; realm="\"foo\\\\bar\""(RR3R/R(RR3R/RR<R=tinputtres((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_roundtrip¶s,   (R!R"R+R-R.R2R?RB(((s//usr/local/lib/python2.7/test/test_cookielib.pyR#hs   $t FakeResponsecBs eZgdd„Zd„ZRS(cCsOddl}ddl}|jdj|ƒƒ}|j|ƒ|_||_dS(sD headers: list of RFC822-style 'Key: value' strings iÿÿÿÿNs (t mimetoolsR9tjointMessaget_headerst_url(RtheadersturlRDR9R>((s//usr/local/lib/python2.7/test/test_cookielib.pyt__init__ÛscCs|jS(N(RG(R((s//usr/local/lib/python2.7/test/test_cookielib.pytinfoãsN(R!R"RRKRL(((s//usr/local/lib/python2.7/test/test_cookielib.pyRCÚscGst|||dƒS(Ns Set-Cookie2(t _interact(t cookiejarRJtset_cookie_hdrs((s//usr/local/lib/python2.7/test/test_cookielib.pyt interact_2965åscGst|||dƒS(Ns Set-Cookie(RM(RNRJRO((s//usr/local/lib/python2.7/test/test_cookielib.pytinteract_netscapeèsc CsŒddlm}||ƒ}|j|ƒ|jddƒ}g}x%|D]}|jd||fƒqHWt||ƒ} |j| |ƒ|S(sDPerform a single request / response cycle, returning Cookie: header.iÿÿÿÿ(tRequesttCookieRs%s: %s(turllib2RRtadd_cookie_headert get_headertappendRCtextract_cookies( RNRJROthdr_nameRRtreqt cookie_hdrRIR*RA((s//usr/local/lib/python2.7/test/test_cookielib.pyRMës   tFileCookieJarTestscBseZd„Zd„ZRS(cCsÖddlm}tj}|ƒ}t|ddƒ|j|jdddjdƒz3|j |dt ƒ|ƒ}|j |dt ƒWdyt j |ƒWntk r®nXX|j|jdddjdƒdS(Niÿÿÿÿ(t LWPCookieJarshttp://www.acme.com/tboos www.acme.comt/tignore_discard(RR]RtTESTFNRQRt_cookiestvalueRtsavetTruetloadtostunlinktOSError(RR]tfilenameR6((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_lwp_valueless_cookieús  "  c Csddlm}m}m}tj}xg||fD]Y}|ƒ}y|jddƒWn&tk r}}|j|j tƒq2X|j dƒq2WzVt |dƒ}|j dƒx3||fD]%}|ƒ}|j ||j|ƒq»WWdytj|ƒWntk r nXXdS(Niÿÿÿÿ(R]tMozillaCookieJart LoadErrorRjsAfor this test to work, a file with this filename should not exists%expected IOError for invalid filenametwsoops (RR]RlRmRRaRftIOErrorRt __class__tfailtopentwritet assertRaisesRgRhRi( RR]RlRmRjtcookiejar_classR6texcR>((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_bad_magic s&     (R!R"RkRw(((s//usr/local/lib/python2.7/test/test_cookielib.pyR\ùs t CookieTestscBseZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(c CsFddl}ddl}|jƒ}xddtfddtfddtfddtfddtfddtfdd tfd d tfd d tfd d tfd d tfddtfddtfddtfddtfddtfgD]S\}}}|j|ƒ}|j||ƒ}|r1|j|ƒqë|j|ƒqëWdS(Niÿÿÿÿshttp://foo.bar.com/sblah.comsrhubarb.blah.comsrhubarb.foo.bar.coms .foo.bar.coms foo.bar.coms.bar.comtcomshttp://foo.com/srhubarb.foo.coms.foo.comsfoo.coms http://foo/s rhubarb.foos.fooR%s foo.locals.local( RRTtDefaultCookiePolicytFalseReRRtdomain_return_okRt assertFalse( RRRTtpolRJtdomaintoktrequesttr((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_domain_return_okSs0                cCswddlm}m}tj}||ƒ}t|ddƒt|ddƒ|jddd}|j|jƒ|j |j dƒ|jddd }|j|jƒ|j |j d ƒ|j ||ƒd ƒt |ƒ}|j d t d t ƒz&||ƒ}|jd t d t ƒWdtj|jƒX|j t |ƒtjd t d t|ƒƒ|j t|dƒdƒdS(Niÿÿÿÿ(Rltlwp_cookie_strshttp://www.acme.com/teggss"spam"; path=/foo/s www.acme.comR_s/foo/s"spam"sJ"spam"; path="/foo/"; domain="www.acme.com"; path_spec; discard; version=0tignore_expiresR`spath_specified=%sshttp://www.acme.com/foo/s "spam"; eggs(RRlR„RRaRQRbt assertIsNoneRcRtnametreprRdRetrevertRgRhRjtretsubR{(RRlR„RjR6tcookietold_str((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_missing_valuers2      c Cs;ddlm}m}xdtdfdtdfttdfttdfttdfttdfgD]Î\}}}|d|d|ƒ}||ƒ}t|ddƒy|jd d d }Wntk rÞ|j |ƒqeX|j |j |ƒt |dd ƒ|re|jd d d } |j | j dƒqeqeWdS(Niÿÿÿÿ(t CookieJarRziitrfc2109_as_netscapetrfc2965shttp://www.example.com/sni=ni; Version=1swww.example.comR_tnisfoo=bar; Version=1R%( RRRzRR{ReRQRbtKeyErrorR‡RR(RP( RRRzR‘R’R(tpolicyR6Rt cookie2965((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_rfc2109_handling”s.         cCsÔddlm}m}|ƒ}t|ddƒt|ddƒt|ddƒt|ddƒt|dd ƒ|jd d d }|j|jd ƒ|j|jƒ|j|j |ƒ|j |j ƒ|j|j d ƒƒ|j |j dƒƒ|jdd d}|j|jdƒ|j |jƒ|j|j dƒ|j|j ƒ|jdd d}|j |j ƒ|j |j ƒ|jdd d}|jdd d}|j |jƒ|j |jƒdS(Niÿÿÿÿ(RtDEFAULT_HTTP_PORTshttp://www.acme.com/s0spam=eggs; DoMain=.acme.com; port; blArgh="feep"sni=ni; port=80,8080shttp://www.acme.com:80/snini=nisfoo=bar; expires=s-spam=eggs; expires="Foo Bar 25 33:22:11 3022"s .acme.comR_R7tblArghtblarghs www.acme.comR“s80,8080tniniR%(RRR˜RQRbRRRtdomain_specifiedtportR}tport_specifiedthas_nonstandard_attrR‡R'(RRR˜R6RR%R7((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_ns_parserµs6  cCstddlm}|ƒ}t|ddƒt|ddƒ|jdd}|jd|kƒ|jd |kƒdS( Niÿÿÿÿ(Rshttp://www.acme.com/s expires=eggssversion=eggs; spam=eggss www.acme.comR_R'R((RRRQRbR(RRR6tcookies((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_ns_parser_special_namesÚs cCs²ddlm}m}|ƒ}|tjƒdƒ}t|dd|ƒ|jt|ƒdƒ|tjƒdƒ}t|dd|ƒt|dƒ}|jt|ƒdƒ|jd|koÉd |kƒt|dd |ƒt|dd |ƒ|jt|ƒd ƒt|dd |ƒt|dd|ƒt|dƒ}|jt|ƒdƒt|ddƒ|jt|ƒdƒ|jƒ|jt|ƒdƒ|j d|ƒdS(Niÿÿÿÿ(t time2netscapeRishttp://www.acme.com/sspam="bar"; expires=%sisfoo="eggs"; expires=%ss spam="bar"R%seggs="bar"; expires=%ssbar="bar"; expires=%sis!eggs="bar"; expires=%s; max-age=0s bar="bar"; max-age=0; expires=%sshttp://www.rhubarb.net/s whum="fizz"i( RR£RRRQRtlenRtclear_session_cookiestassertIn(RR£RR6tfuturetnowth((s//usr/local/lib/python2.7/test/test_cookielib.pyt test_expiresçs8        cCsµddlm}m}|dtƒ}||ƒ}t|ddƒ|jd|jdƒ||ƒ}t|dd ƒ|jd|jdƒ||ƒ}t|d d ƒ|jd |jdƒ||ƒ}t|d d ƒ|jd |jdƒ|ƒ}t|ddƒ|jd|jdƒ|ƒ}t|ddƒ|jd|jdƒ|ƒ}t|d dƒ|jd|jdƒ|ƒ}t|d dƒ|jd|jdƒdS(Niÿÿÿÿ(RRzR’shttp://www.acme.com/sspam="bar"; Version="1"R_s www.acme.comshttp://www.acme.com/blahseggs="bar"; Version="1"s http://www.acme.com/blah/rhubarbs/blah/s!http://www.acme.com/blah/rhubarb/s/blah/rhubarb/s spam="bar"s eggs="bar"s/blahs /blah/rhubarb(RRRzReRPR¦RbRQ(RRRzR~R6((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_default_paths8          cCs\tjƒ}d}d}t|||ƒ|jd|jdƒ|jt||ƒ|ƒdS(Nshttp://example.com/?spam/eggss eggs="bar"R_s example.com(RRRQR¦RbR(RtcjturiRc((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_default_path_with_query9s  c Cshddlm}dddddddddddg }x*|D]"\}}|j||ƒ|ƒq>WdS(Niÿÿÿÿ(t escape_paths /foo%2f/bars /foo%2F/bars /foo%%/bars /fo%19o/bars /fo%7do/bars /fo%7Do/bars /foo/bar&s /foo//bars ~/foo/bars /foo/bars /foo%19/bars /}foo/bars /%7Dfoo/baru /foo/barê¯s/foo/bar%EA%AF%8D(s /foo%2f/bars /foo%2F/bar(s /foo%2F/bars /foo%2F/bar(s /foo%%/bars /foo%%/bar(s /fo%19o/bars /fo%19o/bar(s /fo%7do/bars /fo%7Do/bar(s /foo/bar&s /foo/bar&(s /foo//bars /foo//bar(s ~/foo/bars ~/foo/bar(s /foo/bars /foo%19/bar(s /}foo/bars /%7Dfoo/bar(u /foo/barê¯s/foo/bar%EA%AF%8D(RR¯R(RR¯tcasesR<R((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_escape_pathCs cCsŠddlm}ddlm}|dƒ}|j||ƒdƒ|dƒ}|j||ƒdƒ|dƒ}|j||ƒd ƒdS( Niÿÿÿÿ(RR(t request_pathsThttp://www.example.com/rheum/rhaponticum;foo=bar;sing=song?apples=pears&spam=eggs#nis$/rheum/rhaponticum;foo=bar;sing=songsBhttp://www.example.com/rheum/rhaponticum?apples=pears&spam=eggs#nis/rheum/rhaponticumshttp://www.example.comR_(RTRRRR²R(RRRR²RZ((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_request_path[s   cCsˆddlm}ddlm}m}|ddidd6ƒ}|j||ƒdƒ|d didd6ƒ}|j||ƒ|ƒdS( Niÿÿÿÿ(RR(t request_portR˜shttp://www.acme.com:1234/RIswww.acme.com:4321tHostt1234shttp://www.acme.com/(RTRRRR´R˜R(RRRR´R˜RZ((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_request_portks  cCsàddlm}ddlm}|ddidd6ƒ}|j||ƒdƒ|d did d6ƒ}|j||ƒd ƒ|d did d6ƒ}|j||ƒd ƒ|d didd6ƒ}|j||ƒd ƒdS(Niÿÿÿÿ(RR(t request_hostshttp://1.1.1.1/RIswww.acme.com:80Rµs1.1.1.1shttp://www.acme.com/sirrelevant.coms www.acme.coms/resource.htmls&http://www.acme.com:2345/resource.htmlswww.acme.com:5432(RTRRRR¸R(RRRR¸RZ((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_request_hostus    cCs¬ddlm}|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|dƒƒ|j|d ƒƒ|j|d ƒƒdS( Niÿÿÿÿ(tis_HDNs foo.bar.coms1foo2.3bar4.5coms 192.168.1.1Rt.s .foo.bar.coms..foosfoo.(RRºRR}(RRº((s//usr/local/lib/python2.7/test/test_cookielib.pyt test_is_HDNŒscCsÄddlm}|j|dƒdƒ|j|dƒdƒ|j|dƒdƒ|j|dƒdƒ|j|dƒdƒ|j|d ƒd ƒ|j|d ƒd ƒ|j|d ƒd ƒdS( Niÿÿÿÿ(treachs www.acme.coms .acme.comsacme.coms acme.locals.locals.comR»Rs 192.168.0.1(RR½R(RR½((s//usr/local/lib/python2.7/test/test_cookielib.pyt test_reach—scCsÄddlm}m}|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|d d ƒƒ|j|d d ƒƒ|j|d d ƒƒ|j|d dƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒ|j|ddƒƒdS(Niÿÿÿÿ(t domain_matchtuser_domain_matchs 192.168.1.1s.168.1.1sx.y.comsx.Y.coms.Y.comsY.coms a.b.c.coms.c.coms example.locals.locals blah.blahRs.rhubarb.rhubarbsacme.coms .acme.comsrhubarb.acme.comswww.rhubarb.acme.comsy.coms.y.coms.comRytms.mR»(RR¿RÀRR}(RR¿RÀ((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_domain_match¢s@cCsCddlm}|ƒ}t|ddƒ|jt|ƒdƒdS(Niÿÿÿÿ(Rshttp://www.nasty.com/s)foo=bar; domain=friendly.org; Version="1"i(RRRPRR¤(RRR6((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_wrong_domainÇs   cCsµddlm}m}|dtƒ}|d|ƒ}t|ddƒt|ddƒ|jt|ƒdƒxDd d d d gD]0}t|d |dƒ|jt|ƒdƒq}WdS(Niÿÿÿÿ(RRzt strict_domainR•shttp://example.co.uk/s no=problemos!okey=dokey; Domain=.example.co.ukis.co.uks.org.zas.tx.uss.name.usshttp://example.%s/sspam=eggs; Domain=.co.uk(RRRzReRQRR¤(RRRztcpR¬t pseudo_tld((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_strict_domainÒs  cCs´ddlm}m}|ƒ}t|ddƒ|jt|ƒdƒ|j|jdddjd ƒ|jt|dƒdƒ|jt|d ƒdƒ|d |jƒ}|j |ƒ|jt|d ƒd ƒt|d dƒt|ddƒ|jt|ƒdƒ|j|jdddjdƒ|j|jdddjdƒ|jt|dƒdƒt|ddƒ|jt|ƒdƒt|ddƒ|jt|ƒdƒdS(Niÿÿÿÿ(RRzshttp://foo.net/sns=barisfoo.netR_tnsR&shttp://www.foo.net/tstrict_ns_domainRshttp://foo.net/foo/sspam1=eggs; domain=foo.netshttp://foo.net/foo/bar/sspam2=eggs; domain=.foo.netis.foo.nets/footspam1R…s/foo/bartspam2sspam2=eggs; spam1=eggs; ns=barsnini="ni"; domain=.netshttp://foo.co.uksnasty=trick; domain=.co.uki( RRRzRQRR¤RbRctDomainStrictNonDomaint set_policy(RRRzR6R~((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_two_component_domain_nsâs6 "    cCs´ddlm}m}|dtƒ}||ƒ}t|ddƒ|jt|ƒdƒ|j|jddd jd ƒ|jt|dƒd ƒ|jt|d ƒd ƒt|ddƒ|jt|ƒdƒ|jt|dƒd ƒt|ddƒ|j|jdddjdƒ|jt|ƒdƒ|jt|dƒd ƒ|jt|dƒdƒt|ddƒ|jt|ƒdƒt|ddƒ|jt|ƒdƒdS(Niÿÿÿÿ(RRzR’shttp://foo.net/sfoo=bar; Version="1"isfoo.netR_R%R&s$Version=1; foo=barshttp://www.foo.net/Rshttp://foo.net/foos1spam=eggs; domain=foo.net; path=/foo; Version="1"shttp://www.foo.net/foo/s&spam=eggs; domain=foo.net; Version="1"s.foo.nets/foo/R7R…ishttp://foo.net/foo/s($Version=1; spam=eggs; $Domain="foo.net"s#ni="ni"; domain=".net"; Version="1"shttp://foo.co.uk/s'nasty=trick; domain=.co.uk; Version="1"i( RRRzReRPRR¤RbRc(RRRzR~R6((s//usr/local/lib/python2.7/test/test_cookielib.pyt!test_two_component_domain_rfc2965s: "    c Cs‘ddlm}m}ddlm}|d|ddgddgƒƒ}|d ƒ}d g}t|d ƒ}|j||ƒ|jt|ƒd ƒ|d ƒ}t|d ƒ}|j||ƒ|jt|ƒd ƒ|dƒ}t|dƒ}|j||ƒ|jt|ƒd ƒ|dƒ}t|dƒ}|j ||ƒ}|j |d ƒ|jt|ƒdƒ|j |ƒ|j |j dƒƒdS(Niÿÿÿÿ(RRz(RRR•tblocked_domainssacme.comtallowed_domainss www.acme.comshttp://acme.com/s*Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/ishttp://www.acme.com/ishttp://www.coyote.com/iRS(RRRzRTRRRCRXRR¤t make_cookiest set_cookieRUR}t has_header( RRRzRRR6RZRIRAR¡((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_domain_allowBs2        c Csddlm}m}ddlm}|dtddgƒ}|d|ƒ}dg}|d ƒ}t|d ƒ}|j||ƒ|jt |ƒd ƒ|j d gƒ} |j||ƒ|jt |ƒd ƒ|j ƒ|d ƒ}t|d ƒ}|j||ƒ|jt |ƒd ƒ|d ƒ}|j |ƒ|j |jdƒƒ|j |jdƒƒ|j ƒ|j dgƒ|j||ƒ|jt |ƒd ƒ|d ƒ}t|d ƒ}|j||ƒ} |j| d ƒ|jt |ƒdƒ|j |ƒ|j|jdƒƒdS(Niÿÿÿÿ(RRz(RRR’RÐs .acme.comR•s*Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/shttp://www.acme.com/isacme.comishttp://www.roadrunner.net/RStCookie2i(RRRzRTRRReRCRXRR¤tset_blocked_domainstclearRURRÔRÒRÓR}( RRRzRRR~R6RIRZRAtpR¡((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_domain_blockdsB         c Csddlm}m}xøttfD]ê}xádD]Ù}|ƒ}|rc|dtƒ}t}d}n|dtƒ}t}d}|j|ƒd} ||| d||fƒ||| d ||fƒ|j|j d d d j d ƒ|j |j d d dj dƒq0Wq#WdS(Niÿÿÿÿ(RRzt RR’s ; Version=1shttp://www.acme.com/s foo1=bar%s%ssfoo2=bar%s; secure%ss www.acme.comR_tfoo1s#non-secure cookie registered securetfoo2s#secure cookie registered non-secure(RÛR( RRRzReR{RQRPRÍR}RbtsecureR( RRRzRÈt whitespaceR6R~tinttvsRJ((s//usr/local/lib/python2.7/test/test_cookielib.pyt test_secures*    cCsaddlm}m}|d|dtƒƒ}t|ddƒt|dƒ}|j|dƒdS(Niÿÿÿÿ(RRzR•R’shttp://www.acme.com/sfoo=\b"a"r; Version=1s$Version=1; foo=\\b\"a\"r(RRRzReRPR(RRRzR6R©((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_quote_cookie_value¨s cCsšddlm}m}ddlm}d}||dtƒƒ}t||dƒ||ƒ}|jt|ƒdƒ|j |ƒ|j |j dƒƒdS( Niÿÿÿÿ(RRz(RRshttp://www.acme.comR’sfoo=bar; Version=1iRS( RRRzRTRRReRPRR¤RURRÔ(RRRzRRRJR6RZ((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_missing_final_slash¯s  cCsõddlm}m}|dtƒ}||ƒ}d}t||dƒt||ƒ}|jd|dƒ||ƒ}d}t||dƒt||ƒ}|jd |d ƒ||ƒ}d}t||d ƒt||ƒ}|jd |d ƒdS( Niÿÿÿÿ(RRzR’shttp://foo.bar.com/sspam=eggs; Version=1tDomains*absent domain returned with domain presents%spam=eggs; Version=1; Domain=.bar.coms$Domain=".bar.com"sdomain not returneds$spam=eggs; Version=1; Domain=bar.coms$Domain="bar.com"(RRRzReRPt assertNotInR¦(RRRzR~R6RJR©((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_domain_mirror»s$    cCs±ddlm}m}|dtƒ}||ƒ}d}t||dƒt||ƒ}|jd|dƒ||ƒ}d}t||dƒt||ƒ}|jd |d ƒdS( Niÿÿÿÿ(RRzR’shttp://foo.bar.com/sspam=eggs; Version=1tPaths&absent path returned with path presentsspam=eggs; Version=1; Path=/s $Path="/"spath not returned(RRRzReRPRæR¦(RRRzR~R6RJR©((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_path_mirrorÔs  cCs9ddlm}m}|dtƒ}||ƒ}d}t||dƒt||ƒ}|jd|dƒ||ƒ}d}t||dƒt||ƒ}|j|d d ƒ||ƒ}d}t||d ƒt||ƒ}|jd |d ƒ||ƒ}d}t||dƒt||ƒ}|jd|dƒdS(Niÿÿÿÿ(RRzR’shttp://foo.bar.com/sspam=eggs; Version=1tPorts&absent port returned with port presentsspam=eggs; Version=1; Ports\$Port([^=]|$)s-port with no value not returned with no valuesspam=eggs; Version=1; Port="80"s $Port="80"s5port with single value not returned with single values$spam=eggs; Version=1; Port="80,8080"s$Port="80,8080"s;port with multiple values not returned with multiple values(RRRzReRPRæRR¦(RRRzR~R6RJR©((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_port_mirrorås2       cCsgddlm}m}||dtƒƒ}d}t||dƒt||ƒ}|jd|dƒdS(Niÿÿÿÿ(RRzR’shttp://foo.bar.com/sfspam=eggs; Version=1; Comment="does anybody read these?"; CommentURL="http://foo.bar.net/comment.html"tComments:Comment or CommentURL cookie-attributes returned to server(RRRzReRPRæ(RRRzR6RJR©((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_no_return_comments c Cs}ddlm}m}m}||dtƒƒ}t|ddƒt|ddƒt|ddƒt|dd ƒt|d d ƒd d d d d g}dddddg}dddddg}dddddg}x¡tdƒD]“} d } x„|D]|} |j| |ƒ|j | j || ƒ|j | j || ƒ|j | j || ƒ|j | j || ƒ| d } qõWqâWdS(Niÿÿÿÿ(RRSRzR’shttp://blah.spam.org/sefoo=eggs; Version=1; Comment="does anybody read these?"; CommentURL="http://foo.bar.net/comment.html"shttp://www.acme.com/blah/sspam=bar; securesfoo=bar; secure; Version=1sfoo=bar; path=/; Version=1shttp://www.sol.nossbang=wallop; version=1; domain=".sol.no"; port="90,100, 80,8080"; max-age=100; Comment = "Just kidding! (\"|\\\\) "iitbangR%R7s.sol.nos blah.spam.orgs www.acme.comR_s/blahs/blah/i(RRRSRzReRPRQtrangetassertIsInstanceRR(RˆRtpath( RRRSRztcstversionstnamestdomainstpathstiR6((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_Cookie_iterators0      cCsœddlm}|j|dgƒddddggƒ|j|d gƒdddggƒ|j|dgƒddggƒ|j|d gƒgƒdS(Niÿÿÿÿ(R$sfoo=bar; path=/; domainR%R&RñR_RR(R)s)foo=bar; expires=Foo Bar 12 33:22:11 2000R'R(sfoosbar(spathR_(sdomainN(sversionR)(sfoosbar(sexpiresN(sversionR)(sfooN(sversionR)(RR$RR(RR$((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_parse_ns_headers4s   cCs˜d„}xNdgdgdgdgdggD](}||ƒ}|jt|ƒdƒq.Wdg}||ƒ}|jd d d }|j|jƒdS( NcSsXddlm}ddlm}|ƒ}|dƒ}t|dƒ}|j||ƒ|S(Niÿÿÿÿ(R(RRshttp://www.example.com/(RRRTRRRCRX(RIRRRR6RZR‚((s//usr/local/lib/python2.7/test/test_cookielib.pytcookiejar_from_cookie_headersLs  s Set-Cookie: s Set-Cookie2: s-Set-Cookie2: a=foo; path=/; Version=1; domainsSet-Cookie: b=foo; max-age=oopssSet-Cookie: b=foo; version=spamis3Set-Cookie: c=foo; expires=Foo Bar 12 33:22:11 2000swww.example.comR_R6(RR¤RbR‡R'(RRúRIR6R((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_bad_cookie_headerJs    (!R!R"RƒRR—R R¢RªR«R®R±R³R·R¹R¼R¾RÂRÃRÇRÎRÏRÕRÚRâRãRäRçRéRëRíRøRùRû(((s//usr/local/lib/python2.7/test/test_cookielib.pyRx$s>/  " ! % ( *    %  2 . " +     ! " tLWPCookieTestscBsteZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( c CsCddlm}m}ddlm}tjƒdd}g}||dtƒƒ}|ddid d 6ƒ}|jd |ƒt |d ƒ}|j ||ƒ|d ƒ}|j |ƒ|j |j d ƒdƒ|j |j dƒdƒ|jdƒt |d ƒ}|j ||ƒ|dƒ}|j |ƒ|j d ƒ} |jd| ƒ|jd| ƒ|jdƒt |dƒ}|j ||ƒ|d ƒ}|j |ƒ|j d ƒ} |jd| ƒ|jd| ƒ|jd| ƒ|dƒ}|j |ƒ|j d ƒ} |jd| ƒ|jd| ƒ|j| jdƒƒdS(Niÿÿÿÿ(RRz(RRiiR’shttp://www.acme.com:80/RIswww.acme.com:80RµsVSet-Cookie: CUSTOMER=WILE_E_COYOTE; path=/ ; expires=Wednesday, 09-Nov-%d 23:12:40 GMTshttp://www.acme.com/RSsCUSTOMER=WILE_E_COYOTERÖs $Version="1"s4Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/shttp://www.acme.com/foo/bars PART_NUMBER=ROCKET_LAUNCHER_0001s%Set-Cookie: SHIPPING=FEDEX; path=/fooshttp://www.acme.comsSHIPPING=FEDEXshttp://www.acme.com/foo/sSHIPPING=FEDEX;(RRRzRTRRRt localtimeReRWRCRXRURRVR¦RæRt startswith( RRRzRRt year_plus_oneRIR6RZRAR©((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_netscape_example_1nsN&           cCsûddlm}ddlm}|ƒ}g}|dƒ}|jdƒt|dƒ}|j||ƒ|dƒ}|j|ƒ|j|j dƒdƒ|jdƒt|dƒ}|j||ƒ|d ƒ}|j|ƒ|j |j dƒd ƒdS( Niÿÿÿÿ(R(RRshttp://www.acme.com/s4Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/RSs PART_NUMBER=ROCKET_LAUNCHER_0001s6Set-Cookie: PART_NUMBER=RIDING_ROCKET_0023; path=/ammoshttp://www.acme.com/ammosBPART_NUMBER=RIDING_ROCKET_0023;\s*PART_NUMBER=ROCKET_LAUNCHER_0001( RRRTRRRWRCRXRURRVR(RRRRR6RIRZRA((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_netscape_example_2Ìs(       cCsáddlm}m}||dtƒƒ}t|ddƒ}|j|ƒt|ddƒ}|j|dƒt|d d ƒ}|j|d ƒ|j|d ƒ|j|d ƒt|dƒ}|j|dƒ|jd|ƒdS(Niÿÿÿÿ(RRzR’shttp://www.acme.com/acme/logins3Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"s!http://www.acme.com/acme/pickitems=Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"s=^\$Version="?1"?; Customer="?WILE_E_COYOTE"?; \$Path="/acme"$s!http://www.acme.com/acme/shippings+Shipping="FedEx"; Version="1"; Path="/acme"s^\$Version="?1"?;s7Part_Number="?Rocket_Launcher_0001"?;\s*\$Path="\/acme"s-Customer="?WILE_E_COYOTE"?;\s*\$Path="\/acme"s http://www.acme.com/acme/processs%Shipping="?FedEx"?;\s*\$Path="\/acme"t WILE_E_COYOTE(RRRzReRPR}RR¦(RRRzR6R((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_ietf_example_1s*          cCsddlm}m}||dtƒƒ}t|dddƒt|dƒ}|j|dƒt|d ƒ}|jd |ƒ|jd |ƒdS( Niÿÿÿÿ(RRzR’s&http://www.acme.com/acme/ammo/specifics=Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"s@Part_Number="Riding_Rocket_0023"; Version="1"; Path="/acme/ammo"s!http://www.acme.com/acme/ammo/...s(Riding_Rocket_0023.*Rocket_Launcher_0001shttp://www.acme.com/acme/parts/tRocket_Launcher_0001tRiding_Rocket_0023(RRRzReRPRR¦Ræ(RRRzR6R((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_ietf_example_2ts   c Cszddlm}m}|dtƒ}|d|ƒ}d}t|ddƒ}|j|ƒt|ddƒ}|jt|ƒd ƒt|d d ƒ}|jt|ƒd ƒt|d d ƒ}|jt|ƒd ƒt|ddƒ}|jt|ƒd ƒt|ddƒ}|jt|ƒd ƒt|ddƒ}|jt|ƒdƒt|ddƒ}|jt|ƒdƒt|ddƒ}|jt|ƒdƒt|ddƒ}|jt|ƒdƒt|ddƒ}|jt|ƒdƒtj }zE|j |dtƒt |ƒ}|d|ƒ}|j |dtƒWdyt j|ƒWntk r^nXX|j|t |ƒƒdS(Niÿÿÿÿ(RzR]R’R•s max-age=3600shttp://www.acme.coms!foo=bar; domain=".com"; version=1s'ping=pong; domain="acme.com"; version=1ishttp://www.a.acme.coms'whiz=bang; domain="acme.com"; version=1s,wow=flutter; domain=".a.acme.com"; version=1ishttp://125.125.125.125s*zzzz=ping; domain="125.125.125"; version=1shttp://www.sol.nos6blah=rhubarb; domain=".sol.no"; path="/foo"; version=1shttp://www.sol.no/foo/bars3bing=bong; domain=".sol.no"; path="/foo"; version=1is5whiz=ffft; domain=".sol.no"; port="90,100"; version=1ssbang=wallop; version=1; domain=".sol.no"; port="90,100, 80,8080"; max-age=100; Comment = "Just kidding! (\"|\\\\) "is9foo9=bar; version=1; domain=".sol.no"; port; max-age=100;ishttp://www.sol.no/Set-Cookie: p2=perm;Path=/;expires=Fri, 02-Feb-%d 23:24:20 GMTs<Set-Cookie: s2=session;Path=/scripts;Domain=.perlmeister.coms2Set-Cookie2: s3=session;Version=1;Discard;Path="/"t session_aftert perm_aftertsession_beforet perm_befores %s_befores%s_after( RRRTRRRRýRWRCRXRcR¥RtassertNotEqual( RRRRRÿRZRIRAR6tcounterRtkey((s//usr/local/lib/python2.7/test/test_cookielib.pyttest_session_cookies¦s:              (R!R"RRRRR R RRRRRR(((s//usr/local/lib/python2.7/test/test_cookielib.pyRüks ^ 6 r 8 ]  +    "cCstjtttttƒdS(N(Rt run_unittestRR#RxR\Rü(tverbose((s//usr/local/lib/python2.7/test/test_cookielib.pyt test_mainÔs t__main__R(t__doc__RRgR‹RtunittestRRRRR#RCRPRQRMR\RxRüRRR!Re(((s//usr/local/lib/python2.7/test/test_cookielib.pyts.    Zr   +ÿÿÿJÿÿk