diff --git a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/WordPressTests.groovy b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/WordPressTests.groovy index 5ab05fc5d7..e53151fda4 100644 --- a/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/WordPressTests.groovy +++ b/appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/WordPressTests.groovy @@ -37,11 +37,11 @@ class WordPressTests { private static MySQLContainer MYSQL = new MySQLContainer( DockerImageName.parse("${System.getProperty('DOCKER_MIRROR') ?: 'docker.io'}/library/mysql:8.0") .asCompatibleSubstituteFor('mysql')) - .withDatabaseName('wordpress') - .withUsername('root') + .withDatabaseName('wp61') + .withUsername('test') .withPassword('test') .withNetwork(network) - .withNetworkAliases('mysql') + .withNetworkAliases('mysql-integration') .waitingFor(Wait.forLogMessage(".*ready for connections.*", 1)) as MySQLContainer @Container @@ -52,7 +52,7 @@ class WordPressTests { baseTag: 'apache2-fpm-php', phpVersion: phpVersion, phpVariant: variant, - www: 'wordpress', + www: '../../../tests/Frameworks/WordPress/Version_6_1', ).withNetwork(network) as AppSecContainer static void main(String[] args) { @@ -63,14 +63,14 @@ class WordPressTests { static void installWordPress() { def mysqlInfo = MYSQL.containerInfo def mysqlIp = mysqlInfo.networkSettings.networks.values().find { - it.aliases?.contains('mysql') + it.aliases?.contains('mysql-integration') }?.ipAddress assert mysqlIp != null : "Could not determine MySQL container IP" log.info("MySQL IP: {}", mysqlIp) def res = CONTAINER.execInContainer('bash', '-c', - "sed -i \"s/'mysql'/'${mysqlIp}'/\" /var/www/public/wp-config.php") + "sed -i \"s/'mysql-integration'/'${mysqlIp}'/\" /var/www/public/wp-config.php") assert res.exitCode == 0 : "Failed to update wp-config.php: ${res.stderr}" // Run wp-cli with tracing and AppSec disabled so these CLI processes diff --git a/appsec/tests/integration/src/test/www/wordpress/docker-init.sh b/appsec/tests/integration/src/test/www/wordpress/docker-init.sh deleted file mode 100755 index 7ba2e9e499..0000000000 --- a/appsec/tests/integration/src/test/www/wordpress/docker-init.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -ex - -cd /var/www/public - -export DD_TRACE_CLI_ENABLED=false - -# Copy WordPress source from the project mount -cp -a /project/tests/Frameworks/WordPress/Version_6_1/. . -# Restore our custom files (the cp above overwrites them in the overlay upper dir) -cp /test-resources/public/wp-config.php wp-config.php -cp /test-resources/public/index.php index.php -cp /test-resources/public/login_trigger.php login_trigger.php -cp /test-resources/public/hello.php hello.php - -# Download WP-CLI -curl -sf https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp -chmod +x /usr/local/bin/wp - -chown -R www-data:www-data /var/www/public diff --git a/appsec/tests/integration/src/test/www/wordpress/public/index.php b/appsec/tests/integration/src/test/www/wordpress/public/index.php deleted file mode 100644 index 86ca28d0a7..0000000000 --- a/appsec/tests/integration/src/test/www/wordpress/public/index.php +++ /dev/null @@ -1,12 +0,0 @@ - . so Apache finds the files without materializing a second copy; +# this lets edits in the host checkout be reflected immediately through the +# overlay mount. +ln -sfn . /var/www/public + +# Download WP-CLI for use by WordPressTests.groovy's @BeforeAll install step. +curl -sf https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -o /usr/local/bin/wp +chmod +x /usr/local/bin/wp diff --git a/appsec/tests/integration/src/test/www/wordpress/public/hello.php b/tests/Frameworks/WordPress/Version_6_1/hello.php similarity index 100% rename from appsec/tests/integration/src/test/www/wordpress/public/hello.php rename to tests/Frameworks/WordPress/Version_6_1/hello.php diff --git a/tests/Frameworks/WordPress/Version_6_1/index.php b/tests/Frameworks/WordPress/Version_6_1/index.php index 136b31f504..7579e450d1 100644 --- a/tests/Frameworks/WordPress/Version_6_1/index.php +++ b/tests/Frameworks/WordPress/Version_6_1/index.php @@ -7,7 +7,9 @@ */ # Appsec mock. This wont be needed on customer apps since this functions will be exposed by appsec. -require __DIR__.'/../../../Appsec/Mock.php'; +if (file_exists(__DIR__.'/../../../Appsec/Mock.php')) { + require __DIR__.'/../../../Appsec/Mock.php'; +} /** * Tells WordPress to load the WordPress theme and output it. diff --git a/appsec/tests/integration/src/test/www/wordpress/public/login_trigger.php b/tests/Frameworks/WordPress/Version_6_1/login_trigger.php similarity index 100% rename from appsec/tests/integration/src/test/www/wordpress/public/login_trigger.php rename to tests/Frameworks/WordPress/Version_6_1/login_trigger.php diff --git a/appsec/tests/integration/src/test/www/wordpress/public/signup_trigger.php b/tests/Frameworks/WordPress/Version_6_1/signup_trigger.php similarity index 100% rename from appsec/tests/integration/src/test/www/wordpress/public/signup_trigger.php rename to tests/Frameworks/WordPress/Version_6_1/signup_trigger.php diff --git a/tests/Frameworks/WordPress/Version_6_1/wp-config.php b/tests/Frameworks/WordPress/Version_6_1/wp-config.php index 0a4f02ea47..c6e5cd4ed3 100644 --- a/tests/Frameworks/WordPress/Version_6_1/wp-config.php +++ b/tests/Frameworks/WordPress/Version_6_1/wp-config.php @@ -98,4 +98,6 @@ require_once ABSPATH . 'wp-settings.php'; //Appsec mock. This wont be needed on customer apps since this functions will be exposed by appsec -require __DIR__.'/../../../Appsec/Mock.php'; +if (file_exists(__DIR__.'/../../../Appsec/Mock.php')) { + require __DIR__.'/../../../Appsec/Mock.php'; +}