summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <f.joffrey@gmail.com>2015-02-10 10:33:47 -0800
committerJoffrey F <f.joffrey@gmail.com>2015-02-10 10:33:47 -0800
commit5cc7cc12ed783d1e8974bbfc222e309651562569 (patch)
treefb8091d505dd092d3af821306c3b1b0594d3e3fd
parent3e1dded35025c064b4840b57ade78e24e59b0833 (diff)
parentf3717f5815d432a9afdccad2e748b1b4ffab0651 (diff)
downloaddocker-py-5cc7cc12ed783d1e8974bbfc222e309651562569.tar.gz
Merge pull request #474 from gierschv/fix-build-remote
Fix crash when building from remote sources
-rw-r--r--docker/client.py2
-rw-r--r--tests/test.py14
2 files changed, 16 insertions, 0 deletions
diff --git a/docker/client.py b/docker/client.py
index 179e9d3..172441b 100644
--- a/docker/client.py
+++ b/docker/client.py
@@ -450,6 +450,8 @@ class Client(requests.Session):
# Send the full auth configuration (if any exists), since the build
# could use any (or all) of the registries.
if self._auth_configs:
+ if headers is None:
+ headers = {}
headers['X-Registry-Config'] = auth.encode_full_header(
self._auth_configs
)
diff --git a/tests/test.py b/tests/test.py
index 7ada2a9..bf9e254 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -2003,6 +2003,20 @@ class DockerClientTest(Cleanup, unittest.TestCase):
except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e))
+ def test_build_remote_with_registry_auth(self):
+ try:
+ self.client._auth_configs = {
+ 'https://example.com': {
+ 'user': 'example',
+ 'password': 'example',
+ 'email': 'example@example.com'
+ }
+ }
+
+ self.client.build(path='https://github.com/docker-library/mongo')
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+
#######################
# PY SPECIFIC TESTS #
#######################