diff mbox series

[2/2] t5516/t5601: be less strict about the number of credential warnings

Message ID 98fa5270cb720f2f038c4bb9571c7d306ff5d759.1667245639.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series t5516/t5601: avoid using localhost for failing HTTPS requests | expand

Commit Message

Johannes Schindelin Oct. 31, 2022, 7:47 p.m. UTC
From: Johannes Schindelin <johannes.schindelin@gmx.de>

It is unclear as to _why_, but under certain circumstances the warning
about credentials being passed as part of the URL seems to be swallowed
by the `git remote-https` helper in the Windows jobs of Git's CI builds.

Since it is not actually important how many times Git prints the
warning/error message, as long as it prints it at least once, let's just
make the test a bit more lenient and test for the latter instead of the
former, which works around these CI issues.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t5516-fetch-push.sh | 8 ++++----
 t/t5601-clone.sh      | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Jeff King Oct. 31, 2022, 11:22 p.m. UTC | #1
On Mon, Oct 31, 2022 at 07:47:18PM +0000, Johannes Schindelin via GitGitGadget wrote:

> From: Johannes Schindelin <johannes.schindelin@gmx.de>
> 
> It is unclear as to _why_, but under certain circumstances the warning
> about credentials being passed as part of the URL seems to be swallowed
> by the `git remote-https` helper in the Windows jobs of Git's CI builds.
> 
> Since it is not actually important how many times Git prints the
> warning/error message, as long as it prints it at least once, let's just
> make the test a bit more lenient and test for the latter instead of the
> former, which works around these CI issues.

This makes sense to me. Regardless of whether we actually fix the
multiple outputs (which are user-visible and kind of ugly), I don't
think there's any reason for our tests to assert the somewhat
undesirable output. So this can proceed independently of any fix.

> diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
> index 8dd4610a8c2..980c594940b 100755
> --- a/t/t5516-fetch-push.sh
> +++ b/t/t5516-fetch-push.sh
> @@ -1860,15 +1860,15 @@ test_expect_success LIBCURL 'fetch warns or fails when using username:password'
>  
>  	test_must_fail git -c transfer.credentialsInUrl=warn fetch https://username:password@224.0.0.1 2>err &&
>  	grep "warning: $message" err >warnings &&
> -	test_line_count = 3 warnings &&
> +	test_line_count -ge 1 warnings &&

I think this test_line_count (and all the others) is now superfluous;
the exit code of grep will tell us if we found anything.

I don't mind it too much, though, if we're planning to fix the duplicate
messages, at which point it becomes s/-ge/=/.

-Peff
Taylor Blau Nov. 1, 2022, 12:57 a.m. UTC | #2
On Mon, Oct 31, 2022 at 07:22:48PM -0400, Jeff King wrote:
> > diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
> > index 8dd4610a8c2..980c594940b 100755
> > --- a/t/t5516-fetch-push.sh
> > +++ b/t/t5516-fetch-push.sh
> > @@ -1860,15 +1860,15 @@ test_expect_success LIBCURL 'fetch warns or fails when using username:password'
> >
> >  	test_must_fail git -c transfer.credentialsInUrl=warn fetch https://username:password@224.0.0.1 2>err &&
> >  	grep "warning: $message" err >warnings &&
> > -	test_line_count = 3 warnings &&
> > +	test_line_count -ge 1 warnings &&
>
> I think this test_line_count (and all the others) is now superfluous;
> the exit code of grep will tell us if we found anything.
>
> I don't mind it too much, though, if we're planning to fix the duplicate
> messages, at which point it becomes s/-ge/=/.

Yeah, agreed. Let's leave it alone, unless somebody else feels strongly.

Thanks,
Taylor
Jeff King Nov. 1, 2022, 2:27 a.m. UTC | #3
On Mon, Oct 31, 2022 at 07:47:18PM +0000, Johannes Schindelin via GitGitGadget wrote:

> diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
> index 0b386c74818..b72cdeb6243 100755
> --- a/t/t5601-clone.sh
> +++ b/t/t5601-clone.sh
> @@ -78,19 +78,19 @@ test_expect_success LIBCURL 'clone warns or fails when using username:password'
>  
>  	test_must_fail git -c transfer.credentialsInUrl=warn clone https://username:password@224.0.0.1 attempt2 2>err &&
>  	grep "warning: $message" err >warnings &&
> -	test_line_count = 2 warnings &&
> +	test_line_count -ge 1 warnings &&
>  
>  	test_must_fail git -c transfer.credentialsInUrl=die clone https://username:password@224.0.0.1 attempt3 2>err &&
>  	grep "fatal: $message" err >warnings &&
> -	test_line_count = 1 warnings &&
> +	test_line_count -ge 1 warnings &&
>  
>  	test_must_fail git -c transfer.credentialsInUrl=die clone https://username:@224.0.0.1 attempt3 2>err &&
>  	grep "fatal: $message" err >warnings &&
> -	test_line_count = 1 warnings
> +	test_line_count -ge 1 warnings
>  '
>  
>  test_expect_success LIBCURL 'clone does not detect username:password when it is https://username@domain:port/' '
> -	test_must_fail git -c transfer.credentialsInUrl=warn clone https://username@localhost:8080 attempt3 2>err &&
> +	test_must_fail git -c transfer.credentialsInUrl=warn clone https://username@224.0.0.1:8080 attempt3 2>err &&
>  	! grep "uses plaintext credentials" err
>  '

By the way, this last part of the hunk obviously belongs in the first
patch. I adjusted as appropriate in the patch I just sent.

-Peff
diff mbox series

Patch

diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 8dd4610a8c2..980c594940b 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1860,15 +1860,15 @@  test_expect_success LIBCURL 'fetch warns or fails when using username:password'
 
 	test_must_fail git -c transfer.credentialsInUrl=warn fetch https://username:password@224.0.0.1 2>err &&
 	grep "warning: $message" err >warnings &&
-	test_line_count = 3 warnings &&
+	test_line_count -ge 1 warnings &&
 
 	test_must_fail git -c transfer.credentialsInUrl=die fetch https://username:password@224.0.0.1 2>err &&
 	grep "fatal: $message" err >warnings &&
-	test_line_count = 1 warnings &&
+	test_line_count -ge 1 warnings &&
 
 	test_must_fail git -c transfer.credentialsInUrl=die fetch https://username:@224.0.0.1 2>err &&
 	grep "fatal: $message" err >warnings &&
-	test_line_count = 1 warnings
+	test_line_count -ge 1 warnings
 '
 
 
@@ -1881,7 +1881,7 @@  test_expect_success LIBCURL 'push warns or fails when using username:password' '
 	grep "warning: $message" err >warnings &&
 	test_must_fail git -c transfer.credentialsInUrl=die push https://username:password@224.0.0.1 2>err &&
 	grep "fatal: $message" err >warnings &&
-	test_line_count = 1 warnings
+	test_line_count -ge 1 warnings
 '
 
 test_expect_success 'push with config push.useBitmaps' '
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 0b386c74818..b72cdeb6243 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -78,19 +78,19 @@  test_expect_success LIBCURL 'clone warns or fails when using username:password'
 
 	test_must_fail git -c transfer.credentialsInUrl=warn clone https://username:password@224.0.0.1 attempt2 2>err &&
 	grep "warning: $message" err >warnings &&
-	test_line_count = 2 warnings &&
+	test_line_count -ge 1 warnings &&
 
 	test_must_fail git -c transfer.credentialsInUrl=die clone https://username:password@224.0.0.1 attempt3 2>err &&
 	grep "fatal: $message" err >warnings &&
-	test_line_count = 1 warnings &&
+	test_line_count -ge 1 warnings &&
 
 	test_must_fail git -c transfer.credentialsInUrl=die clone https://username:@224.0.0.1 attempt3 2>err &&
 	grep "fatal: $message" err >warnings &&
-	test_line_count = 1 warnings
+	test_line_count -ge 1 warnings
 '
 
 test_expect_success LIBCURL 'clone does not detect username:password when it is https://username@domain:port/' '
-	test_must_fail git -c transfer.credentialsInUrl=warn clone https://username@localhost:8080 attempt3 2>err &&
+	test_must_fail git -c transfer.credentialsInUrl=warn clone https://username@224.0.0.1:8080 attempt3 2>err &&
 	! grep "uses plaintext credentials" err
 '