Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
0282e120
Kaydet (Commit)
0282e120
authored
Agu 27, 2015
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge branch 'aanand-default-cert-path'
üst
ddf879cc
e8af8b37
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
5 deletions
+41
-5
utils.py
docker/utils/utils.py
+7
-1
utils_test.py
tests/utils_test.py
+34
-4
No files found.
docker/utils/utils.py
Dosyayı görüntüle @
0282e120
...
@@ -114,7 +114,7 @@ def exclude_paths(root, patterns, dockerfile=None):
...
@@ -114,7 +114,7 @@ def exclude_paths(root, patterns, dockerfile=None):
components
=
p
.
split
(
'/'
)
components
=
p
.
split
(
'/'
)
paths
+=
[
paths
+=
[
'/'
.
join
(
components
[:
end
])
'/'
.
join
(
components
[:
end
])
for
end
in
range
(
1
,
len
(
components
)
+
1
)
for
end
in
range
(
1
,
len
(
components
)
+
1
)
]
]
return
set
(
paths
)
return
set
(
paths
)
...
@@ -363,9 +363,14 @@ def kwargs_from_env(ssl_version=None, assert_hostname=None):
...
@@ -363,9 +363,14 @@ def kwargs_from_env(ssl_version=None, assert_hostname=None):
tls_verify
=
os
.
environ
.
get
(
'DOCKER_TLS_VERIFY'
)
tls_verify
=
os
.
environ
.
get
(
'DOCKER_TLS_VERIFY'
)
params
=
{}
params
=
{}
if
host
:
if
host
:
params
[
'base_url'
]
=
(
host
.
replace
(
'tcp://'
,
'https://'
)
params
[
'base_url'
]
=
(
host
.
replace
(
'tcp://'
,
'https://'
)
if
tls_verify
else
host
)
if
tls_verify
else
host
)
if
tls_verify
and
not
cert_path
:
cert_path
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
'~'
),
'.docker'
)
if
tls_verify
and
cert_path
:
if
tls_verify
and
cert_path
:
params
[
'tls'
]
=
tls
.
TLSConfig
(
params
[
'tls'
]
=
tls
.
TLSConfig
(
client_cert
=
(
os
.
path
.
join
(
cert_path
,
'cert.pem'
),
client_cert
=
(
os
.
path
.
join
(
cert_path
,
'cert.pem'
),
...
@@ -374,6 +379,7 @@ def kwargs_from_env(ssl_version=None, assert_hostname=None):
...
@@ -374,6 +379,7 @@ def kwargs_from_env(ssl_version=None, assert_hostname=None):
verify
=
True
,
verify
=
True
,
ssl_version
=
ssl_version
,
ssl_version
=
ssl_version
,
assert_hostname
=
assert_hostname
)
assert_hostname
=
assert_hostname
)
return
params
return
params
...
...
tests/utils_test.py
Dosyayı görüntüle @
0282e120
...
@@ -19,6 +19,11 @@ from .helpers import make_tree
...
@@ -19,6 +19,11 @@ from .helpers import make_tree
import
pytest
import
pytest
TEST_CERT_DIR
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'testdata/certs'
,
)
class
UtilsTest
(
base
.
BaseTestCase
):
class
UtilsTest
(
base
.
BaseTestCase
):
longMessage
=
True
longMessage
=
True
...
@@ -90,11 +95,18 @@ class UtilsTest(base.BaseTestCase):
...
@@ -90,11 +95,18 @@ class UtilsTest(base.BaseTestCase):
for
host
,
expected
in
valid_hosts
.
items
():
for
host
,
expected
in
valid_hosts
.
items
():
self
.
assertEqual
(
parse_host
(
host
),
expected
,
msg
=
host
)
self
.
assertEqual
(
parse_host
(
host
),
expected
,
msg
=
host
)
def
test_kwargs_from_env
(
self
):
def
test_kwargs_from_env_empty
(
self
):
os
.
environ
.
update
(
DOCKER_HOST
=
''
,
DOCKER_CERT_PATH
=
''
,
DOCKER_TLS_VERIFY
=
''
)
kwargs
=
kwargs_from_env
()
self
.
assertEqual
(
None
,
kwargs
.
get
(
'base_url'
))
self
.
assertEqual
(
None
,
kwargs
.
get
(
'tls'
))
def
test_kwargs_from_env_tls
(
self
):
os
.
environ
.
update
(
DOCKER_HOST
=
'tcp://192.168.59.103:2376'
,
os
.
environ
.
update
(
DOCKER_HOST
=
'tcp://192.168.59.103:2376'
,
DOCKER_CERT_PATH
=
os
.
path
.
join
(
DOCKER_CERT_PATH
=
TEST_CERT_DIR
,
os
.
path
.
dirname
(
__file__
),
'testdata/certs'
),
DOCKER_TLS_VERIFY
=
'1'
)
DOCKER_TLS_VERIFY
=
'1'
)
kwargs
=
kwargs_from_env
(
assert_hostname
=
False
)
kwargs
=
kwargs_from_env
(
assert_hostname
=
False
)
self
.
assertEqual
(
'https://192.168.59.103:2376'
,
kwargs
[
'base_url'
])
self
.
assertEqual
(
'https://192.168.59.103:2376'
,
kwargs
[
'base_url'
])
...
@@ -110,6 +122,24 @@ class UtilsTest(base.BaseTestCase):
...
@@ -110,6 +122,24 @@ class UtilsTest(base.BaseTestCase):
except
TypeError
as
e
:
except
TypeError
as
e
:
self
.
fail
(
e
)
self
.
fail
(
e
)
def
test_kwargs_from_env_no_cert_path
(
self
):
try
:
temp_dir
=
tempfile
.
mkdtemp
()
cert_dir
=
os
.
path
.
join
(
temp_dir
,
'.docker'
)
shutil
.
copytree
(
TEST_CERT_DIR
,
cert_dir
)
os
.
environ
.
update
(
HOME
=
temp_dir
,
DOCKER_CERT_PATH
=
''
,
DOCKER_TLS_VERIFY
=
'1'
)
kwargs
=
kwargs_from_env
()
self
.
assertIn
(
cert_dir
,
kwargs
[
'tls'
]
.
verify
)
self
.
assertIn
(
cert_dir
,
kwargs
[
'tls'
]
.
cert
[
0
])
self
.
assertIn
(
cert_dir
,
kwargs
[
'tls'
]
.
cert
[
1
])
finally
:
if
temp_dir
:
shutil
.
rmtree
(
temp_dir
)
def
test_parse_env_file_proper
(
self
):
def
test_parse_env_file_proper
(
self
):
env_file
=
self
.
generate_tempfile
(
env_file
=
self
.
generate_tempfile
(
file_content
=
'USER=jdoe
\n
PASS=secret'
)
file_content
=
'USER=jdoe
\n
PASS=secret'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment