|
57 | 57 | cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml |
58 | 58 | mkdir ${{ github.workspace }}/cfssl |
59 | 59 | cp -r .ddev/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl |
60 | | - ls -l ${{ github.workspace }}/cfssl |
61 | 60 | ddev start |
62 | 61 |
|
63 | 62 | - name: Set BOUNCER_KEY and PROXY_IP env |
|
84 | 83 | run: | |
85 | 84 | ddev composer update --working-dir ./${{env.EXTENSION_PATH}} |
86 | 85 |
|
87 | | - - name: Prepare PHP UNIT tests |
| 86 | + - name: Run "Unit Tests" |
| 87 | + run: | |
| 88 | + ddev exec /usr/bin/php ./${{env.EXTENSION_PATH}}/vendor/bin/phpunit --testdox --colors --exclude-group ignore ./${{env.EXTENSION_PATH}}/tests/Unit |
| 89 | +
|
| 90 | + - name: Prepare PHP Integration and end-to-end tests |
88 | 91 | run: | |
89 | 92 | ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{env.EXTENSION_PATH}}/tests |
90 | 93 | ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{env.EXTENSION_PATH}}/tests |
@@ -120,8 +123,6 @@ jobs: |
120 | 123 | cd ${{ github.workspace }}/.ddev |
121 | 124 | ddev nginx-config custom_files/crowdsec-prepend-nginx-site.conf |
122 | 125 | cd ${{ github.workspace }} |
123 | | - cp ${{env.EXTENSION_PATH}}/tests/end-to-end/php-scripts/cache-actions.php.dist ${{env.EXTENSION_PATH}}/scripts/public/cache-actions.php |
124 | | - cp ${{env.EXTENSION_PATH}}/tests/end-to-end/php-scripts/geolocation-test.php.dist ${{env.EXTENSION_PATH}}/scripts/public/geolocation-test.php |
125 | 126 | cp ${{env.EXTENSION_PATH}}/tests/end-to-end/settings/base.php.dist crowdsec-lib-settings.php |
126 | 127 | sed -i -e 's/REPLACE_API_KEY/${{ env.BOUNCER_KEY }}/g' crowdsec-lib-settings.php |
127 | 128 | sed -i -e 's/REPLACE_PROXY_IP/${{ env.PROXY_IP }}/g' crowdsec-lib-settings.php |
@@ -163,10 +164,77 @@ jobs: |
163 | 164 | exit 1 |
164 | 165 | fi |
165 | 166 |
|
| 167 | + - name: Run "Display error with bad settings" test |
| 168 | + run: | |
| 169 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}} |
| 170 | + sed -i 's/\x27cache_system\x27 => Constants::CACHE_SYSTEM_PHPFS/\x27cache_system\x27 => 1/g' scripts/auto-prepend/settings.php |
| 171 | + cat scripts/auto-prepend/settings.php |
| 172 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/ |
| 173 | + ./__scripts__/run-tests.sh ci "./__tests__/6-display-error-on.js" |
| 174 | + PENDING_TESTS=$(grep -oP '"numPendingTests":\K(.*),"numRuntimeErrorTestSuites"' .test-results.json | sed 's/,"numRuntimeErrorTestSuites"//g') |
| 175 | + if [[ $PENDING_TESTS == "0" ]] |
| 176 | + then |
| 177 | + echo "No pending tests: OK" |
| 178 | + else |
| 179 | + echo "There are pending tests: $PENDING_TESTS (KO)" |
| 180 | + exit 1 |
| 181 | + fi |
| 182 | +
|
| 183 | + - name: Run "No display error with bad settings" test |
| 184 | + run: | |
| 185 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}} |
| 186 | + sed -i 's/\x27cache_system\x27 => Constants::CACHE_SYSTEM_PHPFS/\x27cache_system\x27 => 1/g' scripts/auto-prepend/settings.php |
| 187 | + sed -i 's/\x27display_errors\x27 => true/\x27display_errors\x27 => false/g' scripts/auto-prepend/settings.php |
| 188 | + cat scripts/auto-prepend/settings.php |
| 189 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/ |
| 190 | + ./__scripts__/run-tests.sh ci "./__tests__/5-display-error-off.js" |
| 191 | + PENDING_TESTS=$(grep -oP '"numPendingTests":\K(.*),"numRuntimeErrorTestSuites"' .test-results.json | sed 's/,"numRuntimeErrorTestSuites"//g') |
| 192 | + if [[ $PENDING_TESTS == "0" ]] |
| 193 | + then |
| 194 | + echo "No pending tests: OK" |
| 195 | + else |
| 196 | + echo "There are pending tests: $PENDING_TESTS (KO)" |
| 197 | + exit 1 |
| 198 | + fi |
| 199 | +
|
| 200 | + - name: Run "No display error with error while bouncing" test |
| 201 | + run: | |
| 202 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}} |
| 203 | + sed -i 's/\x27cache_system\x27 => 1/\x27cache_system\x27 => Constants::CACHE_SYSTEM_PHPFS/g' scripts/auto-prepend/settings.php |
| 204 | + sed -i 's/\x27forced_test_ip\x27 => \x27\x27/\x27forced_test_ip\x27 => \x27bad-ip\x27/g' scripts/auto-prepend/settings.php |
| 205 | + cat scripts/auto-prepend/settings.php |
| 206 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/ |
| 207 | + ./__scripts__/run-tests.sh ci "./__tests__/5-display-error-off.js" |
| 208 | + PENDING_TESTS=$(grep -oP '"numPendingTests":\K(.*),"numRuntimeErrorTestSuites"' .test-results.json | sed 's/,"numRuntimeErrorTestSuites"//g') |
| 209 | + if [[ $PENDING_TESTS == "0" ]] |
| 210 | + then |
| 211 | + echo "No pending tests: OK" |
| 212 | + else |
| 213 | + echo "There are pending tests: $PENDING_TESTS (KO)" |
| 214 | + exit 1 |
| 215 | + fi |
| 216 | +
|
| 217 | + - name: Run "Display error with error while bouncing" test |
| 218 | + run: | |
| 219 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}} |
| 220 | + sed -i 's/\x27display_errors\x27 => false/\x27display_errors\x27 => true/g' scripts/auto-prepend/settings.php |
| 221 | + cat scripts/auto-prepend/settings.php |
| 222 | + cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/ |
| 223 | + ./__scripts__/run-tests.sh ci "./__tests__/6-display-error-on.js" |
| 224 | + PENDING_TESTS=$(grep -oP '"numPendingTests":\K(.*),"numRuntimeErrorTestSuites"' .test-results.json | sed 's/,"numRuntimeErrorTestSuites"//g') |
| 225 | + if [[ $PENDING_TESTS == "0" ]] |
| 226 | + then |
| 227 | + echo "No pending tests: OK" |
| 228 | + else |
| 229 | + echo "There are pending tests: $PENDING_TESTS (KO)" |
| 230 | + exit 1 |
| 231 | + fi |
| 232 | +
|
166 | 233 | - name: Run "live mode with cURL and without geolocation" test |
167 | 234 | run: | |
168 | 235 | cd ${{ github.workspace }}/${{env.EXTENSION_PATH}} |
169 | 236 | sed -i 's/\x27use_curl\x27 => false/\x27use_curl\x27 => true/g' scripts/auto-prepend/settings.php |
| 237 | + sed -i 's/\x27forced_test_ip\x27 => \x27bad-ip\x27/\x27forced_test_ip\x27 => \x27\x27/g' scripts/auto-prepend/settings.php |
170 | 238 | cat scripts/auto-prepend/settings.php |
171 | 239 | cd ${{ github.workspace }}/${{env.EXTENSION_PATH}}/tests/end-to-end/ |
172 | 240 | ./__scripts__/run-tests.sh ci "./__tests__/1-live-mode.js" |
@@ -201,7 +269,6 @@ jobs: |
201 | 269 | run: | |
202 | 270 | cd ${{ github.workspace }}/${{env.EXTENSION_PATH}} |
203 | 271 | sed -i 's/\x27use_curl\x27 => false/\x27use_curl\x27 => true/g' scripts/auto-prepend/settings.php |
204 | | - sed -i 's/\x27use_curl\x27 => true/\x27use_curl\x27 => false/g' scripts/auto-prepend/settings.php |
205 | 272 | sed -i 's/\x27enabled\x27 => false/\x27enabled\x27 => true/g' scripts/auto-prepend/settings.php |
206 | 273 | sed -i 's/\x27forced_test_forwarded_ip\x27 => \x27\x27/\x27forced_test_forwarded_ip\x27 => \x27${{env.JP_TEST_IP}}\x27/g' scripts/auto-prepend/settings.php |
207 | 274 | cat scripts/auto-prepend/settings.php |
@@ -332,7 +399,6 @@ jobs: |
332 | 399 | echo "There are pending tests: $PENDING_TESTS (KO)" |
333 | 400 | exit 1 |
334 | 401 | fi |
335 | | - |
336 | 402 |
|
337 | 403 | - name: Run "stream mode with TLS auth and cURL and Memcached" test |
338 | 404 | run: | |
|
0 commit comments