summaryrefslogtreecommitdiffstats
path: root/git-interface/test/t0002-serve.sh
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-08-05 21:22:36 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2016-08-05 21:23:20 +0200
commit9a03c7fbdd9a1eff197d9c14301ab23aabc88109 (patch)
tree3c3e9bf8ce7536ea6610bd70000d92710a24e2b2 /git-interface/test/t0002-serve.sh
parent008eace8dbeb0343ae3908cb8373d669efcb8e63 (diff)
downloadaurweb-9a03c7fbdd9a1eff197d9c14301ab23aabc88109.tar.xz
t0002: Add more git-serve tests
Add tests for common scenarios that should be detected/handled by the git-serve script. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'git-interface/test/t0002-serve.sh')
-rwxr-xr-xgit-interface/test/t0002-serve.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/git-interface/test/t0002-serve.sh b/git-interface/test/t0002-serve.sh
index 7e17bcb..f36f1d8 100755
--- a/git-interface/test/t0002-serve.sh
+++ b/git-interface/test/t0002-serve.sh
@@ -15,6 +15,8 @@ test_expect_success 'Test help.' '
test_expect_success 'Test setup-repo and list-repos.' '
SSH_ORIGINAL_COMMAND="setup-repo foobar" AUR_USER=user \
"$GIT_SERVE" 2>&1 &&
+ SSH_ORIGINAL_COMMAND="setup-repo foobar2" AUR_USER=tu \
+ "$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
*foobar
EOF
@@ -23,4 +25,64 @@ test_expect_success 'Test setup-repo and list-repos.' '
test_cmp expected actual
'
+test_expect_success 'Test git-receive-pack.' '
+ cat >expected <<-EOF &&
+ user
+ foobar
+ foobar
+ EOF
+ SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'Test git-receive-pack with an invalid repository name.' '
+ SSH_ORIGINAL_COMMAND="git-receive-pack /!.git/" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1 >actual
+'
+
+test_expect_success "Test git-upload-pack." '
+ cat >expected <<-EOF &&
+ user
+ foobar
+ foobar
+ EOF
+ SSH_ORIGINAL_COMMAND="git-upload-pack /foobar.git/" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Try to pull from someone else's repository." '
+ cat >expected <<-EOF &&
+ user
+ foobar2
+ foobar2
+ EOF
+ SSH_ORIGINAL_COMMAND="git-upload-pack /foobar2.git/" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Try to push to someone else's repository." '
+ SSH_ORIGINAL_COMMAND="git-receive-pack /foobar2.git/" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1
+'
+
+test_expect_success "Try to push to someone else's repository as Trusted User." '
+ cat >expected <<-EOF &&
+ tu
+ foobar
+ foobar
+ EOF
+ SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
+ AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
test_done