ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
R\¬Qc@s?ddlZddlZddlZddlZddlZddlmZejddeƒZ    ejdƒZ
dej fd„ƒYZ de
j fd    „ƒYZd
dd „ƒYZd ejfd „ƒYZdejfd„ƒYZdefd„ƒYZd„Zdefd„ƒYZd„Zedkr;eƒndS(iÿÿÿÿN(t test_supportt    mimetoolst
deprecatedt    threadingtLoopbackHttpServercBs eZdZd„Zd„ZRS(s^HTTP server w/ a few modifications that make it useful for
    loopback testing purposes.
    cCs*tjj|||ƒ|jjdƒdS(Ngð?(tBaseHTTPServert
HTTPServert__init__tsockett
settimeout(tselftserver_addresstRequestHandlerClass((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRs cCs,|jjƒ\}}|jdƒ||fS(s"BaseHTTPServer method, overridden.g$@(RtacceptR    (R
trequesttclient_address((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt get_requests (t__name__t
__module__t__doc__RR(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRs        tLoopbackHttpServerThreadcBs)eZdZd„Zd„Zd„ZRS(s2Stoppable thread that runs a loopback http server.cCsVtjj|ƒt|_tjƒ|_d|_td|ƒ|_    |j    j
|_ dS(NsHTTP/1.0s    127.0.0.1i(s    127.0.0.1i( RtThreadRtFalset_stoptEventtreadytprotocol_versionRthttpdt server_porttport(R
trequest_handler((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyR-s         cCst|_|jƒdS(s.Stops the webserver if it's currently running.N(tTrueRtjoin(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytstop8s    cCs.|jjƒx|js)|jjƒqWdS(N(RtsetRRthandle_request(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytrun@s  (RRRRR!R$(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyR*s        tDigestAuthHandlercBs_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z    d„Z
d    „Z RS(
s-Handler for performing digest authentication.cCs1d|_g|_i|_d|_d|_dS(Nis
Test Realmtauth(t _request_numt_noncest_userst _realm_namet_qop(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRJs
                cCs ||_dS(N(R+(R
tqop((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytset_qopQscCs ||_dS(N(R)(R
tusers((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt    set_usersTscCs ||_dS(N(R*(R
trealm((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt    set_realmXscCsA|jd7_tjt|jƒƒjƒ}|jj|ƒ|S(Ni(R'thashlibtmd5tstrt    hexdigestR(tappend(R
tnonce((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt_generate_nonce[scCs®|jdƒ}||d}|jdƒ}i}xu|D]m}|jdƒ\}}|jƒ}|ddkr|ddkr|dd!}n |jƒ}|||<q9W|S(Nt it,t=it"iÿÿÿÿ(tfindtsplittstrip(R
tauth_strtfirst_space_indextpartst    auth_dicttparttnametvalue((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt_create_auth_dictas    c Cs°i}|j|ƒ||d<||d<||d<d|}tj|ƒjƒ}d|}tj|ƒjƒ}    ||d<|    |d<d|}
tj|
ƒjƒ} | |d    kS(
Ntpasswordtmethodturis#%(username)s:%(realm)s:%(password)ss%(method)s:%(uri)stHA1tHA2s3%(HA1)s:%(nonce)s:%(nc)s:%(cnonce)s:%(qop)s:%(HA2)stresponse(tupdateR2R3R5( R
RCRHRIRJt
final_dicttHA1_strRKtHA2_strRLt response_strRM((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt_validate_authrs 
 
 
 
 
 
 
cCsg|jddƒ|jddƒ|jdd|j|j|jƒfƒ|jƒ|jjdƒtS(Ni—sProxy Authentication Requireds Content-Types    text/htmlsProxy-Authenticates(Digest realm="%s", qop="%s",nonce="%s", sProxy Authentication Required.(    t send_responset send_headerR*R+R8t end_headerstwfiletwriteR(R
R((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt_return_auth_challenge„s
cCst|jƒdkrtSd|jkr5|j|ƒS|j|jdƒ}|d|jkrr|j|d}n |j|ƒS|jdƒ|jkr¤|j|ƒS|jj|dƒt    }x>|j
|j gD]*}|j |||j |ƒrÑt}qÑqÑW|s|j|ƒStSdS(sPerforms digest authentication on the given HTTP request
        handler.  Returns True if authentication was successful, False
        otherwise.
 
        If no users have been set, then digest auth is effectively
        disabled and this method will always return True.
        isProxy-AuthorizationtusernameR7N(tlenR)RtheadersRYRGtgetR(tremoveRtpatht
short_pathRStcommand(R
RRCRHtauth_validatedR_((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyR#“s,                 ( RRRRR-R/R1R8RGRSRYR#(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyR%Gs                                tFakeProxyHandlercBs)eZdZd„Zd„Zd„ZRS(sÏThis is a 'fake proxy' that makes it look like the entire
    internet has gone down due to a sudden zombie invasion.  It main
    utility is in providing us with authentication support for
    testing.
    cOs#||_tjj|||ŽdS(N(tdigest_auth_handlerRtBaseHTTPRequestHandlerR(R
Rdtargstkwargs((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRÈs    cGsdS(N((R
tformatRf((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt log_messageÎscCsštj|jdƒ\}}}}}}||_|jj|ƒr–|jddƒ|jddƒ|jƒ|jj    d|jƒ|jj    dƒndS(NthttpiÈtOKs Content-Types    text/htmlsYou've reached %s!<BR>sFOur apologies, but our server is down due to a sudden zombie invasion.(
turlparseR_R`RdR#RTRURVRWRX(R
tscmtnetlocR_tparamstquerytfragment((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytdo_GETÓs!    
(RRRRRiRr(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRcÁs        t BaseTestCasecBseZd„Zd„ZRS(cCstjƒ|_dS(N(Rtthreading_setupt_threads(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytsetUpâscCstj|jŒdS(N(Rtthreading_cleanupRu(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttearDownås(RRRvRx(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRsás    tProxyAuthTestscBsVeZdZdZdZdZd„Zd„Zd„Zd„Z    d„Z
d    „Z RS(
shttp://localhostttesterttest123t    TestRealmcsÛttˆƒjƒtƒˆ_ˆjjiˆjˆj6ƒˆjjˆj    ƒ‡fd†}t
|ƒˆ_ ˆj j ƒˆj j jƒdˆj j}tji|d6ƒ}tjƒˆ_tj|ˆjƒˆ_dS(Ncstˆj||ŽS(N(RcRd(RfRg(R
(sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytcreate_fake_proxy_handlerõsshttp://127.0.0.1:%dRj(tsuperRyRvR%RdR/tPASSWDtUSERR1tREALMRtservertstartRtwaitRturllib2t ProxyHandlertProxyDigestAuthHandlertproxy_digest_handlert build_openertopener(R
R}t    proxy_urlthandler((R
sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRvðs  cCs$|jjƒtt|ƒjƒdS(N(R‚R!R~RyRx(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRxs cCs\|jj|j|j|j|jdƒ|jjdƒ|jt    j
|j j |jƒdS(NtbadR&( Rˆt add_passwordRtURLR€RRdR-t assertRaisesR…t    HTTPErrorRŠtopen(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt-test_proxy_with_bad_password_raises_httperrors      cCs3|jjdƒ|jtj|jj|jƒdS(NR&(RdR-RR…R‘RŠR’R(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt,test_proxy_with_no_password_raises_httperror s     cCsk|jj|j|j|j|jƒ|jjdƒ|jj    |jƒ}x|j
ƒr\qMW|j ƒdS(NR&( RˆRŽRRR€RRdR-RŠR’treadtclose(R
tresult((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_proxy_qop_auth_worksscCs•|jj|j|j|j|jƒ|jjdƒy|jj    |jƒ}Wnt
j k
rjd}nX|r‘x|j ƒrƒqtW|jƒndS(Nsauth-int(RˆRŽRRR€RRdR-RŠR’R…tURLErrortNoneR•R–(R
R—((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt0test_proxy_qop_auth_int_works_or_throws_urlerrors
( RRRR€RRRvRxR“R”R˜R›(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRyés                        cs&dtjf‡‡fd†ƒY‰ˆS(NtFakeHTTPRequestHandlercsMeZdZgZgZdZd„Zd„Z‡‡fd†Zd„Z    RS(s    TestHTTP/iPcSs)|jƒ}|r%|jj|ƒndS(N(t    send_headRWRX(R
tbody((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRr5s cSsC|jd}|jjt|ƒƒ}|jƒ|jj|ƒdS(NsContent-Length(R\trfileR•tintRrtrequestsR6(R
tcontent_lengtht    post_data((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytdo_POST:s 
cs¤|jˆ_|jj|jƒˆjdƒ\}}}|j|ƒx+|D]#\}}|j|||jƒqKW|r–|jddƒ|j    ƒ|S|j    ƒdS(Nis Content-types
text/plain(
R\theaders_receivedR¡R6R_tpopRTRURRV(R
t response_codeR\RžtheaderRF(Rœt    responses(sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyR@s  
cWsdS(N((R
Rf((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRiOs(
RRtserver_versionR¡R¥RRrR¤RRi((RœR©(sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRœ.s        (RRe(R©((RœR©sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytGetRequestHandler,s"%t TestUrlopencBsƒeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z    d„Z
d    „Z d
„Z d „Z d „Zd „ZRS(sGTests urllib2.urlopen using the network.
 
    These tests are not exhaustive.  Assuming that testing using files does a
    good job overall of some of the basic interface features.  There are no
    tests exercising the optional 'data' and 'proxies' arguments.  No tests
    for transparent redirection have been written.
    cCsBtjiƒ}tj|ƒ}tj|ƒtt|ƒjƒdS(N(R…R†R‰tinstall_openerR~R¬Rv(R
t proxy_handlerRŠ((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyRv_s cCsQt|ƒ}t|ƒ|_|jjƒ|jjjƒ|jj}||_|S(N(R«RR‚RƒRR„R(R
R©RŒR((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt start_serveres       cCs¤d}dd
gdfdg|fg}|j|ƒ}zYtjd|jƒ}|jƒ}|jƒ|j||ƒ|j|jdd    gƒWd|jj    ƒXdS( NsWe got here...i.tLocations"http://localhost:%s/somewhere_elsetiÈshttp://localhost:%s/t/s/somewhere_else(R°s"http://localhost:%s/somewhere_else(
R¯R…turlopenRR•R–t assertEqualR¡R‚R!(R
texpected_responseR©RŒtftdata((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_redirectionps 
cCs´d}|jdg|fgƒ}z~ytjd|jƒWntjk
rT}nX|jdƒ|jƒ}|jƒ|j||ƒ|j|j    dgƒWd|j
j ƒXdS(NsBad bad bad...i”shttp://localhost:%s/weebles404 should raise URLErrors/weeble( R¯R…R³RR™tfailR•R–R´R¡R‚R!(R
RµRŒR¶R·((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_404„s  
cCsŒd}|jdg|fgƒ}zVtjd|jƒ}|jƒ}|jƒ|j||ƒ|j|jdgƒWd|jj    ƒXdS(Ns pycon 2008...iÈshttp://localhost:%s/bizarres/bizarre(
R¯R…R³RR•R–R´R¡R‚R!(R
RµRŒR¶R·((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_200™s 
cCs’d}|jdg|fgƒ}z\tjd|jdƒ}|jƒ}|jƒ|j||ƒ|j|jddgƒWd|jj    ƒXdS(Ns pycon 2008...iÈshttp://localhost:%s/bizarresget=with_feelings/bizarre(
R¯R…R³RR•R–R´R¡R‚R!(R
RµRŒR¶R·((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_200_with_parameters§s 
cCs{|jdgdfgƒ}zKtjd|jdidd6ƒ}tj|ƒ|j|jddƒWd|jjƒXdS(NiÈs we don't careshttp://localhost:%s/R\s bytes=20-39tRange(    R¯R…tRequestRR³R´R¥R‚R!(R
RŒtreq((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_sending_headers¶s cCs |jdgdfgƒ}zptjd|jƒ}x+d
D]#}|jt||ƒd|ƒq;Wz|j|jƒd    ƒWd|jƒXWd|jj    ƒXdS( NiÈs we don't careshttp://localhost:%sR•R–tinfotgeturls3object returned from urlopen lacks the %s attributescalling 'read' failed(sreadsclosesinfosgeturl(
R¯R…R³Rt
assertTruethasattrR•R–R‚R!(R
RŒtopen_urltattr((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt
test_basicÁs  cCs‚|jdgdfgƒ}zRtjd|jƒ}|jƒ}|j|tjdƒ|j|j    ƒdƒWd|j
j ƒXdS(NiÈs we don't careshttp://localhost:%ssAobject returned by 'info' is not an instance of mimetools.Messagetplain( R¯R…R³RRÁtassertIsInstanceRtMessageR´t
getsubtypeR‚R!(R
RŒRÅtinfo_obj((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt    test_infoÐs cCsm|jdgdfgƒ}z=tjd|jƒ}|jƒ}|j|d|jƒWd|jjƒXdS(NiÈs we don't careshttp://localhost:%s(R¯R…R³RRÂR´R‚R!(R
RŒRÅturl((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt test_geturlÝs  cCs'tjdƒ|jttjdƒdS(Ntnetworkshttp://sadflkjsasf.i.nvali.d./(RtrequiresRtIOErrorR…R³(R
((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_bad_addressés     cCsqd}|jdg|fgƒ}z;tjd|jƒ}x|D]}|j||ƒqAWWd|jjƒXdS(Ns pycon 2008...iÈshttp://localhost:%s(R¯R…R³RR´R‚R!(R
RµRŒR·tline((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyttest_iterations c    CsÞddddddg}dj|ƒ}|jdg|fgƒ}zktjd    |jƒ}xNt|ƒD]@\}}|j|||d
|t||ƒt|ƒfƒqjWWd|jj    ƒX|j|d t|ƒƒdS( NsWe
sgot
shere
s    verylong i s
R±iÈshttp://localhost:%ssQFetched line number %s doesn't match expected:
    Expected length was %s, got %si(
R R¯R…R³Rt    enumerateR´R[R‚R!(R
tlinesRµRŒR·tindexRÔ((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pytztest_line_iterations)(RRRRvR¯R¸RºR»R¼RÀRÇRÍRÏRÓRÕRÙ(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyR¬Vs                                                
cCstjttƒdS(N(Rt run_unittestRyR¬(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt    test_mainst__main__((RlR…RtunittestR2ttestRt import_moduleRRRRRRRR%ReRctTestCaseRsRyR«R¬RÛR(((sb/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/test/test_urllib2_localnet.pyt<module>s$     z C    *È