Skip to content

Commit

Permalink
feat(*): Add compatibility with 6.3 (#144)
Browse files Browse the repository at this point in the history
* tests(6.3): Add 6.3 in tests matrix

* test(*): Update database after install to avaoi database update required message

* tests(*): Fix version not as expected and database update required message error

* ci(*): Update missing action

* test(multisite): Fix multi notice

* feat(*): Prepare release 2.5.1
  • Loading branch information
julienloizelet authored Sep 14, 2023
1 parent 1a3768a commit 41b9d19
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 32 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/end-to-end-auto-prepend-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wp-version: [ "4.9", "5.0", "5.2", "5.4", "5.6", "5.8", "5.9", "6.0", "6.1", "6.2" ]
wp-version: [ "4.9", "5.0", "5.2", "5.4", "5.6", "5.8", "6.0", "6.1", "6.2","6.3" ]
php-version: [ "7.2", "7.4", "8.0" ]
exclude:
- { php-version: "7.4", wp-version: "4.9" }
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
sudo apt-get -q update
sudo apt-get -q -y install libnss3-tools ddev
mkcert -install
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
- name: Set WP_VERSION_CODE env
Expand All @@ -60,6 +60,12 @@ jobs:
- name: Create empty WordPress DDEV project (with Nginx)
run: ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }} --php-version=${{ matrix.php-version }} --webserver-type=nginx-fpm

- name: Disable automatic update
run: |
# @see https://wordpress.org/documentation/article/configuring-automatic-background-updates/#constant-to-disable-all-updates
sed -i -e 's/#ddev-generated//g' wp-config-ddev.php
echo "define( 'AUTOMATIC_UPDATER_DISABLED', true );" >> wp-config-ddev.php
- name: Add Redis, Memcached, Crowdsec and Playwright
run: |
ddev get ddev/ddev-redis
Expand All @@ -77,7 +83,7 @@ jobs:

- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
run: |
ddev exec wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='[email protected]'
ddev wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='[email protected]'
- name: Clone ${{ env.EXTENSION_NAME }} files
uses: actions/checkout@v3
Expand Down Expand Up @@ -109,11 +115,8 @@ jobs:
ddev exec php -v
ddev exec -s crowdsec crowdsec -version
- name: Run Plugin activation tests
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
file_path: 1-activate-plugin.js
- name: Activate plugin with wp
run: ddev wp plugin install crowdsec --activate

- name: Configure CrowdSec and Wordpress bouncer plugin
run: |
Expand Down Expand Up @@ -183,4 +186,17 @@ jobs:
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
file_path: 8-geolocation.js
file_path: 8-geolocation.js

- name: Check tested version
run: |
CURRENT_VERSION=$(ddev wp core version)
if [[ ${{ matrix.wp-version }} == $CURRENT_VERSION ]]
then
echo "Tested version was as expected"
else
echo "Tested version was not as expected"
echo $CURRENT_VERSION
echo ${{ matrix.wp-version }}
exit 1
fi
32 changes: 28 additions & 4 deletions .github/workflows/end-to-end-multisite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ on:
push:
branches:
- main
- feat/multisite
paths-ignore:
- '**.md'
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: Debug with tmate
default: false

permissions:
contents: read
Expand All @@ -20,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wp-version: [ "4.9", "6.2" ]
wp-version: [ "4.9", "6.2", "6.3" ]
php-version: [ "7.2" ]
subsite: ["site1", "site2"]

Expand All @@ -42,7 +46,7 @@ jobs:
sudo apt-get -q update
sudo apt-get -q -y install libnss3-tools ddev
mkcert -install
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
- name: Set WP_VERSION_CODE env
Expand All @@ -54,6 +58,12 @@ jobs:
- name: Create empty WordPress DDEV project (with Apache)
run: ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }} --php-version=${{ matrix.php-version }} --webserver-type=apache-fpm

- name: Disable automatic update
run: |
# @see https://wordpress.org/documentation/article/configuring-automatic-background-updates/#constant-to-disable-all-updates
sed -i -e 's/#ddev-generated//g' wp-config-ddev.php
echo "define( 'AUTOMATIC_UPDATER_DISABLED', true );" >> wp-config-ddev.php
- name: Add Redis, Memcached, Crowdsec and Playwright
run: |
ddev get ddev/ddev-redis
Expand Down Expand Up @@ -183,11 +193,25 @@ jobs:
file_path: 8-geolocation.js
subsite: ${{ matrix.subsite }}

- name: Check tested version
run: |
CURRENT_VERSION=$(ddev wp core version)
if [[ ${{ matrix.wp-version }} == $CURRENT_VERSION ]]
then
echo "Tested version was as expected"
else
echo "Tested version was not as expected"
echo $CURRENT_VERSION
echo ${{ matrix.wp-version }}
exit 1
fi
- name: tmate debugging session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 15
if: failure()
if: failure() && github.event.inputs.debug_enabled == 'true'


