Example #1
0
 def test_create_ssl_context(self):
     configuration = mock.Mock()
     configuration.emc_ssl_cert_verify = True
     configuration.emc_ssl_cert_path = "./cert_path/"
     self.mock_object(ssl, 'create_default_context')
     context = utils.create_ssl_context(configuration)
     self.assertIsNotNone(context)
Example #2
0
 def test_create_ssl_context(self):
     configuration = mock.Mock()
     configuration.emc_ssl_cert_verify = True
     configuration.emc_ssl_cert_path = "./cert_path/"
     self.mock_object(ssl, 'create_default_context')
     context = utils.create_ssl_context(configuration)
     self.assertIsNotNone(context)
Example #3
0
 def test_no_create_default_context(self):
     """Test scenario of running on python 2.7.8 or earlier."""
     configuration = mock.Mock()
     configuration.emc_ssl_cert_verify = False
     self.mock_object(ssl, 'create_default_context',
                      mock.Mock(side_effect=AttributeError))
     context = utils.create_ssl_context(configuration)
     self.assertIsNone(context)
Example #4
0
 def test_no_create_default_context(self):
     """Test scenario of running on python 2.7.8 or earlier."""
     configuration = mock.Mock()
     configuration.emc_ssl_cert_verify = False
     self.mock_object(ssl, 'create_default_context',
                      mock.Mock(side_effect=AttributeError))
     context = utils.create_ssl_context(configuration)
     self.assertIsNone(context)
Example #5
0
 def __init__(self, configuration, debug=True):
     super(XMLAPIConnector, self).__init__()
     self.storage_ip = configuration.emc_nas_server
     self.username = configuration.emc_nas_login
     self.password = configuration.emc_nas_password
     self.debug = debug
     self.auth_url = 'https://' + self.storage_ip + '/Login'
     self._url = 'https://{}/servlets/CelerraManagementServices'.format(
         self.storage_ip)
     context = enas_utils.create_ssl_context(configuration)
     if context:
         https_handler = url_request.HTTPSHandler(context=context)
     else:
         https_handler = url_request.HTTPSHandler()
     cookie_handler = url_request.HTTPCookieProcessor(
         http_cookiejar.CookieJar())
     self.url_opener = url_request.build_opener(https_handler,
                                                cookie_handler)
     self._do_setup()
Example #6
0
 def __init__(self, configuration, debug=True):
     super(XMLAPIConnector, self).__init__()
     self.storage_ip = enas_utils.convert_ipv6_format_if_needed(
         configuration.emc_nas_server)
     self.username = configuration.emc_nas_login
     self.password = configuration.emc_nas_password
     self.debug = debug
     self.auth_url = 'https://' + self.storage_ip + '/Login'
     self._url = 'https://{}/servlets/CelerraManagementServices'.format(
         self.storage_ip)
     context = enas_utils.create_ssl_context(configuration)
     if context:
         https_handler = url_request.HTTPSHandler(context=context)
     else:
         https_handler = url_request.HTTPSHandler()
     cookie_handler = url_request.HTTPCookieProcessor(
         http_cookiejar.CookieJar())
     self.url_opener = url_request.build_opener(https_handler,
                                                cookie_handler)
     self._do_setup()
Example #7
0
 def test_create_ssl_context_no_verify(self):
     configuration = mock.Mock()
     configuration.emc_ssl_cert_verify = False
     self.mock_object(ssl, 'create_default_context')
     context = utils.create_ssl_context(configuration)
     self.assertFalse(context.check_hostname)
Example #8
0
 def test_create_ssl_context_no_verify(self):
     configuration = mock.Mock()
     configuration.emc_ssl_cert_verify = False
     self.mock_object(ssl, 'create_default_context')
     context = utils.create_ssl_context(configuration)
     self.assertFalse(context.check_hostname)