diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2016-09-20 20:53:44 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2016-09-29 22:07:24 +0200 |
commit | 49c7e53572be8be7848ff99aa5e60ffd4dc316eb (patch) | |
tree | 6e198cd8171f3f8c267fcb9c0acaf4b464c0dcce /git-interface/test/t0003-update.sh | |
parent | 1a999810e3a6da21181c91f6b383f69db399cf1c (diff) | |
download | aur-49c7e53572be8be7848ff99aa5e60ffd4dc316eb.tar.gz aur-49c7e53572be8be7848ff99aa5e60ffd4dc316eb.tar.xz |
Reorganize tests
Move and rename the existing git-interface tests such that tests for
other scripts can be added easily.
In particular, the following changes are made:
* Move the existing tests from git-interface/test/ to test/.
* Rename t0001-auth.sh to t1100-git-auth.sh.
* Rename t0002-serve.sh to t1200-git-serve.sh.
* Rename t0003-update.sh to t1300-git-update.sh.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'git-interface/test/t0003-update.sh')
-rwxr-xr-x | git-interface/test/t0003-update.sh | 432 |
1 files changed, 0 insertions, 432 deletions
diff --git a/git-interface/test/t0003-update.sh b/git-interface/test/t0003-update.sh deleted file mode 100755 index b642089c..00000000 --- a/git-interface/test/t0003-update.sh +++ /dev/null @@ -1,432 +0,0 @@ -#!/bin/sh - -test_description='git-update tests' - -. ./setup.sh - -test_expect_success 'Test update hook on a fresh repository.' ' - old=0000000000000000000000000000000000000000 && - new=$(git -C aur.git rev-parse HEAD^) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 && - cat >expected <<-EOF && - 1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/ - 1|GPL - 1|1 - 1|1|python-pygit2|| - 1|1 - EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && - test_cmp expected actual -' - -test_expect_success 'Test update hook on another fresh repository.' ' - old=0000000000000000000000000000000000000000 && - test_when_finished "git -C aur.git checkout refs/namespaces/foobar/refs/heads/master" && - git -C aur.git checkout -q refs/namespaces/foobar2/refs/heads/master && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar2 AUR_PRIVILEGED=0 \ - "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 && - cat >expected <<-EOF && - 1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/ - 2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/ - 1|GPL - 2|MIT - 1|1 - 2|2 - 1|1|python-pygit2|| - 2|1|python-pygit2|| - 1|1 - 2|1 - EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && - test_cmp expected actual -' - -test_expect_success 'Test update hook on an updated repository.' ' - old=$(git -C aur.git rev-parse HEAD^) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 && - cat >expected <<-EOF && - 2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/ - 3|1|foobar|1-2|aurweb test package.|https://aur.archlinux.org/ - 1|GPL - 2|MIT - 2|2 - 3|1 - 2|1|python-pygit2|| - 3|1|python-pygit2|| - 1|1 - 2|1 - EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && - test_cmp expected actual -' - -test_expect_success 'Test restore mode.' ' - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - "$GIT_UPDATE" restore 2>&1 && - cat >expected <<-EOF && - 2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/ - 3|1|foobar|1-2|aurweb test package.|https://aur.archlinux.org/ - 1|GPL - 2|MIT - 2|2 - 3|1 - 2|1|python-pygit2|| - 3|1|python-pygit2|| - 1|1 - 2|1 - EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && - test_cmp expected actual -' - -test_expect_success 'Test restore mode on a non-existent repository.' ' - cat >expected <<-EOD && - error: restore: repository not found: foobar3 - EOD - AUR_USER=user AUR_PKGBASE=foobar3 AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" restore >actual 2>&1 && - test_cmp expected actual -' - -test_expect_success 'Pushing to a branch other than master.' ' - old=0000000000000000000000000000000000000000 && - new=$(git -C aur.git rev-parse HEAD) && - cat >expected <<-EOD && - error: pushing to a branch other than master is restricted - EOD - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/pu "$old" "$new" >actual 2>&1 && - test_cmp expected actual -' - -test_expect_success 'Performing a non-fast-forward ref update.' ' - old=$(git -C aur.git rev-parse HEAD) && - new=$(git -C aur.git rev-parse HEAD^) && - cat >expected <<-EOD && - error: denying non-fast-forward (you should pull first) - EOD - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - test_cmp expected actual -' - -test_expect_success 'Performing a non-fast-forward ref update as Trusted User.' ' - old=$(git -C aur.git rev-parse HEAD) && - new=$(git -C aur.git rev-parse HEAD^) && - AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \ - "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 -' - -test_expect_success 'Removing .SRCINFO.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - git -C aur.git rm -q .SRCINFO && - git -C aur.git commit -q -m "Remove .SRCINFO" && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing .SRCINFO$" actual -' - -test_expect_success 'Removing .SRCINFO with a follow-up fix.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - git -C aur.git rm -q .SRCINFO && - git -C aur.git commit -q -m "Remove .SRCINFO" && - git -C aur.git revert --no-edit HEAD && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing .SRCINFO$" actual -' - -test_expect_success 'Removing PKGBUILD.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - git -C aur.git rm -q PKGBUILD && - git -C aur.git commit -q -m "Remove PKGBUILD" && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing PKGBUILD$" actual -' - -test_expect_success 'Pushing a tree with a subdirectory.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - mkdir aur.git/subdir && - touch aur.git/subdir/file && - git -C aur.git add subdir/file && - git -C aur.git commit -q -m "Add subdirectory" && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: the repository must not contain subdirectories$" actual -' - -test_expect_success 'Pushing a tree with a large blob.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - printf "%256001s" x >aur.git/file && - git -C aur.git add file && - git -C aur.git commit -q -m "Add large blob" && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: maximum blob size (250.00KiB) exceeded$" actual -' - -test_expect_success 'Pushing .SRCINFO with a non-matching package base.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/\(pkgbase.*\)foobar/\1foobar2/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Change package base" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: invalid pkgbase: foobar2, expected foobar$" actual -' - -test_expect_success 'Pushing .SRCINFO with invalid syntax.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/=//" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Break .SRCINFO" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 -' - -test_expect_success 'Pushing .SRCINFO without pkgver.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "/pkgver/d" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Remove pkgver" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing mandatory field: pkgver$" actual -' - -test_expect_success 'Pushing .SRCINFO without pkgrel.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "/pkgrel/d" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Remove pkgrel" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing mandatory field: pkgrel$" actual -' - -test_expect_success 'Pushing .SRCINFO with epoch.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/.*pkgrel.*/\\0\\nepoch = 1/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Add epoch" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - "$GIT_UPDATE" refs/heads/master "$old" "$new" 2>&1 && - cat >expected <<-EOF && - 2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/ - 3|1|foobar|1:1-2|aurweb test package.|https://aur.archlinux.org/ - EOF - echo "SELECT * FROM Packages;" | sqlite3 aur.db >actual && - test_cmp expected actual -' - -test_expect_success 'Pushing .SRCINFO with invalid pkgname.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/\(pkgname.*\)foobar/\1!/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Change pkgname" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: invalid package name: !$" actual -' - -test_expect_success 'Pushing .SRCINFO with invalid epoch.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/.*pkgrel.*/\\0\\nepoch = !/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Change epoch" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: invalid epoch: !$" actual -' - -test_expect_success 'Missing install file.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/.*depends.*/\\0\\ninstall = install/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Add install field" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing install file: install$" actual -' - -test_expect_success 'Missing changelog file.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/.*depends.*/\\0\\nchangelog = changelog/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Add changelog field" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing changelog file: changelog$" actual -' - -test_expect_success 'Missing source file.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - ( - cd aur.git && - sed "s/.*depends.*/\\0\\nsource = file/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Add file to the source array" - ) && - new=$(git -C aur.git rev-parse HEAD) && - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - grep -q "^error: missing source file: file$" actual -' - -test_expect_success 'Pushing a blacklisted package.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - echo "pkgname = forbidden" >>aur.git/.SRCINFO && - git -C aur.git commit -q -am "Add blacklisted package" && - new=$(git -C aur.git rev-parse HEAD) && - cat >expected <<-EOD && - error: package is blacklisted: forbidden - EOD - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - test_cmp expected actual -' - -test_expect_success 'Pushing a blacklisted package as Trusted User.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - echo "pkgname = forbidden" >>aur.git/.SRCINFO && - git -C aur.git commit -q -am "Add blacklisted package" && - new=$(git -C aur.git rev-parse HEAD) && - cat >expected <<-EOD && - warning: package is blacklisted: forbidden - EOD - AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \ - "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - test_cmp expected actual -' - -test_expect_success 'Pushing a package already in the official repositories.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - echo "pkgname = official" >>aur.git/.SRCINFO && - git -C aur.git commit -q -am "Add official package" && - new=$(git -C aur.git rev-parse HEAD) && - cat >expected <<-EOD && - error: package already provided by [core]: official - EOD - AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - test_cmp expected actual -' - -test_expect_success 'Pushing a package already in the official repositories as Trusted User.' ' - old=$(git -C aur.git rev-parse HEAD) && - test_when_finished "git -C aur.git reset --hard $old" && - echo "pkgname = official" >>aur.git/.SRCINFO && - git -C aur.git commit -q -am "Add official package" && - new=$(git -C aur.git rev-parse HEAD) && - cat >expected <<-EOD && - warning: package already provided by [core]: official - EOD - AUR_USER=tu AUR_PKGBASE=foobar AUR_PRIVILEGED=1 \ - "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - test_cmp expected actual -' - -test_expect_success 'Trying to hijack a package.' ' - old=0000000000000000000000000000000000000000 && - test_when_finished "git -C aur.git checkout refs/namespaces/foobar/refs/heads/master" && - ( - cd aur.git && - git checkout -q refs/namespaces/foobar2/refs/heads/master && - sed "s/\\(.*pkgname.*\\)2/\\1/" .SRCINFO >.SRCINFO.new - mv .SRCINFO.new .SRCINFO - git commit -q -am "Change package name" - ) && - new=$(git -C aur.git rev-parse HEAD) && - cat >expected <<-EOD && - error: cannot overwrite package: foobar - EOD - AUR_USER=user AUR_PKGBASE=foobar2 AUR_PRIVILEGED=0 \ - test_must_fail "$GIT_UPDATE" refs/heads/master "$old" "$new" >actual 2>&1 && - test_cmp expected actual -' - -test_done |