From 4c63ca3cd8ce471ec418d449397ac15454b363c5 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 6 Oct 2013 22:48:28 +0100 Subject: Test repository removal --- git.liw.fi.yarn | 52 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 11 deletions(-) (limited to 'git.liw.fi.yarn') diff --git a/git.liw.fi.yarn b/git.liw.fi.yarn index 7ce5e13..25c017a 100644 --- a/git.liw.fi.yarn +++ b/git.liw.fi.yarn @@ -85,6 +85,13 @@ be able to remove the repository. WHEN tstusr attempts to remove repository tstrepo THEN attempt failed with error matching "You may not destroy repositories you do not own" + + WHEN admin removes repository tstrepo + THEN admin can't see repository tstrepo + AND admin can't clone tstrepo using git + AND admin can't clone tstrepo using ssh + AND tstusr can't see repository tstrepo + AND tstusr can't clone tstrepo using ssh FINALLY remove repository tstrepo on server AND remove user tstusr on server @@ -213,10 +220,18 @@ Repositories can only be created by the admin. Repository listing ------------------ +Can a user see the desired repository in the `gitano ls` output? + IMPLEMENTS THEN (\S+) can see repository (\S+) - run_gitano_as "$MATCH_1" ls | - awk -v "r=$MATCH_2" '$NF == r' | - grep . + repo_exists "$MATCH_1" "$MATCH_2" + +And sometimes they shouldn't see it anymore. + + IMPLEMENTS THEN (\S+) can't see repository (\S+) + if repo_exists "$MATCH_1" "$MATCH_2" + then + die "$MATCH_1 can see repository $MATCH_2 but shouldn't" + fi Repository cloning ------------------ @@ -241,24 +256,39 @@ a ./ssh script that runs the real ssh, but adds a `-i` option to the desired keyfile. But we only do that for non-admin users. IMPLEMENTS THEN (\S+) can clone (\S+) using ssh - localdir="$DATADIR/admin/$MATCH_2" + clone_with_ssh "$MATCH_1" "$MATCH_2" + +We also need to be able to check we can't clone. + + IMPLEMENTS THEN admin can't clone (\S+) using git + localdir="$DATADIR/meh" rm -rf "$localdir" - mkdir -p "$localdir" - url="ssh://$GITANO@$GITHOST/$MATCH_2" - if [ "$MATCH_1" = admin ] + if git clone "git://$GITHOST/$MATCH_1" "$localdir" then - git clone "$url" "$localdir" - else - KEYFILE="$DATADIR/$MATCH_1.key" \ - PATH="$SRCDIR:$PATH" git clone "$url" "$localdir" + die "repository $MATCH_1 can be cloned over git, but shouldn't" fi + IMPLEMENTS THEN (\S+) can't clone (\S+) using ssh + if clone_with_ssh "$MATCH_1" "$MATCH_2" + then + die "$MATCH_1 can clone $MATCH_2 over ssh, but shouldn't" + fi + + Repository removal ------------------ At the end, we need to clean up repositories. IMPLEMENTS FINALLY remove repository (\S+) on server + if repo_exists admin "$MATCH_1" + then + destroy_repo admin "$MATCH_1" + fi + +An admin can remove a repository. + + IMPLEMENTS WHEN admin removes repository (\S+) destroy_repo admin "$MATCH_1" A non-admin may try to remove a repository. It should fail, but they -- cgit v1.2.1