mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
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>
This commit is contained in:
parent
008eace8db
commit
9a03c7fbdd
2 changed files with 79 additions and 2 deletions
|
@ -29,8 +29,8 @@ ssh-options = restrict
|
|||
[serve]
|
||||
repo-path = ./aur.git/
|
||||
repo-regex = [a-z0-9][a-z0-9.+_-]*$
|
||||
git-shell-cmd = /usr/bin/git-shell
|
||||
git-update-cmd = /srv/http/aurweb/git-interface/git-update.py
|
||||
git-shell-cmd = ./git-shell.sh
|
||||
git-update-cmd = ./update.sh
|
||||
ssh-cmdline = ssh aur@aur.archlinux.org
|
||||
|
||||
[update]
|
||||
|
@ -42,6 +42,21 @@ cat >notify.sh <<-EOF
|
|||
EOF
|
||||
chmod +x notify.sh
|
||||
|
||||
cat >git-shell.sh <<-\EOF
|
||||
#!/bin/sh
|
||||
echo $AUR_USER
|
||||
echo $AUR_PKGBASE
|
||||
echo $GIT_NAMESPACE
|
||||
EOF
|
||||
chmod +x git-shell.sh
|
||||
|
||||
cat >update.sh <<-\EOF
|
||||
#!/bin/sh
|
||||
echo $AUR_USER
|
||||
echo $AUR_PKGBASE
|
||||
EOF
|
||||
chmod +x update.sh
|
||||
|
||||
AUR_CONFIG=config
|
||||
export AUR_CONFIG
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue