Skip to content

Commit 4aef1dc

Browse files
authored
Execute Docker credential programm through shell on Windows (#4763)
1 parent 5370e25 commit 4aef1dc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/main/java/org/testcontainers/utility/RegistryAuthLocator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.github.dockerjava.api.model.AuthConfig;
66
import com.google.common.annotations.VisibleForTesting;
77
import org.apache.commons.lang.StringUtils;
8+
import org.apache.commons.lang.SystemUtils;
89
import org.slf4j.Logger;
910
import org.zeroturnaround.exec.InvalidResultException;
1011
import org.zeroturnaround.exec.ProcessExecutor;
@@ -337,8 +338,9 @@ private String extractCredentialProviderErrorMessage(InvalidResultException inva
337338
private String runCredentialProgram(String hostName, String credentialHelperName)
338339
throws InvalidResultException, InterruptedException, TimeoutException, IOException {
339340

341+
String[] command = SystemUtils.IS_OS_WINDOWS ? new String[] {"cmd", "/c", credentialHelperName, "get"} : new String[]{credentialHelperName, "get"};
340342
return new ProcessExecutor()
341-
.command(credentialHelperName, "get")
343+
.command(command)
342344
.redirectInput(new ByteArrayInputStream(hostName.getBytes()))
343345
.readOutput(true)
344346
.exitValueNormal()

0 commit comments

Comments
 (0)