@@ -106,11 +106,13 @@ class ResolveAuthTest(unittest.TestCase):
106
106
private_config = {'auth' : encode_auth ({'username' : 'privateuser' })}
107
107
legacy_config = {'auth' : encode_auth ({'username' : 'legacyauth' })}
108
108
109
- auth_config = auth .parse_auth ({
110
- 'https://index.docker.io/v1/' : index_config ,
111
- 'my.registry.net' : private_config ,
112
- 'http://legacy.registry.url/v1/' : legacy_config ,
113
- })
109
+ auth_config = {
110
+ 'auths' : auth .parse_auth ({
111
+ 'https://index.docker.io/v1/' : index_config ,
112
+ 'my.registry.net' : private_config ,
113
+ 'http://legacy.registry.url/v1/' : legacy_config ,
114
+ })
115
+ }
114
116
115
117
def test_resolve_authconfig_hostname_only (self ):
116
118
assert auth .resolve_authconfig (
@@ -360,9 +362,8 @@ def test_load_config_custom_config_env_with_auths(self):
360
362
361
363
with mock .patch .dict (os .environ , {'DOCKER_CONFIG' : folder }):
362
364
cfg = auth .load_config (None )
363
- assert registry in cfg
364
- assert cfg [registry ] is not None
365
- cfg = cfg [registry ]
365
+ assert registry in cfg ['auths' ]
366
+ cfg = cfg ['auths' ][registry ]
366
367
assert cfg ['username' ] == 'sakuya'
367
368
assert cfg ['password' ] == 'izayoi'
368
369
assert cfg [
'email' ]
== '[email protected] '
@@ -390,38 +391,13 @@ def test_load_config_custom_config_env_utf8(self):
390
391
391
392
with mock .patch .dict (os .environ , {'DOCKER_CONFIG' : folder }):
392
393
cfg = auth .load_config (None )
393
- assert registry in cfg
394
- assert cfg [registry ] is not None
395
- cfg = cfg [registry ]
394
+ assert registry in cfg ['auths' ]
395
+ cfg = cfg ['auths' ][registry ]
396
396
assert cfg ['username' ] == b'sakuya\xc3 \xa6 ' .decode ('utf8' )
397
397
assert cfg ['password' ] == b'izayoi\xc3 \xa6 ' .decode ('utf8' )
398
398
assert cfg [
'email' ]
== '[email protected] '
399
399
assert cfg .get ('auth' ) is None
400
400
401
- def test_load_config_custom_config_env_with_headers (self ):
402
- folder = tempfile .mkdtemp ()
403
- self .addCleanup (shutil .rmtree , folder )
404
-
405
- dockercfg_path = os .path .join (folder , 'config.json' )
406
- config = {
407
- 'HttpHeaders' : {
408
- 'Name' : 'Spike' ,
409
- 'Surname' : 'Spiegel'
410
- },
411
- }
412
-
413
- with open (dockercfg_path , 'w' ) as f :
414
- json .dump (config , f )
415
-
416
- with mock .patch .dict (os .environ , {'DOCKER_CONFIG' : folder }):
417
- cfg = auth .load_config (None )
418
- assert 'HttpHeaders' in cfg
419
- assert cfg ['HttpHeaders' ] is not None
420
- cfg = cfg ['HttpHeaders' ]
421
-
422
- assert cfg ['Name' ] == 'Spike'
423
- assert cfg ['Surname' ] == 'Spiegel'
424
-
425
401
def test_load_config_unknown_keys (self ):
426
402
folder = tempfile .mkdtemp ()
427
403
self .addCleanup (shutil .rmtree , folder )
@@ -448,7 +424,7 @@ def test_load_config_invalid_auth_dict(self):
448
424
json .dump (config , f )
449
425
450
426
cfg = auth .load_config (dockercfg_path )
451
- assert cfg == {'scarlet.net' : {}}
427
+ assert cfg == {'auths' : { ' scarlet.net' : {} }}
452
428
453
429
def test_load_config_identity_token (self ):
454
430
folder = tempfile .mkdtemp ()
@@ -469,7 +445,7 @@ def test_load_config_identity_token(self):
469
445
json .dump (config , f )
470
446
471
447
cfg = auth .load_config (dockercfg_path )
472
- assert registry in cfg
473
- cfg = cfg [registry ]
448
+ assert registry in cfg [ 'auths' ]
449
+ cfg = cfg ['auths' ][ registry ]
474
450
assert 'IdentityToken' in cfg
475
451
assert cfg ['IdentityToken' ] == token
0 commit comments