From patchwork Wed Jun 26 20:54:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13713426 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95B678F47 for ; Wed, 26 Jun 2024 20:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.130.231.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719435275; cv=none; b=pre7tYYaSfWpogxmLmee3IX+VNhFsSLC4PV5yLTk9Q4uc+0YEkmI+wPm4fu0Op+3sdKWiW3JHU0VJFbi54Zntks0USXGcYCGf8JhjX99SPbgaFJriuO650RdHRNWeMbltT/GdMlgkf9q8YIPB5P4lbJwMiaueSdpsPYUrwXnjL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719435275; c=relaxed/simple; bh=xys1S4AX7ZY9PMt9bxQoBf3J9XdaLtTgtl8H39QRIAs=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mQ8c28J8Se1KdjbcaVwLCZnzXPxR82eISYAuRTv6J6eQAR5H+6ZEYmAVRrpfY0ntKaddLFPgT7nX+RMuvBSB6FqXOgBGeekVnb6bq/HyydlJoCcEojsV5zQPgk+Ld4M9Q1QFrUpywEAQ/GkD1iTu99hdafgDC8RMW8gHcmGF5Pg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=peff.net; spf=pass smtp.mailfrom=peff.net; arc=none smtp.client-ip=104.130.231.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=peff.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peff.net Received: (qmail 26011 invoked by uid 109); 26 Jun 2024 20:54:30 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 26 Jun 2024 20:54:30 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 25182 invoked by uid 111); 26 Jun 2024 20:54:29 -0000 Received: from Unknown (HELO coredump.intra.peff.net) (10.0.1.3) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 26 Jun 2024 16:54:29 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 26 Jun 2024 16:54:28 -0400 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 1/3] t5553: use local url for invalid fetch Message-ID: <20240626205428.GA1457138@coredump.intra.peff.net> References: <20240626205355.GA1009060@coredump.intra.peff.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240626205355.GA1009060@coredump.intra.peff.net> We test how "fetch --set-upstream" behaves when given an invalid URL, using the bogus URL "http://nosuchdomain.example.com". But finding out that it is invalid requires an actual DNS lookup. Reduce our dependency on external factors by using an invalid local filesystem URL, which works just as well for our purposes. Signed-off-by: Jeff King --- t/t5553-set-upstream.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh index 48050162c2..70e3376d31 100755 --- a/t/t5553-set-upstream.sh +++ b/t/t5553-set-upstream.sh @@ -73,10 +73,10 @@ test_expect_success 'fetch --set-upstream main:other does not set the branch oth check_config_missing other2 ' -test_expect_success 'fetch --set-upstream http://nosuchdomain.example.com fails with invalid url' ' +test_expect_success 'fetch --set-upstream ./does-not-exist fails with invalid url' ' # main explicitly not cleared, we check that it is not touched from previous value clear_config other other2 && - test_must_fail git fetch --set-upstream http://nosuchdomain.example.com && + test_must_fail git fetch --set-upstream ./does-not-exist && check_config main upstream refs/heads/other && check_config_missing other && check_config_missing other2 @@ -143,10 +143,10 @@ test_expect_success 'pull --set-upstream upstream tag does not set the tag' ' check_config_missing three ' -test_expect_success 'pull --set-upstream http://nosuchdomain.example.com fails with invalid url' ' +test_expect_success 'pull --set-upstream ./does-not-exist fails with invalid url' ' # main explicitly not cleared, we check that it is not touched from previous value clear_config other other2 three && - test_must_fail git pull --set-upstream http://nosuchdomain.example.com && + test_must_fail git pull --set-upstream ./does-not-exist && check_config main upstream refs/heads/other && check_config_missing other && check_config_missing other2 && From patchwork Wed Jun 26 20:55:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13713427 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 187588F47 for ; Wed, 26 Jun 2024 20:55:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.130.231.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719435330; cv=none; b=aq+1UyX2+3jxeurNGgsQZgnek2Lhk8GreR+eL4KWby8lOhSC34fjUb36zjxzIxUMJyXGBXp/LF4ATMFcuPqWMt86RqG0v91N8mqv5tPmr4k4M82LkfemIDy4jP2qsh2Ba90aoe4aSo7CWcnfDKltSjGD0xbZfuJDEcl4bnnpfCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719435330; c=relaxed/simple; bh=iZZ+3Di3p5blLU+uPIrlQ2n3urJ+y86QsaO0p8oEbdY=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QmhFVo9qVq2BF16kM5RzGCq6Ctrg+mr6YgqiqeuVqHVBxb1Ivz7lMxj73Et7eF+XNHfAc0jy50TUvQGGE2FnpVFO14cznnFThoiyhxEQGdrDG6TLIMB3M03tmp2fO+piGWAA+UbRxG5DBDEMfWyrY6ksDFBseDgyAxicfMZwbF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=peff.net; spf=pass smtp.mailfrom=peff.net; arc=none smtp.client-ip=104.130.231.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=peff.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peff.net Received: (qmail 26066 invoked by uid 109); 26 Jun 2024 20:55:28 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 26 Jun 2024 20:55:28 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 25216 invoked by uid 111); 26 Jun 2024 20:55:26 -0000 Received: from Unknown (HELO coredump.intra.peff.net) (10.0.1.3) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 26 Jun 2024 16:55:26 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 26 Jun 2024 16:55:25 -0400 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 2/3] t5551: do not confirm that bogus url cannot be used Message-ID: <20240626205525.GB1457138@coredump.intra.peff.net> References: <20240626205355.GA1009060@coredump.intra.peff.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240626205355.GA1009060@coredump.intra.peff.net> t5551 tries to access a URL with a bogus hostname and confirms that http.curloptResolve lets us use this otherwise unresolvable name. Before doing so, though, we confirm that trying to access the bogus hostname without http.curloptResolve fails as expected. This isn't testing Git at all, but is confirming the test's assumptions. That's often a good thing to do, but in this case it means that we'll actually try to resolve the external name. Even though it's unlikely that "gitbogusexamplehost.invalid" would ever resolve, the DNS lookup itself may take time. It's probably reasonable to just assume that this obviously-bogus name would not actually resolve in practice, which lets us reduce our test suite's dependency on the outside world. Signed-off-by: Jeff King --- t/t5551-http-fetch-smart.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh index a623a1058c..7b5ab0eae1 100755 --- a/t/t5551-http-fetch-smart.sh +++ b/t/t5551-http-fetch-smart.sh @@ -643,7 +643,6 @@ test_expect_success 'clone empty SHA-256 repository with protocol v0' ' test_expect_success 'passing hostname resolution information works' ' BOGUS_HOST=gitbogusexamplehost.invalid && BOGUS_HTTPD_URL=$HTTPD_PROTO://$BOGUS_HOST:$LIB_HTTPD_PORT && - test_must_fail git ls-remote "$BOGUS_HTTPD_URL/smart/repo.git" >/dev/null && git -c "http.curloptResolve=$BOGUS_HOST:$LIB_HTTPD_PORT:127.0.0.1" ls-remote "$BOGUS_HTTPD_URL/smart/repo.git" >/dev/null ' From patchwork Wed Jun 26 20:57:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff King X-Patchwork-Id: 13713429 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1A1A8F47 for ; Wed, 26 Jun 2024 20:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=104.130.231.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719435470; cv=none; b=mD3YuhUsqdH4MHAD9smC5vN70jYai7sOyVSO3v6giWJmk76ybHzmShUGDQMocJPFVW1qDS9h+ezhf8vuBKf/w1AIu/9D4YlyOptUtrfFXLDXaGwryhL59w62neL1StHxV5XYIbBA35yJ8BKJ/9wYy8TAk8bNvkfKzxNmhU+u0EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719435470; c=relaxed/simple; bh=py/ZcYIsM2S62F8hMqJIi8l2VOb08GM12fGAJUoKrhQ=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VcwaWV7hrIgpC1o7wDnkpsTgqhMoKl2er/cRpfVchmSIsRs8pS/gEPq0HLkIgtK+3XigliZUgjjESOGIe9T9Y7jVWWl37yuMrM0E/dDXDmPIKKSX0ZadJxdu8ui2sB0ivc8HH+qA/DsP/+59FYR4uNAQYyrdX612kaiqc/G3Ne4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=peff.net; spf=pass smtp.mailfrom=peff.net; arc=none smtp.client-ip=104.130.231.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=peff.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peff.net Received: (qmail 26195 invoked by uid 109); 26 Jun 2024 20:57:48 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 26 Jun 2024 20:57:48 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 25221 invoked by uid 111); 26 Jun 2024 20:57:46 -0000 Received: from Unknown (HELO coredump.intra.peff.net) (10.0.1.3) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 26 Jun 2024 16:57:46 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 26 Jun 2024 16:57:45 -0400 From: Jeff King To: git@vger.kernel.org Subject: [PATCH 3/3] t/lib-bundle-uri: use local fake bundle URLs Message-ID: <20240626205745.GC1457138@coredump.intra.peff.net> References: <20240626205355.GA1009060@coredump.intra.peff.net> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240626205355.GA1009060@coredump.intra.peff.net> A few of the bundle URI tests point config at a fake bundle; they care only that the client has been configured with _some_ bundle, but it doesn't have to actually contain objects. For the file:// tests, we use "$BUNDLE_URI_REPO_URI/fake.bdl", a non-existent file inside the actual remote repo. But for git:// and http:// tests, we use "https://example.com/fake.bdl". This works OK in practice, but it means we actually make a request to example.com (which returns a placeholder HTML response). That can be annoying when running the test suite on a spotty network (it doesn't produce a wrong result, since we expect it to fail, but it may introduce delays). We can reduce our dependency on the outside world by using a local URL. It would work to just do "file://$PWD/fake.bdl" here, since the bundle code does not care about the actual location. But in the long run I suspect we may have more restrictions on which protocols can be passed around as bundle URIs. So instead, let's stick with the file:// repo's pattern and just point to a bogus name based on the remote repo's URL. For http this makes perfect sense; we'll make a request to the local http server and find that there's nothing there. For git:// it's a little weird, as you wouldn't normally access a bundle file over git:// at all. But it's probably the most reasonable guess we can make for now, and anybody who tightens protocol selection later will know better what's the best path forward. Signed-off-by: Jeff King --- t/lib-bundle-uri-protocol.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/lib-bundle-uri-protocol.sh b/t/lib-bundle-uri-protocol.sh index a4a1af8d02..de09b6b02e 100644 --- a/t/lib-bundle-uri-protocol.sh +++ b/t/lib-bundle-uri-protocol.sh @@ -18,15 +18,15 @@ git) start_git_daemon --export-all --enable=receive-pack BUNDLE_URI_PARENT="$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent" BUNDLE_URI_REPO_URI="$GIT_DAEMON_URL/parent" - BUNDLE_URI_BUNDLE_URI="https://example.com/fake.bdl" + BUNDLE_URI_BUNDLE_URI="$BUNDLE_URI_REPO_URI/fake.bdl" test_set_prereq BUNDLE_URI_GIT ;; http) . "$TEST_DIRECTORY"/lib-httpd.sh start_httpd BUNDLE_URI_PARENT="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" BUNDLE_URI_REPO_URI="$HTTPD_URL/smart/http_parent" - BUNDLE_URI_BUNDLE_URI="https://example.com/fake.bdl" + BUNDLE_URI_BUNDLE_URI="$BUNDLE_URI_REPO_URL/fake.bdl" test_set_prereq BUNDLE_URI_HTTP ;; *)