blob: 52fdcd1e61d5b84188e0f25896246599a48a93ad (
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
|
#!/bin/sh
test_description='git-serve tests'
. ./setup.sh
test_expect_success 'Test interactive shell.' '
"$GIT_SERVE" 2>&1 | grep -q "Interactive shell is disabled."
'
test_expect_success 'Test help.' '
SSH_ORIGINAL_COMMAND=help "$GIT_SERVE" 2>&1 | grep -q "^Commands:$"
'
test_expect_success 'Test setup-repo and list-repos.' '
SSH_ORIGINAL_COMMAND="setup-repo foobar" AUR_USER=user \
"$GIT_SERVE" 2>&1 &&
SSH_ORIGINAL_COMMAND="setup-repo foobar2" AUR_USER=tu \
"$GIT_SERVE" 2>&1 &&
cat >expected <<-EOF &&
*foobar
EOF
SSH_ORIGINAL_COMMAND="list-repos" AUR_USER=user \
"$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success 'Test git-receive-pack.' '
cat >expected <<-EOF &&
user
foobar
foobar
EOF
SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success 'Test git-receive-pack with an invalid repository name.' '
SSH_ORIGINAL_COMMAND="git-receive-pack /!.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
test_must_fail "$GIT_SERVE" 2>&1 >actual
'
test_expect_success "Test git-upload-pack." '
cat >expected <<-EOF &&
user
foobar
foobar
EOF
SSH_ORIGINAL_COMMAND="git-upload-pack /foobar.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success "Try to pull from someone else's repository." '
cat >expected <<-EOF &&
user
foobar2
foobar2
EOF
SSH_ORIGINAL_COMMAND="git-upload-pack /foobar2.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success "Try to push to someone else's repository." '
SSH_ORIGINAL_COMMAND="git-receive-pack /foobar2.git/" \
AUR_USER=user AUR_PRIVILEGED=0 \
test_must_fail "$GIT_SERVE" 2>&1
'
test_expect_success "Try to push to someone else's repository as Trusted User." '
cat >expected <<-EOF &&
tu
foobar
foobar
EOF
SSH_ORIGINAL_COMMAND="git-receive-pack /foobar.git/" \
AUR_USER=tu AUR_PRIVILEGED=1 \
"$GIT_SERVE" 2>&1 >actual &&
test_cmp expected actual
'
test_expect_success "Test restore." '
echo "DELETE FROM PackageBases WHERE Name = \"foobar\";" | \
sqlite3 aur.db &&
cat >expected <<-EOF &&
user
foobar
EOF
SSH_ORIGINAL_COMMAND="restore foobar" AUR_USER=user AUR_PRIVILEGED=0 \
"$GIT_SERVE" 2>&1 >actual
test_cmp expected actual
'
test_expect_success "Try to restore an existing package base." '
SSH_ORIGINAL_COMMAND="restore foobar2" AUR_USER=user AUR_PRIVILEGED=0 \
test_must_fail "$GIT_SERVE" 2>&1
'
test_done
|