summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-02-13 12:26:08 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-03-04 16:48:58 +0000
commita0ce52fd449aa7d425951da38181daa10a978739 (patch)
tree6b4b2fa4752c6f5b994d873c8a0c7e9b9f4d89a8 /testing
parent5fe2954fdc6452d34fab9c821f396a2a8804535a (diff)
downloadgitano-a0ce52fd449aa7d425951da38181daa10a978739.tar.gz
adds test for checking start_tree
Diffstat (limited to 'testing')
-rw-r--r--testing/03-treedelta-rules.yarn59
-rw-r--r--testing/admin-patches/must-start-with-FOO.patch13
2 files changed, 72 insertions, 0 deletions
diff --git a/testing/03-treedelta-rules.yarn b/testing/03-treedelta-rules.yarn
index e7c0def..699327d 100644
--- a/testing/03-treedelta-rules.yarn
+++ b/testing/03-treedelta-rules.yarn
@@ -16,6 +16,8 @@ The first part of the treedelta support are the gitano/starttree and
gitano/targetttee lists. These contain the flattened entry names for
everything in the trees.
+First, let's look at what it takes to prevent the creation of files with FOO in.
+
SCENARIO may not create files called FOO
GIVEN a standard instance
AND testinstance using adminkey has patched gitano-admin with no-create-FOO.patch
@@ -32,3 +34,60 @@ everything in the trees.
THEN stderr contains No FOOs allowed
FINALLY the instance is torn down
+
+Next, let's look at how we might require a FOO to be present...
+
+ SCENARIO source must have a FOO
+ 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 testrepo alice
+ AND alice, using main, clones testrepo as testrepo
+ THEN alice testrepo has no file called FOO
+
+We now have a repo which has no FOO in it, let's first check that our admin
+rule which requires `start_tree` contain a FOO by trying to push an empty tree
+
+ GIVEN testinstance using adminkey has patched gitano-admin with must-start-with-FOO.patch
+
+ WHEN alice, using main, expecting failure, pushes an empty commit in testrepo
+ THEN stderr contains Needs a FOO
+
+Next, let's create a FOO in our tree, prove that `start_tree` != `target_tree`
+
+ WHEN alice applies add-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN stderr contains Needs a FOO
+
+And if we back out the rule, we can push it...
+
+ GIVEN testinstance using adminkey has patched gitano-admin with the reverse of must-start-with-FOO.patch
+
+ WHEN alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains new branch
+
+And if we put the rule back in, an empty commit will make it through because
+`start_tree` now does contain a FOO
+
+ GIVEN testinstance using adminkey has patched gitano-admin with must-start-with-FOO.patch
+
+ WHEN alice, using main, pushes an empty commit in testrepo
+ THEN the output contains master -> master
+
+And once again, prove `start_tree` != `target_tree` by backing out the FOO
+and proving we can push that.
+
+ WHEN alice reverts add-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN the output contains master -> master
+
+And of course, now `start_tree` does not contain a FOO, so no matter what
+we do to `target_tree` we can't push...
+
+ WHEN alice applies add-a-FOO.patch in testrepo
+ AND alice, using main, pushes testrepo to testrepo.git
+ THEN stderr contains Needs a FOO
+
+ FINALLY the instance is torn down
diff --git a/testing/admin-patches/must-start-with-FOO.patch b/testing/admin-patches/must-start-with-FOO.patch
new file mode 100644
index 0000000..d206700
--- /dev/null
+++ b/testing/admin-patches/must-start-with-FOO.patch
@@ -0,0 +1,13 @@
+diff --git a/rules/project.lace b/rules/project.lace
+index aafa17c..388766a 100644
+--- a/rules/project.lace
++++ b/rules/project.lace
+@@ -43,6 +43,8 @@ include global:remoteconfigchecks op_is_config
+ # Okay, if we're altering the admin ref, in we go
+ include global:adminchecks is_admin_ref
+
++deny "Needs a FOO" op_is_normal ![start_tree is FOO]
++
+ # Now we're into branch operations. Owners can do any normal operation
+ # Normal ops are create/delete/fastforward on refs
+ allow "Owners can create refs" op_is_normal is_owner