29 changes: 25 additions & 4 deletions .github/workflows/end-to-end-test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wp-version: [ "4.9", "5.0", "5.2", "5.4", "5.6", "5.8", "6.0", "6.1", "6.2" ]
wp-version: [ "4.9", "5.0", "5.2", "5.4", "5.6", "5.8", "6.0", "6.1", "6.2", "6.3" ]
php-version: [ "7.2", "7.4", "8.0" ]
exclude:
- { php-version: "7.4", wp-version: "4.9" }
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
sudo apt-get -q update
sudo apt-get -q -y install libnss3-tools ddev
mkcert -install
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
ddev config global --instrumentation-opt-in=false --omit-containers=ddev-ssh-agent
- name: Set WP_VERSION_CODE env
Expand All @@ -60,6 +60,12 @@ jobs:
- name: Create empty WordPress DDEV project (with Apache)
run: ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }} --php-version=${{ matrix.php-version }} --webserver-type=apache-fpm

- name: Disable automatic update
run: |
# @see https://wordpress.org/documentation/article/configuring-automatic-background-updates/#constant-to-disable-all-updates
sed -i -e 's/#ddev-generated//g' wp-config-ddev.php
echo "define( 'AUTOMATIC_UPDATER_DISABLED', true );" >> wp-config-ddev.php
- name: Add Redis, Memcached, Crowdsec and Playwright
run: |
ddev get ddev/ddev-redis
Expand All @@ -77,7 +83,7 @@ jobs:

- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
run: |
ddev exec wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='[email protected]'
ddev wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='[email protected]'
- name: Clone ${{ env.EXTENSION_NAME }} files
uses: actions/checkout@v3
Expand Down Expand Up @@ -109,6 +115,7 @@ jobs:
ddev exec php -v
ddev exec -s crowdsec crowdsec -version
- name: Run Plugin activation tests
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
with:
Expand Down Expand Up @@ -163,4 +170,18 @@ jobs:
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
file_path: 8-geolocation.js
file_path: 8-geolocation.js

- name: Check tested version
run: |
CURRENT_VERSION=$(ddev wp core version)
if [[ ${{ matrix.wp-version }} == $CURRENT_VERSION ]]
then
echo "Tested version was as expected"
else
echo "Tested version was not as expected"
echo $CURRENT_VERSION
echo ${{ matrix.wp-version }}
exit 1
fi
9 changes: 7 additions & 2 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wp-version: [ "4.9", "5.0", "5.2", "5.4", "5.6", "5.8", "5.9", "6.0", "6.1", "6.2" ]
wp-version: [ "4.9", "5.0", "5.2", "5.4", "5.6", "5.8", "5.9", "6.0", "6.1", "6.3" ]
php-version: [ "7.2", "7.4", "8.0" ]
exclude:
- { php-version: "7.4", wp-version: "4.9" }
Expand Down Expand Up @@ -65,6 +65,11 @@ jobs:
- name: Create empty WordPress DDEV project (with Apache)
run: ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }} --php-version=${{ matrix.php-version }} --webserver-type=apache-fpm

- name: Disable automatic update
run: |
# @see https://wordpress.org/documentation/article/configuring-automatic-background-updates/#constant-to-disable-all-updates
sed -i -e 's/#ddev-generated//g' wp-config-ddev.php
echo "define( 'AUTOMATIC_UPDATER_DISABLED', true );" >> wp-config-ddev.php
- name: Add Redis, Memcached, Crowdsec and Playwright
run: |
Expand Down Expand Up @@ -209,4 +214,4 @@ jobs:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 15
if: failure() && github.event.inputs.debug_enabled == 'true'
if: failure() && github.event.inputs.debug_enabled == 'true'
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
strategy:
fail-fast: false
matrix:
wp-version: [ "4.9", "5.0", "5.5", "5.9", "6.1", "6.2" ]
wp-version: [ "4.9", "5.0", "5.5", "5.9", "6.1", "6.3" ]
php-version: [ "7.2", "7.4", "8.0" ]
exclude:
- { php-version: "7.4", wp-version: "4.9" }
Expand Down Expand Up @@ -206,6 +206,12 @@ jobs:
- name: Create empty WordPress DDEV project (with Apache)
run: ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }} --php-version=${{ matrix.php-version }} --webserver-type=apache-fpm

- name: Disable automatic update
run: |
# @see https://wordpress.org/documentation/article/configuring-automatic-background-updates/#constant-to-disable-all-updates
sed -i -e 's/#ddev-generated//g' wp-config-ddev.php
echo "define( 'AUTOMATIC_UPDATER_DISABLED', true );" >> wp-config-ddev.php
- name: Add Redis, Memcached, Crowdsec and Playwright
run: |
ddev get ddev/ddev-redis
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).



## [2.5.1](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.5.1) - 2023-09-14
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.5.0...v2.5.1)

