Skip to content

Commit ee80e84

Browse files
jeremy-davis-sonarsourcehenryju
authored andcommitted
SQSCANGHA-112 Fix redirect test to deal with TLS
1 parent cbabf05 commit ee80e84

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

.github/qa-nginx-redirecting/compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ services:
55
- 8080:8080
66
volumes:
77
- $GITHUB_WORKSPACE/.github/qa-nginx-redirecting/nginx.conf:/etc/nginx/nginx.conf:ro
8+
- $GITHUB_WORKSPACE/.github/qa-nginx-redirecting/nginx.crt:/etc/nginx/nginx.crt:ro
9+
- $GITHUB_WORKSPACE/.github/qa-nginx-redirecting/nginx.key:/etc/nginx/nginx.key:ro
810
healthcheck:
9-
test: ["CMD", "curl", "--fail", "localhost:8080/health"]
11+
test: ["CMD", "curl", "--fail", "--insecure", "https://localhost:8080/health"]
1012
interval: 10s
1113
timeout: 5s
1214
retries: 20
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Generate self-signed SSL certificate for localhost with 1-day expiry
4+
openssl req -x509 -nodes -days 1 -newkey rsa:2048 \
5+
-keyout nginx.key \
6+
-out nginx.crt \
7+
-subj "/C=US/ST=CA/L=Local/O=Test/CN=localhost" \
8+
-addext "subjectAltName=DNS:localhost,IP:127.0.0.1"
9+
10+
echo "SSL certificates generated with 1-day expiry: nginx.crt and nginx.key"

.github/qa-nginx-redirecting/nginx.conf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ http {
1818
include /etc/nginx/conf.d/*.conf;
1919

2020
server {
21-
listen 8080;
21+
listen 8080 ssl;
22+
ssl_certificate /etc/nginx/nginx.crt;
23+
ssl_certificate_key /etc/nginx/nginx.key;
2224

2325
location /health {
2426
add_header 'Content-Type' 'text/plain';

.github/workflows/qa-main.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ jobs:
207207
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output.properties"}'
208208
- name: Assert
209209
run: |
210-
# The new JavaScript implementation uses @actions/tool-cache which caches tools differently
211-
# Instead of checking for the zip file, verify the tool was installed by checking it's in PATH
210+
# Verify the tool was installed by checking it's in PATH
212211
if ! command -v sonar-scanner &> /dev/null; then
213212
echo "Error: sonar-scanner not found in PATH"
214213
exit 1
@@ -482,6 +481,9 @@ jobs:
482481
then
483482
exit 1
484483
fi
484+
- name: Generate SSL certificates for nginx
485+
run: ./generate-ssl.sh
486+
working-directory: .github/qa-nginx-redirecting
485487
- name: Start nginx via Docker Compose
486488
run: docker compose up -d --wait
487489
working-directory: .github/qa-nginx-redirecting
@@ -490,14 +492,19 @@ jobs:
490492
uses: ./
491493
with:
492494
scannerVersion: 6.2.1.4610
493-
scannerBinariesUrl: http://localhost:8080/clientRedirectToSonarBinaries
495+
scannerBinariesUrl: https://localhost:8080/clientRedirectToSonarBinaries
494496
env:
495497
NO_CACHE: true
498+
NODE_TLS_REJECT_UNAUTHORIZED: 0
496499
SONAR_HOST_URL: http://not_actually_used
497500
SONAR_SCANNER_JSON_PARAMS: '{"sonar.scanner.internal.dumpToFile": "./output1.properties"}'
498501
- name: Assert Sonar Scanner CLI was downloaded
499502
run: |
500-
./test/assertFileExists "$RUNNER_TEMP/sonarscanner/sonar-scanner-cli-6.2.1.4610-linux-x64.zip"
503+
# Verify the tool was installed by checking it's in PATH
504+
if ! command -v sonar-scanner &> /dev/null; then
505+
echo "Error: sonar-scanner not found in PATH"
506+
exit 1
507+
fi
501508
useSslCertificate:
502509
name: >
503510
'SONAR_ROOT_CERT' is converted to truststore

0 commit comments

Comments
 (0)