Skip to content

Commit a32bae6

Browse files
laoneobrianteeman
andauthored
[5.3] Run system tests on https (#44850)
* Test on ssl * cs * relative * no ca * up * debug * path * add docker compose file to run the drone environment locally * Enable PHP 8.4 in system tests * Remove references * test without certs in config * restore * sign * docs * Revert to 8.3 * docs * certs * Temp fix with conf file * no certs * use from image * readd * Fetch newsfeeds on http because of self signed certificates * more doc * Rename to entrypoint * more docs * Revert "more docs" This reverts commit bb07132. * revert as images are now up to date * Update tests/System/README.md Co-authored-by: Brian Teeman <[email protected]> --------- Co-authored-by: Brian Teeman <[email protected]>
1 parent d19e161 commit a32bae6

File tree

9 files changed

+78
-34
lines changed

9 files changed

+78
-34
lines changed

.drone.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ steps:
128128
- name: prepare_system_tests
129129
depends_on:
130130
- npm
131-
image: joomlaprojects/docker-images:cypress8.1
131+
image: joomlaprojects/docker-images:cypress8.4
132132
volumes:
133133
- name: cypress-cache
134134
path: /root/.cache/Cypress
@@ -149,19 +149,19 @@ steps:
149149
environment:
150150
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
151151
commands:
152-
- bash tests/System/drone-system-run.sh "$(pwd)" cmysql mysqli mysql
152+
- bash tests/System/entrypoint.sh "$(pwd)" cmysql mysqli mysql
153153

154154
- name: phpmax-system-mysql
155155
depends_on:
156156
- phpmin-system-mysql
157-
image: joomlaprojects/docker-images:cypress8.2
157+
image: joomlaprojects/docker-images:cypress8.3
158158
volumes:
159159
- name: cypress-cache
160160
path: /root/.cache/Cypress
161161
environment:
162162
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
163163
commands:
164-
- bash tests/System/drone-system-run.sh "$(pwd)" cmysqlmax mysqli mysql
164+
- bash tests/System/entrypoint.sh "$(pwd)" cmysqlmax mysqli mysql
165165
when:
166166
event:
167167
exclude:
@@ -170,7 +170,7 @@ steps:
170170
- name: phpnext-system-mysql
171171
depends_on:
172172
- phpmax-system-mysql
173-
image: joomlaprojects/docker-images:cypress8.3
173+
image: joomlaprojects/docker-images:cypress8.4
174174
volumes:
175175
- name: cypress-cache
176176
path: /root/.cache/Cypress
@@ -180,7 +180,7 @@ steps:
180180
commands:
181181
- echo "This test is disabled because php next is not stable yet"
182182
- exit 1
183-
- bash tests/System/drone-system-run.sh "$(pwd)" cmysqlnext mysqli mysql
183+
- bash tests/System/entrypoint.sh "$(pwd)" cmysqlnext mysqli mysql
184184
when:
185185
event:
186186
exclude:
@@ -196,7 +196,7 @@ steps:
196196
environment:
197197
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
198198
commands:
199-
- bash tests/System/drone-system-run.sh "$(pwd)" cpostgres pgsql postgres
199+
- bash tests/System/entrypoint.sh "$(pwd)" cpostgres pgsql postgres
200200
when:
201201
event:
202202
exclude:
@@ -205,19 +205,19 @@ steps:
205205
- name: phpmax-system-postgres
206206
depends_on:
207207
- phpmin-system-postgres
208-
image: joomlaprojects/docker-images:cypress8.2
208+
image: joomlaprojects/docker-images:cypress8.3
209209
volumes:
210210
- name: cypress-cache
211211
path: /root/.cache/Cypress
212212
environment:
213213
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
214214
commands:
215-
- bash tests/System/drone-system-run.sh "$(pwd)" cpostgresmax pgsql postgres
215+
- bash tests/System/entrypoint.sh "$(pwd)" cpostgresmax pgsql postgres
216216

217217
- name: phpnext-system-postgres
218218
depends_on:
219219
- phpmax-system-postgres
220-
image: joomlaprojects/docker-images:cypress8.3
220+
image: joomlaprojects/docker-images:cypress8.4
221221
volumes:
222222
- name: cypress-cache
223223
path: /root/.cache/Cypress
@@ -227,7 +227,7 @@ steps:
227227
commands:
228228
- echo "This test is disabled because php next is not stable yet"
229229
- exit 1
230-
- bash tests/System/drone-system-run.sh "$(pwd)" cpostgresnext pgsql postgres
230+
- bash tests/System/entrypoint.sh "$(pwd)" cpostgresnext pgsql postgres
231231
when:
232232
event:
233233
exclude:
@@ -433,6 +433,6 @@ trigger:
433433

434434
---
435435
kind: signature
436-
hmac: 1d94d558654c2898eea3360184eede03be6b48154c110579fe0254ea0780d91a
436+
hmac: caca91b7aa40832a891260e03c42f8b7fc31b6971d201bf69291a87b158d5ce7
437437

438438
...

cypress.config.dist.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default defineConfig({
1111
setupNodeEvents(on, config) {
1212
setupPlugins(on, config);
1313
},
14-
baseUrl: 'http://localhost/',
14+
baseUrl: 'https://localhost/',
1515
specPattern: [
1616
'tests/System/integration/install/**/*.cy.{js,jsx,ts,tsx}',
1717
'tests/System/integration/administrator/**/*.cy.{js,jsx,ts,tsx}',

tests/System/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,10 @@ If you encounter the following error while running the System Tests on slow mach
326326
...
327327
}
328328
```
329+
330+
## Docker
331+
The system tests can also be executed in headless mode with docker compose. The following command does a cleanup and then starts the system tests from the current docker-compose.yml file:
332+
333+
`docker compose down && docker compose up system-tests`
334+
335+
The database is used with a temporary filesystem, so the data always gets deleted when the tests are started, therefor the installation test must be performed as the first step. The webserver is accessible on the host from http://localhost:8080 or https://localhost:8443 and PHPMyAdmin on http://localhost:8081.

tests/System/cypress-system-run.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/System/docker-compose.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
services:
2+
system-tests:
3+
image: joomlaprojects/docker-images:cypress8.4
4+
environment:
5+
CYPRESS_VERIFY_TIMEOUT: 100000
6+
JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK: 1
7+
entrypoint: bash /app/tests/System/entrypoint.sh /app j mysqli mysql
8+
depends_on:
9+
- phpmyadmin
10+
ports:
11+
- 8080:80
12+
- 8443:443
13+
volumes:
14+
- ../..:/app
15+
- /tmp/cypress-cache:/root/.cache/Cypress
16+
working_dir: /app
17+
18+
mysql:
19+
image: mysql:8.3
20+
environment:
21+
MYSQL_USER: joomla_ut
22+
MYSQL_PASSWORD: joomla_ut
23+
MYSQL_ROOT_PASSWORD: joomla_ut
24+
MYSQL_DATABASE: test_joomla
25+
command: --default-authentication-plugin=mysql_native_password
26+
tmpfs:
27+
- /var/lib/mysql
28+
29+
phpmyadmin:
30+
image: phpmyadmin/phpmyadmin
31+
environment:
32+
PMA_HOST: mysql
33+
PMA_USER: joomla_ut
34+
PMA_PASSWORD: joomla_ut
35+
depends_on:
36+
- mysql
37+
ports:
38+
- 8081:80

tests/System/drone-system-run.sh renamed to tests/System/entrypoint.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/usr/bin/env bash
2+
3+
# This script is intended to be used as a docker entrypoint file within a joomlaprojects/docker-images:cypressX image
4+
# Check out the docker-compose.yml file how to prepare docker to run it or execute `docker compose up system-tests`.
5+
26
set -e
37
JOOMLA_BASE=$1
48
TEST_GROUP=$2
@@ -24,4 +28,15 @@ apache2ctl -D FOREGROUND &
2428
echo "[RUNNER] Run cypress tests"
2529
chmod +rwx /root
2630

27-
npx cypress run --browser=firefox --e2e --env cmsPath=/tests/www/$TEST_GROUP,db_type=$DB_ENGINE,db_host=$DB_HOST,db_password=joomla_ut,db_prefix="${TEST_GROUP}_" --config baseUrl=http://localhost/$TEST_GROUP,screenshotsFolder=$JOOMLA_BASE/tests/System/output/screenshots
31+
# Copy the cypress config if it doesn't exist
32+
if [ ! -f cypress.config.mjs ]; then
33+
cp cypress.config.dist.mjs cypress.config.mjs
34+
fi
35+
36+
# Do an install if the cache folder is empty
37+
if [ -z "$( ls -A '/root/.cache/Cypress' )" ]; then
38+
npx cypress install
39+
npx cypress verify
40+
fi
41+
42+
npx cypress run --browser=firefox --e2e --env cmsPath=/tests/www/$TEST_GROUP,db_type=$DB_ENGINE,db_host=$DB_HOST,db_password=joomla_ut,db_prefix="${TEST_GROUP}_" --config baseUrl=https://localhost/$TEST_GROUP,screenshotsFolder=$JOOMLA_BASE/tests/System/output/screenshots

tests/System/integration/install/Installation.cy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ describe('Install Joomla', () => {
3333
cy.config_setParameter('mailer', 'smtp');
3434
cy.config_setParameter('smtphost', Cypress.env('smtp_host'));
3535
cy.config_setParameter('smtpport', Cypress.env('smtp_port'));
36+
cy.config_setParameter('force_ssl', '2');
3637
});
3738
});

tests/System/integration/site/components/com_newsfeed/NewsFeed.cy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
describe('Test in frontend that the newsfeeds details view', () => {
22
['joomla.org'].forEach((file) => {
33
it(`can display a feed in a menu item from ${file}`, () => {
4-
cy.db_createNewsFeed({ name: 'automated test feed 1', link: `${Cypress.config('baseUrl')}/tests/System/data/com_newsfeeds/${file}.xml` })
4+
cy.db_createNewsFeed({ name: 'automated test feed 1', link: `${Cypress.config('baseUrl').replace('https://', 'http://')}/tests/System/data/com_newsfeeds/${file}.xml` })
55
.then((feed) => cy.db_createMenuItem({ title: 'automated test feeds', link: `index.php?option=com_newsfeeds&view=newsfeed&id=${feed.id}` }))
66
.then(() => {
77
cy.visit('/');
@@ -14,7 +14,7 @@ describe('Test in frontend that the newsfeeds details view', () => {
1414
});
1515

1616
it(`can display a feed without a menu item from ${file}`, () => {
17-
cy.db_createNewsFeed({ name: 'automated test feed 1', link: `${Cypress.config('baseUrl')}/tests/System/data/com_newsfeeds/${file}.xml` })
17+
cy.db_createNewsFeed({ name: 'automated test feed 1', link: `${Cypress.config('baseUrl').replace('https://', 'http://')}/tests/System/data/com_newsfeeds/${file}.xml` })
1818
.then((feed) => {
1919
cy.visit(`/index.php?option=com_newsfeeds&view=newsfeed&id=${feed.id}`);
2020

tests/System/integration/site/modules/mod_feed/Default.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe('Test in frontend that the feed module', () => {
44
cy.db_createModule({
55
title: 'automated test feed',
66
module: 'mod_feed',
7-
params: `{"rssurl": "${Cypress.config('baseUrl')}/tests/System/data/com_newsfeeds/${file}.xml" }`,
7+
params: `{"rssurl": "${Cypress.config('baseUrl').replace('https://', 'http://')}/tests/System/data/com_newsfeeds/${file}.xml" }`,
88
})
99
.then(() => {
1010
cy.visit('/');

0 commit comments

Comments
 (0)