Skip to content

Commit fb47ed9

Browse files
Upgrade: pywbem version to 0.17.6 (#11589)
1 parent 7090d75 commit fb47ed9

8 files changed

Lines changed: 418 additions & 19 deletions
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
diff --git a/minimum-constraints.txt b/minimum-constraints.txt
2+
index 570295ab..e771637b 100644
3+
--- a/minimum-constraints.txt
4+
+++ b/minimum-constraints.txt
5+
@@ -92,7 +92,6 @@ wheel==0.33.5; python_version >= '3.8'
6+
# Direct dependencies for install (must be consistent with requirements.txt)
7+
8+
M2Crypto==0.31.0
9+
-mock==2.0.0
10+
ordereddict==1.1
11+
ply==3.10
12+
PyYAML==3.11; python_version == '2.6'
13+
diff --git a/pywbem_mock/_wbemconnection_mock.py b/pywbem_mock/_wbemconnection_mock.py
14+
index aa27b305..3eedb330 100644
15+
--- a/pywbem_mock/_wbemconnection_mock.py
16+
+++ b/pywbem_mock/_wbemconnection_mock.py
17+
@@ -40,7 +40,7 @@ try:
18+
from collections import Counter
19+
except ImportError:
20+
from backport_collections import Counter
21+
-from mock import Mock
22+
+from unittest.mock import Mock
23+
import six
24+
25+
# pylint: disable=ungrouped-imports
26+
diff --git a/requirements.txt b/requirements.txt
27+
index 3ac782d5..1e5cd238 100644
28+
--- a/requirements.txt
29+
+++ b/requirements.txt
30+
@@ -11,9 +11,6 @@
31+
32+
# On Windows, M2Crypto must be installed via pywbem_os_setup.bat
33+
M2Crypto>=0.31.0; python_version < '3.0' and sys_platform != 'win32'
34+
-mock>=2.0.0,<3.0.0; python_version == '2.6'
35+
-mock>=2.0.0,<4.0.0; python_version >= '2.7' and python_version <= '3.5'
36+
-mock>=2.0.0; python_version >= '3.6'
37+
ordereddict>=1.1; python_version == '2.6'
38+
ply>=3.10
39+
# PyYAML 5.3 has removed support for Python 3.4; fixes narrow build error
40+
diff --git a/tests/unittest/pywbem/test_cim_obj.py b/tests/unittest/pywbem/test_cim_obj.py
41+
index 2f6b89d2..d3f8a9aa 100755
42+
--- a/tests/unittest/pywbem/test_cim_obj.py
43+
+++ b/tests/unittest/pywbem/test_cim_obj.py
44+
@@ -9,7 +9,7 @@ from __future__ import absolute_import, print_function
45+
import sys
46+
import re
47+
from datetime import timedelta, datetime
48+
-from mock import patch
49+
+from unittest.mock import patch
50+
try:
51+
from collections import OrderedDict
52+
except ImportError:
53+
diff --git a/tests/unittest/pywbem/test_itermethods.py b/tests/unittest/pywbem/test_itermethods.py
54+
index f7d0f8da..c613c3df 100644
55+
--- a/tests/unittest/pywbem/test_itermethods.py
56+
+++ b/tests/unittest/pywbem/test_itermethods.py
57+
@@ -24,7 +24,7 @@ from __future__ import absolute_import, print_function
58+
import pytest
59+
import six
60+
61+
-from mock import Mock
62+
+from unittest.mock import Mock
63+
64+
# pylint: disable=wrong-import-position, wrong-import-order, invalid-name
65+
from ...utils import import_installed
66+
diff --git a/tests/unittest/pywbem/test_valuemapping.py b/tests/unittest/pywbem/test_valuemapping.py
67+
index bf93b87c..263294a5 100644
68+
--- a/tests/unittest/pywbem/test_valuemapping.py
69+
+++ b/tests/unittest/pywbem/test_valuemapping.py
70+
@@ -7,7 +7,7 @@ from __future__ import absolute_import
71+
72+
import re
73+
import pytest
74+
-from mock import Mock
75+
+from unittest.mock import Mock
76+
77+
# pylint: disable=wrong-import-position, wrong-import-order, invalid-name
78+
from ...utils import import_installed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/pywbem/_recorder.py b/pywbem/_recorder.py
2+
index f5b2b7d6..70de34fe 100644
3+
--- a/pywbem/_recorder.py
4+
+++ b/pywbem/_recorder.py
5+
@@ -689,8 +689,8 @@ class LogOperationRecorder(BaseOperationRecorder):
6+
# Format the 'summary' and 'paths' detail_levels
7+
if self.api_detail_level == 'summary': # pylint: disable=R1705
8+
if isinstance(ret, list):
9+
- if ret:
10+
- ret_type = type(ret[0]).__name__ if ret else ""
11+
+ if len(ret) > 0:
12+
+ ret_type = type(ret[0]).__name__
13+
return _format("list of {0}; count={1}",
14+
ret_type, len(ret))
15+
return "Empty"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/pywbem/_cim_obj.py b/pywbem/_cim_obj.py
2+
index d91a2cb1..5c9a69a5 100644
3+
--- a/pywbem/_cim_obj.py
4+
+++ b/pywbem/_cim_obj.py
5+
@@ -1954,6 +1954,7 @@ class CIMInstanceName(_CIMComparisonMixin):
6+
_format("WBEM URI has an invalid format for its keybindings: "
7+
"{0!A}", keybindings_str))
8+
9+
+ kb_assigns = []
10+
if m.group(1):
11+
kb_assigns = [m.group(1)]
12+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/pywbem/_cim_xml.py b/pywbem/_cim_xml.py
2+
index 133b070d..c0ad603e 100644
3+
--- a/pywbem/_cim_xml.py
4+
+++ b/pywbem/_cim_xml.py
5+
@@ -1829,12 +1829,12 @@ class RESPONSEDESTINATION(CIMElement):
6+
7+
::
8+
9+
- <!ELEMENT RESPONSEDESTINATON (INSTANCE)>
10+
+ <!ELEMENT RESPONSEDESTINATION (INSTANCE)>
11+
"""
12+
13+
def __init__(self, data):
14+
# We use call by class name because it is an old-style class.
15+
- CIMElement.__init__(self, 'RESPONSEDESTINATON')
16+
+ CIMElement.__init__(self, 'RESPONSEDESTINATION')
17+
self.appendChild(data)
18+
19+
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
diff --git a/pywbem/_cim_http.py b/pywbem/_cim_http.py
2+
index b6080058..2779d7aa 100644
3+
--- a/pywbem/_cim_http.py
4+
+++ b/pywbem/_cim_http.py
5+
@@ -57,22 +57,12 @@ from ._utils import _ensure_unicode, _ensure_bytes, _format
6+
7+
_ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'
8+
9+
-if six.PY2 and not _ON_RTD: # RTD has no swig to install M2Crypto
10+
- # pylint: disable=wrong-import-order,wrong-import-position
11+
- from M2Crypto import SSL
12+
- from M2Crypto.Err import SSLError
13+
- from M2Crypto.m2 import OPENSSL_VERSION_TEXT as OPENSSL_VERSION
14+
- _HAVE_M2CRYPTO = True
15+
- # pylint: disable=invalid-name
16+
- SocketErrors = (socket.error, socket.sslerror)
17+
-else:
18+
- # pylint: disable=wrong-import-order,wrong-import-position
19+
- import ssl as SSL
20+
- from ssl import SSLError, CertificateError
21+
- from ssl import OPENSSL_VERSION
22+
- _HAVE_M2CRYPTO = False
23+
- # pylint: disable=invalid-name
24+
- SocketErrors = (socket.error,)
25+
+# pylint: disable=wrong-import-order
26+
+import ssl as SSL
27+
+from ssl import SSLError, CertificateError
28+
+from ssl import OPENSSL_VERSION
29+
+# pylint: disable=invalid-name
30+
+SocketErrors = (socket.error,)
31+
32+
__all__ = ['DEFAULT_CA_CERT_PATHS']
33+
34+
@@ -519,12 +509,25 @@ def wbem_request(url, data, creds, cimxml_headers=None, debug=False, x509=None,
35+
# Note: We do not use strict=True in the following call, because it
36+
# is not clear what side effects that would have, and if no status
37+
# line comes back we'll certainly find out about that.
38+
+ ssl_context = SSL.create_default_context(purpose=SSL.Purpose.SERVER_AUTH)
39+
+ ssl_context.check_hostname = False
40+
+
41+
+ if no_verification:
42+
+ ssl_context.verify_mode = SSL.CERT_NONE
43+
+
44+
+ if cert_file and key_file:
45+
+ ssl_context.load_cert_chain(cert_file, key_file)
46+
+
47+
+ if ca_certs:
48+
+ ssl_context.load_verify_locations(ca_certs)
49+
+
50+
+ # 3.12 removed key_file, cert_file, etc.
51+
httplib.HTTPSConnection.__init__(self, host=host, port=port,
52+
- key_file=key_file,
53+
- cert_file=cert_file,
54+
+ context=ssl_context,
55+
timeout=timeout)
56+
self.ca_certs = ca_certs
57+
self.verify_callback = verify_callback
58+
+ self.ctx = ssl_context
59+
# issue 297: Verify_callback is not used in py 3
60+
if verify_callback is not None and six.PY3:
61+
warnings.warn("The 'verify_callback' parameter was specified "
62+
@@ -534,137 +537,25 @@ def wbem_request(url, data, creds, cimxml_headers=None, debug=False, x509=None,
63+
def connect(self):
64+
# pylint: disable=too-many-branches
65+
"""Connect to a host on a given (SSL) port."""
66+
+ # set up the socket
67+
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
68+
+ sock.settimeout(self.timeout)
69+
70+
- # Connect for M2Crypto ssl package
71+
- if _HAVE_M2CRYPTO:
72+
- # Calling httplib.HTTPSConnection.connect(self) does not work
73+
- # because of its ssl.wrap_socket() call. So we copy the code of
74+
- # that connect() method modulo the ssl.wrap_socket() call.
75+
-
76+
- # Another change is that we do not pass the timeout value
77+
- # on to the socket call, because that does not work with
78+
- # M2Crypto.
79+
-
80+
- if sys.version_info[0:2] >= (2, 7):
81+
- # the source_address parameter was added in Python 2.7
82+
- self.sock = socket.create_connection(
83+
- (self.host, self.port), None, self.source_address)
84+
- else:
85+
- self.sock = socket.create_connection(
86+
- (self.host, self.port), None)
87+
-
88+
- # Removed code for tunneling support.
89+
-
90+
- # End of code from httplib.HTTPSConnection.connect(self).
91+
-
92+
- ctx = SSL.Context('sslv23')
93+
-
94+
- if self.cert_file:
95+
- ctx.load_cert(self.cert_file, keyfile=self.key_file)
96+
- if self.ca_certs:
97+
- ctx.set_verify(
98+
- SSL.verify_peer | SSL.verify_fail_if_no_peer_cert,
99+
- depth=9, callback=verify_callback)
100+
- # M2Crypto requires binary strings as path names and
101+
- # otherwise raises TypeError.
102+
- ca_certs = _ensure_bytes(self.ca_certs)
103+
- if os.path.isdir(self.ca_certs):
104+
- ctx.load_verify_locations(capath=ca_certs)
105+
- else:
106+
- ctx.load_verify_locations(cafile=ca_certs)
107+
- try:
108+
- self.sock = SSL.Connection(ctx, self.sock)
109+
-
110+
- # Below is a body of SSL.Connection.connect() method
111+
- # except for the first line (socket connection).
112+
-
113+
- # Removed code for tunneling support.
114+
-
115+
- # Setting the timeout on the input socket does not work
116+
- # with M2Crypto, with such a timeout set it calls a
117+
- # different low level function (nbio instead of bio)
118+
- # that does not work. The symptom is that reading the
119+
- # response returns None.
120+
- # Therefore, we set the timeout at the level of the outer
121+
- # M2Crypto socket object.
122+
- # pylint: disable=using-constant-test
123+
-
124+
- if self.timeout is not None:
125+
- self.sock.set_socket_read_timeout(
126+
- SSL.timeout(self.timeout))
127+
- self.sock.set_socket_write_timeout(
128+
- SSL.timeout(self.timeout))
129+
-
130+
- self.sock.addr = (self.host, self.port)
131+
- self.sock.setup_ssl()
132+
- self.sock.set_connect_state()
133+
- ret = self.sock.connect_ssl()
134+
- if self.ca_certs:
135+
- check = getattr(self.sock, 'postConnectionCheck',
136+
- self.sock.clientPostConnectionCheck)
137+
- if check is not None:
138+
- if not check(self.sock.get_peer_cert(), self.host):
139+
- raise ConnectionError(
140+
- 'SSL error: post connection check failed',
141+
- conn_id=conn_id)
142+
- return ret
143+
-
144+
- except (SSLError, SSL.SSLError,
145+
- SSL.Checker.SSLVerificationError) as arg:
146+
- raise ConnectionError(
147+
- _format("SSL error {0}: {1}; OpenSSL version: {2}",
148+
- arg.__class__, arg, OPENSSL_VERSION),
149+
- conn_id=conn_id)
150+
-
151+
- # Connect using Python SSL module
152+
- else:
153+
- # Setup the socket context
154+
-
155+
- # Note: PROTOCOL_SSLv23 allows talking to servers with TLS but
156+
- # not with SSL. For details, see the table in
157+
- # https://docs.python.org/3/library/ssl.html#ssl.wrap_socket
158+
- # Within the defined set of protocol versions, SSLv23 selects
159+
- # the highest protocol version that both client and server
160+
- # support.
161+
- # Issue #893: Consider the use of default_context()
162+
- ctx = SSL.SSLContext(SSL.PROTOCOL_SSLv23)
163+
-
164+
- if self.cert_file:
165+
- ctx.load_cert_chain(self.cert_file, keyfile=self.key_file)
166+
- if self.ca_certs:
167+
- # We need to use CERT_REQUIRED to require that the server
168+
- # certificate is being validated by the client (against the
169+
- # certificates in ca_certs).
170+
- ctx.verify_mode = SSL.CERT_REQUIRED
171+
- if os.path.isdir(self.ca_certs):
172+
- ctx.load_verify_locations(capath=self.ca_certs)
173+
- else:
174+
- ctx.load_verify_locations(cafile=self.ca_certs)
175+
- ctx.check_hostname = True
176+
- else:
177+
- ctx.check_hostname = False
178+
- ctx.verify_mode = SSL.CERT_NONE
179+
-
180+
- # setup the socket
181+
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
182+
- sock.settimeout(self.timeout)
183+
-
184+
- try:
185+
- self.sock = ctx.wrap_socket(sock,
186+
- server_hostname=self.host)
187+
- return self.sock.connect((self.host, self.port))
188+
+ try:
189+
+ self.sock = self.ctx.wrap_socket(sock)
190+
+ return self.sock.connect((self.host, self.port))
191+
192+
- except SSLError as arg:
193+
- raise ConnectionError(
194+
- _format("SSL error {0}: {1}; OpenSSL version: {2}",
195+
- arg.__class__, arg, OPENSSL_VERSION),
196+
- conn_id=conn_id)
197+
- except CertificateError as arg:
198+
- raise ConnectionError(
199+
- _format("SSL certificate error {0}: {1}; "
200+
- "OpenSSL version: {2}",
201+
- arg.__class__, arg, OPENSSL_VERSION),
202+
- conn_id=conn_id)
203+
+ except SSLError as arg:
204+
+ raise ConnectionError(
205+
+ _format("SSL error {0}: {1}; OpenSSL version: {2}",
206+
+ arg.__class__, arg, OPENSSL_VERSION),
207+
+ conn_id=conn_id)
208+
+ except CertificateError as arg:
209+
+ raise ConnectionError(
210+
+ _format("SSL certificate error {0}: {1}; "
211+
+ "OpenSSL version: {2}",
212+
+ arg.__class__, arg, OPENSSL_VERSION),
213+
+ conn_id=conn_id)
214+
215+
class FileHTTPConnection(HTTPBaseConnection, httplib.HTTPConnection):
216+
"""Execute client connection based on a unix domain socket. """
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"Signatures": {
3-
"pywbem-0.15.0.tar.gz": "6a08ae720bb6b3f6f4eaa69e6505037e8ca4031aee3ae5560be310591fe44a28"
3+
"pywbem-0.17.6.tar.gz": "a36404f6f95f8c88bf996e183c7b6121e2046cb19df894f0ea2601b50006a70d"
44
}
5-
}
5+
}

0 commit comments

Comments
 (0)