MCPcopy Index your code
hub / github.com/docker/docker-py / test_load_config_with_random_name

Method test_load_config_with_random_name

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

Source from the content-addressed store, hash-verified

288 assert cfg['email'] == email
289
290 def test_load_config_with_random_name(self):
291 folder = tempfile.mkdtemp()
292 self.addCleanup(shutil.rmtree, folder)
293
294 dockercfg_path = os.path.join(
295 folder,
296 f'.{random.randrange(100000)}.dockercfg',
297 )
298 registry = 'https://your.private.registry.io'
299 auth_ = base64.b64encode(b'sakuya:izayoi').decode('ascii')
300 config = {
301 registry: {
302 'auth': f'{auth_}',
303 'email': 'sakuya@scarlet.net'
304 }
305 }
306
307 with open(dockercfg_path, 'w') as f:
308 json.dump(config, f)
309
310 cfg = auth.load_config(dockercfg_path).auths
311 assert registry in cfg
312 assert cfg[registry] is not None
313 cfg = cfg[registry]
314 assert cfg['username'] == 'sakuya'
315 assert cfg['password'] == 'izayoi'
316 assert cfg['email'] == 'sakuya@scarlet.net'
317 assert cfg.get('auth') is None
318
319 def test_load_config_custom_config_env(self):
320 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