summaryrefslogtreecommitdiffstats
path: root/git-interface/test/t0002-serve.sh
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-09-18 13:20:39 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2016-09-18 14:01:08 +0200
commit5f43e2aaa9bcd233a310d4f6bf65640976457d85 (patch)
tree48ba459ab431d29bb3aeff2134a4e86d86739b0c /git-interface/test/t0002-serve.sh
parent94ac084d9dc130d9bbee2b9abfe4ea154a6a8439 (diff)
downloadaur-5f43e2aaa9bcd233a310d4f6bf65640976457d85.tar.gz
aur-5f43e2aaa9bcd233a310d4f6bf65640976457d85.tar.xz
t0002: Add tests for adopt/disown/set-comaintainers
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'git-interface/test/t0002-serve.sh')
-rwxr-xr-xgit-interface/test/t0002-serve.sh207
1 files changed, 207 insertions, 0 deletions
diff --git a/git-interface/test/t0002-serve.sh b/git-interface/test/t0002-serve.sh
index ce8340e6..2f1926e2 100755
--- a/git-interface/test/t0002-serve.sh
+++ b/git-interface/test/t0002-serve.sh
@@ -110,4 +110,211 @@ test_expect_success "Try to restore an existing package base." '
test_must_fail "$GIT_SERVE" 2>&1
'
+test_expect_success "Disown all package bases." '
+ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Adopt a package base as a regular user." '
+ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ *foobar
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Adopt an already adopted package base." '
+ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1
+'
+
+test_expect_success "Adopt a package base as a Trusted User." '
+ SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ *foobar2
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Disown one's own package base as a regular user." '
+ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Disown one's own package base as a Trusted User." '
+ SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Try to steal another user's package as a regular user." '
+ SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ *foobar2
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1
+'
+
+test_expect_success "Try to steal another user's package as a Trusted User." '
+ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ *foobar
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1
+'
+
+test_expect_success "Try to disown another user's package as a regular user." '
+ SSH_ORIGINAL_COMMAND="adopt foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ *foobar2
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ SSH_ORIGINAL_COMMAND="disown foobar2" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1
+'
+
+test_expect_success "Try to disown another user's package as a Trusted User." '
+ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1
+'
+
+test_expect_success "Adopt a package base and add co-maintainers." '
+ SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ SSH_ORIGINAL_COMMAND="set-comaintainers foobar user3 user4" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ 5|3|1
+ 6|3|2
+ EOF
+ echo "SELECT * FROM PackageComaintainers ORDER BY Priority;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Update package base co-maintainers." '
+ SSH_ORIGINAL_COMMAND="set-comaintainers foobar user2 user3 user4" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ 4|3|1
+ 5|3|2
+ 6|3|3
+ EOF
+ echo "SELECT * FROM PackageComaintainers ORDER BY Priority;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Try to add co-maintainers to an orphan package base." '
+ SSH_ORIGINAL_COMMAND="set-comaintainers foobar2 user2 user3 user4" \
+ AUR_USER=user AUR_PRIVILEGED=0 \
+ test_must_fail "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ 4|3|1
+ 5|3|2
+ 6|3|3
+ EOF
+ echo "SELECT * FROM PackageComaintainers ORDER BY Priority;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Disown a package base and check (co-)maintainer list." '
+ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ *foobar
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user2 AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ 5|3|1
+ 6|3|2
+ EOF
+ echo "SELECT * FROM PackageComaintainers ORDER BY Priority;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success "Force-disown a package base and check (co-)maintainer list." '
+ SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=tu AUR_PRIVILEGED=1 \
+ "$GIT_SERVE" 2>&1 &&
+ cat >expected <<-EOF &&
+ EOF
+ SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user3 AUR_PRIVILEGED=0 \
+ "$GIT_SERVE" 2>&1 >actual &&
+ test_cmp expected actual &&
+ cat >expected <<-EOF &&
+ EOF
+ echo "SELECT * FROM PackageComaintainers ORDER BY Priority;" | \
+ sqlite3 aur.db >actual &&
+ test_cmp expected actual
+'
+
test_done