Skip to content

Commit b32e991

Browse files
test(e2e): Add end to end test for captcha flow and display error setting
1 parent 8441107 commit b32e991

File tree

12 files changed

+413
-322
lines changed

12 files changed

+413
-322
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
- name: Prepare for playwright test
104104
run: |
105105
cd ${{ github.workspace }}
106+
cp .ddev/custom_files/crowdsec/php/cache-actions.php cache-actions.php
106107
cp -r .ddev/custom_files/crowdsec/cfssl/* my-own-modules/${{ env.EXTENSION_PATH }}/tls
107108
cd my-own-modules/${{ env.EXTENSION_PATH }}
108109
docker cp "tls" ddev-${{ env.WP_VERSION_CODE }}-playwright://var/www/html/wp-content/plugins/crowdsec

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
- name: Prepare for playwright test
104104
run: |
105105
cd ${{ github.workspace }}
106+
cp .ddev/custom_files/crowdsec/php/cache-actions.php cache-actions.php
106107
cp -r .ddev/custom_files/crowdsec/cfssl/* my-own-modules/${{ env.EXTENSION_PATH }}/tls
107108
cd my-own-modules/${{ env.EXTENSION_PATH }}
108109
docker cp "tls" ddev-${{ env.WP_VERSION_CODE }}-playwright://var/www/html/wp-content/plugins/crowdsec

docs/DEVELOPER.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ As we use a TLS ready CrowdSec container, you have first to copy some certificat
150150
cd wp-sources
151151
cp -r .ddev/custom_files/crowdsec/cfssl/* wp-content/plugins/crowdsec/tls
152152
```
153+
And we use also a custom php script to make some cache test. Thus, you should copy this php script too in the root
154+
folder:
155+
156+
```bash
157+
cd wp-sources
158+
cp .ddev/custom_files/crowdsec/php/cache-actions.php cache-actions.php
159+
```
160+
153161

154162
Then, ensure that `run-tests.sh` and `test-init.sh` files are executable.
155163

inc/bounce-current-ip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function safelyBounceCurrentIp()
3030
'(line ' . $e->getLine() . ')', true
3131
));
3232
}
33-
$displayErrors = $crowdSecConfigs['crowdsec_display_errors'] ?? false;
33+
$displayErrors = (bool)($crowdSecConfigs['crowdsec_display_errors'] ?? false);
3434
if (true === $displayErrors) {
3535
throw new BouncerException($e->getMessage(), $e->getCode(), $e);
3636
}

inc/options-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
require_once __DIR__ . '/Constants.php';
33

4-
function getCrowdSecOptionsConfig()
4+
function getCrowdSecOptionsConfig(): array
55
{
66
return [
77
['name' => 'crowdsec_api_url', 'default' => '', 'autoInit' => true],

inc/standalone-bounce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
'(line ' . $e->getLine() . ')', true
2626
));
2727
}
28-
$displayErrors = $crowdSecConfigs['crowdsec_display_errors'] ?? false;
28+
$displayErrors = (bool)($crowdSecConfigs['crowdsec_display_errors'] ?? false);
2929
if (true === $displayErrors) {
3030
throw new BouncerException($e->getMessage(), $e->getCode(), $e);
3131
}

tests/e2e-ddev/__scripts__/run-tests.sh

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ case $TYPE in
6060
COMMAND="yarn --cwd ${YARN_PATH} cross-env"
6161
LAPI_URL_FROM_PLAYWRIGHT=https://${CROWDSEC_URL_FROM_HOST}
6262
CURRENT_IP=$(ddev find-ip host)
63-
TIMEOUT=31000
63+
TIMEOUT=60000
6464
HEADLESS=false
6565
SLOWMO=150
66-
PLUGIN_PATH="../../../../wp-content/plugins/crowdsec"
66+
PLUGIN_PATH="../../"
6767
;;
6868

6969
"docker")
@@ -72,7 +72,7 @@ case $TYPE in
7272
COMMAND="ddev exec -s playwright yarn --cwd ${YARN_PATH} cross-env"
7373
LAPI_URL_FROM_PLAYWRIGHT=https://crowdsec:8080
7474
CURRENT_IP=$(ddev find-ip playwright)
75-
TIMEOUT=31000
75+
TIMEOUT=60000
7676
HEADLESS=true
7777
SLOWMO=0
7878
PLUGIN_PATH="/var/www/html/wp-content/plugins/crowdsec"

tests/e2e-ddev/__scripts__/test-init.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)