-
Notifications
You must be signed in to change notification settings - Fork 0
251 lines (226 loc) · 9.78 KB
/
tests-integration.yml
File metadata and controls
251 lines (226 loc) · 9.78 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Integration Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test-integration:
name: NC ${{ matrix.nextcloud-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nextcloud-version: ["32", "33"]
services:
nextcloud:
image: nextcloud:${{ matrix.nextcloud-version }}
env:
SQLITE_DATABASE: nextcloud
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
ports:
- 8080:80
options: >-
--health-cmd "curl -f http://localhost/status.php || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 30
--health-start-period 60s
smtp4dev:
image: rnwood/smtp4dev:latest
env:
ServerOptions__BasePath: /smtp4dev
ports:
- 9025:25
- 9143:143
- 9080:80
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Wait for Nextcloud
run: |
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/status.php | python3 -c "import sys,json; sys.exit(0 if json.load(sys.stdin)['installed'] else 1)" 2>/dev/null; then
echo "Nextcloud is ready"
break
fi
echo "Waiting... ($i)"
sleep 3
done
- name: Configure Nextcloud for testing
run: |
NC_CONTAINER=${{ job.services.nextcloud.id }}
OCC="docker exec $NC_CONTAINER su -s /bin/bash www-data -c"
$OCC "php occ config:system:set ratelimit_protection_enabled --value=false --type=boolean"
$OCC "php occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean"
$OCC "php occ config:system:set loglevel --value=2 --type=integer"
$OCC "php occ config:system:set ratelimit_overwrite files_sharing.shareapi.createshare user limit --value=1000 --type=integer"
$OCC "php occ config:system:set ratelimit_overwrite files_sharing.shareapi.createshare user period --value=60 --type=integer"
$OCC "php occ app:install spreed" || echo "spreed already installed"
$OCC "php occ app:install announcementcenter" || echo "announcementcenter already installed"
$OCC "php occ app:install collectives" || echo "collectives already installed"
$OCC "php occ app:install mail"
SMTP4DEV_IP=$(docker inspect ${{ job.services.smtp4dev.id }} --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
echo "smtp4dev IP: $SMTP4DEV_IP"
$OCC "php occ mail:account:create admin 'Test Mail' test@localhost $SMTP4DEV_IP 143 none test test $SMTP4DEV_IP 25 none test test"
$OCC "php occ mail:account:sync 1"
APP_PASS=$($OCC "php occ user:auth-tokens:add admin" | grep -oP '[A-Za-z0-9]{72}' | head -1)
if [ -z "$APP_PASS" ]; then echo "::error::Failed to generate app password"; exit 1; fi
echo "::add-mask::$APP_PASS"
echo "NC_APP_PASSWORD=$APP_PASS" >> "$GITHUB_ENV"
- name: Run integration tests
env:
NEXTCLOUD_URL: http://localhost:8080
NEXTCLOUD_USER: admin
NEXTCLOUD_PASSWORD: ${{ env.NC_APP_PASSWORD }}
NEXTCLOUD_MCP_APP_PASSWORD: "true"
SMTP4DEV_HOST: localhost
SMTP4DEV_HTTP_PORT: "9080"
SMTP4DEV_SMTP_PORT: "9025"
MAIL_RECIPIENT: test@localhost
NC_CONTAINER: ${{ job.services.nextcloud.id }}
MAIL_ACCOUNT_ID: "1"
run: pytest tests/integration/ -v -m integration --ignore=tests/integration/test_session_cache.py --cov=nc_mcp_server --cov-report=xml:coverage-integration.xml
- name: Upload coverage
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5
with:
files: coverage-integration.xml
flags: integration,nc${{ matrix.nextcloud-version }}
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Dump Nextcloud logs on failure
if: failure()
run: |
docker exec ${{ job.services.nextcloud.id }} cat /var/www/html/data/nextcloud.log 2>/dev/null | tail -50 || echo "No logs found"
test-session-cache:
name: Session cache (NC ${{ matrix.nextcloud-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nextcloud-version: ["32", "33"]
services:
nextcloud:
image: nextcloud:${{ matrix.nextcloud-version }}
env:
SQLITE_DATABASE: nextcloud
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
ports:
- 8080:80
options: >-
--health-cmd "curl -f http://localhost/status.php || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 30
--health-start-period 60s
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Wait for Nextcloud
run: |
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/status.php | python3 -c "import sys,json; sys.exit(0 if json.load(sys.stdin)['installed'] else 1)" 2>/dev/null; then
echo "Nextcloud is ready"
break
fi
echo "Waiting... ($i)"
sleep 3
done
- name: Configure Nextcloud for testing
run: |
NC_CONTAINER=${{ job.services.nextcloud.id }}
docker exec $NC_CONTAINER su -s /bin/bash www-data -c "php occ config:system:set ratelimit_protection_enabled --value=false --type=boolean"
docker exec $NC_CONTAINER su -s /bin/bash www-data -c "php occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean"
- name: Run session cache tests (regular password)
env:
NEXTCLOUD_URL: http://localhost:8080
NEXTCLOUD_USER: admin
NEXTCLOUD_PASSWORD: admin
NC_CONTAINER: ${{ job.services.nextcloud.id }}
run: pytest tests/integration/test_session_cache.py -v -m integration --cov=nc_mcp_server --cov-report=xml:coverage-session-cache.xml
- name: Upload coverage
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5
with:
files: coverage-session-cache.xml
flags: session-cache
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Dump Nextcloud logs on failure
if: failure()
run: |
docker exec ${{ job.services.nextcloud.id }} cat /var/www/html/data/nextcloud.log 2>/dev/null | tail -50 || echo "No logs found"
test-user-permissions:
name: User permissions (NC ${{ matrix.nextcloud-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
nextcloud-version: ["32", "33"]
services:
nextcloud:
image: nextcloud:${{ matrix.nextcloud-version }}
env:
SQLITE_DATABASE: nextcloud
NEXTCLOUD_ADMIN_USER: admin
NEXTCLOUD_ADMIN_PASSWORD: admin
ports:
- 8080:80
options: >-
--health-cmd "curl -f http://localhost/status.php || exit 1"
--health-interval 10s
--health-timeout 5s
--health-retries 30
--health-start-period 60s
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
cache: pip
- name: Install dependencies
run: pip install -e ".[dev]"
- name: Wait for Nextcloud
run: |
for i in $(seq 1 60); do
if curl -sf http://localhost:8080/status.php | python3 -c "import sys,json; sys.exit(0 if json.load(sys.stdin)['installed'] else 1)" 2>/dev/null; then
echo "Nextcloud is ready"
break
fi
echo "Waiting... ($i)"
sleep 3
done
- name: Configure Nextcloud for testing
run: |
NC_CONTAINER=${{ job.services.nextcloud.id }}
docker exec $NC_CONTAINER su -s /bin/bash www-data -c "php occ config:system:set ratelimit_protection_enabled --value=false --type=boolean"
docker exec $NC_CONTAINER su -s /bin/bash www-data -c "php occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean"
docker exec $NC_CONTAINER su -s /bin/bash www-data -c "php occ app:install spreed" || echo "spreed already installed"
- name: Run user permission tests
env:
NEXTCLOUD_URL: http://localhost:8080
NEXTCLOUD_USER: admin
NEXTCLOUD_PASSWORD: admin
run: pytest tests/integration/test_user_permissions.py -v -m integration --cov=nc_mcp_server --cov-report=xml:coverage-user-perms.xml
- name: Upload coverage
uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v5
with:
files: coverage-user-perms.xml
flags: user-permissions
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
- name: Dump Nextcloud logs on failure
if: failure()
run: |
docker exec ${{ job.services.nextcloud.id }} cat /var/www/html/data/nextcloud.log 2>/dev/null | tail -50 || echo "No logs found"