### Added

- Add compatibility with WordPress 6.3


---


## [2.5.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.5.0) - 2023-06-01
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.4.1...v2.5.0)

Expand Down
6 changes: 3 additions & 3 deletions crowdsec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* Plugin URI: https://github.com/crowdsecurity/cs-wordpress-bouncer
* Description: Safer Together. Protect your WordPress application with CrowdSec.
* 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
* Version: 2.5.0
* Version: 2.5.1
* Author: CrowdSec
* Author URI: https://www.crowdsec.net/
* Github: https://github.com/crowdsecurity/cs-wordpress-bouncer
* License: MIT
* License URI: https://opensource.org/licenses/MIT
* Requires PHP: 7.2
* Requires at least: 4.9
* Tested up to: 6.2
* Stable tag: 2.5.0
* Tested up to: 6.3
* Stable tag: 2.5.1
* Text Domain: crowdsec-wp
* First release: 2021.
*/
Expand Down
4 changes: 4 additions & 0 deletions docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ ddev get julienloizelet/ddev-tools
ddev get julienloizelet/ddev-playwright
```

If you wish to use an older version of WordPress, add

`define( 'AUTOMATIC_UPDATER_DISABLED', true );` in the `wp-config-ddev.php` file.

- Launch DDEV

```shell
Expand Down
2 changes: 1 addition & 1 deletion inc/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ class Constants extends LibConstants
public const LOG_BASE_PATH = __DIR__ . '/../logs/';
public const CACHE_PATH = __DIR__ . '/../.cache';
public const CONFIG_PATH = __DIR__ . '/standalone-settings.php';
public const VERSION = 'v2.5.0';
public const VERSION = 'v2.5.1';
}
4 changes: 2 additions & 2 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: 6.2
Stable tag: 2.5.0
Tested up to: 6.3
Stable tag: 2.5.1
Requires PHP: 7.2
License: MIT
License URI: https://opensource.org/licenses/MIT
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e-ddev/__scripts__/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ case $TYPE in

"docker")
DEBUG_STRING=""
YARN_PATH="./var/www/html/wp-content/plugins/crowdsec/tests/e2e-ddev"
YARN_PATH="./wp-content/plugins/crowdsec/tests/e2e-ddev"
COMMAND="ddev exec -s playwright yarn --cwd ${YARN_PATH} cross-env"
LAPI_URL_FROM_PLAYWRIGHT=https://crowdsec:8080
CURRENT_IP=$(ddev find-ip playwright)
Expand All @@ -99,7 +99,7 @@ case $TYPE in

"ci")
DEBUG_STRING="DEBUG=pw:api"
YARN_PATH="./var/www/html/wp-content/plugins/crowdsec/tests/e2e-ddev"
YARN_PATH="./wp-content/plugins/crowdsec/tests/e2e-ddev"
COMMAND="ddev exec -s playwright xvfb-run --auto-servernum -- yarn --cwd ${YARN_PATH} cross-env"
LAPI_URL_FROM_PLAYWRIGHT=https://crowdsec:8080
CURRENT_IP=$(ddev find-ip playwright)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e-ddev/__scripts__/test-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ if ! ddev --version >/dev/null 2>&1; then
exit 1
fi

ddev exec -s playwright yarn --cwd ./var/www/html/wp-content/plugins/crowdsec/tests/e2e-ddev --force && \
ddev exec -s playwright yarn --cwd ./wp-content/plugins/crowdsec/tests/e2e-ddev --force && \
ddev exec -s playwright yarn global add cross-env
2 changes: 1 addition & 1 deletion tests/e2e-ddev/__tests__/1-activate-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe(`Setup CrowdSec plugin`, () => {
it('Should install CrowdSec plugin"', async () => {
// "Plugins" page
await wait(2000);
await goToAdmin("/plugins.php");
await goToAdmin("plugins.php");
if (WP55 || WP56 || WP57 || WP58 || WP59) {
await page.click("#activate-crowdsec");
} else if(MULTISITE == "true"){
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e-ddev/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
jest.setTimeout(TIMEOUT);

const goToAdmin = async (endpoint = "") => {
const adminUrl = MULTISITE == "true" ? `${ADMIN_URL}network` : `${ADMIN_URL}`;
const adminUrl = MULTISITE == "true" ? `${ADMIN_URL}network/` : `${ADMIN_URL}`;
await page.goto(`${adminUrl}${endpoint}`);
};

Expand Down Expand Up @@ -82,7 +82,7 @@ const onAdminSaveSettings = async (check = true) => {

if (check) {
if (MULTISITE == "true") {
await expect(page).toHaveText(".notice", "saved.");
await expect(page).toHaveText(".wrap .notice", "saved.");
} else {
await expect(page).toHaveText(
"#setting-error-settings_updated",
Expand Down

0 comments on commit 41b9d19

Please sign in to comment.