MCPcopy
hub / github.com/docker/docker-py / test_load_config_custom_config_env

Method test_load_config_custom_config_env

tests/unit/auth_test.py:319–344  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

joinMethod · 0.80
load_configMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected