def test_verify_true(self, fake_const): """ssl_context - ``get_context`` returns a default context when VERIFY True""" context = ssl_context.get_context() expected = ssl.create_default_context() self.assertEqual(context.verify_mode, expected.verify_mode) self.assertEqual(context.protocol, expected.protocol)
def __init__(self, host, user, password, port=443, base_dir=None): self._conn = connect.SmartConnect(host=host, user=user, pwd=password, port=port, sslContext=get_context()) self._base_dir = base_dir if base_dir else const.INF_VCENTER_TOP_LVL_DIR self._net_cache = None
def _upload_disk(self, disk): """ Upload an individual disk from the OVA :param disk: **Required** The name of the disk within the OVF file :type disk: String """ vmdk = self._disks.get(disk.path, None) if vmdk is None: return url = self._get_device_url(disk) headers = { 'Content-length': self._get_tarfile_size(vmdk), 'Content-Type': 'application/x-vnd.vmware-streamVmdk' } # Create the request object req = Request(url, method='POST', data=vmdk, headers=headers) # Start uploading the disk urlopen(req, context=get_context())
def test_verify_false(self): """ssl_context - ``get_context`` wont enforce TLS cert verification when VERIFY is False""" context = ssl_context.get_context() self.assertEqual(context.verify_mode, ssl.CERT_NONE)