Skip to content

Commit 1ea86d5

Browse files
Merge pull request #111 from julienloizelet/feat/tls-auth
Feat/tls auth
2 parents 5184aec + e0fb1c3 commit 1ea86d5

Some content is hidden

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

61 files changed

+1213
-649
lines changed

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

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- name: Install DDEV
5050
env:
51-
DDEV_VERSION: v1.19.3
51+
DDEV_VERSION: v1.21.1
5252
run: |
5353
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
5454
sudo apt-get -qq update
@@ -103,6 +103,9 @@ jobs:
103103
- name: Prepare for playwright test
104104
run: |
105105
cd ${{ github.workspace }}
106+
cp -r .ddev/custom_files/crowdsec/cfssl/* my-own-modules/${{ env.EXTENSION_PATH }}/tls
107+
cd my-own-modules/${{ env.EXTENSION_PATH }}
108+
docker cp "tls" ddev-${{ env.WP_VERSION_CODE }}-playwright://var/www/html/wp-content/plugins/crowdsec
106109
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
107110
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
108111
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
@@ -117,13 +120,14 @@ jobs:
117120
chmod +x run-tests.sh
118121
119122
- name: Run Plugin activation tests
120-
run: |
121-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
122-
./run-tests.sh ci "./__tests__/1-activate-plugin.js"
123+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
124+
with:
125+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
126+
file_path: 1-activate-plugin.js
123127

124128
- name: Configure CrowdSec and Wordpress bouncer plugin
125129
run: |
126-
ddev crowdsec-config
130+
ddev crowdsec-config
127131
128132
- name: Prepare auto-prepend-file mode test suite
129133
run: |
@@ -146,35 +150,47 @@ jobs:
146150
fi
147151
148152
- name: Run Live mode remediation tests
149-
run: |
150-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
151-
./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js"
153+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
154+
with:
155+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
156+
file_path: 2-live-mode-remediations.js
157+
158+
- name: Run more Live mode remediation tests
159+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
160+
with:
161+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
162+
file_path: 3-live-mode-more.js
152163

153164
- name: Run Live mode cache tests
154-
run: |
155-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
156-
./run-tests.sh ci "./__tests__/4-live-mode-cache.js"
165+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
166+
with:
167+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
168+
file_path: 4-live-mode-cache.js
157169

158170
- name: Prepare cron usage
159171
run: |
160172
sed -i 's/fastcgi_finish_request/\/\/fastcgi_finish_request/g' wp-cron.php
161173
162174
- name: Run Stream mode tests
163-
run: |
164-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
165-
./run-tests.sh ci "./__tests__/5-stream-mode.js"
175+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
176+
with:
177+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
178+
file_path: 5-stream-mode.js
166179

167180
- name: Run Redis tests
168-
run: |
169-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
170-
./run-tests.sh ci "./__tests__/6-redis.js"
181+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
182+
with:
183+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
184+
file_path: 6-redis.js
171185

172186
- name: Run Memcached tests
173-
run: |
174-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
175-
./run-tests.sh ci "./__tests__/7-memcached.js"
187+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
188+
with:
189+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
190+
file_path: 7-memcached.js
176191

177192
- name: Run Geolocation tests
178-
run: |
179-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
180-
./run-tests.sh ci "./__tests__/8-geolocation.js"
193+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
194+
with:
195+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
196+
file_path: 8-geolocation.js

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

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- name: Install DDEV
5050
env:
51-
DDEV_VERSION: v1.19.3
51+
DDEV_VERSION: v1.21.1
5252
run: |
5353
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
5454
sudo apt-get -qq update
@@ -103,6 +103,9 @@ jobs:
103103
- name: Prepare for playwright test
104104
run: |
105105
cd ${{ github.workspace }}
106+
cp -r .ddev/custom_files/crowdsec/cfssl/* my-own-modules/${{ env.EXTENSION_PATH }}/tls
107+
cd my-own-modules/${{ env.EXTENSION_PATH }}
108+
docker cp "tls" ddev-${{ env.WP_VERSION_CODE }}-playwright://var/www/html/wp-content/plugins/crowdsec
106109
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
107110
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
108111
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
@@ -117,44 +120,57 @@ jobs:
117120
chmod +x run-tests.sh
118121
119122
- name: Run Plugin activation tests
120-
run: |
121-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
122-
./run-tests.sh ci "./__tests__/1-activate-plugin.js"
123+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
124+
with:
125+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
126+
file_path: 1-activate-plugin.js
123127

124128
- name: Configure CrowdSec and Wordpress bouncer plugin
125129
run: |
126130
ddev crowdsec-config
127131
128132
- name: Run Live mode remediation tests
129-
run: |
130-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
131-
./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js"
133+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
134+
with:
135+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
136+
file_path: 2-live-mode-remediations.js
137+
138+
- name: Run more Live mode remediation tests
139+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
140+
with:
141+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
142+
file_path: 3-live-mode-more.js
132143

133144
- name: Run Live mode cache tests
134-
run: |
135-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
136-
./run-tests.sh ci "./__tests__/4-live-mode-cache.js"
145+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
146+
with:
147+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
148+
file_path: 4-live-mode-cache.js
137149

138150
- name: Prepare cron usage
139151
run: |
140152
sed -i 's/fastcgi_finish_request/\/\/fastcgi_finish_request/g' wp-cron.php
141153
142154
- name: Run Stream mode tests
143-
run: |
144-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
145-
./run-tests.sh ci "./__tests__/5-stream-mode.js"
155+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
156+
with:
157+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
158+
file_path: 5-stream-mode.js
146159

147160
- name: Run Redis tests
148-
run: |
149-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
150-
./run-tests.sh ci "./__tests__/6-redis.js"
161+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
162+
with:
163+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
164+
file_path: 6-redis.js
151165

152166
- name: Run Memcached tests
153-
run: |
154-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
155-
./run-tests.sh ci "./__tests__/7-memcached.js"
167+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
168+
with:
169+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
170+
file_path: 7-memcached.js
156171

157172
- name: Run Geolocation tests
158-
run: |
159-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
160-
./run-tests.sh ci "./__tests__/8-geolocation.js"
173+
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
174+
with:
175+
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
176+
file_path: 8-geolocation.js
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Single end-to-end test"
2+
author: "Julien Loizelet"
3+
description: "A Github Action that runs a single end-to-end test"
4+
inputs:
5+
test_path:
6+
required: true
7+
description: "Path to end to end scripts"
8+
9+
file_path:
10+
required: true
11+
description: "Path to the js test file"
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- name: Run test
17+
shell: bash
18+
run: |
19+
cd ${{ inputs.test_path }}/__scripts__
20+
./run-tests.sh ci "./__tests__/${{ inputs.file_path }}"
21+
cd ${{ inputs.test_path }}
22+
PENDING_TESTS=$(grep -oP '"numPendingTests":\K(.*),"numRuntimeErrorTestSuites"' .test-results.json | sed 's/,"numRuntimeErrorTestSuites"//g')
23+
if [[ $PENDING_TESTS == "0" ]]
24+
then
25+
echo "No pending tests: OK"
26+
else
27+
echo "There are pending tests: $PENDING_TESTS (KO)"
28+
exit 1
29+
fi
30+
31+
branding:
32+
icon: "code"
33+
color: "green"

.github/workflows/release.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,28 @@ jobs:
4343
# Check crowdsec.php, readme.txt, inc/Constants.php and CHANGELOG.md
4444
run: |
4545
CURRENT_DATE=$(date +'%Y-%m-%d')
46-
CHANGELOG_VERSION=$(grep -o -E "## \[(.*)\] - $CURRENT_DATE" CHANGELOG.md | head -1 | sed 's/ //g')
46+
CHANGELOG_VERSION=$(grep -o -E "## \[(.*)\].* - $CURRENT_DATE" CHANGELOG.md | head -1 | sed 's/ //g')
4747
echo $CURRENT_DATE
4848
echo $CHANGELOG_VERSION
4949
echo "##[${{ env.VERSION_NUMBER }}]-$CURRENT_DATE"
50-
if [[ $CHANGELOG_VERSION == "##[${{ env.VERSION_NUMBER }}]-$CURRENT_DATE" ]]
50+
if [[ $CHANGELOG_VERSION == "##[${{ env.VERSION_NUMBER }}](${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/releases/tag/v${{ env.VERSION_NUMBER }})-$CURRENT_DATE" ]]
5151
then
5252
echo "Version in CHANGELOG.md: OK"
5353
else
5454
echo "Version in CHANGELOG.md: KO"
5555
exit 1
5656
fi
57+
COMPARISON=$(grep -oP "\/compare\/\K(.*)$" CHANGELOG.md | head -1)
58+
LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} ${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/releases/latest | grep -oP "\/tag\/\K(.*)$")
59+
if [[ $COMPARISON == "$LAST_TAG...v${{ env.VERSION_NUMBER }})" ]]
60+
then
61+
echo "VERSION COMPARISON OK"
62+
else
63+
echo "VERSION COMPARISON KO"
64+
echo $COMPARISON
65+
echo "$LAST_TAG...v${{ env.VERSION_NUMBER }})"
66+
exit 1
67+
fi
5768
CROWDSEC_VERSION=$(grep -E "Version: (.*)" crowdsec.php | sed 's/ //g')
5869
echo $CROWDSEC_VERSION
5970
echo "*Version:${{ env.VERSION_NUMBER }}"
@@ -121,7 +132,7 @@ jobs:
121132

122133
- name: Prepare release notes
123134
run: |
124-
VERSION_RELEASE_NOTES=$(awk -v ver="[${{ env.VERSION_NUMBER }}]" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p && NF' CHANGELOG.md)
135+
VERSION_RELEASE_NOTES=$(awk -v ver="[${{ env.VERSION_NUMBER }}](${{ env.GITHUB_SERVER_URL }}/${{ env.GITHUB_REPOSITORY }}/releases/tag/v${{ env.VERSION_NUMBER }})" '/^## / { if (p) { exit }; if ($2 == ver) { p=1; next} } p && NF' CHANGELOG.md | sed ':a;N;$!ba;s/\n---/ /g')
125136
echo "$VERSION_RELEASE_NOTES" >> CHANGELOG.txt
126137
cat CHANGELOG.txt
127138

0 commit comments

Comments
 (0)