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
40770878
Kaydet (Commit)
40770878
authored
Şub 01, 2015
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Additional tests and small improvement to auth.resolve_authconfig
üst
3d6d5e10
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
3 deletions
+59
-3
__init__.py
docker/auth/__init__.py
+2
-1
auth.py
docker/auth/auth.py
+2
-2
utils_test.py
tests/utils_test.py
+55
-0
No files found.
docker/auth/__init__.py
Dosyayı görüntüle @
40770878
...
@@ -3,5 +3,5 @@ from .auth import (
...
@@ -3,5 +3,5 @@ from .auth import (
encode_header
,
encode_header
,
load_config
,
load_config
,
resolve_authconfig
,
resolve_authconfig
,
resolve_repository_name
resolve_repository_name
,
)
# flake8: noqa
)
# flake8: noqa
\ No newline at end of file
docker/auth/auth.py
Dosyayı görüntüle @
40770878
...
@@ -75,7 +75,7 @@ def resolve_authconfig(authconfig, registry=None):
...
@@ -75,7 +75,7 @@ def resolve_authconfig(authconfig, registry=None):
# Default to the public index server
# Default to the public index server
registry
=
registry
or
INDEX_URL
registry
=
registry
or
INDEX_URL
#
Ff it
s not the index server there are three cases:
#
If it'
s not the index server there are three cases:
#
#
# 1. this is a full config url -> it should be used as is
# 1. this is a full config url -> it should be used as is
# 2. it could be a full url, but with the wrong protocol
# 2. it could be a full url, but with the wrong protocol
...
@@ -84,7 +84,7 @@ def resolve_authconfig(authconfig, registry=None):
...
@@ -84,7 +84,7 @@ def resolve_authconfig(authconfig, registry=None):
# as there is only one auth entry which is fully qualified we need to start
# as there is only one auth entry which is fully qualified we need to start
# parsing and matching
# parsing and matching
if
'/v1/'
not
in
registry
:
if
'/v1/'
not
in
registry
:
registry
=
registry
+
'/v1/'
registry
=
os
.
path
.
join
(
registry
,
'v1/'
)
if
not
registry
.
startswith
(
'http:'
)
and
not
registry
.
startswith
(
'https:'
):
if
not
registry
.
startswith
(
'http:'
)
and
not
registry
.
startswith
(
'https:'
):
registry
=
'https://'
+
registry
registry
=
'https://'
+
registry
...
...
tests/utils_test.py
Dosyayı görüntüle @
40770878
...
@@ -8,6 +8,7 @@ from docker.utils import (
...
@@ -8,6 +8,7 @@ from docker.utils import (
parse_repository_tag
,
parse_host
,
convert_filters
,
kwargs_from_env
,
parse_repository_tag
,
parse_host
,
convert_filters
,
kwargs_from_env
,
create_host_config
create_host_config
)
)
from
docker.auth
import
resolve_authconfig
class
UtilsTest
(
unittest
.
TestCase
):
class
UtilsTest
(
unittest
.
TestCase
):
...
@@ -100,6 +101,60 @@ class UtilsTest(unittest.TestCase):
...
@@ -100,6 +101,60 @@ class UtilsTest(unittest.TestCase):
empty_config
=
create_host_config
()
empty_config
=
create_host_config
()
self
.
assertEqual
(
empty_config
,
{})
self
.
assertEqual
(
empty_config
,
{})
def
test_resolve_authconfig
(
self
):
auth_config
=
{
'https://index.docker.io/v1/'
:
{
'auth'
:
'indexuser'
},
'http://my.registry.net/v1/'
:
{
'auth'
:
'privateuser'
}
}
# hostname only
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'my.registry.net'
),
{
'auth'
:
'privateuser'
}
)
# no protocol
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'my.registry.net/v1/'
),
{
'auth'
:
'privateuser'
}
)
# no path
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'http://my.registry.net'
),
{
'auth'
:
'privateuser'
}
)
# no path, trailing slash
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'http://my.registry.net/'
),
{
'auth'
:
'privateuser'
}
)
# no path, wrong secure protocol
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'https://my.registry.net'
),
{
'auth'
:
'privateuser'
}
)
# no path, wrong insecure protocol
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'http://index.docker.io'
),
{
'auth'
:
'indexuser'
}
)
# with path, wrong protocol
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'https://my.registry.net/v1/'
),
{
'auth'
:
'privateuser'
}
)
# default registry
self
.
assertEqual
(
resolve_authconfig
(
auth_config
),
{
'auth'
:
'indexuser'
}
)
# default registry (explicit None)
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
None
),
{
'auth'
:
'indexuser'
}
)
# fully explicit
self
.
assertEqual
(
resolve_authconfig
(
auth_config
,
'http://my.registry.net/v1/'
),
{
'auth'
:
'privateuser'
}
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
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