def test_http_proxy_with_cert_file(self, hs): conn = connect.SoapStubAdapter( 'sdkTunnel', 8089, httpProxyHost='vcsa', certKeyFile='my_key_file', certFile='my_cert_file').GetConnection() conn.request('GET', '/') hs.assert_called_once_with('vcsa:80', cert_file='my_cert_file', key_file='my_key_file') conn.set_tunnel.assert_called_once_with('sdkTunnel:8089')
def test_http_proxy(self): conn = connect.SoapStubAdapter( 'vcenter.test', httpProxyHost='my-http-proxy', httpProxyPort=8080).GetConnection() self.assertEqual(conn._tunnel_host, 'vcenter.test') self.assertEqual(conn._tunnel_port, 443) conn.request('GET', '/') conn.getresponse()
def test_invoke_method_login_session_exception(self): def login_fail(*args, **kwargs): raise vim_session.SESSION_EXCEPTIONS[0]() stub = connect.SoapStubAdapter() vim_session = connect.VimSessionOrientedStub(stub, login_fail) self.assertRaises(SystemError, vim_session.InvokeAccessor, "mo", "info")
def connect_sms_env(self, vcenter_ip): """Create a session (verified or unverified) with the SMS service on the requested vCenter Server. Args: vcenter_ip (str): IP address of the vCenter Server you wish to connect to the SMS service on. Returns: sms_instance (sms.ServiceInstance): Service Instance for the SMS service on vCenter. """ client_stub = self.vc_instance._GetStub() ssl_context = client_stub.schemeArgs.get('context') session_cookie = client_stub.cookie.split('"')[1] additional_headers = {'vcSessionCookie': session_cookie} stub = connect.SoapStubAdapter(vcenter_ip, path='/sms/sdk', version='sms.version.version5', sslContext=ssl_context, requestContext=additional_headers) sms_instance = sms.ServiceInstance('ServiceInstance', stub) return sms_instance
def should_fail(): connect.SoapStubAdapter('vcsa', 80, httpProxyHost='vcsa').GetConnection()
def test_ssl_tunnel(self): connect.SoapStubAdapter('sdkTunnel', 8089, httpProxyHost='vcsa').GetConnection()
def should_fail(): conn = connect.SoapStubAdapter('vcsa', 80, httpProxyHost='unreachable').GetConnection() conn.request('GET', '/') conn.getresponse()