#!/bin/sh global test_description := ''test disabling of git-over-http in clone/fetch'' source ./test-lib.sh source "$TEST_DIRECTORY/lib-proto-disable.sh" source "$TEST_DIRECTORY/lib-httpd.sh" start_httpd test_expect_success 'create git-accessible repo' ' bare="$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && test_commit one && git --bare init "$bare" && git push "$bare" HEAD && git -C "$bare" config http.receivepack true ' test_proto "smart http" http "$HTTPD_URL/smart/repo.git" test_expect_success 'curl redirects respect whitelist' ' test_must_fail env GIT_ALLOW_PROTOCOL=http:https \ git clone "$HTTPD_URL/ftp-redir/repo.git" 2>stderr && { test_i18ngrep "ftp.*disabled" stderr || test_i18ngrep "your curl version is too old" } ' test_expect_success 'curl limits redirects' ' test_must_fail git clone "$HTTPD_URL/loop-redir/smart/repo.git" ' stop_httpd test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"test disabling of git-over-http in clone/fetch">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY") (/lib-proto-disable.sh))}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY") (/lib-httpd.sh))}) (C {(start_httpd)}) (C {(test_expect_success)} {(SQ <"create git-accessible repo">)} { (SQ <"\n"> <"\tbare=\"$HTTPD_DOCUMENT_ROOT_PATH/repo.git\" &&\n"> <"\ttest_commit one &&\n"> <"\tgit --bare init \"$bare\" &&\n"> <"\tgit push \"$bare\" HEAD &&\n"> <"\tgit -C \"$bare\" config http.receivepack true\n"> ) } ) (C {(test_proto)} {(DQ ("smart http"))} {(http)} {(DQ ($ VSub_Name "$HTTPD_URL") (/smart/repo.git))}) (C {(test_expect_success)} {(SQ <"curl redirects respect whitelist">)} { (SQ <"\n"> <"\ttest_must_fail env GIT_ALLOW_PROTOCOL=http:https \\\n"> <"\t\tgit clone \"$HTTPD_URL/ftp-redir/repo.git\" 2>stderr &&\n"> <"\t{\n"> <"\t\ttest_i18ngrep \"ftp.*disabled\" stderr ||\n"> <"\t\ttest_i18ngrep \"your curl version is too old\"\n"> <"\t}\n"> ) } ) (C {(test_expect_success)} {(SQ <"curl limits redirects">)} {(SQ <"\n"> <"\ttest_must_fail git clone \"$HTTPD_URL/loop-redir/smart/repo.git\"\n">)} ) (C {(stop_httpd)}) (C {(test_done)}) ] )