summaryrefslogtreecommitdiff
path: root/git.liw.fi.yarn
blob: a469e6d4ad66eed72b9e9ff212c5e6b2e4dffd9b (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Test suite for ACL on git.liw.fi
================================

Introduction
------------

This is a test suite for my Gitano ACL setup on git.liw.fi. It is run
against either the real or a test instance of the setup. It requires
the person running it to have admin access on the Gitano instance,
so the tests can create and remove users and repositories.

Pre-requisites
--------------

Yarn must be run with `--env` used to set the environment variables
`GITANO` and `GITHOST`. `GITANO` must be the Unix user for the
Gitano instance (typically `git`), and `GITHOST` must be the address
of the host (IP address or domain name).

The person running this test suite must be able to log in to the
Gitano instance using their normal ssh key. In other words,
`ssh "$GITANO@$GITHOST" whoami` must work.

See the `check` script for details on how to invoke yarn for this test
suite.

The test suite will create a user called `tstusr` and `tstusr2`, and
remove them after the test suite. The users may get created and
removed multiple times.

User creation
-------------

The admin must be able to create and remove a user.

	SCENARIO admin can create and remove a user
	ASSUMING no tstusr user exists on server
	GIVEN an ssh key for tstusr
	WHEN admin creates user tstusr
	THEN user tstusr exists
	AND user tstusr can access gitano
	WHEN admin removes user tstusr
	THEN user tstusr doesn't exist
	FINALLY remove user tstusr on server

A non-admin mustn't be able to create or remove users.

	SCENARIO non-admin attempts to create or remove users
	ASSUMING no tstusr user exists on server
	AND no tstusr2 user exists on server
	GIVEN an ssh key for tstusr
	AND an ssh key for tstusr2
	WHEN admin creates user tstusr
	AND tstusr attempts to create user tstusr2
	THEN gitano failed with error matching "You may not perform site administration"
	FINALLY remove user tstusr on server

Implementations
---------------

Verify that there are no test related users on the server. If there
is, something's gone wrong in a previous run, and things should be
cleaned up manually. Or another run of the test suite is going on, and
we shouldn't interfere with that.

We split up the various assumptions so the implementation code
doesn't make assumptions on user names, etc.

	IMPLEMENTS ASSUMING no (\S+) user exists on server
	if user_exists "$MATCH_1"
	then
		die "User $MATCH_1 exists on server, but shouldn't"
	fi
	
Create an ssh key for a user. This is generated for a scenario,
then discarded.

	IMPLEMENTS GIVEN an ssh key for (\S+)
	ssh-keygen -f "$DATADIR/$MATCH_1.key" -N ''
	
Create a user on the server. Only an admin should be able to do
this, but anyone can try. Note that since we only care about
usernames, we invent the real name and e-mail address.

	IMPLEMENTS WHEN (\S+) creates user (\S+)
	user_add "$MATCH_1" "$MATCH_2"

Verify a user exists on the server.

	IMPLEMENTS THEN user (\S+) exists
	user_exists "$MATCH_1"

Verify a user can access gitano (by invoking whoami).

	IMPLEMENTS THEN user (\S+) can access gitano
	run_gitano_as "$MATCH_1" whoami | grep "User name: $MATCH_1\$"

Remove a user.

	IMPLEMENTS WHEN (\S+) removes user (\S+)
	user_del "$MATCH_1" "$MATCH_2"

Verify a user doesn't exist on the server.

	IMPLEMENTS THEN user (\S+) doesn't exist
	if user_exists "$MATCH_1"
	then
		die "User $MATCH_1 exists on server, but shouldn't"
	fi

Clean up user.

	IMPLEMENTS FINALLY remove user (\S+) on server
	user_del admin "$MATCH_1"

Attempt to create a user; check later if it worked.

	IMPLEMENTS WHEN (\S+) attempts to create user (\S+)
	attempt user_add "$MATCH_1" "$MATCH_2"

Check error message from latest gitano run that we assumed would fail.

	IMPLEMENTS THEN gitano failed with error matching "(.*)"
	echo ==========================
	cat "$DATADIR/attempt.stderr"
	echo ==========================
	grep "$MATCH_1" "$DATADIR/attempt.stderr"