-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add ci job to run wopi-validator-core
Signed-off-by: Julius Knorr <[email protected]>
- Loading branch information
1 parent
ef1ab86
commit 56918eb
Showing
2 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
# SPDX-License-Identifier: MIT | ||
name: WOPI validator tests | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- stable* | ||
|
||
env: | ||
APP_NAME: richdocuments | ||
|
||
jobs: | ||
changes: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
src: ${{ steps.changes.outputs.src}} | ||
|
||
steps: | ||
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 | ||
id: changes | ||
continue-on-error: true | ||
with: | ||
filters: | | ||
src: | ||
- '.github/workflows/**' | ||
- 'appinfo/**' | ||
- 'lib/**' | ||
- 'templates/**' | ||
- 'tests/**' | ||
- 'vendor/**' | ||
- 'vendor-bin/**' | ||
- '.php-cs-fixer.dist.php' | ||
- 'composer.json' | ||
- 'composer.lock' | ||
sqlite: | ||
runs-on: ubuntu-latest | ||
|
||
needs: changes | ||
if: needs.changes.outputs.src != 'false' | ||
|
||
strategy: | ||
# do not stop on another job's failure | ||
fail-fast: false | ||
matrix: | ||
php-versions: ['8.1'] | ||
server-versions: ['master'] | ||
|
||
name: wopi-${{ matrix.php-versions }}-${{ matrix.server-versions }} | ||
|
||
services: | ||
collabora: | ||
image: collabora/code:latest | ||
env: | ||
extra_params: '--o:ssl.enable=false' | ||
aliasgroup1: 'http://nextcloud' | ||
ports: | ||
- "9980:9980" | ||
|
||
steps: | ||
- name: Checkout server | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: nextcloud/server | ||
ref: ${{ matrix.server-versions }} | ||
|
||
- name: Checkout submodules | ||
shell: bash | ||
run: | | ||
auth_header="$(git config --local --get http.https://github.com/.extraheader)" | ||
git submodule sync --recursive | ||
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 | ||
- name: Checkout app | ||
uses: actions/checkout@v2 | ||
with: | ||
path: apps/${{ env.APP_NAME }} | ||
|
||
- name: Set up php ${{ matrix.php-versions }} | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-versions }} | ||
tools: phpunit:8.5.14 | ||
extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite, gd, zip, apcu | ||
ini-values: | ||
apc.enable_cli=on | ||
coverage: none | ||
|
||
- name: Set up Nextcloud | ||
env: | ||
DB_PORT: 4444 | ||
run: | | ||
mkdir data | ||
echo '<?php $CONFIG=["memcache.local"=>"\OC\Memcache\APCu","hashing_default_password"=>true];' > config/config.php | ||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin | ||
./occ config:system:set trusted_domains 1 --value=172.17.0.1 | ||
./occ app:enable --force ${{ env.APP_NAME }} | ||
# For now we require a some wopi server to be setup to generate a token | ||
./occ config:app:set richdocuments wopi_url --value="http://localhost:9980" | ||
./occ config:app:set richdocuments public_wopi_url --value="http://localhost:9980" | ||
./occ config:system:set allow_local_remote_servers --value true --type bool | ||
./occ richdocuments:activate-config | ||
- name: Run WOPI validator tests | ||
working-directory: apps/${{ env.APP_NAME }} | ||
run: | | ||
PHP_CLI_SERVER_WORKERS=10 php -S 172.17.0.1:8080 -t ../../ & | ||
NEXTCLOUD_URL=http://172.17.0.1:8080 ./tests/wopi-test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
|
||
# current timestamp as filename | ||
FILENAME=$(date +%s) | ||
|
||
NEXTCLOUD_URL=${NEXTCLOUD_URL:-http://nextcloud.local} | ||
USERNAME=${USERNAME:-admin} | ||
PASSWORD=${PASSWORD:-admin} | ||
HOST_IP=${HOST_IP:-172.17.0.1} | ||
|
||
curl $NEXTCLOUD_URL/status.php --max-time 5 --retry 5 --retry-delay 0 --retry-max-time 30 --retry-connrefused | ||
|
||
curl -X PUT -u $USERNAME:$PASSWORD $NEXTCLOUD_URL/remote.php/webdav/$FILENAME.odt -s | ||
|
||
PROPFIND_RESULT=$(curl -X PROPFIND -u $USERNAME:$PASSWORD $NEXTCLOUD_URL/remote.php/webdav/$FILENAME.odt --data '<?xml version="1.0"?><d:propfind xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:ocs="http://open-collaboration-services.org/ns"><d:prop><oc:fileid /></d:prop></d:propfind>' -s) | ||
FILE_ID=$(echo $PROPFIND_RESULT | grep -ohE '<oc:fileid>(.*)</oc:fileid>' | cut -d'>' -f 2 | cut -d'<' -f 1) | ||
|
||
COOKIEJAR=/tmp/cookie-jar | ||
rm -f $COOKIEJAR | ||
CSRF_TOKEN=$(curl $NEXTCLOUD_URL/index.php/login --cookie-jar $COOKIEJAR -s | grep requesttoken | grep -ohE 'data-requesttoken="(.*)"' | cut -d'"' -f 2) | ||
|
||
echo "File id: $FILE_ID" | ||
echo "CSRF token: $CSRF_TOKEN" | ||
|
||
|
||
WOPI_TOKEN=$(curl -u $USERNAME:$PASSWORD --cookie-jar $COOKIEJAR $NEXTCLOUD_URL/index.php/apps/richdocuments/token?fileId=$FILE_ID -X POST -H "requesttoken: $CSRF_TOKEN" -s | jq -r .token) | ||
|
||
# Nextcloud needed a valid mimetype before ut the wopi test can only be ran with a .wopitest file | ||
curl -X MOVE -u $USERNAME:$PASSWORD $NEXTCLOUD_URL/remote.php/webdav/$FILENAME.odt -H "Destination: $NEXTCLOUD_URL/remote.php/webdav/$FILENAME.wopitest" | ||
|
||
WOPI_URL="$NEXTCLOUD_URL/index.php/apps/richdocuments/wopi/files/$FILE_ID" | ||
|
||
echo "WOPI URL: $WOPI_URL" | ||
echo "WOPI token generated: $WOPI_TOKEN" | ||
|
||
docker run --add-host nextcloud.local:${HOST_IP} --rm tylerbutler/wopi-validator -- -w $WOPI_URL -t $WOPI_TOKEN -l 0 "$@" |