Skip to content

Add a regression suite for OKAPI installations - #653

Merged
hxdimpf merged 2 commits into
opencaching:masterfrom
OpencachingDeutschland:up/tests
Oct 19, 2026
Merged

hxdimpf merged 2 commits into
opencaching:masterfrom
OpencachingDeutschland:up/tests

Conversation

@hxdimpf

@hxdimpf hxdimpf commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

The second of the changes from OpencachingDeutschland/okapi, cut into separate PRs (see #632, follows #650).

A regression suite for OKAPI installations (tests/). Node.js 18+, no dependencies. It checks an installation from the outside, over HTTP, so the same checks run against OCDE, OCPL or a dev setup. That is how the coming PRs will be tested on both platforms. It only uses services that exist upstream today. The later PRs add their checks to it.

  • Read-only (node run.mjs, safe against production):
    • level 0: apisrv/installation, optionally checking the deployed revision with --expect-revision; the error for a missing consumer key;
    • level 1: an unknown consumer key is rejected; caches/search/all, caches/geocache, logs/logs;
    • level 3: users/user signed with PLAINTEXT and with HMAC-SHA1 (same user from both), HMAC with parameters that need percent-encoding, a wrong secret rejected, logs/capabilities.
    • The run starts by printing the apisrv/installation and logs/capabilities responses, so every run records what it ran against.
  • Writing (node run.mjs --write): refused unless the target sets allowWrite: true. It writes only per-user data on an existing cache (writeCache) and removes it again: save_personal_notes set, read back and cleared; logs/submit a comment, then logs/edit and logs/delete.
  • Credentials: they go in a gitignored config.js (template: config.example.js). Several installations can be configured as named targets (--target). Levels whose credentials a target lacks are skipped, not failed.

Also: a one-line TODO: drop when PHP 8 is required comment in OkapiErrorHandler, as @jrmajor suggested in #650. No code change.

Tested: against an OCDE installation and two OCPL installations (the official 2018 devel dump with all updates, on MariaDB 10.11 and on MariaDB 10.0), PHP 8.2-FPM behind Apache:

read-only --write
OCDE 11 passed, 0 failed 12 passed, 0 failed
OCPL, MariaDB 10.11 11 passed, 0 failed 13 passed, 0 failed
OCPL, MariaDB 10.0 11 passed, 0 failed 13 passed, 0 failed

The skips are expected: no --expect-revision was given, and the OCDE dev setup runs OKAPI standalone, where logs/submit can't run. OkapiErrorHandler.php passes php -l on PHP 7.4.

Merged without the usual wait: it only adds tests/, which OKAPI itself never loads, and one comment line. Review comments are still welcome and go into a follow-up PR.

A Node.js suite without dependencies that checks an installation over HTTP:
installation info, error format, consumer key and OAuth (PLAINTEXT and
HMAC-SHA1, including parameters that need percent-encoding), plus an optional
writing level for dev/test installations (personal notes, logs submit/edit/
delete on an existing cache; everything it writes is removed again).

The same checks run against OCDE and OCPL installations.
@hxdimpf

hxdimpf commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

Merging this one without the usual wait: it only adds tests/ (OKAPI itself never loads it) and one comment line in OkapiErrorHandler. Review comments are still welcome, @jrmajor, @andrixnet, @kojoty; anything that comes up goes into a follow-up PR. The packages that change OKAPI itself keep the usual process: review, then time for OCPL to look.

@andrixnet

Copy link
Copy Markdown
Contributor

We all will have to learn how to use it :-)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants