diff options
Diffstat (limited to 'testing/library.yarn')
-rw-r--r-- | testing/library.yarn | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/testing/library.yarn b/testing/library.yarn new file mode 100644 index 0000000..105e4c8 --- /dev/null +++ b/testing/library.yarn @@ -0,0 +1,81 @@ +<!-- -*- markdown -*- --> +Test library for Gitano +======================= + +When running tests under yarn, for each scenario, we are provided with a +temporary working directory called `$DATADIR` which is a fresh directory for +each scenario being run. Within that base, we can set up any number of fake +SSH keys, a fake Gitano instance, fake users, and use them to make clones, do +pushes etc. Nearly all of the implementations rely on a tool in the testing +directory called `gitano-test-tool` the path to which is available as `$GTT`. + +For ease of testing, the fake user who gets to "own" the Gitano instance will +be called `testinstance` and the keyset which they get to use in order to +access the repository will be called `adminkey`. This is important when it +comes to cloning, pushing, etc. + +Managing the fake unix users +---------------------------- + + IMPLEMENTS GIVEN a unix user called ([a-z][a-z0-9]*) + $GTT createunixuser $MATCH_1 + + IMPLEMENTS GIVEN ([a-z][a-z0-9]*) has keys called ([a-z][a-z0-9]*) + $GTT createsshkey $MATCH_1 $MATCH_2 + +General instance management +--------------------------- + + IMPLEMENTS GIVEN a standard instance + $GTT createunixuser testinstance + $GTT createsshkey testinstance adminkey + $GTT setupstandard testinstance adminkey + +Repository access +----------------- + + IMPLEMENTS WHEN ([a-z][a-z0-9]*),? using ([a-z][a-z0-9]*),? clones ([^ ]+) as ([^ ]+) + $GTT cloneviassh $MATCH_1 $MATCH_2 "$MATCH_3" "$MATCH_4" + +Clone manipulation +------------------ + + IMPLEMENTS THEN ([a-z][a-z0-9]*) has a clone of ([^ ]+) + $GTT cloneexists $MATCH_1 "$MATCH_2" + + IMPLEMENTS WHEN git pull happens in ([a-z][a-z0-9]*) ([^ ]+) + cd "$($GTT clonelocation $MATCH_1 "$MATCH_2")" + git pull + + IMPLEMENTS THEN ([a-z][a-z0-9]*) ([^ ]+) has a file called (.+) + cd "$($GTT clonelocation $MATCH_1 "$MATCH_2")" + test -r "$MATCH_3" + + IMPLEMENTS THEN ([a-z][a-z0-9]*) ([^ ]+) has no file called (.+) + set -x + cd "$($GTT clonelocation $MATCH_1 "$MATCH_2")" + if test -r "$MATCH_3"; then false; else true; fi + +Admin repo manipulation +----------------------- + + IMPLEMENTS WHEN ([a-z][a-z0-9]*),? using ([a-z][a-z0-9]*),? adds user ([a-z][a-z0-9]*),? using ([a-z][a-z0-9]*) ([a-z][a-z0-9]*) + $GTT runcommand $MATCH_1 $MATCH_2 \ + user add $MATCH_3 $MATCH_3@testinstance "$MATCH_3's real name" + $GTT runcommand $MATCH_1 $MATCH_2 \ + as $MATCH_3 sshkey add default < \ + $($GTT pubkeyfilename $MATCH_4 $MATCH_5) + + IMPLEMENTS WHEN ([a-z][a-z0-9]*),? using ([a-z][a-z0-9]*),? deletes user ([a-z][a-z0-9]*) + TOKEN=$($GTT runcommand $MATCH_1 $MATCH_2 user del $MATCH_3 2>&1 | $GTT findtoken) + $GTT runcommand $MATCH_1 $MATCH_2 user del $MATCH_3 $TOKEN + +Generic utility methods +----------------------- + + IMPLEMENTS THEN failure ensues + cd $DATADIR + find . + cat user-home-testinstance/.ssh/authorized_keys + /bin/false + |