From c38a8051fb5ef2effb7f9e49dfcad58d79937631 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 30 Oct 2023 11:38:01 +0100 Subject: [PATCH] test: verifies downloads through https proxies Signed-off-by: Marc Nuri --- src/it/https-proxy/invoker.properties | 1 + src/it/https-proxy/pom.xml | 37 +++++++++++++++++++++++++++ src/it/https-proxy/setup.groovy | 14 ++++++++++ src/it/https-proxy/verify.groovy | 9 +++++++ 4 files changed, 61 insertions(+) create mode 100644 src/it/https-proxy/invoker.properties create mode 100644 src/it/https-proxy/pom.xml create mode 100644 src/it/https-proxy/setup.groovy create mode 100644 src/it/https-proxy/verify.groovy diff --git a/src/it/https-proxy/invoker.properties b/src/it/https-proxy/invoker.properties new file mode 100644 index 0000000..67f66d7 --- /dev/null +++ b/src/it/https-proxy/invoker.properties @@ -0,0 +1 @@ +invoker.goals.1=verify -U -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 diff --git a/src/it/https-proxy/pom.xml b/src/it/https-proxy/pom.xml new file mode 100644 index 0000000..9d2f393 --- /dev/null +++ b/src/it/https-proxy/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + com.marcnuri.plugins.it + no-action + 0.1-SNAPSHOT + Maven Integration Test :: Gradle API :: HTTPS Proxy + + + + org.codehaus.groovy + groovy-all + ${version.groovy} + pom + provided + + + org.gradle + gradle-all + ${version.gradle.8} + provided + + + + + + + com.marcnuri.plugins + gradle-api-maven-plugin + @project.version@ + true + + + + diff --git a/src/it/https-proxy/setup.groovy b/src/it/https-proxy/setup.groovy new file mode 100644 index 0000000..89da5e2 --- /dev/null +++ b/src/it/https-proxy/setup.groovy @@ -0,0 +1,14 @@ +def proc = 'docker run --rm -d --name test-proxy -p 0.0.0.0:3128:3128 ubuntu/squid:5.2-22.04_beta'.execute() +proc.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-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/https-proxy/verify.groovy b/src/it/https-proxy/verify.groovy new file mode 100644 index 0000000..4ffd146 --- /dev/null +++ b/src/it/https-proxy/verify.groovy @@ -0,0 +1,9 @@ +def logOut = new StringBuilder(), logErr = new StringBuilder() +def dockerLogs = 'docker logs test-proxy'.execute() +dockerLogs.consumeProcessOutput(logOut, logErr) +dockerLogs.waitForOrKill(10_000) +def dockerStop = 'docker stop test-proxy'.execute() +dockerStop.waitForOrKill(30_000) +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')