Compare commits

..
Author SHA1 Message Date
Michal Klos e0a8dc1989 Revert "feat: [OCISDEV-744] build-and-test, lint"
This reverts commit 32a7d1fdd4.
2026-04-01 10:11:01 +02:00
Michal Klos 1516b0c3c9 Revert "feat: [OCISDEV-744] build-and-test, lint"
This reverts commit e35c524e3e.
2026-04-01 10:11:01 +02:00
Michal Klos 456fb2de70 Revert "feat: [OCISDEV-744] build-and-test, lint"
This reverts commit a18fb74da9.
2026-04-01 10:11:01 +02:00
Michal Klos 84b07df58d Revert "feat: [OCISDEV-744] build-and-test, lint"
This reverts commit 2526a4ff64.
2026-04-01 10:11:01 +02:00
Michal Klos e59787b9cd Revert "feat: [OCISDEV-744] build-and-test, lint"
This reverts commit bd0e8f00f1.
2026-04-01 10:11:01 +02:00
Michal Klos 08397e8aa3 Revert "feat: [OCISDEV-744] build-and-test, lint"
This reverts commit 0db1b6bf35.
2026-04-01 10:11:01 +02:00
Michal Klos e8022813f3 Revert "feat: [OCISDEV-744] build-and-test, lint"
This reverts commit b965c883e2.
2026-04-01 10:11:01 +02:00
Michal Klos 41fa1514f9 Revert "feat: [OCISDEV-744] build-and-test, lint, fix flakiness"
This reverts commit 4c8039b6cd.
2026-04-01 10:11:01 +02:00
Michal Klos 4414100ede Revert "feat: [OCISDEV-744] build-and-test, lint, fix flakiness"
This reverts commit 5e87222571.
2026-04-01 10:11:01 +02:00
Michal Klos 5e87222571 feat: [OCISDEV-744] build-and-test, lint, fix flakiness 2026-04-01 10:10:04 +02:00
Michal Klos 4c8039b6cd feat: [OCISDEV-744] build-and-test, lint, fix flakiness 2026-04-01 10:10:04 +02:00
Michal Klos b965c883e2 feat: [OCISDEV-744] build-and-test, lint 2026-04-01 10:10:04 +02:00
Michal Klos 0db1b6bf35 feat: [OCISDEV-744] build-and-test, lint 2026-04-01 10:10:04 +02:00
Michal Klos bd0e8f00f1 feat: [OCISDEV-744] build-and-test, lint 2026-04-01 10:10:04 +02:00
Michal Klos 2526a4ff64 feat: [OCISDEV-744] build-and-test, lint 2026-04-01 10:10:04 +02:00
Michal Klos a18fb74da9 feat: [OCISDEV-744] build-and-test, lint 2026-04-01 10:10:04 +02:00
Michal Klos e35c524e3e feat: [OCISDEV-744] build-and-test, lint 2026-04-01 10:10:04 +02:00
Michal Klos 32a7d1fdd4 feat: [OCISDEV-744] build-and-test, lint 2026-04-01 10:10:04 +02:00
Michal Klos 0f3ce714f8 feat: [OCISDEV-741] integration 2026-03-31 14:29:12 +02:00
Michal Klos 8898eb4ef7 feat: [OCISDEV-741] local-api-test, apiCollaboration
# Conflicts:
#	.github/workflows/acceptance-tests.yml
#	tests/acceptance/run-github.py
2026-03-31 10:39:28 +02:00
Michal Klos 55856cb722 feat: [OCISDEV-744] cli-test 2026-03-30 18:02:21 +02:00
dependabot[bot] aba9654f87 build(deps): bump actions/checkout from 4 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-30 13:35:32 +02:00
Michal Klos 46d772f4f6 feat: [OCISDEV-741] local-api-test, apiSpaces 2026-03-30 12:45:26 +02:00
Michal Klos d0b41ea4a9 feat: [OCISDEV-741] local-api-test part 2 2026-03-27 17:29:46 +01:00
dependabot[bot] 7234648e14 build(deps): bump fpicalausa/remove-stale-branches from 1.6.0 to 2.4.0
Bumps [fpicalausa/remove-stale-branches](https://github.com/fpicalausa/remove-stale-branches) from 1.6.0 to 2.4.0.
- [Release notes](https://github.com/fpicalausa/remove-stale-branches/releases)
- [Commits](https://github.com/fpicalausa/remove-stale-branches/compare/v1.6.0...v2.4.0)

---
updated-dependencies:
- dependency-name: fpicalausa/remove-stale-branches
  dependency-version: 2.4.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-26 17:01:11 +01:00
Thomas Müller c49316b424 ci: [ocisdev-730] code quality 2026-03-26 14:57:42 +01:00
Michal Klos 825838898d feat: [OCISDEV-743] build and unit test 2026-03-26 13:56:07 +01:00
Thomas Müller 524cd79841 ci: add ecosystem github-actions to dependabot 2026-03-26 13:00:28 +01:00
Michal Klos a7a5ed8a91 feat: [OCISDEV-740] acceptance test, coverage P0 2026-03-26 09:34:06 +01:00
Michal Klos b620b5453a feat: [OCISDEV-732] acceptance test (#12143)
* feat: acceptance test - graph

* feat: acceptance test - graph

* feat: acceptance test - graph

* fix: remove drone

* feat: run each behat suite as a separate worker

* feat: rename
2026-03-25 14:20:04 +01:00
9 changed files with 1779 additions and 6 deletions

No files matched your search

+5
View File
@@ -19,4 +19,9 @@ updates:
schedule:
interval: "weekly"
open-pull-requests-limit: 2
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
+2 -4
View File
@@ -55,8 +55,7 @@ branches:
require_code_owner_reviews: false
required_status_checks:
strict: false
contexts:
- continuous-integration/drone/pr
contexts: []
enforce_admins: null
restrictions:
apps: []
@@ -74,8 +73,7 @@ branches:
require_code_owner_reviews: false
required_status_checks:
strict: false
contexts:
- continuous-integration/drone/pr
contexts: []
enforce_admins: null
restrictions:
apps: []
+320
View File
@@ -0,0 +1,320 @@
name: Acceptance Tests
on:
pull_request:
workflow_dispatch:
jobs:
coding-standard:
name: coding-standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: PHP code style
run: |
make vendor-bin-codestyle
make vendor-bin-codesniffer
make test-php-style
- name: Check env var annotations
run: make check-env-var-annotations
check-gherkin-standard:
name: check-gherkin-standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Lint feature files
run: |
npm install -g @gherlint/gherlint@1.1.0
make test-gherkin-lint
check-suites-in-expected-failures:
name: check-suites-in-expected-failures
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Check suites
run: bash tests/acceptance/check-deleted-suites-in-expected-failure.sh
build-and-test:
name: build-and-test
needs: [coding-standard, check-gherkin-standard, check-suites-in-expected-failures]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
- name: Build ocis
run: make -C ocis build
- name: Unit tests
run: make test
local-api-tests:
name: ${{ matrix.suite }}
needs: [build-and-test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
# contract & locks
- apiContract
- apiLocks
# settings & notifications (needs email)
- apiSettings
- apiNotification
- apiCors
# graph
- apiGraphUser
- apiGraph
- apiGraphGroup
# spaces & dav
- apiSpaces
- apiSpacesShares
- apiSpacesDavOperation
- apiDownloads
- apiAsyncUpload
- apiDepthInfinity
- apiArchiver
- apiActivities
# search
- apiSearch1
# - apiSearch2
- apiSearchContent # needs Tika
# sharing
- apiSharingNgShares
- apiReshare
- apiSharingNgPermissions
- apiSharingNgAdditionalShareRole
- apiSharingNgDriveInvitation
- apiSharingNgItemInvitation
- apiSharingNgDriveLinkShare
- apiSharingNgItemLinkShare
- apiSharingNgLinkShareManagement
# auth
- apiAuthApp
# antivirus (needs ClamAV)
- apiAntivirus
# federation (needs email + federation ocis)
# - apiOcm
# collaboration (needs WOPI)
- apiCollaboration
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
- name: Install libcurl 8.12.0 from source
run: |
sudo apt-get update -qq
sudo apt-get install -y libssl-dev libnghttp2-dev libpsl-dev libldap-dev libssh-dev zlib1g-dev libvips-dev
cd /tmp
curl -sLO https://curl.se/download/curl-8.12.0.tar.gz
tar xzf curl-8.12.0.tar.gz
cd curl-8.12.0
./configure --with-ssl --with-zlib --with-nghttp2 --prefix=/usr/local --enable-versioned-symbols --silent
make -j$(nproc) --silent
sudo make install --silent
sudo ldconfig
curl --version | head -1
php -r '
$v = curl_version()["version"];
echo "PHP curl: $v\n";
if (version_compare($v, "8.12.0", "<")) {
fwrite(STDERR, "FATAL: PHP sees libcurl $v, need >= 8.12.0\n");
exit(1);
}
'
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: Run ${{ matrix.suite }}
run: BEHAT_SUITES=${{ matrix.suite }} python3 tests/acceptance/run-github.py
cli-tests:
needs: [build-and-test]
name: ${{ matrix.suite }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
- cliCommands,apiServiceAvailability # grouped like drone; needs ClamAV + email
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: Run ${{ matrix.suite }}
run: BEHAT_SUITES="${{ matrix.suite }}" python3 tests/acceptance/run-github.py
core-api-tests:
name: ${{ matrix.suite }}
needs: [build-and-test]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
suite:
- "coreApiShareManagementBasicToShares,coreApiShareManagementToShares"
- "coreApiSharees,coreApiSharePublicLink2"
- "coreApiShareOperationsToShares1,coreApiShareOperationsToShares2,coreApiSharePublicLink1,coreApiShareCreateSpecialToShares1,coreApiShareCreateSpecialToShares2,coreApiShareUpdateToShares"
- "coreApiTrashbin,coreApiTrashbinRestore,coreApiWebdavEtagPropagation1,coreApiWebdavEtagPropagation2"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: go.mod
cache: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24"
- name: Enable pnpm
run: corepack enable && corepack prepare pnpm@10.28.1 --activate
- name: Install libcurl 8.12.0 from source
run: |
sudo apt-get update -qq
sudo apt-get install -y libssl-dev libnghttp2-dev libpsl-dev libldap-dev libssh-dev zlib1g-dev libvips-dev
cd /tmp
curl -sLO https://curl.se/download/curl-8.12.0.tar.gz
tar xzf curl-8.12.0.tar.gz
cd curl-8.12.0
./configure --with-ssl --with-zlib --with-nghttp2 --prefix=/usr/local --enable-versioned-symbols --silent
make -j$(nproc) --silent
sudo make install --silent
sudo ldconfig
curl --version | head -1
php -r '
$v = curl_version()["version"];
echo "PHP curl: $v\n";
if (version_compare($v, "8.12.0", "<")) {
fwrite(STDERR, "FATAL: PHP sees libcurl $v, need >= 8.12.0\n");
exit(1);
}
'
- uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: "8.4"
extensions: curl, xml, mbstring, zip
tools: composer
- name: Run ${{ matrix.suite }}
run: >
BEHAT_SUITES="${{ matrix.suite }}"
ACCEPTANCE_TEST_TYPE=core-api
EXPECTED_FAILURES_FILE=tests/acceptance/expected-failures-API-on-OCIS-storage.md
python3 tests/acceptance/run-github.py
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs-${{ matrix.suite }}
path: tests/acceptance/output/
litmus:
name: litmus
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run litmus
run: python3 tests/acceptance/run-litmus.py
cs3api:
name: cs3api
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run cs3api validator
run: python3 tests/acceptance/run-cs3api.py
wopi-builtin:
name: wopi-builtin
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run WOPI validator (builtin)
run: python3 tests/acceptance/run-wopi.py --type builtin
wopi-cs3:
name: wopi-cs3
needs: [build-and-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Run WOPI validator (cs3)
run: python3 tests/acceptance/run-wopi.py --type cs3
all-acceptance-tests:
needs: [local-api-tests, cli-tests, core-api-tests, litmus, cs3api, wopi-builtin, wopi-cs3]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check all jobs passed
run: |
if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
exit 1
fi
+1 -1
View File
@@ -17,7 +17,7 @@ jobs:
name: Remove Stale Branches
runs-on: ubuntu-latest
steps:
- uses: fpicalausa/remove-stale-branches@v1.6.0
- uses: fpicalausa/remove-stale-branches@v2.4.0
with:
ignore-unknown-authors: true
default-recipient: "kobergj"
+1 -1
View File
@@ -18,7 +18,7 @@ jobs:
container: golang:1.25-alpine
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Run CI Reporter
working-directory: tools/ci-reporter
+143
View File
@@ -0,0 +1,143 @@
#!/usr/bin/env python3
"""
Run CS3 API validator tests locally and in GitHub Actions CI.
Config sourced from .drone.star cs3ApiTests() — single source of truth.
Usage: python3 tests/acceptance/run-cs3api.py
"""
import os
import shutil
import signal
import subprocess
import sys
import time
from pathlib import Path
# ---------------------------------------------------------------------------
# Constants (mirroring .drone.star)
# ---------------------------------------------------------------------------
# HTTPS — matching drone: ocis init generates a self-signed cert; proxy uses TLS by default.
# Host-side curl calls use -k (insecure) to skip cert verification.
OCIS_URL = "https://127.0.0.1:9200"
CS3API_IMAGE = "owncloud/cs3api-validator:0.2.1"
def get_docker_bridge_ip() -> str:
"""Return the Docker bridge gateway IP, reachable from host and Docker containers."""
r = subprocess.run(
["docker", "network", "inspect", "bridge",
"--format", "{{range .IPAM.Config}}{{.Gateway}}{{end}}"],
capture_output=True, text=True, check=True,
)
return r.stdout.strip()
def base_server_env(repo_root: Path, ocis_config_dir: str, ocis_public_url: str) -> dict:
"""OCIS server environment matching drone ocisServer(deploy_type='cs3api_validator')."""
return {
"OCIS_URL": ocis_public_url,
"OCIS_CONFIG_DIR": ocis_config_dir,
"STORAGE_USERS_DRIVER": "ocis",
"PROXY_ENABLE_BASIC_AUTH": "true",
# No PROXY_TLS override — drone lets ocis use its default TLS (self-signed cert from init)
# IDP excluded: its static assets are absent when running as a host process
"OCIS_EXCLUDE_RUN_SERVICES": "idp",
"OCIS_LOG_LEVEL": "error",
"IDM_CREATE_DEMO_USERS": "true",
"IDM_ADMIN_PASSWORD": "admin",
"FRONTEND_SEARCH_MIN_LENGTH": "2",
"OCIS_ASYNC_UPLOADS": "true",
"OCIS_EVENTS_ENABLE_TLS": "false",
"NATS_NATS_HOST": "0.0.0.0",
"NATS_NATS_PORT": "9233",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"EVENTHISTORY_STORE": "memory",
"WEB_UI_CONFIG_FILE": str(repo_root / "tests/config/drone/ocis-config.json"),
# cs3api_validator extras (drone ocisServer deploy_type="cs3api_validator")
"GATEWAY_GRPC_ADDR": "0.0.0.0:9142",
"OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD": "false",
}
def wait_for(condition_fn, timeout: int, label: str) -> None:
deadline = time.time() + timeout
while not condition_fn():
if time.time() > deadline:
print(f"Timeout waiting for {label}", file=sys.stderr)
sys.exit(1)
time.sleep(1)
def ocis_healthy(ocis_url: str) -> bool:
r = subprocess.run(
["curl", "-sk", "-uadmin:admin",
f"{ocis_url}/graph/v1.0/users/admin",
"-w", "%{http_code}", "-o", "/dev/null"],
capture_output=True, text=True,
)
return r.stdout.strip() == "200"
def main() -> int:
repo_root = Path(__file__).resolve().parents[2]
ocis_bin = repo_root / "ocis/bin/ocis"
ocis_config_dir = Path.home() / ".ocis/config"
subprocess.run(["make", "-C", str(repo_root / "ocis"), "build"], check=True)
# Docker bridge gateway IP: reachable from both the host and Docker containers.
# cs3api-validator connects to the GRPC gateway at {bridge_ip}:9142.
bridge_ip = get_docker_bridge_ip()
print(f"Docker bridge IP: {bridge_ip}", flush=True)
server_env = {**os.environ}
server_env.update(base_server_env(repo_root, str(ocis_config_dir),
f"https://{bridge_ip}:9200"))
subprocess.run(
[str(ocis_bin), "init", "--insecure", "true"],
env=server_env,
check=True,
)
shutil.copy(
repo_root / "tests/config/drone/app-registry.yaml",
ocis_config_dir / "app-registry.yaml",
)
print("Starting ocis...", flush=True)
ocis_proc = subprocess.Popen(
[str(ocis_bin), "server"],
env=server_env,
)
def cleanup(*_):
try:
ocis_proc.terminate()
except Exception:
pass
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
try:
wait_for(lambda: ocis_healthy(OCIS_URL), 300, "ocis")
print("ocis ready.", flush=True)
print(f"\nRunning cs3api-validator against {bridge_ip}:9142", flush=True)
result = subprocess.run(
["docker", "run", "--rm",
"--entrypoint", "/usr/bin/cs3api-validator",
CS3API_IMAGE,
"/var/lib/cs3api-validator",
f"--endpoint={bridge_ip}:9142"],
)
return result.returncode
finally:
cleanup()
if __name__ == "__main__":
sys.exit(main())
+688
View File
@@ -0,0 +1,688 @@
#!/usr/bin/env python3
"""
Run ocis acceptance tests locally and in GitHub Actions CI.
Config sourced from .drone.star localApiTests — single source of truth.
Usage: BEHAT_SUITES=apiGraph python3 tests/acceptance/run-github.py
"""
import json
import os
import sys
import subprocess
import signal
import time
import tempfile
import shutil
from pathlib import Path
# ---------------------------------------------------------------------------
# Config sourced from .drone.star
# NOTE: EMAIL_SMTP_HOST is "email" (container name) in drone, "localhost" here
# ---------------------------------------------------------------------------
EMAIL_SMTP_HOST = "localhost"
EMAIL_SMTP_PORT = "1025"
EMAIL_PORT = "8025"
EMAIL_SMTP_SENDER = "ownCloud <noreply@example.com>"
LOCAL_API_TESTS = {
"contractAndLock": {
"suites": ["apiContract", "apiLocks"],
},
"settingsAndNotification": {
"suites": ["apiSettings", "apiNotification", "apiCors"],
"emailNeeded": True,
"extraEnvironment": {
"EMAIL_HOST": EMAIL_SMTP_HOST,
"EMAIL_PORT": EMAIL_PORT,
},
"extraServerEnvironment": {
"OCIS_ADD_RUN_SERVICES": "notifications",
"NOTIFICATIONS_SMTP_HOST": EMAIL_SMTP_HOST,
"NOTIFICATIONS_SMTP_PORT": EMAIL_SMTP_PORT,
"NOTIFICATIONS_SMTP_INSECURE": "true",
"NOTIFICATIONS_SMTP_SENDER": EMAIL_SMTP_SENDER,
"NOTIFICATIONS_DEBUG_ADDR": "0.0.0.0:9174",
},
},
"graphUser": {
"suites": ["apiGraphUser"],
},
"spaces": {
"suites": ["apiSpaces"],
},
"spacesShares": {
"suites": ["apiSpacesShares"],
},
"davOperations": {
"suites": [
"apiSpacesDavOperation", "apiDownloads", "apiAsyncUpload",
"apiDepthInfinity", "apiArchiver", "apiActivities",
],
},
"groupAndSearch1": {
"suites": ["apiSearch1", "apiGraph", "apiGraphGroup"],
},
"search2": {
"suites": ["apiSearch2", "apiSearchContent"],
"tikaNeeded": True,
"extraServerEnvironment": {
"FRONTEND_FULL_TEXT_SEARCH_ENABLED": "true",
"SEARCH_EXTRACTOR_TYPE": "tika",
"SEARCH_EXTRACTOR_TIKA_TIKA_URL": "http://localhost:9998",
"SEARCH_EXTRACTOR_CS3SOURCE_INSECURE": "true",
},
},
"sharingNg1": {
"suites": ["apiSharingNgShares", "apiReshare", "apiSharingNgPermissions"],
},
"sharingNgAdditionalShareRole": {
"suites": ["apiSharingNgAdditionalShareRole"],
},
"sharingNgShareInvitation": {
"suites": ["apiSharingNgDriveInvitation", "apiSharingNgItemInvitation"],
},
"sharingNgLinkShare": {
"suites": [
"apiSharingNgDriveLinkShare", "apiSharingNgItemLinkShare",
"apiSharingNgLinkShareManagement",
],
},
"antivirus": {
"suites": ["apiAntivirus"],
"antivirusNeeded": True,
"extraServerEnvironment": {
"ANTIVIRUS_SCANNER_TYPE": "clamav",
"ANTIVIRUS_CLAMAV_SOCKET": "tcp://clamav:3310",
"POSTPROCESSING_STEPS": "virusscan",
"OCIS_ADD_RUN_SERVICES": "antivirus",
"ANTIVIRUS_DEBUG_ADDR": "0.0.0.0:9277",
},
},
"ocm": {
"suites": ["apiOcm"],
"emailNeeded": True,
"federationServer": True,
"extraEnvironment": {
"EMAIL_HOST": EMAIL_SMTP_HOST,
"EMAIL_PORT": EMAIL_PORT,
},
"extraServerEnvironment": {
"OCIS_ADD_RUN_SERVICES": "ocm,notifications",
"OCIS_ENABLE_OCM": "true",
"OCM_OCM_INVITE_MANAGER_INSECURE": "true",
"OCM_OCM_SHARE_PROVIDER_INSECURE": "true",
"OCM_OCM_STORAGE_PROVIDER_INSECURE": "true",
"OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE": "", # set at runtime
"NOTIFICATIONS_SMTP_HOST": EMAIL_SMTP_HOST,
"NOTIFICATIONS_SMTP_PORT": EMAIL_SMTP_PORT,
"NOTIFICATIONS_SMTP_INSECURE": "true",
"NOTIFICATIONS_SMTP_SENDER": EMAIL_SMTP_SENDER,
},
},
"authApp": {
"suites": ["apiAuthApp"],
"extraServerEnvironment": {
"OCIS_ADD_RUN_SERVICES": "auth-app",
"PROXY_ENABLE_APP_AUTH": "true",
},
},
"wopi": {
"suites": ["apiCollaboration"],
"collaborationServiceNeeded": True,
"extraServerEnvironment": {
"GATEWAY_GRPC_ADDR": "0.0.0.0:9142",
},
},
"cliCommands": {
"suites": ["cliCommands", "apiServiceAvailability"],
"antivirusNeeded": True,
"emailNeeded": True,
"extraEnvironment": {
"EMAIL_HOST": EMAIL_SMTP_HOST,
"EMAIL_PORT": EMAIL_PORT,
},
"extraServerEnvironment": {
"NOTIFICATIONS_SMTP_HOST": EMAIL_SMTP_HOST,
"NOTIFICATIONS_SMTP_PORT": EMAIL_SMTP_PORT,
"NOTIFICATIONS_SMTP_INSECURE": "true",
"NOTIFICATIONS_SMTP_SENDER": EMAIL_SMTP_SENDER,
"NOTIFICATIONS_DEBUG_ADDR": "0.0.0.0:9174",
"ANTIVIRUS_SCANNER_TYPE": "clamav",
"ANTIVIRUS_CLAMAV_SOCKET": "tcp://clamav:3310",
"ANTIVIRUS_DEBUG_ADDR": "0.0.0.0:9277",
"OCIS_ADD_RUN_SERVICES": "antivirus,notifications",
},
},
}
# reverse lookup: suite → group config
_SUITE_TO_CONFIG: dict = {}
for _cfg in LOCAL_API_TESTS.values():
for _s in _cfg.get("suites", []):
_SUITE_TO_CONFIG[_s] = _cfg
# GitHub Actions uses --network host: all wopi services share one network namespace.
# Drone gives each service its own container → all can use 9300/9301/9304.
# Assign distinct ports here to avoid collisions.
_WOPI_PORTS = {
"collabora": {"grpc": 9301, "http": 9300, "debug": 9304},
"onlyoffice": {"grpc": 9311, "http": 9310, "debug": 9314},
"fakeoffice": {"grpc": 9321, "http": 9320, "debug": 9324},
}
def merged_config(suites: list) -> dict:
"""Union config for all requested suites."""
merged = {
"emailNeeded": False,
"antivirusNeeded": False,
"tikaNeeded": False,
"federationServer": False,
"collaborationServiceNeeded": False,
"extraServerEnvironment": {},
"extraEnvironment": {},
}
for suite in suites:
cfg = _SUITE_TO_CONFIG.get(suite, {})
for flag in ("emailNeeded", "antivirusNeeded", "tikaNeeded",
"federationServer", "collaborationServiceNeeded"):
if cfg.get(flag):
merged[flag] = True
merged["extraServerEnvironment"].update(cfg.get("extraServerEnvironment", {}))
merged["extraEnvironment"].update(cfg.get("extraEnvironment", {}))
return merged
def base_server_env(repo_root: Path, ocis_url: str, ocis_config_dir: str) -> dict:
"""Base ocis server environment matching drone ocisServer() function."""
return {
"OCIS_URL": ocis_url,
"OCIS_CONFIG_DIR": ocis_config_dir,
"STORAGE_USERS_DRIVER": "ocis",
"PROXY_ENABLE_BASIC_AUTH": "true",
"OCIS_LOG_LEVEL": "error",
"IDM_CREATE_DEMO_USERS": "true",
"IDM_ADMIN_PASSWORD": "admin",
"FRONTEND_SEARCH_MIN_LENGTH": "2",
"OCIS_ASYNC_UPLOADS": "true",
"OCIS_EVENTS_ENABLE_TLS": "false",
"NATS_NATS_HOST": "0.0.0.0",
"NATS_NATS_PORT": "9233",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"EVENTHISTORY_STORE": "memory",
"OCIS_TRANSLATION_PATH": str(repo_root / "tests/config/translations"),
"WEB_UI_CONFIG_FILE": str(repo_root / "tests/config/drone/ocis-config.json"),
"THUMBNAILS_TXT_FONTMAP_FILE": str(repo_root / "tests/config/drone/fontsMap.json"),
# default tika off (overridden by search2 extraServerEnvironment)
"SEARCH_EXTRACTOR_TYPE": "basic",
"FRONTEND_FULL_TEXT_SEARCH_ENABLED": "false",
# debug addresses
"ACTIVITYLOG_DEBUG_ADDR": "0.0.0.0:9197",
"APP_PROVIDER_DEBUG_ADDR": "0.0.0.0:9165",
"APP_REGISTRY_DEBUG_ADDR": "0.0.0.0:9243",
"AUTH_BASIC_DEBUG_ADDR": "0.0.0.0:9147",
"AUTH_MACHINE_DEBUG_ADDR": "0.0.0.0:9167",
"AUTH_SERVICE_DEBUG_ADDR": "0.0.0.0:9198",
"CLIENTLOG_DEBUG_ADDR": "0.0.0.0:9260",
"EVENTHISTORY_DEBUG_ADDR": "0.0.0.0:9270",
"FRONTEND_DEBUG_ADDR": "0.0.0.0:9141",
"GATEWAY_DEBUG_ADDR": "0.0.0.0:9143",
"GRAPH_DEBUG_ADDR": "0.0.0.0:9124",
"GROUPS_DEBUG_ADDR": "0.0.0.0:9161",
"IDM_DEBUG_ADDR": "0.0.0.0:9239",
"IDP_DEBUG_ADDR": "0.0.0.0:9134",
"INVITATIONS_DEBUG_ADDR": "0.0.0.0:9269",
"NATS_DEBUG_ADDR": "0.0.0.0:9234",
"OCDAV_DEBUG_ADDR": "0.0.0.0:9163",
"OCM_DEBUG_ADDR": "0.0.0.0:9281",
"OCS_DEBUG_ADDR": "0.0.0.0:9114",
"POSTPROCESSING_DEBUG_ADDR": "0.0.0.0:9255",
"PROXY_DEBUG_ADDR": "0.0.0.0:9205",
"SEARCH_DEBUG_ADDR": "0.0.0.0:9224",
"SETTINGS_DEBUG_ADDR": "0.0.0.0:9194",
"SHARING_DEBUG_ADDR": "0.0.0.0:9151",
"SSE_DEBUG_ADDR": "0.0.0.0:9139",
"STORAGE_PUBLICLINK_DEBUG_ADDR": "0.0.0.0:9179",
"STORAGE_SHARES_DEBUG_ADDR": "0.0.0.0:9156",
"STORAGE_SYSTEM_DEBUG_ADDR": "0.0.0.0:9217",
"STORAGE_USERS_DEBUG_ADDR": "0.0.0.0:9159",
"THUMBNAILS_DEBUG_ADDR": "0.0.0.0:9189",
"USERLOG_DEBUG_ADDR": "0.0.0.0:9214",
"USERS_DEBUG_ADDR": "0.0.0.0:9145",
"WEB_DEBUG_ADDR": "0.0.0.0:9104",
"WEBDAV_DEBUG_ADDR": "0.0.0.0:9119",
"WEBFINGER_DEBUG_ADDR": "0.0.0.0:9279",
}
def wait_for(condition_fn, timeout: int, label: str, container: str = None) -> None:
start = time.time()
deadline = start + timeout
last_log = start
while not condition_fn():
now = time.time()
if now > deadline:
elapsed = int(now - start)
print(f"Timeout waiting for {label} after {elapsed}s", file=sys.stderr)
# dump docker diagnostics — use explicit container name if provided
cname = container or label
for cmd in (
["docker", "ps", "-a", "--filter", f"name={cname}", "--no-trunc"],
["docker", "logs", "--tail", "50", cname],
):
r = subprocess.run(cmd, capture_output=True, text=True)
if r.stdout.strip():
print(f"--- {' '.join(cmd)} ---", file=sys.stderr)
print(r.stdout, file=sys.stderr)
if r.stderr.strip():
print(r.stderr, file=sys.stderr)
sys.exit(1)
if now - last_log >= 30:
print(f" Waiting for {label}... {int(now - start)}s")
last_log = now
time.sleep(1)
def ocis_healthy(ocis_url: str) -> bool:
r = subprocess.run(
["curl", "-sk", "-uadmin:admin",
f"{ocis_url}/graph/v1.0/users/admin",
"-w", "%{http_code}", "-o", "/dev/null"],
capture_output=True, text=True,
)
return r.stdout.strip() == "200"
def mailpit_healthy() -> bool:
return subprocess.run(
["curl", "-sf", "http://localhost:8025/api/v1/messages"],
capture_output=True,
).returncode == 0
def tika_healthy() -> bool:
return subprocess.run(
["curl", "-sf", "http://localhost:9998"],
capture_output=True,
).returncode == 0
def _tcp_ready(host: str, port: int) -> bool:
"""Check if a TCP port is accepting connections."""
import socket
try:
with socket.create_connection((host, port), timeout=2):
return True
except (ConnectionRefusedError, OSError):
return False
def clamav_healthy() -> bool:
return _tcp_ready("localhost", 3310)
def run(cmd: list, env: dict = None, check: bool = True):
e = {**os.environ, **(env or {})}
return subprocess.run(cmd, env=e, check=check)
def main() -> int:
behat_suites_raw = os.environ.get("BEHAT_SUITES", "").strip()
if not behat_suites_raw:
print("BEHAT_SUITES is required", file=sys.stderr)
return 1
suites = [s.strip() for s in behat_suites_raw.split(",") if s.strip()]
acceptance_test_type = os.environ.get("ACCEPTANCE_TEST_TYPE", "api")
repo_root = Path(__file__).resolve().parents[2]
ocis_bin = repo_root / "ocis/bin/ocis"
wrapper_bin = repo_root / "tests/ociswrapper/bin/ociswrapper"
ocis_url = "https://localhost:9200"
ocis_config_dir = Path.home() / ".ocis/config"
ocis_fed_url = "https://localhost:10200"
cfg = merged_config(suites)
print(f"Suites: {suites}")
print(f"Services: email={cfg['emailNeeded']} tika={cfg['tikaNeeded']} "
f"antivirus={cfg['antivirusNeeded']} federation={cfg['federationServer']} "
f"wopi={cfg['collaborationServiceNeeded']}")
# generate IDP web assets (required for IDP service to start; matches drone ci-node-generate)
run(["make", "-C", str(repo_root / "services/idp"), "ci-node-generate"])
# build (ENABLE_VIPS=true when libvips-dev is installed, matching drone)
build_env = {}
if subprocess.run(["pkg-config", "--exists", "vips"],
capture_output=True).returncode == 0:
build_env["ENABLE_VIPS"] = "true"
run(["make", "-C", str(repo_root / "ocis"), "build"], env=build_env)
run(["make", "-C", str(repo_root / "tests/ociswrapper"), "build"],
env={"GOWORK": "off"})
# php deps
run(["composer", "install", "--no-progress"],
env={"COMPOSER_NO_INTERACTION": "1", "COMPOSER_NO_AUDIT": "1"})
run(["composer", "bin", "behat", "install", "--no-progress"],
env={"COMPOSER_NO_INTERACTION": "1", "COMPOSER_NO_AUDIT": "1"})
# optional services
procs = []
if cfg["emailNeeded"]:
print("Starting mailpit...")
run(["docker", "run", "-d", "--name", "mailpit", "--network", "host",
"axllent/mailpit:v1.22.3"])
wait_for(mailpit_healthy, 60, "mailpit")
print("mailpit ready.")
if cfg["antivirusNeeded"]:
print("Starting clamav...")
run(["docker", "run", "-d", "--name", "clamav", "--network", "host",
"owncloudci/clamavd"])
wait_for(clamav_healthy, 300, "clamav")
print("clamav ready.")
# override socket: drone uses container DNS "clamav", we use localhost
cfg["extraServerEnvironment"]["ANTIVIRUS_CLAMAV_SOCKET"] = "tcp://localhost:3310"
if cfg["tikaNeeded"]:
print("Starting tika...")
run(["docker", "run", "-d", "--name", "tika", "--network", "host",
"apache/tika:3.2.2.0-full"])
wait_for(tika_healthy, 120, "tika")
print("tika ready.")
# OCM federation: rewrite providers.json with localhost URLs
if cfg["federationServer"]:
providers_src = repo_root / "tests/config/drone/providers.json"
providers = json.loads(providers_src.read_text())
for p in providers:
# replace container DNS names with localhost
p["domain"] = p["domain"].replace("ocis-server:9200", "localhost:9200")
p["domain"] = p["domain"].replace("federation-ocis-server:10200", "localhost:10200")
for svc in p.get("services", []):
ep = svc.get("endpoint", {})
ep["path"] = ep.get("path", "").replace("ocis-server:9200", "localhost:9200")
ep["path"] = ep.get("path", "").replace("federation-ocis-server:10200", "localhost:10200")
svc["host"] = svc.get("host", "").replace("ocis-server:9200", "localhost:9200")
svc["host"] = svc.get("host", "").replace("federation-ocis-server:10200", "localhost:10200")
providers_tmp = tempfile.NamedTemporaryFile(
mode="w", suffix=".json", prefix="ocm-providers-", delete=False)
json.dump(providers, providers_tmp)
providers_tmp.close()
cfg["extraServerEnvironment"]["OCM_OCM_PROVIDER_AUTHORIZER_PROVIDERS_FILE"] = providers_tmp.name
# init ocis
run([str(ocis_bin), "init", "--insecure", "true"])
shutil.copy(
repo_root / "tests/config/drone/app-registry.yaml",
ocis_config_dir / "app-registry.yaml",
)
# generate fontsMap.json with correct font path (drone hardcodes /drone/src/...)
font_path = str(repo_root / "tests/config/drone/NotoSans.ttf")
fontmap_tmp = tempfile.NamedTemporaryFile(
mode="w", suffix=".json", prefix="fontsMap-", delete=False)
json.dump({"defaultFont": font_path}, fontmap_tmp)
fontmap_tmp.close()
# assemble ocis server env
server_env = {**os.environ}
server_env.update(base_server_env(repo_root, ocis_url, str(ocis_config_dir)))
server_env["THUMBNAILS_TXT_FONTMAP_FILE"] = fontmap_tmp.name
server_env.update(cfg["extraServerEnvironment"])
# start ociswrapper (primary ocis)
print("Starting ocis...")
wrapper_proc = subprocess.Popen(
[str(wrapper_bin), "serve",
"--bin", str(ocis_bin),
"--url", ocis_url,
"--admin-username", "admin",
"--admin-password", "admin"],
env=server_env,
)
procs.append(wrapper_proc)
# start federation ocis server (second instance on port 10200)
if cfg["federationServer"]:
fed_config_dir = Path.home() / ".ocis-federation/config"
fed_config_dir.mkdir(parents=True, exist_ok=True)
fed_data_dir = Path.home() / ".ocis-federation"
fed_env = {**os.environ}
fed_env.update(base_server_env(repo_root, ocis_fed_url, str(fed_config_dir)))
fed_env.update(cfg["extraServerEnvironment"])
fed_env.update({
"OCIS_URL": ocis_fed_url,
"PROXY_HTTP_ADDR": "0.0.0.0:10200",
"OCIS_BASE_DATA_PATH": str(fed_data_dir),
# use different ports to avoid conflicts with primary
"GATEWAY_GRPC_ADDR": "0.0.0.0:10142",
"NATS_NATS_PORT": "10233",
"NATS_NATS_HOST": "0.0.0.0",
})
# init federation ocis with separate config
run([str(ocis_bin), "init", "--insecure", "true",
"--config-path", str(fed_config_dir)])
shutil.copy(
repo_root / "tests/config/drone/app-registry.yaml",
fed_config_dir / "app-registry.yaml",
)
print("Starting federation ocis...")
fed_proc = subprocess.Popen(
[str(ocis_bin), "server"],
env=fed_env,
)
procs.append(fed_proc)
# ---------------------------------------------------------------------------
# Collaboration service helpers — same names/call pattern as drone.star
# Only deviation: container hostnames → localhost
# ---------------------------------------------------------------------------
def fakeOffice():
# drone: OC_CI_ALPINE container running serve-hosting-discovery.sh with repo at /drone/src
# use same image so BusyBox nc (not OpenBSD nc) handles FIN correctly on stdin EOF
run(["docker", "run", "-d", "--name", "fakeoffice", "--network", "host",
"-v", f"{repo_root}:/drone/src:ro",
"owncloudci/alpine:latest",
"sh", "/drone/src/tests/config/drone/serve-hosting-discovery.sh"])
return []
def collaboraService():
# drone commands copy-pasted verbatim
run(["docker", "run", "-d", "--name", "collabora", "--network", "host",
"-e", "DONT_GEN_SSL_CERT=set",
"-e", f"extra_params=--o:ssl.enable=true --o:ssl.termination=true "
f"--o:welcome.enable=false --o:net.frame_ancestors=https://localhost:9200",
"--entrypoint", "/bin/sh",
"collabora/code:24.04.5.1.1",
"-c", "\n".join([
"set -e",
"coolconfig generate-proof-key",
"bash /start-collabora-online.sh",
])])
return []
def onlyofficeService():
# GitHub runner ships PostgreSQL pre-started on 5432.
# OnlyOffice supervisord starts its own PostgreSQL on 5432 internally.
# With --network host both compete for the same port → OnlyOffice DB never
# starts → docservice stays down → nginx returns 502 forever.
# Drone avoids this because each service has its own network namespace.
subprocess.run(["sudo", "systemctl", "stop", "postgresql"],
capture_output=True)
only_office_json = repo_root / "tests/config/drone/only-office.json"
run(["docker", "run", "-d", "--name", "onlyoffice", "--network", "host",
"-e", "WOPI_ENABLED=true",
"-e", "USE_UNAUTHORIZED_STORAGE=true",
"-v", f"{only_office_json}:/tmp/only-office.json:ro",
"--entrypoint", "/bin/sh",
"onlyoffice/documentserver:9.0.0",
"-c", "\n".join([
"set -e",
"cp /tmp/only-office.json /etc/onlyoffice/documentserver/local.json",
"openssl req -x509 -newkey rsa:4096 -keyout onlyoffice.key -out onlyoffice.crt -sha256 -days 365 -batch -nodes",
"mkdir -p /var/www/onlyoffice/Data/certs",
"cp onlyoffice.key /var/www/onlyoffice/Data/certs/",
"cp onlyoffice.crt /var/www/onlyoffice/Data/certs/",
"chmod 400 /var/www/onlyoffice/Data/certs/onlyoffice.key",
"/app/ds/run-document-server.sh",
])])
return []
def wopiCollaborationService(name, ocis_url=ocis_url):
# drone: startOcisService("collaboration", "wopi-{name}", environment)
# runs: ocis/bin/ocis-debug collaboration server
service_name = "wopi-%s" % name
ports = _WOPI_PORTS[name]
environment = {
**os.environ,
"OCIS_URL": ocis_url,
"MICRO_REGISTRY": "nats-js-kv",
"MICRO_REGISTRY_ADDRESS": "localhost:9233",
"COLLABORATION_LOG_LEVEL": "debug",
"COLLABORATION_GRPC_ADDR": f"0.0.0.0:{ports['grpc']}",
"COLLABORATION_HTTP_ADDR": f"0.0.0.0:{ports['http']}",
"COLLABORATION_DEBUG_ADDR": f"0.0.0.0:{ports['debug']}",
"COLLABORATION_APP_PROOF_DISABLE": "true",
"COLLABORATION_APP_INSECURE": "true",
"COLLABORATION_CS3API_DATAGATEWAY_INSECURE": "true",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"COLLABORATION_WOPI_SECRET": "some-wopi-secret",
}
if name == "collabora":
environment["COLLABORATION_APP_NAME"] = "Collabora"
environment["COLLABORATION_APP_PRODUCT"] = "Collabora"
environment["COLLABORATION_APP_ADDR"] = "https://localhost:9980"
environment["COLLABORATION_APP_ICON"] = "https://localhost:9980/favicon.ico"
elif name == "onlyoffice":
environment["COLLABORATION_APP_NAME"] = "OnlyOffice"
environment["COLLABORATION_APP_PRODUCT"] = "OnlyOffice"
environment["COLLABORATION_APP_ADDR"] = "https://localhost:443"
environment["COLLABORATION_APP_ICON"] = "https://localhost:443/web-apps/apps/documenteditor/main/resources/img/favicon.ico"
elif name == "fakeoffice":
environment["COLLABORATION_APP_NAME"] = "FakeOffice"
environment["COLLABORATION_APP_PRODUCT"] = "Microsoft"
environment["COLLABORATION_APP_ADDR"] = "http://localhost:8080"
environment["COLLABORATION_WOPI_SRC"] = f"http://localhost:{ports['http']}"
print(f"Starting {service_name}...")
return [subprocess.Popen([str(ocis_bin), "collaboration", "server"], env=environment)]
def ocisHealthCheck(name, services=[]):
# drone: curl healthz + readyz on each service (timeout 300s)
for service in services:
host, port = service.rsplit(":", 1)
for endpoint in ("healthz", "readyz"):
wait_for(
lambda h="localhost", p=int(port), ep=endpoint: subprocess.run(
["curl", "-sf", f"http://{h}:{p}/{ep}"], capture_output=True
).returncode == 0,
300, f"{service}/{endpoint}",
)
print(f"health-check-{name}: all services healthy.")
def wopi_discovery_ready(app_url: str) -> bool:
"""Return True once the WOPI app's /hosting/discovery returns HTTP 200."""
url = app_url.rstrip("/") + "/hosting/discovery"
r = subprocess.run(
["curl", "-sfk", url], capture_output=True
)
return r.returncode == 0
# drone.star non-k8s collaborationServiceNeeded path (lines 1195-1196, 1140-1141, 1179-1183)
if cfg["collaborationServiceNeeded"]:
procs += fakeOffice() + collaboraService() + onlyofficeService()
# Wait for each app's /hosting/discovery to return 200 before starting its
# collaboration service. GetAppURLs in server.go calls discovery synchronously
# at startup — non-200 exits the process immediately, healthz never binds.
wait_for(lambda: wopi_discovery_ready("http://localhost:8080"), 300, "fakeoffice discovery", container="fakeoffice")
wait_for(lambda: wopi_discovery_ready("https://localhost:9980"), 300, "collabora discovery", container="collabora")
wait_for(lambda: wopi_discovery_ready("https://localhost:443"), 300, "onlyoffice discovery", container="onlyoffice")
procs += wopiCollaborationService("fakeoffice") + \
wopiCollaborationService("collabora") + \
wopiCollaborationService("onlyoffice")
ocisHealthCheck("wopi", [
f"localhost:{_WOPI_PORTS['collabora']['debug']}",
f"localhost:{_WOPI_PORTS['onlyoffice']['debug']}",
f"localhost:{_WOPI_PORTS['fakeoffice']['debug']}",
])
def cleanup(*_):
for p in procs:
try:
p.terminate()
except Exception:
pass
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
try:
wait_for(lambda: ocis_healthy(ocis_url), 300, "ocis")
print("ocis ready.")
if cfg["federationServer"]:
wait_for(lambda: ocis_healthy(ocis_fed_url), 300, "federation ocis")
print("federation ocis ready.")
# expected failures file
if acceptance_test_type == "core-api":
filter_tags = "~@skipOnGraph&&~@skipOnOcis-OCIS-Storage"
base_failures = repo_root / "tests/acceptance/expected-failures-API-on-OCIS-storage.md"
else:
filter_tags = "~@skip&&~@skipOnGraph&&~@skipOnOcis-OCIS-Storage"
base_failures = repo_root / "tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md"
ef_override = os.environ.get("EXPECTED_FAILURES_FILE")
if ef_override:
p = Path(ef_override)
base_failures = p if p.is_absolute() else repo_root / p
# merge expected-failures-without-remotephp.md (drone does this)
tmp = tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False)
tmp.write(base_failures.read_text())
without_rphp = repo_root / "tests/acceptance/expected-failures-without-remotephp.md"
if without_rphp.exists():
tmp.write("\n")
tmp.write(without_rphp.read_text())
tmp.close()
# run tests
behat_env = {
**os.environ,
"TEST_SERVER_URL": ocis_url,
"TEST_SERVER_FED_URL": ocis_fed_url,
"OCIS_WRAPPER_URL": "http://localhost:5200",
"BEHAT_SUITES": behat_suites_raw,
"ACCEPTANCE_TEST_TYPE": acceptance_test_type,
"BEHAT_FILTER_TAGS": filter_tags,
"EXPECTED_FAILURES_FILE": tmp.name,
"STORAGE_DRIVER": "ocis",
"UPLOAD_DELETE_WAIT_TIME": "0",
"EMAIL_HOST": "localhost",
"EMAIL_PORT": EMAIL_PORT,
"COLLABORATION_SERVICE_URL": f"http://localhost:{_WOPI_PORTS['fakeoffice']['http']}",
}
behat_env.update(cfg["extraEnvironment"])
print(f"Running suites: {behat_suites_raw} (type: {acceptance_test_type})")
result = subprocess.run(
["make", "-C", str(repo_root), "test-acceptance-api"],
env=behat_env,
)
return result.returncode
finally:
cleanup()
if __name__ == "__main__":
sys.exit(main())
+244
View File
@@ -0,0 +1,244 @@
#!/usr/bin/env python3
"""
Run litmus WebDAV compliance tests locally and in GitHub Actions CI.
Config sourced from .drone.star litmus() / setupForLitmus() — single source of truth.
Usage: python3 tests/acceptance/run-litmus.py
"""
import json
import os
import re
import shutil
import signal
import subprocess
import sys
import time
from pathlib import Path
# ---------------------------------------------------------------------------
# Constants (mirroring .drone.star)
# ---------------------------------------------------------------------------
# HTTPS — matching drone: ocis init generates a self-signed cert; proxy uses TLS by default.
# Host-side curl calls use -k (insecure) to skip cert verification.
OCIS_URL = "https://127.0.0.1:9200"
LITMUS_IMAGE = "owncloudci/litmus:latest"
LITMUS_TESTS = "basic copymove props http"
SHARE_ENDPOINT = "ocs/v2.php/apps/files_sharing/api/v1/shares"
def get_docker_bridge_ip() -> str:
"""Return the Docker bridge gateway IP, reachable from host and Docker containers."""
r = subprocess.run(
["docker", "network", "inspect", "bridge",
"--format", "{{range .IPAM.Config}}{{.Gateway}}{{end}}"],
capture_output=True, text=True, check=True,
)
return r.stdout.strip()
def base_server_env(repo_root: Path, ocis_config_dir: str, ocis_public_url: str) -> dict:
"""OCIS server environment matching drone ocisServer() for litmus."""
return {
"OCIS_URL": ocis_public_url,
"OCIS_CONFIG_DIR": ocis_config_dir,
"STORAGE_USERS_DRIVER": "ocis",
"PROXY_ENABLE_BASIC_AUTH": "true",
# No PROXY_TLS override — drone lets ocis use its default TLS (self-signed cert from init)
# IDP excluded: its static assets are absent when running as a host process
"OCIS_EXCLUDE_RUN_SERVICES": "idp",
"OCIS_LOG_LEVEL": "error",
"IDM_CREATE_DEMO_USERS": "true",
"IDM_ADMIN_PASSWORD": "admin",
"FRONTEND_SEARCH_MIN_LENGTH": "2",
"OCIS_ASYNC_UPLOADS": "true",
"OCIS_EVENTS_ENABLE_TLS": "false",
"NATS_NATS_HOST": "0.0.0.0",
"NATS_NATS_PORT": "9233",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"EVENTHISTORY_STORE": "memory",
"WEB_UI_CONFIG_FILE": str(repo_root / "tests/config/drone/ocis-config.json"),
}
def wait_for(condition_fn, timeout: int, label: str) -> None:
deadline = time.time() + timeout
while not condition_fn():
if time.time() > deadline:
print(f"Timeout waiting for {label}", file=sys.stderr)
sys.exit(1)
time.sleep(1)
def ocis_healthy(ocis_url: str) -> bool:
r = subprocess.run(
["curl", "-sk", "-uadmin:admin",
f"{ocis_url}/graph/v1.0/users/admin",
"-w", "%{http_code}", "-o", "/dev/null"],
capture_output=True, text=True,
)
return r.stdout.strip() == "200"
def setup_for_litmus(ocis_url: str) -> tuple:
"""
Translate tests/config/drone/setup-for-litmus.sh to Python.
Returns (space_id, public_token).
"""
# get personal space ID
r = subprocess.run(
["curl", "-sk", "-uadmin:admin", f"{ocis_url}/graph/v1.0/me/drives"],
capture_output=True, text=True, check=True,
)
drives = json.loads(r.stdout)
space_id = ""
for drive in drives.get("value", []):
if drive.get("driveType") == "personal":
web_dav_url = drive.get("root", {}).get("webDavUrl", "")
# last non-empty path segment (same as cut -d"/" -f6 in bash)
space_id = [p for p in web_dav_url.split("/") if p][-1]
break
if not space_id:
print("ERROR: could not determine personal space ID", file=sys.stderr)
sys.exit(1)
print(f"SPACE_ID={space_id}")
# create test folder as einstein
subprocess.run(
["curl", "-sk", "-ueinstein:relativity", "-X", "MKCOL",
f"{ocis_url}/remote.php/webdav/new_folder"],
capture_output=True, check=True,
)
# create share from einstein to admin
r = subprocess.run(
["curl", "-sk", "-ueinstein:relativity",
f"{ocis_url}/{SHARE_ENDPOINT}",
"-d", "path=/new_folder&shareType=0&permissions=15&name=new_folder&shareWith=admin"],
capture_output=True, text=True, check=True,
)
share_id_match = re.search(r"<id>(.+?)</id>", r.stdout)
if share_id_match:
share_id = share_id_match.group(1)
# accept the share as admin
subprocess.run(
["curl", "-X", "POST", "-sk", "-uadmin:admin",
f"{ocis_url}/{SHARE_ENDPOINT}/pending/{share_id}"],
capture_output=True, check=True,
)
# create public share as einstein
r = subprocess.run(
["curl", "-sk", "-ueinstein:relativity",
f"{ocis_url}/{SHARE_ENDPOINT}",
"-d", "path=/new_folder&shareType=3&permissions=15&name=new_folder"],
capture_output=True, text=True, check=True,
)
public_token = ""
token_match = re.search(r"<token>(.+?)</token>", r.stdout)
if token_match:
public_token = token_match.group(1)
print(f"PUBLIC_TOKEN={public_token}")
return space_id, public_token
def run_litmus(name: str, endpoint: str) -> int:
print(f"\nTesting endpoint [{name}]: {endpoint}", flush=True)
result = subprocess.run(
["docker", "run", "--rm",
"-e", f"LITMUS_URL={endpoint}",
"-e", "LITMUS_USERNAME=admin",
"-e", "LITMUS_PASSWORD=admin",
"-e", f"TESTS={LITMUS_TESTS}",
LITMUS_IMAGE,
# No extra CMD — ENTRYPOINT is already litmus-wrapper; passing it again
# would make the wrapper use the path as LITMUS_URL, overriding the env var.
],
)
return result.returncode
def main() -> int:
repo_root = Path(__file__).resolve().parents[2]
ocis_bin = repo_root / "ocis/bin/ocis"
ocis_config_dir = Path.home() / ".ocis/config"
# build (matching drone: restores binary from cache, then runs ocis server directly)
subprocess.run(["make", "-C", str(repo_root / "ocis"), "build"], check=True)
# Docker bridge gateway IP: reachable from both the host (via docker0 interface)
# and Docker containers (via bridge network default gateway). Use this as OCIS_URL
# so that any redirects OCIS generates stay on a hostname the litmus container
# can follow — matching how drone uses "ocis-server:9200" consistently.
# HTTPS: owncloudci/litmus accepts insecure (self-signed) certs, just like drone does.
bridge_ip = get_docker_bridge_ip()
litmus_base = f"https://{bridge_ip}:9200"
print(f"Docker bridge IP: {bridge_ip}", flush=True)
# assemble server env first — same env vars drone sets on the container before
# running `ocis init`, so IDM_ADMIN_PASSWORD=admin is present during init and
# the config is written with the correct password (not a random one)
server_env = {**os.environ}
server_env.update(base_server_env(repo_root, str(ocis_config_dir), litmus_base))
# init ocis with full server env (mirrors drone: env is set before ocis init runs)
subprocess.run(
[str(ocis_bin), "init", "--insecure", "true"],
env=server_env,
check=True,
)
shutil.copy(
repo_root / "tests/config/drone/app-registry.yaml",
ocis_config_dir / "app-registry.yaml",
)
# start ocis server directly (matching drone: no ociswrapper for litmus)
print("Starting ocis...", flush=True)
ocis_proc = subprocess.Popen(
[str(ocis_bin), "server"],
env=server_env,
)
def cleanup(*_):
try:
ocis_proc.terminate()
except Exception:
pass
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
try:
wait_for(lambda: ocis_healthy(OCIS_URL), 300, "ocis")
print("ocis ready.", flush=True)
space_id, _ = setup_for_litmus(OCIS_URL)
endpoints = [
("old-endpoint", f"{litmus_base}/remote.php/webdav"),
("new-endpoint", f"{litmus_base}/remote.php/dav/files/admin"),
("new-shared", f"{litmus_base}/remote.php/dav/files/admin/Shares/new_folder/"),
("old-shared", f"{litmus_base}/remote.php/webdav/Shares/new_folder/"),
("spaces-endpoint", f"{litmus_base}/remote.php/dav/spaces/{space_id}"),
]
failed = []
for name, endpoint in endpoints:
rc = run_litmus(name, endpoint)
if rc != 0:
failed.append(name)
if failed:
print(f"\nFailed endpoints: {', '.join(failed)}", file=sys.stderr)
return 1
print("\nAll litmus tests passed.")
return 0
finally:
cleanup()
if __name__ == "__main__":
sys.exit(main())
+375
View File
@@ -0,0 +1,375 @@
#!/usr/bin/env python3
"""
Run WOPI validator tests locally and in GitHub Actions CI.
Config sourced from .drone.star wopiValidatorTests() — single source of truth.
Usage: python3 tests/acceptance/run-wopi.py --type builtin
python3 tests/acceptance/run-wopi.py --type cs3
"""
import argparse
import json
import os
import re
import shutil
import signal
import socket
import subprocess
import sys
import time
import urllib.parse
from pathlib import Path
# ---------------------------------------------------------------------------
# Constants (mirroring .drone.star)
# ---------------------------------------------------------------------------
# HTTPS — matching drone; host-side curl calls use -k.
OCIS_URL = "https://127.0.0.1:9200"
VALIDATOR_IMAGE = "owncloudci/wopi-validator"
CS3_WOPI_IMAGE = "cs3org/wopiserver:v10.4.0"
FAKEOFFICE_IMAGE = "owncloudci/alpine:latest"
# Testgroups shared between both variants (drone: testgroups list)
SHARED_TESTGROUPS = [
"BaseWopiViewing",
"CheckFileInfoSchema",
"EditFlows",
"Locks",
"AccessTokens",
"GetLock",
"ExtendedLockLength",
"FileVersion",
"Features",
]
# Testgroups only run for builtin (drone: builtinOnlyTestGroups, with -s flag)
BUILTIN_ONLY_TESTGROUPS = [
"PutRelativeFile",
"RenameFileIfCreateChildFileIsNotSupported",
]
def get_docker_bridge_ip() -> str:
r = subprocess.run(
["docker", "network", "inspect", "bridge",
"--format", "{{range .IPAM.Config}}{{.Gateway}}{{end}}"],
capture_output=True, text=True, check=True,
)
return r.stdout.strip()
def wait_for(condition_fn, timeout: int, label: str) -> None:
deadline = time.time() + timeout
while not condition_fn():
if time.time() > deadline:
print(f"Timeout waiting for {label}", file=sys.stderr)
sys.exit(1)
time.sleep(1)
def ocis_healthy(ocis_url: str) -> bool:
r = subprocess.run(
["curl", "-sk", "-uadmin:admin",
f"{ocis_url}/graph/v1.0/users/admin",
"-w", "%{http_code}", "-o", "/dev/null"],
capture_output=True, text=True,
)
return r.stdout.strip() == "200"
def tcp_reachable(host: str, port: int) -> bool:
try:
with socket.create_connection((host, port), timeout=1):
return True
except Exception:
return False
def wopi_discovery_ready(url: str) -> bool:
r = subprocess.run(
["curl", "-sk", "-o", "/dev/null", "-w", "%{http_code}", url],
capture_output=True, text=True,
)
return r.stdout.strip() == "200"
def base_server_env(repo_root: Path, ocis_config_dir: str, ocis_public_url: str,
bridge_ip: str, wopi_type: str) -> dict:
"""
OCIS server environment matching drone ocisServer(deploy_type='wopi_validator').
builtin: also excludes app-provider (collaboration service takes that role).
"""
exclude = "idp,app-provider" if wopi_type == "builtin" else "idp"
return {
"OCIS_URL": ocis_public_url,
"OCIS_CONFIG_DIR": ocis_config_dir,
"STORAGE_USERS_DRIVER": "ocis",
"PROXY_ENABLE_BASIC_AUTH": "true",
# No PROXY_TLS override — drone uses default TLS (self-signed cert from init)
# IDP excluded: static assets absent when running as host process
"OCIS_EXCLUDE_RUN_SERVICES": exclude,
"OCIS_LOG_LEVEL": "error",
"IDM_CREATE_DEMO_USERS": "true",
"IDM_ADMIN_PASSWORD": "admin",
"FRONTEND_SEARCH_MIN_LENGTH": "2",
"OCIS_ASYNC_UPLOADS": "true",
"OCIS_EVENTS_ENABLE_TLS": "false",
"NATS_NATS_HOST": "0.0.0.0",
"NATS_NATS_PORT": "9233",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"EVENTHISTORY_STORE": "memory",
"WEB_UI_CONFIG_FILE": str(repo_root / "tests/config/drone/ocis-config.json"),
# wopi_validator extras (drone ocisServer deploy_type="wopi_validator")
"GATEWAY_GRPC_ADDR": "0.0.0.0:9142",
"APP_PROVIDER_EXTERNAL_ADDR": "com.owncloud.api.app-provider",
"APP_PROVIDER_DRIVER": "wopi",
"APP_PROVIDER_WOPI_APP_NAME": "FakeOffice",
"APP_PROVIDER_WOPI_APP_URL": f"http://{bridge_ip}:8080",
"APP_PROVIDER_WOPI_INSECURE": "true",
"APP_PROVIDER_WOPI_WOPI_SERVER_EXTERNAL_URL": f"http://{bridge_ip}:9300",
"APP_PROVIDER_WOPI_FOLDER_URL_BASE_URL": ocis_public_url,
}
def collab_service_env(bridge_ip: str, ocis_config_dir: str) -> dict:
"""
Environment for 'ocis collaboration server' (builtin wopi-fakeoffice).
Mirrors drone wopiCollaborationService("fakeoffice").
"""
return {
"OCIS_URL": f"https://{bridge_ip}:9200",
"OCIS_CONFIG_DIR": ocis_config_dir,
"MICRO_REGISTRY": "nats-js-kv",
"MICRO_REGISTRY_ADDRESS": "127.0.0.1:9233",
"COLLABORATION_LOG_LEVEL": "debug",
"COLLABORATION_GRPC_ADDR": "0.0.0.0:9301",
"COLLABORATION_HTTP_ADDR": "0.0.0.0:9300",
"COLLABORATION_DEBUG_ADDR": "0.0.0.0:9304",
"COLLABORATION_APP_PROOF_DISABLE": "true",
"COLLABORATION_APP_INSECURE": "true",
"COLLABORATION_CS3API_DATAGATEWAY_INSECURE": "true",
"OCIS_JWT_SECRET": "some-ocis-jwt-secret",
"COLLABORATION_WOPI_SECRET": "some-wopi-secret",
"COLLABORATION_APP_NAME": "FakeOffice",
"COLLABORATION_APP_PRODUCT": "Microsoft",
"COLLABORATION_APP_ADDR": f"http://{bridge_ip}:8080",
# COLLABORATION_WOPI_SRC is what OCIS tells clients to use — must be reachable
# from Docker validator containers (collaboration service runs as host process)
"COLLABORATION_WOPI_SRC": f"http://{bridge_ip}:9300",
}
def prepare_test_file(bridge_ip: str) -> tuple:
"""
Upload test.wopitest via WebDAV, open the WOPI app, extract credentials.
Mirrors the prepare-test-file step from drone.star.
Returns (access_token, access_token_ttl, wopi_src).
"""
headers_file = "/tmp/wopi-headers.txt"
# PUT empty test file (--retry-connrefused/--retry-all-errors matching drone)
subprocess.run(
["curl", "-sk", "-u", "admin:admin", "-X", "PUT",
"--fail", "--retry-connrefused", "--retry", "7", "--retry-all-errors",
f"{OCIS_URL}/remote.php/webdav/test.wopitest",
"-D", headers_file],
check=True,
)
# Extract Oc-Fileid from response headers
headers_text = Path(headers_file).read_text()
print("--- PUT headers ---", flush=True)
print(headers_text[:500], flush=True)
m = re.search(r"Oc-Fileid:\s*(\S+)", headers_text, re.IGNORECASE)
if not m:
print("ERROR: Oc-Fileid not found in PUT response headers", file=sys.stderr)
sys.exit(1)
file_id = m.group(1).strip()
print(f"FILE_ID={file_id}", flush=True)
# POST to app/open to get WOPI access token and wopi src
url = f"{OCIS_URL}/app/open?app_name=FakeOffice&file_id={urllib.parse.quote(file_id, safe='')}"
r = subprocess.run(
["curl", "-sk", "-u", "admin:admin", "-X", "POST",
"--fail", "--retry-connrefused", "--retry", "7", "--retry-all-errors", url],
capture_output=True, text=True, check=True,
)
open_json = json.loads(r.stdout)
print(f"open.json: {r.stdout[:800]}", flush=True)
access_token = open_json["form_parameters"]["access_token"]
access_token_ttl = str(open_json["form_parameters"]["access_token_ttl"])
app_url = open_json.get("app_url", "")
# Construct wopi_src: drone extracts file ID from app_url after 'files%2F',
# then prepends http://wopi-fakeoffice:9300/wopi/files/ — we use bridge_ip instead.
wopi_base = f"http://{bridge_ip}:9300/wopi/files/"
if "files%2F" in app_url:
file_id_encoded = app_url.split("files%2F")[-1].strip().strip('"')
elif "files/" in app_url:
file_id_encoded = app_url.split("files/")[-1].strip().strip('"')
else:
file_id_encoded = urllib.parse.quote(file_id, safe="")
wopi_src = wopi_base + file_id_encoded
print(f"WOPI_SRC={wopi_src}", flush=True)
return access_token, access_token_ttl, wopi_src
def run_validator(group: str, token: str, wopi_src: str, ttl: str,
secure: bool = False) -> int:
print(f"\nRunning testgroup [{group}] secure={secure}", flush=True)
cmd = [
"docker", "run", "--rm",
"--workdir", "/app",
"--entrypoint", "/app/Microsoft.Office.WopiValidator",
VALIDATOR_IMAGE,
]
if secure:
cmd.append("-s")
cmd += ["-t", token, "-w", wopi_src, "-l", ttl, "--testgroup", group]
return subprocess.run(cmd).returncode
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--type", choices=["builtin", "cs3"], required=True,
help="WOPI server type: builtin (collaboration service) or cs3 (cs3org/wopiserver)")
args = parser.parse_args()
wopi_type = args.type
repo_root = Path(__file__).resolve().parents[2]
ocis_bin = repo_root / "ocis/bin/ocis"
ocis_config_dir = Path.home() / ".ocis/config"
subprocess.run(["make", "-C", str(repo_root / "ocis"), "build"], check=True)
bridge_ip = get_docker_bridge_ip()
print(f"Docker bridge IP: {bridge_ip}", flush=True)
procs = []
containers = []
def cleanup(*_):
for p in procs:
try:
p.terminate()
except Exception:
pass
for name in containers:
subprocess.run(["docker", "rm", "-f", name], capture_output=True)
signal.signal(signal.SIGTERM, cleanup)
signal.signal(signal.SIGINT, cleanup)
try:
# --- fakeoffice: serves hosting-discovery.xml on :8080 ---
# Mirrors drone fakeOffice() — owncloudci/alpine running serve-hosting-discovery.sh.
# Repo is mounted at /drone/src (the path the script uses).
containers.append("wopi-fakeoffice-fake")
subprocess.run(["docker", "rm", "-f", "wopi-fakeoffice-fake"], capture_output=True)
subprocess.run([
"docker", "run", "-d", "--name", "wopi-fakeoffice-fake",
"-p", "8080:8080",
"-v", f"{repo_root}:/drone/src",
FAKEOFFICE_IMAGE,
"sh", "/drone/src/tests/config/drone/serve-hosting-discovery.sh",
], check=True)
wait_for(lambda: tcp_reachable(bridge_ip, 8080), 60, "fakeoffice:8080")
print("fakeoffice ready.", flush=True)
# --- Init and start OCIS ---
ocis_public_url = f"https://{bridge_ip}:9200"
server_env = {**os.environ}
server_env.update(base_server_env(
repo_root, str(ocis_config_dir), ocis_public_url, bridge_ip, wopi_type))
subprocess.run(
[str(ocis_bin), "init", "--insecure", "true"],
env=server_env, check=True,
)
shutil.copy(
repo_root / "tests/config/drone/app-registry.yaml",
ocis_config_dir / "app-registry.yaml",
)
print("Starting ocis...", flush=True)
ocis_proc = subprocess.Popen([str(ocis_bin), "server"], env=server_env)
procs.append(ocis_proc)
wait_for(lambda: ocis_healthy(OCIS_URL), 300, "ocis")
print("ocis ready.", flush=True)
# --- Wait for fakeoffice discovery endpoint before starting WOPI service ---
# ocis collaboration server calls GetAppURLs synchronously at startup;
# if /hosting/discovery returns non-200, the process exits immediately.
wait_for(lambda: wopi_discovery_ready("http://127.0.0.1:8080/hosting/discovery"),
300, "fakeoffice /hosting/discovery")
print("fakeoffice discovery ready.", flush=True)
# --- Start wopi server (after OCIS is healthy so NATS/gRPC are up) ---
if wopi_type == "builtin":
# Run 'ocis collaboration server' as a host process.
# Mirrors drone wopiCollaborationService("fakeoffice") → startOcisService("collaboration").
collab_env = {**os.environ}
collab_env.update(collab_service_env(bridge_ip, str(ocis_config_dir)))
print("Starting collaboration service...", flush=True)
collab_proc = subprocess.Popen(
[str(ocis_bin), "collaboration", "server"],
env=collab_env,
)
procs.append(collab_proc)
else:
# cs3: patch wopiserver.conf (replace container hostname with bridge_ip),
# then run cs3org/wopiserver as a Docker container.
conf_text = (repo_root / "tests/config/drone/wopiserver.conf").read_text()
conf_text = conf_text.replace("ocis-server", bridge_ip)
conf_tmp = Path("/tmp/wopiserver-patched.conf")
conf_tmp.write_text(conf_text)
secret_tmp = Path("/tmp/wopisecret")
secret_tmp.write_text("123\n")
containers.append("wopi-cs3server")
subprocess.run(["docker", "rm", "-f", "wopi-cs3server"], capture_output=True)
subprocess.run([
"docker", "run", "-d", "--name", "wopi-cs3server",
"-p", "9300:9300",
"-v", f"{conf_tmp}:/etc/wopi/wopiserver.conf",
"-v", f"{secret_tmp}:/etc/wopi/wopisecret",
"--entrypoint", "/app/wopiserver.py",
CS3_WOPI_IMAGE,
], check=True)
wait_for(lambda: tcp_reachable(bridge_ip, 9300), 120, "wopi-fakeoffice:9300")
print("wopi server ready.", flush=True)
# --- prepare-test-file: upload file, get WOPI credentials ---
access_token, ttl, wopi_src = prepare_test_file(bridge_ip)
# --- Run validator for each testgroup ---
failed = []
for group in SHARED_TESTGROUPS:
rc = run_validator(group, access_token, wopi_src, ttl, secure=False)
if rc != 0:
failed.append(group)
if wopi_type == "builtin":
for group in BUILTIN_ONLY_TESTGROUPS:
rc = run_validator(group, access_token, wopi_src, ttl, secure=True)
if rc != 0:
failed.append(group)
if failed:
print(f"\nFailed testgroups: {', '.join(failed)}", file=sys.stderr)
return 1
print("\nAll WOPI validator tests passed.")
return 0
finally:
cleanup()
if __name__ == "__main__":
sys.exit(main())