summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-01-02 14:48:11 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-01-02 14:48:11 +0000
commit6a663a99320d7748069173c8be1f50a5568b688b (patch)
tree48b75bc69b67c649ebc5e13d6bd7f6c73ebfc6b8 /testing
parente2d36d9ea5b0ff1b59b33300c2174b95b9d1b562 (diff)
downloadgitano-6a663a99320d7748069173c8be1f50a5568b688b.tar.gz
Simplify yarns which create alice/main to use a new implementation
Diffstat (limited to 'testing')
-rw-r--r--testing/01-basics.yarn20
-rw-r--r--testing/02-commands-config.yarn6
-rw-r--r--testing/02-commands-copy.yarn4
-rw-r--r--testing/02-commands-count-objects.yarn4
-rw-r--r--testing/02-commands-create.yarn6
-rw-r--r--testing/02-commands-destroy.yarn4
-rw-r--r--testing/02-commands-graveyard.yarn6
-rw-r--r--testing/02-commands-rename.yarn4
-rw-r--r--testing/02-commands-user.yarn8
-rw-r--r--testing/02-commands-whoami.yarn7
-rw-r--r--testing/library.yarn16
11 files changed, 38 insertions, 47 deletions
diff --git a/testing/01-basics.yarn b/testing/01-basics.yarn
index 4384bbe..c4cf8fc 100644
--- a/testing/01-basics.yarn
+++ b/testing/01-basics.yarn
@@ -24,6 +24,8 @@ Step 1 is to create a standard instance and clone `gitano-admin`
THEN testinstance has a clone of gitano-admin
Next we create the user (alice) and verify that `gitano-admin` shows her.
+In this scenario we're creating alice's user long-hand to show how it can be
+done, but in future we will use a shortcut GIVEN instead.
GIVEN a unix user called alice
AND alice has keys called main
@@ -57,10 +59,8 @@ information lists the `gitano-admin` group which they should be a member of.
Then, just to be sure, we create a new user and ensure that it does not have
membership of `gitano-admin`
- GIVEN a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND alice main runs whoami
+ GIVEN testinstance, using adminkey, adds a new user alice, with a key called main
+ WHEN alice main runs whoami
THEN stdout does not contain gitano-admin
FINALLY the instance is torn down
@@ -75,10 +75,8 @@ when the new user runs 'ls' it doesn't get to see `gitano-admin` but that the
SCENARIO ls will not show repositories you have no access to
GIVEN a standard instance
- AND a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND alice main runs ls
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
+ WHEN alice main runs ls
THEN stdout does not contain gitano-admin
WHEN testinstance adminkey runs ls
THEN stdout contains RW \ gitano-admin
@@ -95,10 +93,8 @@ test that a new user who has a repository created for them can see it in ls.
SCENARIO delegated repository creation works
GIVEN a standard instance
- AND a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND testinstance adminkey runs create somerepo alice
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
+ WHEN testinstance adminkey runs create somerepo alice
AND alice main runs ls
THEN stdout contains RW \ somerepo
diff --git a/testing/02-commands-config.yarn b/testing/02-commands-config.yarn
index 2dbdf21..8275e05 100644
--- a/testing/02-commands-config.yarn
+++ b/testing/02-commands-config.yarn
@@ -52,10 +52,8 @@ but we can change this after it has been created.
WHEN testinstance adminkey, expecting failure, runs config testrepo set project.owner alice
THEN stderr contains Unknown user: alice
- GIVEN a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND testinstance adminkey runs config testrepo set project.owner alice
+ GIVEN testinstance, using adminkey, adds a new user alice, with a key called main
+ WHEN testinstance adminkey runs config testrepo set project.owner alice
AND testinstance adminkey runs config testrepo show
THEN stdout contains project.owner: alice
diff --git a/testing/02-commands-copy.yarn b/testing/02-commands-copy.yarn
index b1a8b82..50a2a45 100644
--- a/testing/02-commands-copy.yarn
+++ b/testing/02-commands-copy.yarn
@@ -26,9 +26,7 @@ Users may copy repositories they can read to paths they can write to.
Users may not copy repositories they can to read to paths they cannot write to.
- GIVEN a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
+ GIVEN testinstance, using adminkey, adds a new user alice, with a key called main
In the default instance only the admin user may create repositories,
so all copies by other users will fail.
diff --git a/testing/02-commands-count-objects.yarn b/testing/02-commands-count-objects.yarn
index 7d958d5..8921358 100644
--- a/testing/02-commands-count-objects.yarn
+++ b/testing/02-commands-count-objects.yarn
@@ -3,9 +3,7 @@
SCENARIO counting objects
GIVEN a standard instance
- AND a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
We can't count objects for a repository we can't read,
since that would be an information leak that the repository exists.
diff --git a/testing/02-commands-create.yarn b/testing/02-commands-create.yarn
index 2dec466..08ff48b 100644
--- a/testing/02-commands-create.yarn
+++ b/testing/02-commands-create.yarn
@@ -4,10 +4,8 @@
GIVEN a standard instance
AND testinstance using adminkey has patched gitano-admin with personal-repo-create.patch
- AND a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND alice main runs create personal/alice/testrepo
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
+ WHEN alice main runs create personal/alice/testrepo
AND alice main runs config personal/alice/testrepo show
THEN stderr is empty
AND stdout contains project.owner: alice
diff --git a/testing/02-commands-destroy.yarn b/testing/02-commands-destroy.yarn
index da2d74f..e545fcd 100644
--- a/testing/02-commands-destroy.yarn
+++ b/testing/02-commands-destroy.yarn
@@ -4,9 +4,7 @@
GIVEN a standard instance
AND testinstance using adminkey has patched gitano-admin with personal-repo-create.patch
- AND a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
We obviously can't destroy a repository that doesn't exist.
diff --git a/testing/02-commands-graveyard.yarn b/testing/02-commands-graveyard.yarn
index 06be518..b4b0eab 100644
--- a/testing/02-commands-graveyard.yarn
+++ b/testing/02-commands-graveyard.yarn
@@ -4,10 +4,8 @@
GIVEN a standard instance
AND testinstance using adminkey has patched gitano-admin with personal-repo-create.patch
- AND a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND alice main runs create personal/alice/testrepo
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
+ WHEN alice main runs create personal/alice/testrepo
AND alice main runs ls
THEN stdout contains personal/alice/testrepo
WHEN alice main runs destroy personal/alice/testrepo --force
diff --git a/testing/02-commands-rename.yarn b/testing/02-commands-rename.yarn
index bf0d922..a207a7f 100644
--- a/testing/02-commands-rename.yarn
+++ b/testing/02-commands-rename.yarn
@@ -19,9 +19,7 @@ When a repository is renamed it does not modify any of the refs.
GIVEN a standard instance
AND testinstance using adminkey has patched gitano-admin with personal-repo-create.patch
- GIVEN a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
WHEN alice main runs create personal/alice/testrepo
WHEN alice main runs create personal/alice/testrepo2
diff --git a/testing/02-commands-user.yarn b/testing/02-commands-user.yarn
index 3ee3beb..9ff95c4 100644
--- a/testing/02-commands-user.yarn
+++ b/testing/02-commands-user.yarn
@@ -3,14 +3,12 @@
SCENARIO user management
GIVEN a standard instance
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
By default, normal users may not create users.
- GIVEN a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND alice main, expecting failure, runs user add bob bob@testinstance Bob Bobertson
- THEN stderr contains CRIT: You may not perform site administration
+ WHEN alice main, expecting failure, runs user add bob bob@testinstance Bob Bobertson
+ THEN stderr contains CRIT: You may not perform site administration
Privileged users may create other users though.
diff --git a/testing/02-commands-whoami.yarn b/testing/02-commands-whoami.yarn
index 8e06c39..19debb0 100644
--- a/testing/02-commands-whoami.yarn
+++ b/testing/02-commands-whoami.yarn
@@ -3,13 +3,10 @@
SCENARIO user introspection
GIVEN a standard instance
- AND a unix user called alice
- AND alice has keys called main
- WHEN testinstance, using adminkey, adds user alice, using alice main
- AND alice main runs whoami
+ AND testinstance, using adminkey, adds a new user alice, with a key called main
+ WHEN alice main runs whoami
THEN stdout contains User name: alice
THEN stdout contains Real name: alice's real name
THEN stdout contains Email address: alice@testinstance
FINALLY the instance is torn down
-
diff --git a/testing/library.yarn b/testing/library.yarn
index 03971cf..7d72ffb 100644
--- a/testing/library.yarn
+++ b/testing/library.yarn
@@ -26,6 +26,21 @@ Managing the fake unix users
IMPLEMENTS WHEN ([a-z][a-z0-9]*) uses their ssh public key called ([a-z][a-z0-9]*) as stdin
cp "$DATADIR/user-home-$MATCH_1/.ssh/$MATCH_2.pub" "$DATADIR/stdin"
+ IMPLEMENTS GIVEN ([a-z][a-z0-9]*),? using ([a-z][a-z0-9_-]*),? adds a new user ([a-z][a-z0-9_-]*), with a key called ([a-z][a-z0-9_-]*)
+ $GTT createunixuser $MATCH_3
+ $GTT createsshkey $MATCH_3 $MATCH_4
+ $GTT runcommand $MATCH_1 $MATCH_2 \
+ user add $MATCH_3 $MATCH_3@testinstance "$MATCH_3's real name" > $DATADIR/stdout 2> $DATADIR/stderr
+ $GTT runcommand $MATCH_1 $MATCH_2 \
+ as $MATCH_3 sshkey add default < \
+ $($GTT pubkeyfilename $MATCH_3 $MATCH_4) >> $DATADIR/stdout 2>> $DATADIR/stderr
+ if [ "$GTT_PROTO" = http ]; then
+ printf "%s" "$MATCH_3" | GTT_PROTO=ssh $GTT runcommand \
+ $MATCH_1 $MATCH_2 as $MATCH_3 passwd \
+ >> $DATADIR/stdout 2>> $DATADIR/stderr
+ fi
+
+
General instance management
---------------------------
@@ -233,4 +248,3 @@ GPG Keyring related helpers
IMPLEMENTS GIVEN gpg key ([0-9A-Fa-f]+) on stdin
$GTT gpg --armor --export $MATCH_1 > $DATADIR/stdin
-