Example #1
0
 def testEnvProxyUrlNouserOrPass(self):
     with patch.dict('os.environ', {'https_proxy': 'https://example.com'}):
         cc = ContentConnection(host="127.0.0.1")
         self.assertEqual(None, cc.proxy_user)
         self.assertEqual(None, cc.proxy_password)
         self.assertEqual("example.com", cc.proxy_hostname)
         self.assertEqual(3128, cc.proxy_port)
     assert 'https_proxy' not in os.environ
Example #2
0
 def testEnvProxyUrl(self):
     with patch.dict('os.environ', {'https_proxy': 'https://*****:*****@example.com:1111'}):
         cc = ContentConnection(host="127.0.0.1")
         self.assertEqual("user", cc.proxy_user)
         self.assertEqual("pass", cc.proxy_password)
         self.assertEqual("example.com", cc.proxy_hostname)
         self.assertEqual(1111, cc.proxy_port)
     assert 'https_proxy' not in os.environ
 def test_content_connection_honors_no_proxy_setting(self):
     with patch.dict('os.environ', {'no_proxy': 'foobar'}):
         cont_conn = ContentConnection(host="foobar", username="******", password="******", insecure=True,
                                       proxy_hostname="proxyfoo", proxy_password="******", proxy_port=42,
                                       proxy_user="******")
         self.assertIs(None, cont_conn.proxy_user)
         self.assertIs(None, cont_conn.proxy_password)
         self.assertIs(None, cont_conn.proxy_hostname)
         self.assertIs(None, cont_conn.proxy_port)
Example #4
0
 def testEnvNoProxyWithAsterisk(self):
     with patch.dict('os.environ', {'no_proxy': '*.localdomain',
                                    'https_proxy': 'https://example.com'}):
         cc = ContentConnection(host="localhost.localdomain")
         self.assertEquals(None, cc.proxy_user)
         self.assertEquals(None, cc.proxy_password)
         self.assertEquals(None, cc.proxy_hostname)
         self.assertEquals(None, cc.proxy_port)
     assert 'no_proxy' not in os.environ and 'https_proxy' not in os.environ
 def test_bad_ca_cert(self):
     with open(os.path.join(self.temp_ent_dir, "foo.pem"), 'w+') as cert:
         cert.write('xxxxxx\n')
     with open(os.path.join(self.temp_ent_dir, "foo-key.pem"), 'w+') as key:
         key.write('xxxxxx\n')
     with self.assertRaises(NoValidEntitlement):
         cont_conn = ContentConnection(host="foobar", username="******", password="******", insecure=True, cert_dir=self.temp_ent_dir)
         cont_conn.get_versions('/')
     restlib = Restlib("somehost", "123", "somehandler")
     restlib.ca_dir = self.temp_ent_dir
     with self.assertRaises(BadCertificateException):
         restlib._load_ca_certificates(ssl.SSLContext(ssl.PROTOCOL_SSLv23))
Example #6
0
 def test_bad_ca_cert(self):
     f = open(os.path.join(self.temp_ent_dir, "foo.pem"), 'w+')
     f.write('xxxxxx\n')
     f.close()
     cont_conn = ContentConnection(host="foobar", username="******", password="******", insecure=True)
     cont_conn.ent_dir = self.temp_ent_dir
     with self.assertRaises(BadCertificateException) as e:
         cont_conn._load_ca_certificates(ssl.SSLContext(ssl.PROTOCOL_SSLv23))
     restlib = Restlib("somehost", "123", "somehandler")
     restlib.ca_dir = self.temp_ent_dir
     with self.assertRaises(BadCertificateException) as e:
         restlib._load_ca_certificates(ssl.SSLContext(ssl.PROTOCOL_SSLv23))
Example #7
0
 def testInsecure(self):
     ContentConnection(host="127.0.0.1", insecure=True)