Skip to content

Commit

Permalink
Merge pull request #48 from crowdsecurity/feature/wp-5-8
Browse files Browse the repository at this point in the history
test(wordpress 5.8): Add compatibility test for WordPress 5.8
  • Loading branch information
julienloizelet authored Oct 22, 2021
2 parents 9c1b178 + 8eda729 commit d194d97
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 10 deletions.
26 changes: 25 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
version: "3"
services:
wordpress5-8:
build:
context: .
dockerfile: ./docker/wp5.8/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
networks:
- wordpress_bouncer_network_ipv4
#- wordpress_bouncer_network_ipv6
depends_on:
- crowdsec
- mysql
- redis
- memcached
environment:
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: super_secret_password
WORDPRESS_DEBUG: 1 # Comment this line the simulate the production mode
WORDPRESS_CONFIG_EXTRA: |
define('WP_CRON_LOCK_TIMEOUT', 1);
# more here https://hub.docker.com/_/wordpress
ports:
- "80:80"
volumes:
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
- ./docker/tests.htaccess:/var/www/html/.htaccess:rw
wordpress5-7:
build:
context: .
Expand Down Expand Up @@ -272,7 +296,7 @@ services:

networks:
wordpress_bouncer_network_ipv4:
name: wordpress_bouncer_network_ipv4
#name: wordpress_bouncer_network_ipv4
#enable_ipv6: false
ipam:
config:
Expand Down
11 changes: 11 additions & 0 deletions docker/wp5.8/php-7.3.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM wordpress:5.8-php7.3

RUN usermod -u 1000 www-data

RUN a2disconf remoteip && a2dismod remoteip && service apache2 restart

RUN apt-get update && apt-get install -y git libmemcached-dev zlib1g-dev \
&& pecl install -o -f redis memcached \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis memcached \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
11 changes: 11 additions & 0 deletions docker/wp5.8/php-7.4.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM wordpress:5.8-php7.4

RUN usermod -u 1000 www-data

RUN a2disconf remoteip && a2dismod remoteip && service apache2 restart

RUN apt-get update && apt-get install -y git libmemcached-dev zlib1g-dev \
&& pecl install -o -f redis memcached \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis memcached \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
11 changes: 11 additions & 0 deletions docker/wp5.8/php-8.0.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM wordpress:5.8-php8.0

RUN usermod -u 1000 www-data

RUN a2disconf remoteip && a2dismod remoteip && service apache2 restart

RUN apt-get update && apt-get install -y git libmemcached-dev zlib1g-dev \
&& pecl install -o -f redis memcached \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis memcached \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
5 changes: 3 additions & 2 deletions docs/contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ docker-compose rm # destroy

```bash
docker-compose down
docker images | grep wordpress-bouncer_wordpress # to get the container id
docker images | grep crowdsec-bouncer_wordpress # to get the container id
docker rmi <container-id>
```

Expand All @@ -69,7 +69,8 @@ Then re-run the stack.
### Try the plugin with another WordPress version


The plugin is tested under each of these WordPress versions: `5.6`, `5.5`, `5.4`, `5.3`, `5.2`, `5.1`, `5.0`, `4.9`.
The plugin is tested under each of these WordPress versions: `5.8`,`5.7`,`5.6`, `5.5`, `5.4`, `5.3`, `5.2`, `5.1`,
`5.0`, `4.9`.
(Representing [more than 90% of the wordpress websites](https://wordpress.org/about/stats/))

#### Add support for a new WordPress version
Expand Down
6 changes: 3 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: crowdsec
Donate link: https://crowdsec.net/
Tags: crowdsec-bouncer, wordpress, security, firewall, captcha, ip-scanner, ip-blocker, ip-blocking, ip-address, ip-database, ip-range-check, crowdsec, ban-hosts, ban-management, anti-hacking, hacker-protection, captcha-image, captcha-generator, captcha-generation, captcha-service
Requires at least: 4.9
Tested up to: 5.7
Stable tag: 1.0.6
Tested up to: 5.8
Stable tag: 1.0.7
Requires PHP: 7.2
License: MIT
License URI: https://opensource.org/licenses/MIT
Expand Down Expand Up @@ -72,4 +72,4 @@ You can:
1. Block aggresive IPs
2. Display a captcha for less aggresive IPs

Get more info on the [CrowdSec official website](https://crowdsec.net).
Get more info on the [CrowdSec official website](https://crowdsec.net).
3 changes: 2 additions & 1 deletion run-tests-with-all-wp-versions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

WORDPRESS_VERSION=5.8 ./run-tests.sh
WORDPRESS_VERSION=5.7 ./run-tests.sh
WORDPRESS_VERSION=5.6 ./run-tests.sh
WORDPRESS_VERSION=5.5 ./run-tests.sh
Expand All @@ -10,4 +11,4 @@ WORDPRESS_VERSION=5.1 ./run-tests.sh
WORDPRESS_VERSION=5.0 ./run-tests.sh
WORDPRESS_VERSION=4.9 ./run-tests.sh

cat tests/e2e/.test-results-* | jq .success
cat tests/e2e/.test-results-* | jq .success
5 changes: 3 additions & 2 deletions tests/e2e/__tests__/0-setup-wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const {
ADMIN_LOGIN,
ADMIN_PASSWORD,
WORDPRESS_VERSION,
WP58,
WP57,
WP56,
WP55,
Expand All @@ -28,7 +29,7 @@ describe(`Setup WordPress ${WORDPRESS_VERSION}`, () => {
// Go to home
await goToPublicPage();

if (WP54 || WP55 || WP56 || WP57) {
if (WP54 || WP55 || WP56 || WP57 || WP58) {
// "Language selection" page
await page.click('option[lang="en"]');
await page.click("#language-continue");
Expand All @@ -38,7 +39,7 @@ describe(`Setup WordPress ${WORDPRESS_VERSION}`, () => {
// "Account creation" page
await page.fill("#weblog_title", "My website");
await page.fill("#user_login", ADMIN_LOGIN);
if (WP53 || WP54 || WP55 || WP56 || WP57) {
if (WP53 || WP54 || WP55 || WP56 || WP57 || WP58) {
await page.fill("#pass1", ADMIN_PASSWORD);
} else {
await page.fill("#pass1-text", ADMIN_PASSWORD);
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/__tests__/1-setup-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const {
BOUNCER_KEY,
ADMIN_URL,
LAPI_URL_FROM_WP,
WP58,
WP57,
WP56,
WP55,
Expand Down Expand Up @@ -37,7 +38,7 @@ describe(`Setup CrowdSec plugin`, () => {
// "Plugins" page
await wait(2000);
await page.goto(`${ADMIN_URL}/plugins.php`);
if (WP55 || WP56|| WP57) {
if (WP55 || WP56|| WP57 || WP58) {
await page.click("#activate-crowdsec");
} else {
await page.click('[aria-label="Activate CrowdSec"]');
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const LAPI_URL_FROM_WP = process.env.LAPI_URL_FROM_WP;
const DEBUG = !!process.env.DEBUG;
const TIMEOUT = (!!process.env.DEBUG ? 5 * 60 : 15) * 1000;
const OTHER_IP = "1.2.3.4";
const WP58 = WORDPRESS_VERSION === "5.8";
const WP57 = WORDPRESS_VERSION === "5.7";
const WP56 = WORDPRESS_VERSION === "5.6";
const WP55 = WORDPRESS_VERSION === "5.5";
Expand All @@ -25,6 +26,7 @@ module.exports = {
ADMIN_PASSWORD,
LAPI_URL_FROM_WP,
OTHER_IP,
WP58,
WP57,
WP56,
WP55,
Expand Down

0 comments on commit d194d97

Please sign in to comment.