Skip to content

Commit 08e7f7d

Browse files
test(end-to-end): Add end-to-end test for TLS auth
1 parent 20c2f6f commit 08e7f7d

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

.github/workflows/test-suite.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,27 @@ jobs:
220220
sed -i 's/\x27stream_mode\x27 => true/\x27stream_mode\x27 => false/g' scripts/auto-prepend/settings.php
221221
cat scripts/auto-prepend/settings.php
222222
cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/__scripts__
223-
./run-tests.sh ci "./__tests__/1-live-mode.js"
223+
./run-tests.sh ci "./__tests__/1-live-mode.js"
224+
225+
- name: Run "live mode with TLS auth" test
226+
run: |
227+
cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}
228+
sed -i 's/\x27auth_type\x27 => \x27api_key\x27/\x27auth_type\x27 => \x27tls\x27/g' scripts/auto-prepend/settings.php
229+
sed -i 's/\x27api_key\x27 => \x27${{env.BOUNCER_KEY}}\x27/\x27api_key\x27 => \x27\x27/g' scripts/auto-prepend/settings.php
230+
sed -i 's/\x27tls_cert_path\x27 => \x27\x27/\x27tls_cert_path\x27 => \x27\/var\/www\/html\/cfssl\/bouncer.pem\x27/g' scripts/auto-prepend/settings.php
231+
sed -i 's/\x27tls_key_path\x27 => \x27\x27/\x27tls_key_path\x27 => \x27\/var\/www\/html\/cfssl\/bouncer-key.pem\x27/g' scripts/auto-prepend/settings.php
232+
sed -i 's/\x27tls_ca_cert_path\x27 => \x27\x27/\x27tls_ca_cert_path\x27 => \x27\/var\/www\/html\/cfssl\/ca-chain.pem\x27/g' scripts/auto-prepend/settings.php
233+
cat scripts/auto-prepend/settings.php
234+
cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/__scripts__
235+
./run-tests.sh ci "./__tests__/1-live-mode.js"
236+
237+
238+
- name: Run "stream mode with TLS auth and cURL" test
239+
run: |
240+
cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}
241+
sed -i 's/\x27stream_mode\x27 => false/\x27stream_mode\x27 => true/g' scripts/auto-prepend/settings.php
242+
sed -i 's/\x27forced_test_forwarded_ip\x27 => \x27${{env.IPV6_TEST_IP}}\x27/\x27forced_test_forwarded_ip\x27 => \x27\x27/g' scripts/auto-prepend/settings.php
243+
sed -i 's/\x27use_curl\x27 => false/\x27use_curl\x27 => true/g' scripts/auto-prepend/settings.php
244+
cat scripts/auto-prepend/settings.php
245+
cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/__scripts__
246+
./run-tests.sh ci "./__tests__/3-stream-mode.js"

tests/end-to-end/settings/base.php.dist

+5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ use CrowdSecBouncer\Constants;
44

55
$crowdSecStandaloneBouncerConfig = [
66
// LAPI Connection
7+
'auth_type' => 'api_key',
78
'api_url' => 'https://crowdsec:8080',
89
'api_key' => 'REPLACE_API_KEY',
910
'api_timeout'=> 1,
1011
'api_user_agent'=> 'CrowdSec PHP Library/test',
1112
'use_curl' => false,
13+
'tls_cert_path' => '',
14+
'tls_key_path' => '',
15+
'tls_verify_peer' => true,
16+
'tls_ca_cert_path' => '',
1217
// Debug/Test
1318
'debug_mode' => true,
1419
'display_errors' => true,

0 commit comments

Comments
 (0)