Artifactspublic-v0

curl

master
ply4 git calls61 ms289 KiB3 cachedprotocol v2
223 lines7.2 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.
13 *
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.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
26#ifndef CURL_DISABLE_NETRC
27#include "netrc.h"
28#include "creds.h"
30static CURLcode t1304_setup(struct Curl_easy **easy)
32 CURLcode result = CURLE_OK;
34 global_init(CURL_GLOBAL_ALL);
35 *easy = curl_easy_init();
36 if(!*easy) {
37 curl_global_cleanup();
38 return CURLE_OUT_OF_MEMORY;
39 }
40 return result;
43static void t1304_stop(struct Curl_easy *easy)
45 curl_easy_cleanup(easy);
46 curl_global_cleanup();
49static bool t1304_no_user(struct Curl_creds *creds)
51 return !creds || !creds->user[0];
54static bool t1304_no_passwd(struct Curl_creds *creds)
56 return !creds || !creds->passwd[0];
59static void t1304_empty_literals(struct Curl_easy *data, const char *filename)
61 static const struct {
62 const char *content;
63 NETRCcode result;
64 const char *login;
65 const char *passwd;
66 } tests[] = {
67 { "default login \"\"", NETRC_OK, "", "" },
68 { "default password \"\"", NETRC_OK, "", "" },
69 { "default login \"\" password secret", NETRC_OK, "", "secret" },
70 { "default password \"\" login admin", NETRC_OK, "admin", "" },
71 { "default login \"\" password \"\"", NETRC_OK, "", "" },
72 { "machine \"\" login ignored password ignored",
73 NETRC_NO_MATCH, NULL, NULL },
74 { "machine \"\" login ignored password ignored\n"
75 "machine example.com login admin password passwd",
76 NETRC_OK, "admin", "passwd" },
77 { "machine example.com login \"\" password \"\"", NETRC_OK, "", "" }
78 };
79 size_t i;
81 for(i = 0; i < CURL_ARRAYSIZE(tests); ++i) {
82 struct store_netrc store;
83 struct Curl_creds *creds = NULL;
84 CURLcode result;
85 NETRCcode res;
87 /* Each cached file starts a fresh lexer, so an empty first literal
88 * cannot rely on an allocation from a previous nonempty literal. */
89 Curl_netrc_init(&store);
90 result = curlx_dyn_add(&store.filebuf, tests[i].content);
91 fail_unless(result == CURLE_OK, "could not store netrc content");
92 store.filename = curlx_strdup(filename);
93 fail_unless(store.filename, "could not store netrc filename");
94 if(!result && store.filename) {
95 store.loaded = TRUE;
96 res = Curl_netrc_scan(data, &store, "example.com", NULL,
97 filename, &creds);
98 fail_unless(res == tests[i].result, "unexpected netrc result");
99 if(tests[i].result == NETRC_OK) {
100 fail_unless(creds, "credentials should have been found");
101 fail_unless(!strcmp(Curl_creds_user(creds), tests[i].login),
102 "unexpected login");
103 fail_unless(!strcmp(Curl_creds_passwd(creds), tests[i].passwd),
104 "unexpected password");
105 }
106 else
107 fail_unless(!creds, "credentials should not have been found");
108 }
109 Curl_creds_unlink(&creds);
110 Curl_netrc_cleanup(&store);
111 }
114static CURLcode test_unit1304(const char *arg)
116 struct Curl_creds *cr_out = NULL;
117 struct Curl_easy *data;
118 NETRCcode res;
119 struct store_netrc store;
121 UNITTEST_BEGIN(t1304_setup(&data))
123 /*
124 * Test a non existent host in our netrc file.
125 */
126 Curl_netrc_init(&store);
127 res = Curl_netrc_scan(data, &store, "test.example.com", NULL, arg, &cr_out);
128 fail_unless(res == NETRC_NO_MATCH, "expected no match");
129 fail_unless(!cr_out, "creds did not return NULL!");
130 Curl_netrc_cleanup(&store);
132 /*
133 * Test a non existent login in our netrc file.
134 */
135 Curl_netrc_init(&store);
136 res = Curl_netrc_scan(data, &store, "example.com", "me", arg, &cr_out);
137 fail_unless(res == NETRC_NO_MATCH, "expected no match");
138 fail_unless(t1304_no_passwd(cr_out), "password is not NULL!");
139 Curl_netrc_cleanup(&store);
141 /*
142 * Test a non existent login and host in our netrc file.
143 */
144 Curl_netrc_init(&store);
145 res = Curl_netrc_scan(data, &store, "test.example.com", "me", arg, &cr_out);
146 fail_unless(res == NETRC_NO_MATCH, "expected no match");
147 fail_unless(t1304_no_passwd(cr_out), "password is not NULL!");
148 Curl_netrc_cleanup(&store);
150 /*
151 * Test a non existent login (substring of an existing one) in our
152 * netrc file.
153 */
154 Curl_netrc_init(&store);
155 res = Curl_netrc_scan(data, &store, "example.com", "a", arg, &cr_out);
156 fail_unless(res == NETRC_NO_MATCH, "expected no match");
157 fail_unless(t1304_no_passwd(cr_out), "password is not NULL!");
158 Curl_netrc_cleanup(&store);
160 /*
161 * Test a non existent login (superstring of an existing one)
162 * in our netrc file.
163 */
164 Curl_netrc_init(&store);
165 res = Curl_netrc_scan(
166 data, &store, "example.com", "administrator", arg, &cr_out);
167 fail_unless(res == NETRC_NO_MATCH, "expected no match");
168 fail_unless(t1304_no_passwd(cr_out), "password is not NULL!");
169 Curl_netrc_cleanup(&store);
171 /*
172 * Test for the first existing host in our netrc file with no user
173 */
174 Curl_netrc_init(&store);
175 res = Curl_netrc_scan(data, &store, "example.com", NULL, arg, &cr_out);
176 fail_unless(res == NETRC_OK, "Host should have been found");
177 fail_unless(!strncmp(Curl_creds_passwd(cr_out), "passwd", 6),
178 "password should be 'passwd'");
179 fail_unless(!t1304_no_user(cr_out), "returned NULL!");
180 fail_unless(!strncmp(Curl_creds_user(cr_out), "admin", 5),
181 "login should be 'admin'");
182 Curl_netrc_cleanup(&store);
184 /*
185 * Test for the second existing host in our netrc file with no user
186 */
187 Curl_netrc_init(&store);
188 res = Curl_netrc_scan(data, &store, "curl.example.com", NULL, arg, &cr_out);
189 fail_unless(res == NETRC_OK, "Host should have been found");
190 fail_unless(!strncmp(Curl_creds_passwd(cr_out), "none", 4),
191 "password should be 'none'");
192 fail_unless(!t1304_no_user(cr_out), "returned NULL!");
193 fail_unless(!strncmp(Curl_creds_user(cr_out), "none", 4),
194 "login should be 'none'");
195 Curl_netrc_cleanup(&store);
197 /*
198 * Test for the last host where we do not want to see the password
199 * if the login does not match.
200 */
201 Curl_netrc_init(&store);
202 res = Curl_netrc_scan(
203 data, &store, "curl.example.com", "hilarious", arg, &cr_out);
204 fail_unless(res == NETRC_NO_MATCH, "expect no match");
205 fail_unless(!Curl_creds_has_passwd(cr_out), "password must be NULL");
206 Curl_netrc_cleanup(&store);
208 Curl_creds_unlink(&cr_out);
210 t1304_empty_literals(data, arg);
212 UNITTEST_END(t1304_stop(data))
215#else
217static CURLcode test_unit1304(const char *arg)
219 UNITTEST_BEGIN_SIMPLE
220 UNITTEST_END_SIMPLE
223#endif
Diagnostics4 git calls · 61 ms
CallStatusSizeTime061 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
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 · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
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 · hit26 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=26
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.0 KiB · hit32 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=32
git.response.bytes=2096
git.response.cache=HIT
git.response.duration_ms=32
git.fetch.wants=6f9526b491b7a15a3a238352cf61efaeb25475ca
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=2096
git.pkt.payload.max=2075
git.sideband.band1.bytes=2074
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
a5e2002d5cb4a9c0
Request
e8c25668…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format