Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
},
"ghcr.io/devcontainers/features/hugo:1": {
"extended": true,
"version": "latest"
"version": "0.161.1"
},
"ghcr.io/devcontainers/features/go:1": {
"version": "1.23"
"version": "1.25"
}
},
"postCreateCommand": "cd wordpress && composer install --ignore-platform-req=ext-intl --no-interaction 2>/dev/null; echo 'Ready'",
Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,38 @@ Then either:

```sh
cd wordpress/
bin/install-wp-tests.sh wordpress_test root '' localhost latest
export TEST_TMP_DIR="${HOME}/tmp/htmltrust-cms-tests"
mkdir -p "$TEST_TMP_DIR"
TMPDIR="$TEST_TMP_DIR" \
WP_TESTS_DIR="$TEST_TMP_DIR/wordpress-tests-lib" \
WP_CORE_DIR="$TEST_TMP_DIR/wordpress" \
bin/install-wp-tests.sh wordpress_test root '' localhost 6.9.4
TMPDIR="$TEST_TMP_DIR" \
WP_TESTS_DIR="$TEST_TMP_DIR/wordpress-tests-lib" \
WP_CORE_DIR="$TEST_TMP_DIR/wordpress" \
composer test
```

The installer downloads WordPress and the WordPress test library into the
disposable directory under `$HOME/tmp`. Set `DB_HOST` in the installer command
when MySQL or MariaDB is running in a container. The test suite expects the
database named by the first argument to exist or for the database user to be
allowed to create it.

For a development container, open this repository in VS Code Dev Containers.
The configuration provides PHP 8.3, Composer, Node 22, Go 1.25, and Hugo
Extended 0.161.1. Run the same commands above from `wordpress/` after the
container starts.

### Using the reference server

The WordPress plugin's signing client is compatible with the Node reference
server in `htmltrust-server-reference`. Start that server at
`http://localhost:3000`, then configure the plugin's server profile with that
URL. The plugin uses the server's author API key for `POST /api/content/sign`
and sends the publication origin as the `domain` field. Use an origin such as
`https://example.com`, including the scheme and optional port.

## The HTML Protocol

Signed content is embedded with a `<signed-section>` wrapper around the actual signed content:
Expand Down
11 changes: 6 additions & 5 deletions wordpress/bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${6-false}

TMPDIR=${TMPDIR-/tmp}
TMPDIR=${TMPDIR-${HOME:-.}/tmp}
TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
mkdir -p "$TMPDIR"
WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/}

Expand Down Expand Up @@ -42,9 +43,9 @@ elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
WP_TESTS_TAG="trunk"
else
# http serves a single offer, whereas https serves multiple. we only want one
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
download http://api.wordpress.org/core/version-check/1.7/ "$TMPDIR/wp-latest.json"
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' "$TMPDIR/wp-latest.json"
LATEST_VERSION=$(grep -o '"version":"[^"]*' "$TMPDIR/wp-latest.json" | sed 's/"version":"//')
if [[ -z "$LATEST_VERSION" ]]; then
echo "Latest WordPress version could not be found"
exit 1
Expand Down Expand Up @@ -152,4 +153,4 @@ install_db() {

install_wp
install_test_suite
install_db
install_db
8 changes: 6 additions & 2 deletions wordpress/tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
$_tests_dir = getenv( 'WP_TESTS_DIR' );

if ( ! $_tests_dir ) {
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
$test_tmp_dir = getenv( 'TMPDIR' );
if ( ! $test_tmp_dir ) {
$test_tmp_dir = rtrim( getenv( 'HOME' ) ?: '.', '/\\' ) . '/tmp';
}
$_tests_dir = rtrim( $test_tmp_dir, '/\\' ) . '/wordpress-tests-lib';
}

if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
Expand Down Expand Up @@ -40,4 +44,4 @@ function _manually_load_plugin() {
// Include test case base classes
require_once dirname( __FILE__ ) . '/class-content-signing-test-case.php';
require_once dirname( __FILE__ ) . '/class-content-signing-db-test-case.php';
require_once dirname( __FILE__ ) . '/class-content-signing-api-client-test-case.php';
require_once dirname( __FILE__ ) . '/class-content-signing-api-client-test-case.php';
Loading