]> git.ipfire.org Git - thirdparty/git.git/commit
t5550: add netrc tests for http 401/403
authorAshlesh Gawande <git@ashlesh.me>
Wed, 7 Jan 2026 07:47:24 +0000 (13:17 +0530)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Jan 2026 02:02:39 +0000 (11:02 +0900)
commit5913fd26aad32bd028a8fe4e5b80fccc28e118af
tree6f25a13300db7a7433c704fe8be18962c5a9d656
parente0bfec3dfc356f7d808eb5ee546a54116b794397
t5550: add netrc tests for http 401/403

git allows using .netrc file to supply credentials for HTTP auth.
Three test cases are added in this patch to provide missing coverage
when cloning over HTTP using .netrc file:

  - First test case checks that the git clone is successful when credentials
    are provided via .netrc file
  - Second test case checks that the git clone fails when the .netrc file
    provides invalid credentials. The HTTP server is expected to return
    401 Unauthorized in such a case. The test checks that the user is
    provided with a prompt for username/password on 401 to provide
    the valid ones.
  - Third test case checks that the git clone fails when the .netrc file
    provides credentials that are valid but do not have permission for
    this user. For example one may have multiple tokens in GitHub
    and uses the one which was not authorized for cloning this repo.
    In such a case the HTTP server returns 403 Forbidden.
    For this test, the apache.conf is modified to return a 403
    on finding a forbidden-user. No prompt for username/password is
    expected after the 403 (unlike 401). This is because prompting may wipe
    out existing credentials or conflict with custom credential helpers.

Signed-off-by: Ashlesh Gawande <git@ashlesh.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-httpd.sh
t/lib-httpd/apache.conf
t/lib-httpd/passwd
t/t5550-http-fetch-dumb.sh