summaryrefslogtreecommitdiff
path: root/testing/02-commands-fsck.yarn
blob: 115bbc6b3a02ba933b0f4a270fd8eea2f0727ded (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!-- -*- markdown -*- -->
fsck ---- Perform a fsck operation on a repository (Takes a repo)
=================================================================

The `fsck` command is a basic pass-through to the underlying `git fsck` being
run on the remote repository.  Apart from ensuring that the caller has `write`
access, to a repository which exists, no other checks are done and any spare
arguments are passed through to `git fsck`.

Simple `fsck` usage
-------------------

In the simple case a `gitano-admin` runs `fsck` against a repository which
definitely exists and as they are `gitano-admin` they have write access.

	SCENARIO Simple `fsck` cases

	GIVEN a standard instance
	 WHEN testinstance adminkey runs fsck gitano-admin
	 THEN stdout is empty
	  AND stderr is empty

No matter how powerful you are, you cannot `fsck` a repository which does not
exist...

	 WHEN testinstance adminkey, expecting failure, runs fsck somethingelse
	 THEN stdout is empty
	  AND stderr contains repository does not exist

Attempting to `fsck` when you have no write access
--------------------------------------------------

Since any non-`gitano-admin` member cannot see `gitano-admin` we can use that
as a test case for ensuring that you must have write access in order to `fsck`
something.

	SCENARIO lowly accolyte fails to fsck

	GIVEN a standard instance
	  AND testinstance has keys called other
	 WHEN testinstance, using adminkey, adds user other, using testinstance other
	  AND testinstance other, expecting failure, runs fsck gitano-admin
	 THEN stdout is empty
	  AND stderr contains Ruleset denied action

Passing commands through to `fsck`
----------------------------------

It is possible to pass arguments through to the `git fsck` subprocess.  By
passing through a bad option, we get to see this in action

	SCENARIO passing arguments to `fsck`

	GIVEN a standard instance
	 WHEN testinstance adminkey, expecting failure, runs fsck gitano-admin --bad-option
	 THEN stdout is empty

We check for `git fsck`'s usage message:

	  AND stderr contains error: unknown option
	  AND stderr contains usage: git fsck

And also we see that Gitano has caught the error

	  AND stderr contains Unable to continue