Artifactspublic-v0

curl

master
ply4 git calls298 ms289 KiB2 cachedprotocol v2
178 lines8.0 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
32log = logging.getLogger(__name__)
35@pytest.mark.skipif(condition=not Env.curl_has_feature('ECH'), reason="no curl ECH support")
36@pytest.mark.skipif(condition=not Env.have_nghttpx_ech(), reason="no nghttpx ECH support")
37@pytest.mark.skipif(condition=not Env.have_openssl_ech(), reason="no openssl cmd ECH support")
38@pytest.mark.skipif(condition=not Env.curl_is_debug(), reason="needs curl debug")
39class TestECH:
41 @pytest.mark.parametrize("ech_mode, exp_result, exp_exit", [
42 ['false', None, 0],
43 ['grease', 'sent GREASE', 0],
44 ['true', 'not configured', 0],
45 ['hard', None, 35] # CURLE_SSL_CONNECT_ERROR
46 ])
47 def test_23_01_ech_no_config(self, env: Env, httpd, nghttpx_tcp, ech_mode, exp_result, exp_exit):
48 run_env = os.environ.copy()
49 curl = CurlClient(env=env, run_env=run_env)
50 url = f'https://{env.domain1}:{nghttpx_tcp.port}/data.json'
51 r = curl.http_download(urls=[url], with_stats=True, extra_args=[
52 '--ech', ech_mode
53 ])
54 r.check_exit_code(exp_exit)
55 if exp_exit == 0:
56 r.check_stats(count=1, http_status=200, exitcode=0)
57 if env.curl_uses_lib('openssl'):
58 ech_result, _, _ = self._get_ech_result(r)
59 assert ech_result == exp_result, f'{r.dump_logs()}'
61 @pytest.mark.parametrize("ech_mode, exp_result, exp_exit", [
62 ['false', None, 0],
63 ['grease', 'sent GREASE', 0],
64 ['true', 'succeeded', 0],
65 ['hard', 'succeeded', 0]
66 ])
67 def test_23_02_ech_good_config(self, env: Env, httpd, nghttpx_tcp, ech_mode, exp_result, exp_exit):
68 run_env = os.environ.copy()
69 curl = CurlClient(env=env, run_env=run_env)
70 url = f'https://{env.domain1}:{nghttpx_tcp.port}/data.json'
71 ech_config = env.get_echconfig_arg(env.domain1)
72 r = curl.http_download(urls=[url], with_stats=True, extra_args=[
73 '--ech', ech_mode, '--ech', f'ecl:{ech_config}'
74 ])
75 r.check_exit_code(exp_exit)
76 if exp_exit == 0:
77 r.check_stats(count=1, http_status=200, exitcode=0)
78 if env.curl_uses_lib('openssl'):
79 ech_result, inner, outer = self._get_ech_result(r)
80 assert ech_result == exp_result, f'{r.dump_logs()}'
81 if ech_result == 'succeeded':
82 assert inner == env.domain1, f'{r.dump_logs()}'
83 assert outer == f'public.{env.domain1}', f'{r.dump_logs()}'
85 @pytest.mark.parametrize("ech_mode, exp_result, exp_exit", [
86 ['false', None, 0],
87 ['grease', 'sent GREASE', 0],
88 ['true', 'rejected', 101], # CURLE_ECH_REQUIRED
89 ['hard', 'rejected', 101]
90 ])
91 def test_23_03_ech_bad_config(self, env: Env, httpd, nghttpx_tcp, ech_mode, exp_result, exp_exit):
92 run_env = os.environ.copy()
93 curl = CurlClient(env=env, run_env=run_env)
94 url = f'https://{env.domain1}:{nghttpx_tcp.port}/data.json'
95 ech_config = env.get_echconfig_arg(env.domain2)
96 r = curl.http_download(urls=[url], with_stats=True, extra_args=[
97 '--ech', ech_mode, '--ech', f'ecl:{ech_config}'
98 ])
99 if env.curl_uses_lib('wolfssl'):
100 # wolfssl ECH errors result in CURLE_PEER_FAILED_VERIFICATION
101 exp_exit = 60 if exp_exit else 0
102 elif env.curl_uses_lib('rustls-ffi'):
103 # rustls ECH errors result in CURLE_SSL_CONNECT_ERROR
104 exp_exit = 35 if exp_exit else 0
105 r.check_exit_code(exp_exit)
106 if env.curl_uses_lib('openssl'):
107 ech_result, _, _ = self._get_ech_result(r)
108 assert ech_result == exp_result, f'{r.dump_logs()}'
110 @pytest.mark.skipif(condition=not Env.curl_uses_lib('openssl'),
111 reason="needs OpenSSL")
112 @pytest.mark.parametrize("ech_mode, exp_result, pub_domain", [
113 ['true', 'succeeded', 'innocent.invalid'],
114 ['hard', 'succeeded', 'innocent.invalid'],
115 ])
116 def test_23_04_ech_outer(self, env: Env, httpd, nghttpx_tcp, ech_mode, exp_result, pub_domain):
117 run_env = os.environ.copy()
118 curl = CurlClient(env=env, run_env=run_env)
119 url = f'https://{env.domain1}:{nghttpx_tcp.port}/data.json'
120 ech_config = env.get_echconfig_arg(env.domain1)
121 r = curl.http_download(urls=[url], with_stats=True, extra_args=[
122 '--ech', ech_mode, '--ech', f'ecl:{ech_config}', '--ech', f'pn:{pub_domain}'
123 ])
124 r.check_exit_code(0)
125 r.check_stats(count=1, http_status=200, exitcode=0)
126 ech_result, inner, outer = self._get_ech_result(r)
127 assert ech_result == exp_result, f'{r.dump_logs()}'
128 assert inner == env.domain1, f'{r.dump_logs()}'
129 assert outer == pub_domain, f'{r.dump_logs()}'
131 def test_23_05_ech_conn_ech_reuse(self, env: Env, httpd, nghttpx_tcp):
132 run_env = os.environ.copy()
133 curl = CurlClient(env=env, run_env=run_env)
134 url1 = f'https://{env.domain1}:{nghttpx_tcp.port}/data1.json'
135 url2 = f'https://{env.domain1}:{nghttpx_tcp.port}/data2.json'
136 r = curl.http_download(urls=[url1, url2], with_stats=True, url_options={
137 url1: ['--ech', 'false'],
138 url2: ['--ech', 'true']
139 })
140 r.check_exit_code(0), f'{r}'
141 r.check_response(http_status=404, count=2, connect_count=2)
143 def test_23_06_ech_conn_ech_config_reuse(self, env: Env, httpd, nghttpx_tcp):
144 run_env = os.environ.copy()
145 curl = CurlClient(env=env, run_env=run_env)
146 url1 = f'https://{env.domain1}:{nghttpx_tcp.port}/data1.json'
147 url2 = f'https://{env.domain1}:{nghttpx_tcp.port}/data2.json'
148 ech_config = env.get_echconfig_arg(env.domain1)
149 r = curl.http_download(urls=[url1, url2], with_stats=True, url_options={
150 url1: ['--ech', 'true'],
151 url2: ['--ech', 'true', '--ech', f'ecl:{ech_config}']
152 })
153 r.check_exit_code(0), f'{r}'
154 r.check_response(http_status=404, count=2, connect_count=2)
156 @pytest.mark.skipif(condition=not Env.curl_uses_lib('openssl'),
157 reason="needs OpenSSL")
158 def test_23_07_ech_conn_ech_pub_reuse(self, env: Env, httpd, nghttpx_tcp):
159 run_env = os.environ.copy()
160 curl = CurlClient(env=env, run_env=run_env)
161 url1 = f'https://{env.domain1}:{nghttpx_tcp.port}/data1.json'
162 url2 = f'https://{env.domain1}:{nghttpx_tcp.port}/data2.json'
163 r = curl.http_download(urls=[url1, url2], with_stats=True, url_options={
164 url1: ['--ech', 'true'],
165 url2: ['--ech', 'true', '--ech', 'pn:innocent.invalid']
166 })
167 r.check_exit_code(0), f'{r}'
168 r.check_response(http_status=404, count=2, connect_count=2)
170 def _get_ech_result(self, r):
171 for line in r.trace_lines:
172 m = re.search(r'ECH: result \'(.+)\' \(inner=(.+), outer=(.+)\)', line)
173 if m:
174 return m.group(1), m.group(2), m.group(3)
175 m = re.search(r'ECH: rejected(.*)', line)
176 if m:
177 return 'rejected', None, None
178 return None, None, None
Diagnostics4 git calls · 298 ms
CallStatusSizeTime0298 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 B · hit2 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=HIT
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 · hit3 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=3
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
fetch2001.8 KiB293 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=293
git.response.bytes=1792
git.response.cache=MISS
git.response.duration_ms=293
git.fetch.wants=c436f069ea7c60cea5705efe524edf917b6eb898
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=1792
git.pkt.payload.max=1771
git.sideband.band1.bytes=1770
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
a5e2b365ba2dcf33
Request
2f565a25…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format