Skip to content

Commit b3041e7

Browse files
committed
HTTPS FIX
1 parent 5c9df41 commit b3041e7

File tree

8 files changed

+58
-34
lines changed

8 files changed

+58
-34
lines changed
File renamed without changes.

.env.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ if [ "${NODE_API_PORT}" = "" ]; then
66
exit 1;
77
fi
88

9+
if [ "${NODE_API_PORT_HTTPS}" = "" ]; then
10+
11+
echo "${0} error: NODE_API_PORT_HTTPS is not defined"
12+
13+
exit 1;
14+
fi
15+
916
if [ "${LOCAL_HOSTS}" = "" ]; then
1017

1118
echo "${0} error: LOCAL_HOSTS is not defined"

.github/healtcheck.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
*
3030
* TIMEOUT="500" node .github/healtcheck.js front
3131
*
32+
* to change port:
33+
* NODE_API_PORT=8888 node .github/healtcheck.js
34+
*
3235
*/
3336
// const path = require("path");
3437
import path from "path";
@@ -72,16 +75,6 @@ if (/^\d+$/.test(process.env.TIMEOUT)) {
7275
path: env,
7376
});
7477

75-
const protMatch = /^https?$/;
76-
77-
if (!protMatch.test(process.env.NODE_API_PROTOCOL)) {
78-
throw th(`process.env.NODE_API_PROTOCOL >${process.env.NODE_API_PROTOCOL}< doesn't match pattern ${protMatch}`);
79-
}
80-
81-
if (typeof process.env.NODE_API_PORT_HTTPS !== "string") {
82-
throw th(`NODE_API_PORT_HTTPS is undefined`);
83-
}
84-
8578
setTimeout(() => {
8679
logger(
8780
`healthcheck timeout error after ${healthcheckTimeoutMilliseconds} miliseconds (${parseFloat(
@@ -92,7 +85,7 @@ if (/^\d+$/.test(process.env.TIMEOUT)) {
9285
process.exit(1);
9386
}, healthcheckTimeoutMilliseconds);
9487

95-
const server_front_endpoint = `${process.env.NODE_API_PROTOCOL}://0.0.0.0:${process.env.NODE_API_PORT_HTTPS}/healthcheck`;
88+
const server_front_endpoint = `${process.env.NODE_API_PROTOCOL}://0.0.0.0:${process.env.NODE_API_PORT}/healthcheck`;
9689

9790
const promise = Promise.all([
9891
new Promise((resolve) => {

.github/workflows/pipeline.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109

110110
- name: Build
111111
run: |
112-
cp .env.template .env
112+
cp .env.pipeline .env
113113
/bin/bash build.sh
114114
115115
- name: run local server (NODE_ENV=production)
@@ -118,12 +118,13 @@ jobs:
118118
119119
- name: servers healthchecks
120120
run: |
121-
TIMEOUT="2000" node .github/healtcheck.js
121+
source .env
122+
source .env.sh
123+
NODE_API_PORT="${NODE_API_PORT_HTTPS}" TIMEOUT="2000" node .github/healtcheck.js
122124
# - name: test cli (using routes endpoint)
123125
# run: |
124126
# /bin/bash console.sh routes
125127
- name: UNIT TESTS
126-
# if: "!contains(github.event.head_commit.message, '[q]')"
127128
if: |
128129
!(github.event.head_commit.message == 'q' ||
129130
startsWith(github.event.head_commit.message, 'q ') ||
@@ -136,24 +137,25 @@ jobs:
136137
# TYPE=int /bin/bash test.sh
137138

138139
- name: JASMINE TESTS
139-
# if: "!contains(github.event.head_commit.message, '[q]')"
140140
if: |
141141
!(github.event.head_commit.message == 'q' ||
142142
startsWith(github.event.head_commit.message, 'q ') ||
143143
endsWith(github.event.head_commit.message, ' q') ||
144144
contains(github.event.head_commit.message, ' q '))
145145
run: |
146+
# this script is launching koa server, using it and killing it, so it can be ran on any arbitrary port
146147
NODE_API_PORT=4273 /bin/bash jasmine/test.sh --env .env -- --target docker
147148
148149
- name: E2E TESTS
149-
# if: "!contains(github.event.head_commit.message, '[q]')"
150150
if: |
151151
!(github.event.head_commit.message == 'q' ||
152152
startsWith(github.event.head_commit.message, 'q ') ||
153153
endsWith(github.event.head_commit.message, ' q') ||
154154
contains(github.event.head_commit.message, ' q '))
155155
run: |
156-
/bin/bash playwright.sh --target docker
156+
source .env
157+
source .env.sh
158+
NODE_API_PORT="${NODE_API_PORT_HTTPS}" /bin/bash playwright.sh --target docker
157159
158160
- name: ps aux
159161
run: |

jasmine/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Lifecycle phases of this script:
77
# Generally what this script is doing is perparing (bundling) all desired test files to be delivered to the browser context.
88
# Then it launches temporary http server for playwright testing.
9+
# (NOTE: for that you can use any arbitrary port, recommended is to override NODE_API_PORT env var to some free port)
910
# All tests are executed (using jasmine-core lib) in the browser after load and result of all tests are fetched.
1011
# Testing in playwright is done with just one test with one expect().toEqual()
1112
# comparing desired state of fetched states with desired state.
@@ -367,6 +368,9 @@ EEE
367368
# echo 'wait'
368369
# read -n 1
369370

371+
372+
# this will launch on http and https ports
373+
# so it will use NODE_API_PORT and NODE_API_PORT_HTTPS env vars
370374
NODE_OPTIONS="" node "${_DIR}/server_koa.js" --web "${ROOT}" --asset_list "${ASSETLIST}" --env "${ENVFILE}" 1>> "${LOGFILE}" 2>> "${LOGFILE}" & disown
371375

372376
set +x

playwright.config.js

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@ if (typeof process.env.ENVFILE === "string" && process.env.ENVFILE.trim()) {
5151
dotenv.config();
5252
}
5353

54-
55-
// WARNING: this is tweak introduced with introduction of https for local development vvv
56-
// WARNING: this is tweak introduced with introduction of https for local development vvv
57-
// WARNING: this is tweak introduced with introduction of https for local development vvv
58-
process.env.NODE_API_PORT = process.env.NODE_API_PORT_HTTPS;
59-
// WARNING: this is tweak introduced with introduction of https for local development ^^^
60-
// WARNING: this is tweak introduced with introduction of https for local development ^^^
61-
// WARNING: this is tweak introduced with introduction of https for local development ^^^
62-
6354
mockEnv(process.env);
6455

6556
const protocolRegex = /^https?:\/\//;
@@ -169,18 +160,12 @@ const config = {
169160
name: "chromium",
170161
use: {
171162
...devices["Desktop Chrome"],
172-
launchOptions: {
173-
args: ["--ignore-certificate-errors"], // https://stackoverflow.com/a/76610601
174-
},
175163
},
176164
},
177165
{
178166
name: "firefox",
179167
use: {
180168
...devices["Desktop Firefox"],
181-
launchOptions: {
182-
args: ["--ignore-certificate-errors"], // https://stackoverflow.com/a/76610601
183-
},
184169
},
185170
},
186171
// { // too much problems with running tests - commenting out
@@ -229,6 +214,37 @@ const config = {
229214
// },
230215
};
231216

217+
if (protocolRegex.test(process.env.BASE_URL)) {
218+
log(`BASE_URL https protocol detected: ${process.env.BASE_URL} - tweaking configuration`);
219+
220+
// Add ignoreHTTPSErrors to global use configuration
221+
config.use.ignoreHTTPSErrors = true;
222+
223+
// Configure enhanced SSL error handling for Chromium
224+
const chromiumProject = config.projects.find((p) => p.name === "chromium");
225+
if (chromiumProject) {
226+
chromiumProject.use.launchOptions = {
227+
args: [
228+
"--ignore-certificate-errors",
229+
"--ignore-ssl-errors",
230+
"--ignore-certificate-errors-spki-list",
231+
"--disable-web-security",
232+
"--allow-running-insecure-content",
233+
"--disable-features=VizDisplayCompositor",
234+
], // Enhanced SSL error handling for self-signed certificates
235+
};
236+
log(`Chromium SSL configuration tweaks applied`);
237+
}
238+
239+
// Configure SSL error handling for Firefox
240+
const firefoxProject = config.projects.find((p) => p.name === "firefox");
241+
if (firefoxProject) {
242+
firefoxProject.use.launchOptions = {
243+
args: ["--ignore-certificate-errors"], // Firefox uses different flags
244+
};
245+
log(`Firefox SSL configuration tweaks applied`);
246+
}
247+
}
232248
/**
233249
* Above just standard default config, and below we will modify it the way we need
234250
*/

testall.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ cat <<EEE
9090
9191
EEE
9292

93-
TIMEOUT="2000" node .github/healtcheck.js
93+
NODE_API_PORT="${NODE_API_PORT_HTTPS}" TIMEOUT="2000" node .github/healtcheck.js
9494

9595
cat <<EEE
9696
@@ -114,4 +114,5 @@ cat <<EEE
114114
115115
EEE
116116

117-
/bin/bash playwright.sh
117+
# because we have launched koa server via https let's switch playwright to use https as well
118+
NODE_API_PORT="${NODE_API_PORT_HTTPS}" /bin/bash playwright.sh

xx.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ cat <<EEE
114114
/bin/bash jasmine/test.sh --env .env
115115
116116
NODE_API_PORT=4273 /bin/bash jasmine/test.sh --env .env -- --target docker
117+
NODE_API_PORT=4273 /bin/bash jasmine/test.sh --env .env -- -- --debug
117118
118119
NODE_API_PORT=4273 /bin/bash jasmine/test.sh ${S}
119120
--env .env ${S}

0 commit comments

Comments
 (0)