test.sh (1021B)
1 #!/bin/sh 2 3 export failed=0 4 fail() { echo "Test $1 failed"; failed=1 ; } 5 pass() { echo "Test $1 passed" ; } 6 7 # Test 0 8 ./git-restrict 2>/dev/null && fail 0 || pass 0 9 10 # Test 1 11 ./git-restrict foo 2>/dev/null && fail 1 || pass 1 12 13 # Test 2 14 SSH_ORIGINAL_COMMAND="cat /etc/passwd" \ 15 ./git-restrict foo 2>/dev/null && fail 2 || pass 2 16 17 # Test 3 18 SSH_ORIGINAL_COMMAND="git-upload-pack bar" \ 19 ./git-restrict foo bar baz 2>/dev/null && fail 3 || pass 3 20 21 # Test 4 22 SSH_ORIGINAL_COMMAND="git-upload-pack 'bar' ; cat /etc/passwd" \ 23 ./git-restrict bar 2>/dev/null && fail 4 || pass 4 24 25 # Test 5 (code 128 given by git-shell when repository isn't available) 26 SSH_ORIGINAL_COMMAND="git-upload-pack 'bar'" \ 27 ./git-restrict foo bar baz 2>/dev/null 28 [ $? = 128 ] || fail 5 && pass 5 29 30 # Test 6 31 SSH_ORIGINAL_COMMAND="git-upload-pack 'bar.git'" \ 32 ./git-restrict foo bar baz 2>/dev/null 33 [ $? = 128 ] || fail 6 && pass 6 34 35 # Test 7 36 SSH_ORIGINAL_COMMAND="git-upload-pack 'foo'" \ 37 ./git-restrict bar 2>/dev/null && fail 7 || pass 7 38 39 exit "$failed"