From 244eb621f03a031f4a1f5ade0e45a09bcd57cd5d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 18:07:39 +0000 Subject: [PATCH] test: accept the hex CSRF token of Adminer 6.3.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Short Summary (TL;DR) The sqlite test now accepts any Adminer CSRF token format, because Adminer 6.3.1 switched from digits to hex and broke the nightly tests. ## The Issue The nightly tests failed on all four jobs on 2026-11-24 in [run 45356694839](https://github.com/ddev/ddev-adminer/actions/runs/45356694839). The same commit passed every night before. The `adminer:6-standalone` image moved to Adminer 6.3.1 between those runs. Adminer 6.3.1 writes its CSRF token as `hex:hex`, and earlier releases wrote `digits:digits`. The test searched for `[0-9]+:[0-9]+` inside a command substitution. That grep matched nothing, so `set -e` stopped `health_checks` at `tests/test.bats:101` and printed no reason. The add-on itself works with Adminer 6.3.1. A sqlite insert with the hex token succeeds. ## How This PR Solves The Issue The test fetches the SQL page with `run curl` and asserts that it contains a `name='token'` field. It then takes the field's value whatever its format. If Adminer drops the token again, the failure shows the page instead of exiting silently. ## Manual Testing Instructions ```bash mkdir adminer-sqlite && cd adminer-sqlite ddev config --project-type=php --omit-containers=db ddev dotenv set .ddev/.env.adminer --adminer-default-driver=sqlite --adminer-default-db=/mnt/ddev_app/test.sqlite ddev add-on get ddev/ddev-adminer --pr 60 ddev restart ddev exec sqlite3 test.sqlite "CREATE TABLE items(id INTEGER PRIMARY KEY, name TEXT);" ddev adminer # Expect the items table, and an INSERT from the SQL command page to succeed ``` ## Automated Testing Overview Claude Code ran `bats ./tests/test.bats --filter-tags sqlite` on Linux amd64 with DDEV v1.25.6 and Adminer 6.3.1, and the test passed. On that machine, the `ddev adminer` URL assertion fails for an unrelated local reason, so that one assertion was removed for the run. CI also runs that assertion, and the arm64 and DDEV HEAD jobs, so CI has to confirm them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01UrTUMupgLNPn18VBZJrtex Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UrTUMupgLNPn18VBZJrtex --- tests/test.bats | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test.bats b/tests/test.bats index 6793711..7ab16e5 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -98,7 +98,11 @@ health_checks() { # Make sure Adminer can write the database file owned by the host user, # it only accepts a write together with its CSRF token sql_url="https://${PROJNAME}.ddev.site:9101/${TEST_REDIRECT_LOCATION}&sql=" - token="$(curl -sf --cookie .cookie-jar.txt --cookie-jar .cookie-jar.txt "${sql_url}" | grep -oE "name='token' value='[0-9]+:[0-9]+" | grep -oE '[0-9]+:[0-9]+')" + run curl -sf --cookie .cookie-jar.txt --cookie-jar .cookie-jar.txt "${sql_url}" + assert_success + # The token format changes between Adminer releases (digits before 6.3.1, hex after) + assert_output --regexp "name='token' value='[^']+'" + token="$(grep -oE "name='token' value='[^']+'" <<<"${output}" | head -1 | cut -d"'" -f4)" run curl -sf --cookie .cookie-jar.txt --cookie-jar .cookie-jar.txt \ --data-urlencode "query=INSERT INTO ${TEST_SQLITE_TABLE}(name) VALUES ('gamma');" \ --data "token=${token}" "${sql_url}"