From 9f820e9c5c4ba5ce4be60d818205890a509f1529 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 6 Oct 2013 10:51:04 +0100 Subject: Test that non-admin can't create users --- git.liw.fi.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'git.liw.fi.sh') diff --git a/git.liw.fi.sh b/git.liw.fi.sh index b064ad5..8e3ecd0 100644 --- a/git.liw.fi.sh +++ b/git.liw.fi.sh @@ -10,6 +10,20 @@ die() } +# Attempt to run something, which may fail. Store the stdout, +# stderr, and exit code in $DATADIR. + +attempt() +{ + if "$@" > "$DATADIR/attempt.stdout" 2> "$DATADIR/attempt.stderr" + then + echo 0 > "$DATADIR/attempt.exit" + else + echo $? > "$DATADIR/attempt.exit" + fi +} + + # Run gitano on the server using a desired ssh key. The key is # either the admin key (i.e., they key of whoever invoked the # test suite), or a test key we've created in $DATADIR. @@ -23,7 +37,7 @@ run_gitano_as() ssh "$GITANO@$GITHOST" "$@" else SSH_AUTH_SOCK= ssh -F "ssh.conf" -i "$DATADIR/$keyname.key" \ - "$GITANO@GITHOST" "$@" + "$GITANO@$GITHOST" "$@" fi } @@ -36,6 +50,15 @@ user_exists() } +# Create a user, including setting their ssh key. + +user_add() +{ + run_gitano_as "$1" user add "$2" name foo@example.com + run_gitano_as "$1" as "$2" sshkey add somekey < "$DATADIR/$2.key.pub" +} + + # Remove a user from the server. This is a two-step process. user_del() -- cgit v1.2.1