From 7ec7e765d02f1e77e9e0754ea4dd4c41920bb518 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Thu, 30 May 2024 12:55:55 +0200 Subject: [PATCH] test: use modern Squid Proxy with Authentication container image Signed-off-by: Marc Nuri --- .../maven.settings.https-auth-proxy/setup.groovy | 14 +++++++++++++- .../maven.settings.https-auth-proxy/verify.groovy | 3 ++- .../setup.groovy | 14 +++++++++++++- .../verify.groovy | 3 ++- src/it/system.properties.https-proxy/verify.groovy | 1 + 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/it/maven.settings.https-auth-proxy/setup.groovy b/src/it/maven.settings.https-auth-proxy/setup.groovy index 57f1c34..7f4661d 100644 --- a/src/it/maven.settings.https-auth-proxy/setup.groovy +++ b/src/it/maven.settings.https-auth-proxy/setup.groovy @@ -1,2 +1,14 @@ -def dockerRun = 'docker run --rm -d --name test-auth-proxy -e SQUID_USERNAME=foo -e SQUID_PASSWORD=bar -p 0.0.0.0:3128:3128 robhaswell/squid-authenticated@sha256:6a99946c96d063981b329c22efc2b9ad1ac4e90d16ddcbb9d0b2d6773a7bea2b'.execute() +def dockerRun = 'docker run --rm -d --name test-auth-proxy -e SQUID_USERNAME=foo -e SQUID_PASSWORD=bar -p 0.0.0.0:3128:3128 marcnuri/squid-simple-auth:latest'.execute() dockerRun.waitForOrKill(30_000) +def count = 10 +def ready = false +while(count-- > 0 && !ready) { + def logOut = new StringBuilder(), logErr = new StringBuilder() + def dockerLogs = 'docker logs test-auth-proxy'.execute() + dockerLogs.consumeProcessOutput(logOut, logErr) + dockerLogs.waitForOrKill(10_000) + if (logOut.contains('Accepting HTTP Socket connections')) { + ready = true + } + Thread.sleep(1000) +} diff --git a/src/it/maven.settings.https-auth-proxy/verify.groovy b/src/it/maven.settings.https-auth-proxy/verify.groovy index 651057e..bb821d0 100644 --- a/src/it/maven.settings.https-auth-proxy/verify.groovy +++ b/src/it/maven.settings.https-auth-proxy/verify.groovy @@ -1,9 +1,10 @@ def logOut = new StringBuilder(), logErr = new StringBuilder() -def dockerLogs = 'docker exec test-auth-proxy cat /var/log/squid3/access.log'.execute() +def dockerLogs = 'docker exec test-auth-proxy cat /opt/squid/access.log'.execute() dockerLogs.consumeProcessOutput(logOut, logErr) dockerLogs.waitForOrKill(10_000) def dockerStop = 'docker stop test-auth-proxy'.execute() dockerStop.waitForOrKill(30_000) +new FileWriter(new File(basedir, 'access.log')).withWriter { it << logOut } assert logOut.toString().contains('CONNECT services.gradle.org:443') def buildLog = new File(basedir, 'build.log').text assert buildLog.contains('Gradle 8.2.1 download complete') diff --git a/src/it/system.properties.https-auth-proxy/setup.groovy b/src/it/system.properties.https-auth-proxy/setup.groovy index 57f1c34..7f4661d 100644 --- a/src/it/system.properties.https-auth-proxy/setup.groovy +++ b/src/it/system.properties.https-auth-proxy/setup.groovy @@ -1,2 +1,14 @@ -def dockerRun = 'docker run --rm -d --name test-auth-proxy -e SQUID_USERNAME=foo -e SQUID_PASSWORD=bar -p 0.0.0.0:3128:3128 robhaswell/squid-authenticated@sha256:6a99946c96d063981b329c22efc2b9ad1ac4e90d16ddcbb9d0b2d6773a7bea2b'.execute() +def dockerRun = 'docker run --rm -d --name test-auth-proxy -e SQUID_USERNAME=foo -e SQUID_PASSWORD=bar -p 0.0.0.0:3128:3128 marcnuri/squid-simple-auth:latest'.execute() dockerRun.waitForOrKill(30_000) +def count = 10 +def ready = false +while(count-- > 0 && !ready) { + def logOut = new StringBuilder(), logErr = new StringBuilder() + def dockerLogs = 'docker logs test-auth-proxy'.execute() + dockerLogs.consumeProcessOutput(logOut, logErr) + dockerLogs.waitForOrKill(10_000) + if (logOut.contains('Accepting HTTP Socket connections')) { + ready = true + } + Thread.sleep(1000) +} diff --git a/src/it/system.properties.https-auth-proxy/verify.groovy b/src/it/system.properties.https-auth-proxy/verify.groovy index 651057e..bb821d0 100644 --- a/src/it/system.properties.https-auth-proxy/verify.groovy +++ b/src/it/system.properties.https-auth-proxy/verify.groovy @@ -1,9 +1,10 @@ def logOut = new StringBuilder(), logErr = new StringBuilder() -def dockerLogs = 'docker exec test-auth-proxy cat /var/log/squid3/access.log'.execute() +def dockerLogs = 'docker exec test-auth-proxy cat /opt/squid/access.log'.execute() dockerLogs.consumeProcessOutput(logOut, logErr) dockerLogs.waitForOrKill(10_000) def dockerStop = 'docker stop test-auth-proxy'.execute() dockerStop.waitForOrKill(30_000) +new FileWriter(new File(basedir, 'access.log')).withWriter { it << logOut } assert logOut.toString().contains('CONNECT services.gradle.org:443') def buildLog = new File(basedir, 'build.log').text assert buildLog.contains('Gradle 8.2.1 download complete') diff --git a/src/it/system.properties.https-proxy/verify.groovy b/src/it/system.properties.https-proxy/verify.groovy index 4ffd146..f4e9b5b 100644 --- a/src/it/system.properties.https-proxy/verify.groovy +++ b/src/it/system.properties.https-proxy/verify.groovy @@ -4,6 +4,7 @@ dockerLogs.consumeProcessOutput(logOut, logErr) dockerLogs.waitForOrKill(10_000) def dockerStop = 'docker stop test-proxy'.execute() dockerStop.waitForOrKill(30_000) +new FileWriter(new File(basedir, 'access.log')).withWriter { it << logOut } assert logOut.toString().contains('CONNECT services.gradle.org:443') def buildLog = new File(basedir, 'build.log').text assert buildLog.contains('Gradle 8.2.1 download complete')