From a69145fcdd0add2ed9c4ffae53915ada4c96612c Mon Sep 17 00:00:00 2001 From: Min RK Date: Thu, 31 Jan 2019 10:48:18 +0100 Subject: [PATCH] missing quotes in GIT_CREDENTIAL_ENV echo without quotes removes newline, echo with quotes preserves it. Previously failing test added --- docker/git-credential-env | 2 +- tests/unit/test_docker.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test_docker.py diff --git a/docker/git-credential-env b/docker/git-credential-env index 905d9fee..21f1d505 100755 --- a/docker/git-credential-env +++ b/docker/git-credential-env @@ -1,2 +1,2 @@ #!/bin/bash -echo -e $GIT_CREDENTIAL_ENV +echo -e "$GIT_CREDENTIAL_ENV" diff --git a/tests/unit/test_docker.py b/tests/unit/test_docker.py new file mode 100644 index 00000000..88a5f327 --- /dev/null +++ b/tests/unit/test_docker.py @@ -0,0 +1,21 @@ +"""Tests for docker bits""" + +import os +from subprocess import check_output + +repo_root = os.path.abspath( + os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) +) + + +def test_git_credential_env(): + credential_env = "username=abc\npassword=def" + out = ( + check_output( + os.path.join(repo_root, "docker", "git-credential-env"), + env={'GIT_CREDENTIAL_ENV': credential_env}, + ) + .decode() + .strip() + ) + assert out == credential_env