Skip to content

Commit 06645cd

Browse files
committed
test additional user agent workarounds
1 parent c18dd83 commit 06645cd

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

subprojects/groovy-test-junit6/src/main/java/groovy/junit6/plugin/ForkedJvmExtension.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ private static List<String> buildCommand(Class<?> testClass, Method testMethod,
121121
if (parentInverting) {
122122
cmd.add("-D" + ExpectedToFailExtension.DEFERRED_TO_PARENT_PROP + "=true");
123123
}
124+
// Always-inherited properties: things whose absence in the child JVM
125+
// would cause confusing failures that don't reflect the test's intent.
126+
// - http.agent: parent's User-Agent override (see org.apache.groovy-tested.gradle's
127+
// GROOVY-12005 comment). Maven Central's Cloudflare WAF returns HTTP 404
128+
// for requests bearing the JDK default "Java/<version>" agent; if a child
129+
// JVM doing @Grab inherits the parent's UA it stays consistent with the
130+
// parent test JVM's behaviour. Test authors can still override per-fork
131+
// via systemProperties=[] on @ForkedJvm — explicit entries land later on
132+
// the command line and win.
133+
for (String name : new String[]{"http.agent"}) {
134+
String value = System.getProperty(name);
135+
if (value != null) {
136+
cmd.add("-D" + name + "=" + value);
137+
}
138+
}
124139
// Inherited properties first, then explicit systemProperties — later -D wins on the JVM command line.
125140
for (String name : resolveInherited(config.inheritProperties())) {
126141
cmd.add("-D" + name + "=" + System.getProperty(name));

0 commit comments

Comments
 (0)