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
dd9cff4f
Unverified
Kaydet (Commit)
dd9cff4f
authored
Haz 28, 2018
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Haz 28, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #2068 from docker/c6047-legacy-auth
Fix support for legacy .dockercfg auth config format
üst
5a85cad5
8c35eee0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
57 deletions
+60
-57
container.py
docker/api/container.py
+3
-2
auth.py
docker/auth.py
+3
-3
api_client_test.py
tests/integration/api_client_test.py
+0
-40
auth_test.py
tests/unit/auth_test.py
+54
-12
No files found.
docker/api/container.py
Dosyayı görüntüle @
dd9cff4f
...
...
@@ -139,8 +139,9 @@ class ContainerApiMixin(object):
'changes'
:
changes
}
u
=
self
.
_url
(
"/commit"
)
return
self
.
_result
(
self
.
_post_json
(
u
,
data
=
conf
,
params
=
params
),
json
=
True
)
return
self
.
_result
(
self
.
_post_json
(
u
,
data
=
conf
,
params
=
params
),
json
=
True
)
def
containers
(
self
,
quiet
=
False
,
all
=
False
,
trunc
=
False
,
latest
=
False
,
since
=
None
,
before
=
None
,
limit
=-
1
,
size
=
False
,
...
...
docker/auth.py
Dosyayı görüntüle @
dd9cff4f
...
...
@@ -270,7 +270,7 @@ def load_config(config_path=None, config_dict=None):
"Couldn't find auth-related section ; attempting to interpret"
"as auth-only file"
)
return
parse_auth
(
config_dict
)
return
{
'auths'
:
parse_auth
(
config_dict
)}
def
_load_legacy_config
(
config_file
):
...
...
@@ -287,14 +287,14 @@ def _load_legacy_config(config_file):
)
username
,
password
=
decode_auth
(
data
[
0
])
return
{
return
{
'auths'
:
{
INDEX_NAME
:
{
'username'
:
username
,
'password'
:
password
,
'email'
:
data
[
1
],
'serveraddress'
:
INDEX_URL
,
}
}
}
}
except
Exception
as
e
:
log
.
debug
(
e
)
pass
...
...
tests/integration/api_client_test.py
Dosyayı görüntüle @
dd9cff4f
import
base64
import
os
import
tempfile
import
time
import
unittest
import
warnings
...
...
@@ -24,43 +21,6 @@ class InformationTest(BaseAPIIntegrationTest):
assert
'Debug'
in
res
class
LoadConfigTest
(
BaseAPIIntegrationTest
):
def
test_load_legacy_config
(
self
):
folder
=
tempfile
.
mkdtemp
()
self
.
tmp_folders
.
append
(
folder
)
cfg_path
=
os
.
path
.
join
(
folder
,
'.dockercfg'
)
f
=
open
(
cfg_path
,
'w'
)
auth_
=
base64
.
b64encode
(
b
'sakuya:izayoi'
)
.
decode
(
'ascii'
)
f
.
write
(
'auth = {0}
\n
'
.
format
(
auth_
))
f
.
write
(
'email = sakuya@scarlet.net'
)
f
.
close
()
cfg
=
docker
.
auth
.
load_config
(
cfg_path
)
assert
cfg
[
docker
.
auth
.
INDEX_NAME
]
is
not
None
cfg
=
cfg
[
docker
.
auth
.
INDEX_NAME
]
assert
cfg
[
'username'
]
==
'sakuya'
assert
cfg
[
'password'
]
==
'izayoi'
assert
cfg
[
'email'
]
==
'sakuya@scarlet.net'
assert
cfg
.
get
(
'Auth'
)
is
None
def
test_load_json_config
(
self
):
folder
=
tempfile
.
mkdtemp
()
self
.
tmp_folders
.
append
(
folder
)
cfg_path
=
os
.
path
.
join
(
folder
,
'.dockercfg'
)
f
=
open
(
os
.
path
.
join
(
folder
,
'.dockercfg'
),
'w'
)
auth_
=
base64
.
b64encode
(
b
'sakuya:izayoi'
)
.
decode
(
'ascii'
)
email_
=
'sakuya@scarlet.net'
f
.
write
(
'{{"{0}": {{"auth": "{1}", "email": "{2}"}}}}
\n
'
.
format
(
docker
.
auth
.
INDEX_URL
,
auth_
,
email_
))
f
.
close
()
cfg
=
docker
.
auth
.
load_config
(
cfg_path
)
assert
cfg
[
docker
.
auth
.
INDEX_URL
]
is
not
None
cfg
=
cfg
[
docker
.
auth
.
INDEX_URL
]
assert
cfg
[
'username'
]
==
'sakuya'
assert
cfg
[
'password'
]
==
'izayoi'
assert
cfg
[
'email'
]
==
'sakuya@scarlet.net'
assert
cfg
.
get
(
'Auth'
)
is
None
class
AutoDetectVersionTest
(
unittest
.
TestCase
):
def
test_client_init
(
self
):
client
=
docker
.
APIClient
(
version
=
'auto'
,
**
kwargs_from_env
())
...
...
tests/unit/auth_test.py
Dosyayı görüntüle @
dd9cff4f
...
...
@@ -282,22 +282,64 @@ class LoadConfigTest(unittest.TestCase):
cfg
=
auth
.
load_config
(
folder
)
assert
cfg
is
not
None
def
test_load_config
(
self
):
def
test_load_
legacy_
config
(
self
):
folder
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
folder
)
docker
cfg_path
=
os
.
path
.
join
(
folder
,
'.dockercfg'
)
with
open
(
dockercfg_path
,
'w'
)
as
f
:
auth_
=
base64
.
b64encode
(
b
'sakuya:izayoi'
)
.
decode
(
'ascii'
)
cfg_path
=
os
.
path
.
join
(
folder
,
'.dockercfg'
)
auth_
=
base64
.
b64encode
(
b
'sakuya:izayoi'
)
.
decode
(
'ascii'
)
with
open
(
cfg_path
,
'w'
)
as
f
:
f
.
write
(
'auth = {0}
\n
'
.
format
(
auth_
))
f
.
write
(
'email = sakuya@scarlet.net'
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
assert
auth
.
INDEX_NAME
in
cfg
assert
cfg
[
auth
.
INDEX_NAME
]
is
not
None
cfg
=
cfg
[
auth
.
INDEX_NAME
]
cfg
=
auth
.
load_config
(
cfg_path
)
assert
auth
.
resolve_authconfig
(
cfg
)
is
not
None
assert
cfg
[
'auths'
][
auth
.
INDEX_NAME
]
is
not
None
cfg
=
cfg
[
'auths'
][
auth
.
INDEX_NAME
]
assert
cfg
[
'username'
]
==
'sakuya'
assert
cfg
[
'password'
]
==
'izayoi'
assert
cfg
[
'email'
]
==
'sakuya@scarlet.net'
assert
cfg
.
get
(
'auth'
)
is
None
assert
cfg
.
get
(
'Auth'
)
is
None
def
test_load_json_config
(
self
):
folder
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
folder
)
cfg_path
=
os
.
path
.
join
(
folder
,
'.dockercfg'
)
auth_
=
base64
.
b64encode
(
b
'sakuya:izayoi'
)
.
decode
(
'ascii'
)
email
=
'sakuya@scarlet.net'
with
open
(
cfg_path
,
'w'
)
as
f
:
json
.
dump
(
{
auth
.
INDEX_URL
:
{
'auth'
:
auth_
,
'email'
:
email
}},
f
)
cfg
=
auth
.
load_config
(
cfg_path
)
assert
auth
.
resolve_authconfig
(
cfg
)
is
not
None
assert
cfg
[
'auths'
][
auth
.
INDEX_URL
]
is
not
None
cfg
=
cfg
[
'auths'
][
auth
.
INDEX_URL
]
assert
cfg
[
'username'
]
==
'sakuya'
assert
cfg
[
'password'
]
==
'izayoi'
assert
cfg
[
'email'
]
==
email
assert
cfg
.
get
(
'Auth'
)
is
None
def
test_load_modern_json_config
(
self
):
folder
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
folder
)
cfg_path
=
os
.
path
.
join
(
folder
,
'config.json'
)
auth_
=
base64
.
b64encode
(
b
'sakuya:izayoi'
)
.
decode
(
'ascii'
)
email
=
'sakuya@scarlet.net'
with
open
(
cfg_path
,
'w'
)
as
f
:
json
.
dump
({
'auths'
:
{
auth
.
INDEX_URL
:
{
'auth'
:
auth_
,
'email'
:
email
}
}
},
f
)
cfg
=
auth
.
load_config
(
cfg_path
)
assert
auth
.
resolve_authconfig
(
cfg
)
is
not
None
assert
cfg
[
'auths'
][
auth
.
INDEX_URL
]
is
not
None
cfg
=
cfg
[
'auths'
][
auth
.
INDEX_URL
]
assert
cfg
[
'username'
]
==
'sakuya'
assert
cfg
[
'password'
]
==
'izayoi'
assert
cfg
[
'email'
]
==
email
def
test_load_config_with_random_name
(
self
):
folder
=
tempfile
.
mkdtemp
()
...
...
@@ -318,7 +360,7 @@ class LoadConfigTest(unittest.TestCase):
with
open
(
dockercfg_path
,
'w'
)
as
f
:
json
.
dump
(
config
,
f
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
[
'auths'
]
assert
registry
in
cfg
assert
cfg
[
registry
]
is
not
None
cfg
=
cfg
[
registry
]
...
...
@@ -345,7 +387,7 @@ class LoadConfigTest(unittest.TestCase):
json
.
dump
(
config
,
f
)
with
mock
.
patch
.
dict
(
os
.
environ
,
{
'DOCKER_CONFIG'
:
folder
}):
cfg
=
auth
.
load_config
(
None
)
cfg
=
auth
.
load_config
(
None
)
[
'auths'
]
assert
registry
in
cfg
assert
cfg
[
registry
]
is
not
None
cfg
=
cfg
[
registry
]
...
...
@@ -422,7 +464,7 @@ class LoadConfigTest(unittest.TestCase):
json
.
dump
(
config
,
f
)
cfg
=
auth
.
load_config
(
dockercfg_path
)
assert
cfg
==
{}
assert
cfg
==
{
'auths'
:
{}
}
def
test_load_config_invalid_auth_dict
(
self
):
folder
=
tempfile
.
mkdtemp
()
...
...
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