Artifactspublic-v0

curl

master
ply4 git calls29 ms289 KiB2 cachedprotocol v2
187 lines9.4 KiBRaw
1#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
21# SPDX-License-Identifier: curl
23###########################################################################
25import logging
26import os
27import re
29import pytest
30from testenv import CurlClient, Env, ExecResult
32log = logging.getLogger(__name__)
35@pytest.mark.skipif(condition=Env.setup_incomplete(),
36 reason=f"missing: {Env.incomplete_reason()}")
37class TestProxyAuth:
39 def httpd_configure(self, env, httpd):
40 httpd.set_proxy_auth(True)
41 httpd.reload_if_config_changed()
43 def get_tunnel_proto_used(self, r: ExecResult):
44 for line in r.trace_lines:
45 m = re.match(r'.* CONNECT: \'(\S+)\' negotiated$', line)
46 if m:
47 return m.group(1)
48 assert False, f'tunnel protocol not found in:\n{"".join(r.trace_lines)}'
50 # download via http: proxy (no tunnel), no auth
51 def test_13_01_proxy_no_auth(self, env: Env, httpd, configures_httpd):
52 self.httpd_configure(env, httpd)
53 curl = CurlClient(env=env)
54 url = f'http://localhost:{env.http_port}/data.json'
55 r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
56 extra_args=curl.get_proxy_args(proxys=False))
57 r.check_response(count=1, http_status=407)
59 # download via http: proxy (no tunnel), auth
60 def test_13_02_proxy_auth(self, env: Env, httpd, configures_httpd):
61 self.httpd_configure(env, httpd)
62 curl = CurlClient(env=env)
63 url = f'http://localhost:{env.http_port}/data.json'
64 xargs = curl.get_proxy_args(proxys=False)
65 xargs.extend(['--proxy-user', 'proxy:proxy'])
66 r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
67 extra_args=xargs)
68 r.check_response(count=1, http_status=200)
70 @pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPS-proxy'),
71 reason='curl lacks HTTPS-proxy support')
72 @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available")
73 def test_13_03_proxys_no_auth(self, env: Env, httpd, configures_httpd, nghttpx_fwd):
74 self.httpd_configure(env, httpd)
75 curl = CurlClient(env=env)
76 url = f'http://localhost:{env.http_port}/data.json'
77 xargs = curl.get_proxy_args(proxys=True)
78 r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
79 extra_args=xargs)
80 r.check_response(count=1, http_status=407)
82 @pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPS-proxy'),
83 reason='curl lacks HTTPS-proxy support')
84 @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available")
85 def test_13_04_proxys_auth(self, env: Env, httpd, configures_httpd, nghttpx_fwd):
86 self.httpd_configure(env, httpd)
87 curl = CurlClient(env=env)
88 url = f'http://localhost:{env.http_port}/data.json'
89 xargs = curl.get_proxy_args(proxys=True)
90 xargs.extend(['--proxy-user', 'proxy:proxy'])
91 r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
92 extra_args=xargs)
93 r.check_response(count=1, http_status=200)
95 def test_13_05_tunnel_http_no_auth(self, env: Env, httpd, configures_httpd, nghttpx_fwd):
96 self.httpd_configure(env, httpd)
97 curl = CurlClient(env=env)
98 url = f'http://localhost:{env.http_port}/data.json'
99 xargs = curl.get_proxy_args(proxys=False, tunnel=True)
100 r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
101 extra_args=xargs)
102 # expect "COULD_NOT_CONNECT"
103 r.check_response(exitcode=7, http_status=None)
105 def test_13_06_tunnel_http_auth(self, env: Env, httpd, configures_httpd):
106 self.httpd_configure(env, httpd)
107 curl = CurlClient(env=env)
108 url = f'http://localhost:{env.http_port}/data.json'
109 xargs = curl.get_proxy_args(proxys=False, tunnel=True)
110 xargs.extend(['--proxy-user', 'proxy:proxy'])
111 r = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True,
112 extra_args=xargs)
113 r.check_response(count=1, http_status=200)
115 @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available")
116 @pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPS-proxy'),
117 reason='curl lacks HTTPS-proxy support')
118 @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug")
119 @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings")
120 @pytest.mark.parametrize("proto", Env.http_h1_h2_protos())
121 @pytest.mark.parametrize("tunnel", Env.http_h1_h2_protos())
122 def test_13_07_tunnels_no_auth(self, env: Env, httpd, configures_httpd, nghttpx_fwd, proto, tunnel):
123 self.httpd_configure(env, httpd)
124 if tunnel == 'h2' and not env.curl_uses_lib('nghttp2'):
125 pytest.skip('only supported with nghttp2')
126 curl = CurlClient(env=env)
127 url = f'https://localhost:{env.https_port}/data.json'
128 xargs = curl.get_proxy_args(proxys=True, tunnel=True, proto=tunnel)
129 r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
130 extra_args=xargs)
131 # expect "COULD_NOT_CONNECT"
132 r.check_response(exitcode=7, http_status=None)
133 assert self.get_tunnel_proto_used(r) == tunnel
135 @pytest.mark.skipif(condition=not Env.have_nghttpx(), reason="no nghttpx available")
136 @pytest.mark.skipif(condition=not Env.curl_has_feature('HTTPS-proxy'),
137 reason='curl lacks HTTPS-proxy support')
138 @pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug")
139 @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings")
140 @pytest.mark.parametrize("proto", Env.http_h1_h2_protos())
141 @pytest.mark.parametrize("tunnel", Env.http_h1_h2_protos())
142 def test_13_08_tunnels_auth(self, env: Env, httpd, configures_httpd, nghttpx_fwd, proto, tunnel):
143 self.httpd_configure(env, httpd)
144 if tunnel == 'h2' and not env.curl_uses_lib('nghttp2'):
145 pytest.skip('only supported with nghttp2')
146 curl = CurlClient(env=env)
147 url = f'https://localhost:{env.https_port}/data.json'
148 xargs = curl.get_proxy_args(proxys=True, tunnel=True, proto=tunnel)
149 xargs.extend(['--proxy-user', 'proxy:proxy'])
150 r = curl.http_download(urls=[url], alpn_proto=proto, with_stats=True,
151 extra_args=xargs)
152 r.check_response(count=1, http_status=200,
153 protocol='HTTP/2' if proto == 'h2' else 'HTTP/1.1')
154 assert self.get_tunnel_proto_used(r) == tunnel
156 @pytest.mark.skipif(condition=not Env.curl_has_feature('SPNEGO'),
157 reason='curl lacks SPNEGO support')
158 def test_13_09_negotiate_http(self, env: Env, httpd, configures_httpd):
159 self.httpd_configure(env, httpd)
160 run_env = os.environ.copy()
161 run_env['https_proxy'] = f'http://127.0.0.1:{env.proxy_port}'
162 curl = CurlClient(env=env, run_env=run_env)
163 url = f'https://localhost:{env.https_port}/data.json'
164 r1 = curl.http_download(urls=[url], alpn_proto='http/1.1', with_stats=True, extra_args=[
165 '--negotiate', '--proxy-user', 'proxy:proxy'
166 ])
167 r1.check_response(count=1, http_status=200)
169 def test_13_10_tunnels_mixed_auth(self, env: Env, httpd, configures_httpd):
170 self.httpd_configure(env, httpd)
171 curl = CurlClient(env=env)
172 url1 = f'http://localhost:{env.http_port}/data.json?1'
173 url2 = f'http://localhost:{env.http_port}/data.json?2'
174 url3 = f'http://localhost:{env.http_port}/data.json?3'
175 xargs1 = curl.get_proxy_args(proxys=False, tunnel=True)
176 xargs1.extend(['--proxy-user', 'proxy:proxy']) # good auth
177 xargs2 = curl.get_proxy_args(proxys=False, tunnel=True)
178 xargs2.extend(['--proxy-user', 'ungood:ungood']) # bad auth
179 xargs3 = curl.get_proxy_args(proxys=False, tunnel=True)
180 # no auth
181 r = curl.http_download(urls=[url1, url2, url3], alpn_proto='http/1.1', with_stats=True,
182 url_options={url1: xargs1, url2: xargs2, url3: xargs3})
183 # only url1 succeeds, others fail, no connection reuse
184 assert r.stats[0]['http_code'] == 200, f'{r.dump_logs()}'
185 assert r.stats[1]['http_code'] == 0, f'{r.dump_logs()}'
186 assert r.stats[2]['http_code'] == 0, f'{r.dump_logs()}'
187 assert r.total_connects == 3, f'{r.dump_logs()}'
Diagnostics4 git calls · 29 ms
CallStatusSizeTime029 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=UPDATING
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2002.1 KiB · hit23 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=23
git.response.bytes=2113
git.response.cache=HIT
git.response.duration_ms=23
git.fetch.wants=4e5d45e91882cbf283a6b834f2e6bdf4e6e95b5d
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2113
git.pkt.payload.max=2092
git.sideband.band1.bytes=2091
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e297ac8c672407
Request
57cd1e18…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format