X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft9400-git-cvsserver-server.sh;h=641303e0a18c1c9958e4dae86d1fcdee644dbcff;hb=38c9c9b798a0df875968ae49d699298131dfa24d;hp=d406a8824a382433cbc8c6f499ef3bc1f00301b2;hpb=5610c6e381f54b7733d344010edc6ed20ec15761;p=git.git diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index d406a8824..641303e0a 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -38,7 +38,7 @@ echo >empty && git commit -q -m "First Commit" && git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && - GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" || + GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || exit 1 # note that cvs doesn't accept absolute pathnames @@ -47,6 +47,217 @@ test_expect_success 'basic checkout' \ 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master && test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"' +#------------------------ +# PSERVER AUTHENTICATION +#------------------------ + +cat >request-anonymous <request-git <login-anonymous <login-git <log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_success 'pserver authentication failure (non-anonymous user)' \ + 'if cat request-git | git-cvsserver pserver >log 2>&1 + then + false + else + true + fi && + tail -n1 log | grep -q "^I HATE YOU$"' + +test_expect_success 'pserver authentication (login)' \ + 'cat login-anonymous | git-cvsserver pserver >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_success 'pserver authentication failure (login/non-anonymous user)' \ + 'if cat login-git | git-cvsserver pserver >log 2>&1 + then + false + else + true + fi && + tail -n1 log | grep -q "^I HATE YOU$"' + + +# misuse pserver authentication for testing of req_Root + +cat >request-relative <request-conflict <log 2>&1 + then + echo unexpected success + false + else + true + fi && + tail log | grep -q "^error 1 Root must be an absolute pathname$"' + +test_expect_success 'req_Root failure (conflicting roots)' \ + 'cat request-conflict | git-cvsserver pserver >log 2>&1 && + tail log | grep -q "^error 1 Conflicting roots specified$"' + +test_expect_success 'req_Root (strict paths)' \ + 'cat request-anonymous | git-cvsserver --strict-paths pserver $SERVERDIR >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (strict-paths)' \ + 'cat request-anonymous | git-cvsserver --strict-paths pserver $WORKDIR >log 2>&1' + +test_expect_success 'req_Root (w/o strict-paths)' \ + 'cat request-anonymous | git-cvsserver pserver $WORKDIR/ >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (w/o strict-paths)' \ + 'cat request-anonymous | git-cvsserver pserver $WORKDIR/gitcvs >log 2>&1' + +cat >request-base <log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (base-path)' \ + 'cat request-anonymous | git-cvsserver --strict-paths --base-path $WORKDIR pserver $SERVERDIR >log 2>&1' + +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1 + +test_expect_success 'req_Root (export-all)' \ + 'cat request-anonymous | git-cvsserver --export-all pserver $WORKDIR >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +test_expect_failure 'req_Root failure (export-all w/o whitelist)' \ + 'cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || + false' + +test_expect_success 'req_Root (everything together)' \ + 'cat request-base | git-cvsserver --export-all --strict-paths --base-path $WORKDIR/ pserver $SERVERDIR >log 2>&1 && + tail -n1 log | grep -q "^I LOVE YOU$"' + +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 + +#-------------- +# CONFIG TESTS +#-------------- + +test_expect_success 'gitcvs.enabled = false' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && + if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 + then + echo unexpected cvs success + false + else + true + fi && + cat cvs.log | grep -q "GITCVS emulation disabled" && + test ! -d cvswork2' + +rm -fr cvswork2 +test_expect_success 'gitcvs.ext.enabled = true' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && + GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + diff -q cvswork cvswork2' + +rm -fr cvswork2 +test_expect_success 'gitcvs.ext.enabled = false' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false && + GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && + if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 + then + echo unexpected cvs success + false + else + true + fi && + cat cvs.log | grep -q "GITCVS emulation disabled" && + test ! -d cvswork2' + +rm -fr cvswork2 +test_expect_success 'gitcvs.dbname' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && + GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + diff -q cvswork cvswork2 && + test -f "$SERVERDIR/gitcvs.ext.master.sqlite" && + cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"' + +rm -fr cvswork2 +test_expect_success 'gitcvs.ext.dbname' \ + 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && + GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && + GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && + GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && + diff -q cvswork cvswork2 && + test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" && + test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" && + cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"' + + +#------------ +# CVS UPDATE +#------------ + +rm -fr "$SERVERDIR" +cd "$WORKDIR" && +git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && +GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && +GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || +exit 1 + test_expect_success 'cvs update (create new file)' \ 'echo testfile1 >testfile1 && git add testfile1 && @@ -123,4 +334,75 @@ test_expect_success 'cvs update (re-add deleted file)' \ test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" && diff -q testfile1 ../testfile1' +cd "$WORKDIR" +test_expect_success 'cvs update (merge)' \ + 'echo Line 0 >expected && + for i in 1 2 3 4 5 6 7 + do + echo Line $i >>merge + echo Line $i >>expected + done && + echo Line 8 >>expected && + git add merge && + git commit -q -m "Merge test (pre-merge)" && + git push gitcvs.git >/dev/null && + cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update && + test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" && + diff -q merge ../merge && + ( echo Line 0; cat merge ) >merge.tmp && + mv merge.tmp merge && + cd "$WORKDIR" && + echo Line 8 >>merge && + git add merge && + git commit -q -m "Merge test (merge)" && + git push gitcvs.git >/dev/null && + cd cvswork && + sleep 1 && touch merge && + GIT_CONFIG="$git_config" cvs -Q update && + diff -q merge ../expected' + +cd "$WORKDIR" + +cat >expected.C <>>>>>> merge.3 +EOF + +for i in 1 2 3 4 5 6 7 8 +do + echo Line $i >>expected.C +done + +test_expect_success 'cvs update (conflict merge)' \ + '( echo LINE 0; cat merge ) >merge.tmp && + mv merge.tmp merge && + git add merge && + git commit -q -m "Merge test (conflict)" && + git push gitcvs.git >/dev/null && + cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update && + diff -q merge ../expected.C' + +cd "$WORKDIR" +test_expect_success 'cvs update (-C)' \ + 'cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update -C && + diff -q merge ../merge' + +cd "$WORKDIR" +test_expect_success 'cvs update (merge no-op)' \ + 'echo Line 9 >>merge && + cp merge cvswork/merge && + git add merge && + git commit -q -m "Merge test (no-op)" && + git push gitcvs.git >/dev/null && + cd cvswork && + sleep 1 && touch merge && + GIT_CONFIG="$git_config" cvs -Q update && + diff -q merge ../merge' + test_done