def test_get_credential_store_no_default(self): auth_config = { 'credHelpers': { 'registry1.io': 'truesecret', 'registry2.io': 'powerlock' }, } assert auth.get_credential_store(auth_config, 'registry2.io') == 'powerlock' assert auth.get_credential_store(auth_config, 'registry3.io') is None
def test_get_credential_store_no_default(self): auth_config = { 'credHelpers': { 'registry1.io': 'truesecret', 'registry2.io': 'powerlock' }, } assert auth.get_credential_store( auth_config, 'registry2.io' ) == 'powerlock' assert auth.get_credential_store( auth_config, 'registry3.io' ) is None
def test_get_credential_store_default_index(self): auth_config = { 'credHelpers': { 'https://index.docker.io/v1/': 'powerlock' }, 'credsStore': 'truesecret' } assert auth.get_credential_store(auth_config, None) == 'powerlock' assert auth.get_credential_store(auth_config, 'docker.io') == 'powerlock' assert auth.get_credential_store(auth_config, 'images.io') == 'truesecret'
def test_get_credential_store_default_index(self): auth_config = { 'credHelpers': { 'https://index.docker.io/v1/': 'powerlock' }, 'credsStore': 'truesecret' } assert auth.get_credential_store(auth_config, None) == 'powerlock' assert auth.get_credential_store( auth_config, 'docker.io' ) == 'powerlock' assert auth.get_credential_store( auth_config, 'images.io' ) == 'truesecret'
def test_get_credential_store(self): auth_config = { 'credHelpers': { 'registry1.io': 'truesecret', 'registry2.io': 'powerlock' }, 'credsStore': 'blackbox', } assert auth.get_credential_store(auth_config, 'registry1.io') == 'truesecret' assert auth.get_credential_store(auth_config, 'registry2.io') == 'powerlock' assert auth.get_credential_store(auth_config, 'registry3.io') == 'blackbox'
def get_credential_store_instance(self, registry, dockercfg_path): ''' Return an instance of docker.credentials.Store used by the given registry. :return: A Store or None :rtype: Union[docker.credentials.Store, NoneType] ''' # Older versions of docker-py don't have this feature. try: credstore_env = self.client.credstore_env except AttributeError: credstore_env = None config = auth.load_config(config_path=dockercfg_path) if hasattr(auth, 'get_credential_store'): store_name = auth.get_credential_store(config, registry) elif 'credsStore' in config: store_name = config['credsStore'] else: store_name = None # Make sure that there is a credential helper before trying to instantiate a # Store object. if store_name: self.log("Found credential store %s" % store_name) return Store(store_name, environment=credstore_env) return DockerFileStore(dockercfg_path)
def test_get_credential_store(self): auth_config = { 'credHelpers': { 'registry1.io': 'truesecret', 'registry2.io': 'powerlock' }, 'credsStore': 'blackbox', } assert auth.get_credential_store( auth_config, 'registry1.io' ) == 'truesecret' assert auth.get_credential_store( auth_config, 'registry2.io' ) == 'powerlock' assert auth.get_credential_store( auth_config, 'registry3.io' ) == 'blackbox'