Exemple #1
0
 def test_nectar_config(self):
     descriptor = {
         constants.MAX_CONCURRENT: "10",
         constants.MAX_SPEED: "1024",
         constants.SSL_VALIDATION: "true",
         constants.SSL_CA_CERT: "ssl-ca-certificate",
         constants.SSL_CLIENT_KEY: "ssl-client-key",
         constants.SSL_CLIENT_CERT: "ssl-client-certificate",
         constants.PROXY_URL: "proxy-url",
         constants.PROXY_PORT: "5000",
         constants.PROXY_USERID: "proxy-userid",
         constants.PROXY_PASSWORD: "******",
         constants.BASIC_AUTH_USERID: "basic_auth-userid",
         constants.BASIC_AUTH_PASSWORD: "******",
     }
     conf = nectar_config(descriptor)
     self.assertEqual(conf.max_concurrent, 10)
     self.assertEqual(conf.max_speed, 1024)
     self.assertEqual(conf.ssl_validation, True)
     self.assertEqual(conf.ssl_ca_cert_path, descriptor[constants.SSL_CA_CERT])
     self.assertEqual(conf.ssl_client_key_path, descriptor[constants.SSL_CLIENT_KEY])
     self.assertEqual(conf.ssl_client_cert_path, descriptor[constants.SSL_CLIENT_CERT])
     self.assertEqual(conf.proxy_url, descriptor[constants.PROXY_URL])
     self.assertEqual(conf.proxy_port, 5000)
     self.assertEqual(conf.proxy_username, descriptor[constants.PROXY_USERID])
     self.assertEqual(conf.proxy_password, descriptor[constants.PROXY_PASSWORD])
     self.assertEqual(conf.basic_auth_username, descriptor[constants.BASIC_AUTH_USERID])
     self.assertEqual(conf.basic_auth_password, descriptor[constants.BASIC_AUTH_PASSWORD])
Exemple #2
0
 def test_nectar_config(self):
     descriptor = {
         constants.MAX_CONCURRENT: '10',
         constants.MAX_SPEED: '1024',
         constants.SSL_VALIDATION: 'true',
         constants.SSL_CA_CERT: 'ssl-ca-certificate',
         constants.SSL_CLIENT_KEY: 'ssl-client-key',
         constants.SSL_CLIENT_CERT: 'ssl-client-certificate',
         constants.PROXY_URL: 'proxy-url',
         constants.PROXY_PORT: '5000',
         constants.PROXY_USERID: 'proxy-userid',
         constants.PROXY_PASSWORD: '******'
     }
     conf = nectar_config(descriptor)
     self.assertEqual(conf.max_concurrent, 10)
     self.assertEqual(conf.max_speed, 1024)
     self.assertEqual(conf.ssl_validation, True)
     self.assertEqual(conf.ssl_ca_cert_path,
                      descriptor[constants.SSL_CA_CERT])
     self.assertEqual(conf.ssl_client_key_path,
                      descriptor[constants.SSL_CLIENT_KEY])
     self.assertEqual(conf.ssl_client_cert_path,
                      descriptor[constants.SSL_CLIENT_CERT])
     self.assertEqual(conf.proxy_url, descriptor[constants.PROXY_URL])
     self.assertEqual(conf.proxy_port, 5000)
     self.assertEqual(conf.proxy_username,
                      descriptor[constants.PROXY_USERID])
     self.assertEqual(conf.proxy_password,
                      descriptor[constants.PROXY_PASSWORD])
Exemple #3
0
 def test_nectar_config(self):
     descriptor = {
         constants.MAX_CONCURRENT: '10',
         constants.MAX_SPEED: '1024',
         constants.SSL_VALIDATION: 'true',
         constants.SSL_CA_CERT: 'ssl-ca-certificate',
         constants.SSL_CLIENT_KEY: 'ssl-client-key',
         constants.SSL_CLIENT_CERT: 'ssl-client-certificate',
         constants.PROXY_URL: 'proxy-url',
         constants.PROXY_PORT: '5000',
         constants.PROXY_USERID: 'proxy-userid',
         constants.PROXY_PASSWORD: '******',
         constants.BASIC_AUTH_USERID: 'basic_auth-userid',
         constants.BASIC_AUTH_PASSWORD: '******',
         constants.HEADERS: 'X-RHUI-ID=1234'
     }
     conf = nectar_config(descriptor)
     self.assertEqual(conf.max_concurrent, 10)
     self.assertEqual(conf.max_speed, 1024)
     self.assertEqual(conf.ssl_validation, True)
     self.assertEqual(conf.ssl_ca_cert_path, descriptor[constants.SSL_CA_CERT])
     self.assertEqual(conf.ssl_client_key_path, descriptor[constants.SSL_CLIENT_KEY])
     self.assertEqual(conf.ssl_client_cert_path, descriptor[constants.SSL_CLIENT_CERT])
     self.assertEqual(conf.proxy_url, descriptor[constants.PROXY_URL])
     self.assertEqual(conf.proxy_port, 5000)
     self.assertEqual(conf.proxy_username, descriptor[constants.PROXY_USERID])
     self.assertEqual(conf.proxy_password, descriptor[constants.PROXY_PASSWORD])
     self.assertEqual(conf.basic_auth_username, descriptor[constants.BASIC_AUTH_USERID])
     self.assertEqual(conf.basic_auth_password, descriptor[constants.BASIC_AUTH_PASSWORD])
     self.assertEqual(conf.headers, {'X-RHUI-ID': '1234'})
Exemple #4
0
 def nectar_config(self, config):
     """
     Get a nectar configuration using the specified content source configuration.
     :param config: The content source configuration.
     :type config: dict
     :return: A nectar downloader configuration
     :rtype: nectar.config.DownloaderConfig
     """
     return descriptor.nectar_config(config)
Exemple #5
0
 def nectar_config(self, config):
     """
     Get a nectar configuration using the specified content source configuration.
     :param config: The content source configuration.
     :type config: dict
     :return: A nectar downloader configuration
     :rtype: nectar.config.DownloaderConfig
     """
     return descriptor.nectar_config(config)
Exemple #6
0
 def downloader(self):
     """
     Get a fully configured nectar downloader.
     The returned downloader is configured using properties defined
     in the descriptor.
     :return: A nectar downloader.
     :rtype: nectar.downloaders.Downloader.
     """
     url = self.base_url()
     conf = nectar_config(self.descriptor)
     try:
         parts = urlsplit(url)
         downloader = DOWNLOADER[parts.scheme](conf)
         return downloader
     except KeyError:
         raise ValueError('unsupported protocol: %s', url)
 def get_downloader(self, conduit, config, url):
     if url.startswith('http'):
         return HTTPThreadedDownloader(nectar_config(config))
     if url.startswith('file'):
         return LocalFileDownloader(nectar_config(config))
     raise ValueError('unsupported url')
Exemple #8
0
 def get_downloader(self, conduit, config, url):
     if url.startswith('http'):
         return HTTPThreadedDownloader(nectar_config(config))
     if url.startswith('file'):
         return LocalFileDownloader(nectar_config(config))
     raise ValueError('unsupported url')