Skip to content

Commit 2232190

Browse files
committed
build: Add OpenAPI fuzzer script
Signed-off-by: provokateurin <[email protected]>
1 parent 1091e59 commit 2232190

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,5 @@ cypress/snapshots
186186
cypress/videos
187187

188188
/.direnv
189+
190+
/.hypothesis/

build/openapi-fuzzer.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
user="$1"
5+
spec="$2"
6+
7+
python -m venv venv
8+
source venv/bin/activate
9+
pip install schemathesis==4.1.0
10+
11+
rm data config/config.php -rf
12+
13+
./occ maintenance:install --admin-pass admin
14+
./occ config:system:set auth.bruteforce.protection.enabled --value=false --type=boolean
15+
16+
if [[ "$user" != "admin" ]]; then
17+
./occ app:disable password_policy
18+
NC_PASS="$user" ./occ user:add "$user" --password-from-env
19+
fi
20+
21+
app_password="$(echo "$user" | ./occ user:auth-tokens:add "$user" | tail -n 1)"
22+
23+
# Ensure enough workers will be available to handle all requests
24+
NEXTCLOUD_WORKERS=100 composer serve &> /dev/null &
25+
pid=$!
26+
function cleanup() {
27+
kill "$pid"
28+
}
29+
trap cleanup EXIT
30+
31+
until curl -s -o /dev/null http://localhost:8080/status.php; do sleep 1s; done
32+
33+
schemathesis run \
34+
"$spec" \
35+
--checks all \
36+
--workers 64 \
37+
--url http://localhost:8080 \
38+
-H "OCS-APIRequest: true" \
39+
-H "Accept: application/json" \
40+
-H "Authorization: Bearer $app_password" \
41+
--exclude-checks missing_required_header,unsupported_method,ignored_auth

0 commit comments

Comments
 (0)