@@ -316,3 +316,33 @@ def test_load_config_custom_config_env_with_auths(self):
316
316
self .assertEqual (cfg ['password' ], 'izayoi' )
317
317
self .
assertEqual (
cfg [
'email' ],
'[email protected] ' )
318
318
self .assertEqual (cfg .get ('auth' ), None )
319
+
320
+ def test_load_config_custom_config_env_utf8 (self ):
321
+ folder = tempfile .mkdtemp ()
322
+ self .addCleanup (shutil .rmtree , folder )
323
+
324
+ dockercfg_path = os .path .join (folder , 'config.json' )
325
+ registry = 'https://your.private.registry.io'
326
+ auth_ = base64 .b64encode (
327
+ b'sakuya\xc3 \xa6 :izayoi\xc3 \xa6 ' ).decode ('ascii' )
328
+ config = {
329
+ 'auths' : {
330
+ registry : {
331
+ 'auth' : '{0}' .format (auth_ ),
332
+
333
+ }
334
+ }
335
+ }
336
+
337
+ with open (dockercfg_path , 'w' ) as f :
338
+ json .dump (config , f )
339
+
340
+ with mock .patch .dict (os .environ , {'DOCKER_CONFIG' : folder }):
341
+ cfg = auth .load_config (None )
342
+ assert registry in cfg
343
+ self .assertNotEqual (cfg [registry ], None )
344
+ cfg = cfg [registry ]
345
+ self .assertEqual (cfg ['username' ], b'sakuya\xc3 \xa6 ' .decode ('utf8' ))
346
+ self .assertEqual (cfg ['password' ], b'izayoi\xc3 \xa6 ' .decode ('utf8' ))
347
+ self .
assertEqual (
cfg [
'email' ],
'[email protected] ' )
348
+ self .assertEqual (cfg .get ('auth' ), None )
0 commit comments