[aur-dev] [PATCH 1/5] git-serve: Format usage text automatically
Remove the formatting of the usage text and add code to columnize it automatically instead. Also, add more strict tests for the usage output. These new tests ensure that the usage header is printed, commands are indented properly and no overly long lines are produced. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-serve.py | 26 ++++++++++++++++++-------- git-interface/test/t0002-serve.sh | 10 +++++++++- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/git-interface/git-serve.py b/git-interface/git-serve.py index 38048c9..0187de9 100755 --- a/git-interface/git-serve.py +++ b/git-interface/git-serve.py @@ -117,6 +117,14 @@ def warn(msg): sys.stderr.write("warning: {:s}\n".format(msg)) +def usage(cmds): + sys.stderr.write("Commands:\n") + colwidth = max([len(cmd) for cmd in cmds.keys()]) + 4 + for key in sorted(cmds): + sys.stderr.write(" " + key.ljust(colwidth) + cmds[key] + "\n") + exit(0) + + user = os.environ.get('AUR_USER') privileged = (os.environ.get('AUR_PRIVILEGED', '0') == '1') ssh_cmd = os.environ.get('SSH_ORIGINAL_COMMAND') @@ -187,13 +195,15 @@ elif action == 'restore': os.environ["AUR_PKGBASE"] = pkgbase os.execl(git_update_cmd, git_update_cmd, 'restore') elif action == 'help': - die("Commands:\n" + - " help Show this help message and exit.\n" + - " list-repos List all your repositories.\n" + - " restore <name> Restore a deleted package base.\n" + - " set-keywords <name> [...] Change package base keywords.\n" + - " setup-repo <name> Create a repository (deprecated).\n" + - " git-receive-pack Internal command used with Git.\n" + - " git-upload-pack Internal command used with Git.") + cmds = { + "help": "Show this help message and exit.", + "list-repos": "List all your repositories.", + "restore <name>": "Restore a deleted package base.", + "set-keywords <name> [...]": "Change package base keywords.", + "setup-repo <name>": "Create a repository (deprecated).", + "git-receive-pack": "Internal command used with Git.", + "git-upload-pack": "Internal command used with Git.", + } + usage(cmds) else: die_with_help("invalid command: {:s}".format(action)) diff --git a/git-interface/test/t0002-serve.sh b/git-interface/test/t0002-serve.sh index 52fdcd1..ce8340e 100755 --- a/git-interface/test/t0002-serve.sh +++ b/git-interface/test/t0002-serve.sh @@ -9,7 +9,15 @@ test_expect_success 'Test interactive shell.' ' ' test_expect_success 'Test help.' ' - SSH_ORIGINAL_COMMAND=help "$GIT_SERVE" 2>&1 | grep -q "^Commands:$" + SSH_ORIGINAL_COMMAND=help "$GIT_SERVE" 2>actual && + save_IFS=$IFS + IFS= + while read -r line; do + echo $line | grep -q "^Commands:$" && continue + echo $line | grep -q "^ [a-z]" || return 1 + [ ${#line} -le 80 ] || return 1 + done <actual + IFS=$save_IFS ' test_expect_success 'Test setup-repo and list-repos.' ' -- 2.9.3
Add support for adopting packages from the SSH interface. The syntax is `adopt <pkgbase>`. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-serve.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/git-interface/git-serve.py b/git-interface/git-serve.py index 0187de9..353771c 100755 --- a/git-interface/git-serve.py +++ b/git-interface/git-serve.py @@ -3,12 +3,15 @@ import os import re import shlex +import subprocess import sys import time import config import db +notify_cmd = config.get('notifications', 'notify-cmd') + repo_path = config.get('serve', 'repo-path') repo_regex = config.get('serve', 'repo-regex') git_shell_cmd = config.get('serve', 'git-shell-cmd') @@ -73,6 +76,40 @@ def create_pkgbase(pkgbase, user): conn.close() +def pkgbase_adopt(pkgbase): + pkgbase_id = pkgbase_from_name(pkgbase) + if not pkgbase_id: + die('{:s}: package base not found: {:s}'.format(action, pkgbase)) + + conn = db.Connection() + + cur = conn.execute("SELECT ID FROM PackageBases WHERE ID = ? AND " + + "MaintainerUID IS NULL", [pkgbase_id]) + if not privileged and not cur.fetchone(): + die('{:s}: permission denied: {:s}'.format(action, user)) + + cur = conn.execute("SELECT ID FROM Users WHERE Username = ?", [user]) + userid = cur.fetchone()[0] + if userid == 0: + die('{:s}: unknown user: {:s}'.format(action, user)) + + cur = conn.execute("UPDATE PackageBases SET MaintainerUID = ? " + + "WHERE ID = ?", [userid, pkgbase_id]) + + cur = conn.execute("SELECT COUNT(*) FROM PackageNotifications WHERE " + + "PackageBaseID = ? AND UserID = ?", + [pkgbase_id, userid]) + if cur.fetchone()[0] == 0: + cur = conn.execute("INSERT INTO PackageNotifications " + + "(PackageBaseID, UserID) VALUES (?, ?)", + [pkgbase_id, userid]) + conn.commit() + + subprocess.Popen((notify_cmd, 'adopt', str(pkgbase_id), str(userid))) + + conn.close() + + def pkgbase_set_keywords(pkgbase, keywords): pkgbase_id = pkgbase_from_name(pkgbase) if not pkgbase_id: @@ -194,8 +231,17 @@ elif action == 'restore': os.environ["AUR_USER"] = user os.environ["AUR_PKGBASE"] = pkgbase os.execl(git_update_cmd, git_update_cmd, 'restore') +elif action == 'adopt': + if len(cmdargv) < 2: + die_with_help("{:s}: missing repository name".format(action)) + if len(cmdargv) > 2: + die_with_help("{:s}: too many arguments".format(action)) + + pkgbase = cmdargv[1] + pkgbase_adopt(pkgbase) elif action == 'help': cmds = { + "adopt <name>": "Adopt a package base.", "help": "Show this help message and exit.", "list-repos": "List all your repositories.", "restore <name>": "Restore a deleted package base.", -- 2.9.3
Add support for disowning packages from the SSH interface. The syntax is `disown <pkgbase>`. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-serve.py | 136 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/git-interface/git-serve.py b/git-interface/git-serve.py index 353771c..9959934 100755 --- a/git-interface/git-serve.py +++ b/git-interface/git-serve.py @@ -110,6 +110,123 @@ def pkgbase_adopt(pkgbase): conn.close() +def pkgbase_get_comaintainers(pkgbase): + conn = db.Connection() + + cur = conn.execute("SELECT UserName FROM PackageComaintainers " + + "INNER JOIN Users " + + "ON Users.ID = PackageComaintainers.UsersID " + + "INNER JOIN PackageBases " + + "ON PackageBases.ID = PackageComaintainers.PackageBaseID " + + "WHERE PackageBases.Name = ? " + + "ORDER BY Priority ASC", [pkgbase]) + + return [row[0] for row in cur.fetchall()] + + +def pkgbase_set_comaintainers(pkgbase, userlist): + pkgbase_id = pkgbase_from_name(pkgbase) + if not pkgbase_id: + die('{:s}: package base not found: {:s}'.format(action, pkgbase)) + + if not privileged and not pkgbase_has_full_access(pkgbase, user): + die('{:s}: permission denied: {:s}'.format(action, user)) + + conn = db.Connection() + + userlist_old = set(pkgbase_get_comaintainers(pkgbase)) + + uids_old = set() + for olduser in userlist_old: + cur = conn.execute("SELECT ID FROM Users WHERE Username = ?", + [olduser]) + userid = cur.fetchone()[0] + if userid == 0: + die('{:s}: unknown user: {:s}'.format(action, user)) + uids_old.add(userid) + + uids_new = set() + for newuser in userlist: + cur = conn.execute("SELECT ID FROM Users WHERE Username = ?", + [newuser]) + userid = cur.fetchone()[0] + if userid == 0: + die('{:s}: unknown user: {:s}'.format(action, user)) + uids_new.add(userid) + + uids_add = uids_new - uids_old + uids_rem = uids_old - uids_new + + i = 1 + for userid in uids_new: + if userid in uids_add: + cur = conn.execute("INSERT INTO PackageComaintainers " + + "(PackageBaseID, UsersID, Priority) " + + "VALUES (?, ?, ?)", [pkgbase_id, userid, i]) + subprocess.Popen((notify_cmd, 'comaintainer-add', str(pkgbase_id), + str(userid))) + else: + cur = conn.execute("UPDATE PackageComaintainers " + + "SET Priority = ? " + + "WHERE PackageBaseID = ? AND UsersID = ?", + [i, pkgbase_id, userid]) + i += 1 + + for userid in uids_rem: + cur = conn.execute("DELETE FROM PackageComaintainers " + + "WHERE PackageBaseID = ? AND UsersID = ?", + [pkgbase_id, userid]) + subprocess.Popen((notify_cmd, 'comaintainer-remove', + str(pkgbase_id), str(userid))) + + conn.commit() + conn.close() + + +def pkgbase_disown(pkgbase): + pkgbase_id = pkgbase_from_name(pkgbase) + if not pkgbase_id: + die('{:s}: package base not found: {:s}'.format(action, pkgbase)) + + initialized_by_owner = pkgbase_has_full_access(pkgbase, user) + if not privileged and not initialized_by_owner: + die('{:s}: permission denied: {:s}'.format(action, user)) + + # TODO: Support disowning package bases via package request. + # TODO: Scan through pending orphan requests and close them. + + comaintainers = [] + new_maintainer_userid = None + + conn = db.Connection() + + # Make the first co-maintainer the new maintainer, unless the action was + # enforced by a Trusted User. + if initialized_by_owner: + comaintainers = pkgbase_get_comaintainers(pkgbase) + if len(comaintainers) > 0: + new_maintainer = comaintainers[0] + cur = conn.execute("SELECT ID FROM Users WHERE Username = ?", + [new_maintainer]) + new_maintainer_userid = cur.fetchone()[0] + comaintainers.remove(new_maintainer) + + pkgbase_set_comaintainers(pkgbase, comaintainers) + cur = conn.execute("UPDATE PackageBases SET MaintainerUID = ? " + + "WHERE ID = ?", [new_maintainer_userid, pkgbase_id]) + + conn.commit() + + cur = conn.execute("SELECT ID FROM Users WHERE Username = ?", [user]) + userid = cur.fetchone()[0] + if userid == 0: + die('{:s}: unknown user: {:s}'.format(action, user)) + + subprocess.Popen((notify_cmd, 'disown', str(pkgbase_id), str(userid))) + + conn.close() + + def pkgbase_set_keywords(pkgbase, keywords): pkgbase_id = pkgbase_from_name(pkgbase) if not pkgbase_id: @@ -141,6 +258,16 @@ def pkgbase_has_write_access(pkgbase, user): return cur.fetchone()[0] > 0 +def pkgbase_has_full_access(pkgbase, user): + conn = db.Connection() + + cur = conn.execute("SELECT COUNT(*) FROM PackageBases " + + "INNER JOIN Users " + + "ON Users.ID = PackageBases.MaintainerUID " + + "WHERE Name = ? AND Username = ?", [pkgbase, user]) + return cur.fetchone()[0] > 0 + + def die(msg): sys.stderr.write("{:s}\n".format(msg)) exit(1) @@ -239,9 +366,18 @@ elif action == 'adopt': pkgbase = cmdargv[1] pkgbase_adopt(pkgbase) +elif action == 'disown': + if len(cmdargv) < 2: + die_with_help("{:s}: missing repository name".format(action)) + if len(cmdargv) > 2: + die_with_help("{:s}: too many arguments".format(action)) + + pkgbase = cmdargv[1] + pkgbase_disown(pkgbase) elif action == 'help': cmds = { "adopt <name>": "Adopt a package base.", + "disown <name>": "Disown a package base.", "help": "Show this help message and exit.", "list-repos": "List all your repositories.", "restore <name>": "Restore a deleted package base.", -- 2.9.3
Add support for changing co-maintainers from the SSH interface. The syntax is `set-comaintainers <pkgbase> <user1> <user2>...`. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/git-serve.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/git-interface/git-serve.py b/git-interface/git-serve.py index 9959934..47e7df9 100755 --- a/git-interface/git-serve.py +++ b/git-interface/git-serve.py @@ -374,6 +374,13 @@ elif action == 'disown': pkgbase = cmdargv[1] pkgbase_disown(pkgbase) +elif action == 'set-comaintainers': + if len(cmdargv) < 2: + die_with_help("{:s}: missing repository name".format(action)) + + pkgbase = cmdargv[1] + userlist = cmdargv[2:] + pkgbase_set_comaintainers(pkgbase, userlist) elif action == 'help': cmds = { "adopt <name>": "Adopt a package base.", @@ -381,6 +388,7 @@ elif action == 'help': "help": "Show this help message and exit.", "list-repos": "List all your repositories.", "restore <name>": "Restore a deleted package base.", + "set-comaintainers <name> [...]": "Set package base co-maintainers.", "set-keywords <name> [...]": "Change package base keywords.", "setup-repo <name>": "Create a repository (deprecated).", "git-receive-pack": "Internal command used with Git.", -- 2.9.3
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- git-interface/test/setup.sh | 4 + git-interface/test/t0002-serve.sh | 207 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) diff --git a/git-interface/test/setup.sh b/git-interface/test/setup.sh index 7f3d45a..f9c1616 100644 --- a/git-interface/test/setup.sh +++ b/git-interface/test/setup.sh @@ -86,6 +86,10 @@ sed \ echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (1, 'user', '!', 'user@localhost', 1);" | sqlite3 aur.db echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (2, 'tu', '!', 'tu@localhost', 2);" | sqlite3 aur.db +echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (3, 'dev', '!', 'dev@localhost', 3);" | sqlite3 aur.db +echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (4, 'user2', '!', 'user2@localhost', 1);" | sqlite3 aur.db +echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (5, 'user3', '!', 'user3@localhost', 1);" | sqlite3 aur.db +echo "INSERT INTO Users (ID, UserName, Passwd, Email, AccountTypeID) VALUES (6, 'user4', '!', 'user4@localhost', 1);" | sqlite3 aur.db echo "INSERT INTO SSHPubKeys (UserID, Fingerprint, PubKey) VALUES (1, '$AUTH_FINGERPRINT_USER', '$AUTH_KEYTYPE_USER $AUTH_KEYTEXT_USER');" | sqlite3 aur.db echo "INSERT INTO SSHPubKeys (UserID, Fingerprint, PubKey) VALUES (2, '$AUTH_FINGERPRINT_TU', '$AUTH_KEYTYPE_TU $AUTH_KEYTEXT_TU');" | sqlite3 aur.db diff --git a/git-interface/test/t0002-serve.sh b/git-interface/test/t0002-serve.sh index ce8340e..2f1926e 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 -- 2.9.3
participants (1)
-
Lukas Fleischer