Skip to content

Commit 5b95390

Browse files
Merge pull request #106 from julienloizelet/feat/geolocation
Feat/geolocation
2 parents 8338134 + d82ef73 commit 5b95390

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1871
-1030
lines changed

.github/workflows/end-to-end-auto-prepend-test-suite.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ jobs:
9696

9797
- name: Prepare for playwright test
9898
run: |
99+
cd ${{ github.workspace }}
100+
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
101+
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
102+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
103+
sha256sum -c GeoLite2-Country.tar.gz.sha256.txt
104+
sha256sum -c GeoLite2-City.tar.gz.sha256.txt
105+
tar -xf GeoLite2-Country.tar.gz
106+
tar -xf GeoLite2-City.tar.gz
107+
rm GeoLite2-Country.tar.gz GeoLite2-Country.tar.gz.sha256.txt GeoLite2-City.tar.gz GeoLite2-City.tar.gz.sha256.txt
99108
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
100109
chmod +x test-init.sh
101110
./test-init.sh
@@ -121,7 +130,7 @@ jobs:
121130
cp .ddev/custom_files/phpinfo.php phpinfo.php
122131
curl -v https://${{ env.WP_VERSION_CODE }}.ddev.site/phpinfo.php
123132
PREPENDVERIF=$(curl https://${{ env.WP_VERSION_CODE }}.ddev.site/phpinfo.php | grep -o -E "auto_prepend_file=(.*)php(.*)" | sed 's/<\/tr>//g; s/<\/td>//g;' | tr '\n' '#')
124-
if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#" ]]
133+
if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/wp-content/plugins/crowdsec/inc/standalone-bounce.php#auto_prepend_file=/var/www/html/wp-content/plugins/crowdsec/inc/standalone-bounce.php#" ]]
125134
then
126135
echo "AUTO PREPEND FILE OK"
127136
else
@@ -157,4 +166,9 @@ jobs:
157166
- name: Run Memcached tests
158167
run: |
159168
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
160-
./run-tests.sh ci "./__tests__/7-memcached.js"
169+
./run-tests.sh ci "./__tests__/7-memcached.js"
170+
171+
- name: Run Geolocation tests
172+
run: |
173+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
174+
./run-tests.sh ci "./__tests__/8-geolocation.js"
Lines changed: 147 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,154 @@
11
name: End-to-end test suite
22
on:
3-
push:
4-
branches:
5-
- main
6-
paths-ignore:
7-
- '**.md'
8-
workflow_dispatch:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '**.md'
8+
workflow_dispatch:
99

1010
permissions:
11-
contents: read
11+
contents: read
1212

1313
jobs:
14-
end-to-end-test-suite:
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
wp-version: [ "4.9", "5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "5.7", "5.8", "5.9", "6.0" ]
19-
php-version: [ "7.2", "7.4", "8.0" ]
20-
exclude:
21-
- { php-version: "7.4", wp-version: "4.9" }
22-
- { php-version: "7.4", wp-version: "5.0" }
23-
- { php-version: "7.4", wp-version: "5.1" }
24-
- { php-version: "7.4", wp-version: "5.2" }
25-
- { php-version: "8.0", wp-version: "4.9" }
26-
- { php-version: "8.0", wp-version: "5.0" }
27-
- { php-version: "8.0", wp-version: "5.1" }
28-
- { php-version: "8.0", wp-version: "5.2" }
29-
- { php-version: "8.0", wp-version: "5.3" }
30-
- { php-version: "8.0", wp-version: "5.4" }
31-
- { php-version: "8.0", wp-version: "5.5" }
32-
33-
name: End-to-end test suite
34-
runs-on: ubuntu-latest
35-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
36-
14+
end-to-end-test-suite:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
wp-version: [ "4.9", "5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "5.7", "5.8", "5.9", "6.0" ]
19+
php-version: [ "7.2", "7.4", "8.0" ]
20+
exclude:
21+
- { php-version: "7.4", wp-version: "4.9" }
22+
- { php-version: "7.4", wp-version: "5.0" }
23+
- { php-version: "7.4", wp-version: "5.1" }
24+
- { php-version: "7.4", wp-version: "5.2" }
25+
- { php-version: "8.0", wp-version: "4.9" }
26+
- { php-version: "8.0", wp-version: "5.0" }
27+
- { php-version: "8.0", wp-version: "5.1" }
28+
- { php-version: "8.0", wp-version: "5.2" }
29+
- { php-version: "8.0", wp-version: "5.3" }
30+
- { php-version: "8.0", wp-version: "5.4" }
31+
- { php-version: "8.0", wp-version: "5.5" }
32+
33+
name: End-to-end test suite
34+
runs-on: ubuntu-latest
35+
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
36+
37+
env:
38+
EXTENSION_NAME: "CrowdSec_Bouncer"
39+
EXTENSION_PATH: "crowdsec-bouncer"
40+
41+
steps:
42+
43+
- name: Clone DDEV files
44+
uses: actions/checkout@v2
45+
with:
46+
path: .ddev
47+
repository: julienloizelet/ddev-wp
48+
49+
- name: Install DDEV
3750
env:
38-
EXTENSION_NAME: "CrowdSec_Bouncer"
39-
EXTENSION_PATH: "crowdsec-bouncer"
40-
41-
steps:
42-
43-
- name: Clone DDEV files
44-
uses: actions/checkout@v2
45-
with:
46-
path: .ddev
47-
repository: julienloizelet/ddev-wp
48-
49-
- name: Install DDEV
50-
env:
51-
DDEV_VERSION: v1.19.3
52-
run: |
53-
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
54-
sudo apt-get -qq update
55-
sudo apt-get -qq -y install libnss3-tools
56-
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh
57-
bash install_ddev.sh ${{ env.DDEV_VERSION }}
58-
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
59-
rm install_ddev.sh
60-
61-
- name: Set WP_VERSION_CODE env
62-
# used in some directory path and conventional file naming
63-
# Example : 5.6.5 => wp565
64-
run: |
65-
echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
66-
67-
68-
- name: Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
69-
run: |
70-
cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
71-
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
72-
cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
73-
sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
74-
mkdir wp-content
75-
ddev start
76-
sudo chmod -R 777 ${{ github.workspace }}/wp-content
77-
sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
78-
79-
- name: Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
80-
run: |
81-
wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
82-
tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress
83-
cp -r wordpress/. ${{ github.workspace }}
84-
rm -rf wordpress
85-
rm wordpress-${{ matrix.wp-version }}.tar.gz
86-
87-
- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
88-
run: |
89-
ddev exec wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
90-
91-
92-
- name: Clone ${{ env.EXTENSION_NAME }} files
93-
uses: actions/checkout@v2
94-
with:
95-
path: my-own-modules/${{ env.EXTENSION_PATH }}
96-
97-
- name: Prepare for playwright test
98-
run: |
99-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
100-
chmod +x test-init.sh
101-
./test-init.sh
102-
chmod +x run-tests.sh
103-
104-
- name: Run Plugin activation tests
105-
run: |
106-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
107-
./run-tests.sh ci "./__tests__/1-activate-plugin.js"
108-
109-
- name: Configure CrowdSec and Wordpress bouncer plugin
110-
run: |
111-
ddev crowdsec-config
112-
113-
- name: Run Live mode remediation tests
114-
run: |
115-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
116-
./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js"
117-
118-
- name: Run Live mode cache tests
119-
run: |
120-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
121-
./run-tests.sh ci "./__tests__/4-live-mode-cache.js"
122-
123-
- name: Prepare cron usage
124-
run: |
125-
sed -i 's/fastcgi_finish_request/\/\/fastcgi_finish_request/g' wp-cron.php
126-
127-
- name: Run Stream mode tests
128-
run: |
129-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
130-
./run-tests.sh ci "./__tests__/5-stream-mode.js"
131-
132-
- name: Run Redis tests
133-
run: |
134-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
135-
./run-tests.sh ci "./__tests__/6-redis.js"
136-
137-
- name: Run Memcached tests
138-
run: |
139-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
140-
./run-tests.sh ci "./__tests__/7-memcached.js"
51+
DDEV_VERSION: v1.19.3
52+
run: |
53+
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
54+
sudo apt-get -qq update
55+
sudo apt-get -qq -y install libnss3-tools
56+
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh
57+
bash install_ddev.sh ${{ env.DDEV_VERSION }}
58+
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
59+
rm install_ddev.sh
60+
61+
- name: Set WP_VERSION_CODE env
62+
# used in some directory path and conventional file naming
63+
# Example : 5.6.5 => wp565
64+
run: |
65+
echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
66+
67+
68+
- name: Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
69+
run: |
70+
cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
71+
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
72+
cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
73+
sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
74+
mkdir wp-content
75+
ddev start
76+
sudo chmod -R 777 ${{ github.workspace }}/wp-content
77+
sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
78+
79+
- name: Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
80+
run: |
81+
wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
82+
tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress
83+
cp -r wordpress/. ${{ github.workspace }}
84+
rm -rf wordpress
85+
rm wordpress-${{ matrix.wp-version }}.tar.gz
86+
87+
- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
88+
run: |
89+
ddev exec wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
90+
91+
92+
- name: Clone ${{ env.EXTENSION_NAME }} files
93+
uses: actions/checkout@v2
94+
with:
95+
path: my-own-modules/${{ env.EXTENSION_PATH }}
96+
97+
- name: Prepare for playwright test
98+
run: |
99+
cd ${{ github.workspace }}
100+
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
101+
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
102+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
103+
sha256sum -c GeoLite2-Country.tar.gz.sha256.txt
104+
sha256sum -c GeoLite2-City.tar.gz.sha256.txt
105+
tar -xf GeoLite2-Country.tar.gz
106+
tar -xf GeoLite2-City.tar.gz
107+
rm GeoLite2-Country.tar.gz GeoLite2-Country.tar.gz.sha256.txt GeoLite2-City.tar.gz GeoLite2-City.tar.gz.sha256.txt
108+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
109+
chmod +x test-init.sh
110+
./test-init.sh
111+
chmod +x run-tests.sh
112+
113+
- name: Run Plugin activation tests
114+
run: |
115+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
116+
./run-tests.sh ci "./__tests__/1-activate-plugin.js"
117+
118+
- name: Configure CrowdSec and Wordpress bouncer plugin
119+
run: |
120+
ddev crowdsec-config
121+
122+
- name: Run Live mode remediation tests
123+
run: |
124+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
125+
./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js"
126+
127+
- name: Run Live mode cache tests
128+
run: |
129+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
130+
./run-tests.sh ci "./__tests__/4-live-mode-cache.js"
131+
132+
- name: Prepare cron usage
133+
run: |
134+
sed -i 's/fastcgi_finish_request/\/\/fastcgi_finish_request/g' wp-cron.php
135+
136+
- name: Run Stream mode tests
137+
run: |
138+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
139+
./run-tests.sh ci "./__tests__/5-stream-mode.js"
140+
141+
- name: Run Redis tests
142+
run: |
143+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
144+
./run-tests.sh ci "./__tests__/6-redis.js"
145+
146+
- name: Run Memcached tests
147+
run: |
148+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
149+
./run-tests.sh ci "./__tests__/7-memcached.js"
150+
151+
- name: Run Geolocation tests
152+
run: |
153+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
154+
./run-tests.sh ci "./__tests__/8-geolocation.js"

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [1.7.0] - 2022-07-21
8+
9+
### Added
10+
- Add geolocation feature
11+
12+
### Changed
13+
- Do not throw exception if empty api url as it is the default after a fresh install and activation
14+
- Changed default value for some boolean value as WordPress config are always string
715

816
## [1.6.0] - 2022-06-30
917

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
},
2121
"require": {
22-
"crowdsec/bouncer": "0.22.1",
22+
"crowdsec/bouncer": "0.24.0",
2323
"symfony/polyfill-mbstring": "1.20.0",
2424
"symfony/service-contracts": "2.4.1"
2525
},

0 commit comments

Comments
 (0)