testcontainers/testcontainers-node

A docker auth password that contains a colon truncates the password

Closed this issue · 1 comments

Expected Behaviour
The docker auth password should not be truncated if it contains a :

Actual Behaviour
The docker auth password is truncated if it contains a :

eg. If the password is password1:1 it will be reduced to password1.

Testcontainer Logs
Since the password is truncated, it ends up producing the unauthorized error:

 testcontainers [ERROR] Failed to pull image "testcontainers/ryuk:0.5.1": Error: (HTTP code 500) server error - Head "https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.5.1": unauthorized: incorrect username or password

Steps to Reproduce

  1. Create a docker auth password that contains a colon (:)
  2. Set the credentials in the ~/.docker/config.json
  3. Run your tests with testcontainer

Code
You can clearly see in the code it is currently doing a naive string split on :

https://github.com/testcontainers/testcontainers-node/blob/main/packages/testcontainers/src/container-runtime/auth/auths.ts#L24

A simple fix could be something like this:

const [username, ...passwordParts] = decodedAuth.split(":");
const password = passwordParts.join(":");

I will raise a PR.

Thanks @cristianrgreco. When will a new build be available with this fix?