@@ -287,3 +287,32 @@ def test_load_config_custom_config_env(self):
287
287
self .assertEqual (cfg ['password' ], 'izayoi' )
288
288
self .
assertEqual (
cfg [
'email' ],
'[email protected] ' )
289
289
self .assertEqual (cfg .get ('auth' ), None )
290
+
291
+ def test_load_config_custom_config_env_with_auths (self ):
292
+ folder = tempfile .mkdtemp ()
293
+ self .addCleanup (shutil .rmtree , folder )
294
+
295
+ dockercfg_path = os .path .join (folder , 'config.json' )
296
+ registry = 'https://your.private.registry.io'
297
+ auth_ = base64 .b64encode (b'sakuya:izayoi' ).decode ('ascii' )
298
+ config = {
299
+ 'auths' : {
300
+ registry : {
301
+ 'auth' : '{0}' .format (auth_ ),
302
+
303
+ }
304
+ }
305
+ }
306
+
307
+ with open (dockercfg_path , 'w' ) as f :
308
+ json .dump (config , f )
309
+
310
+ with mock .patch .dict (os .environ , {'DOCKER_CONFIG' : folder }):
311
+ cfg = auth .load_config (None )
312
+ assert registry in cfg
313
+ self .assertNotEqual (cfg [registry ], None )
314
+ cfg = cfg [registry ]
315
+ self .assertEqual (cfg ['username' ], 'sakuya' )
316
+ self .assertEqual (cfg ['password' ], 'izayoi' )
317
+ self .
assertEqual (
cfg [
'email' ],
'[email protected] ' )
318
+ self .assertEqual (cfg .get ('auth' ), None )
0 commit comments