"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/unit/common/middleware/crypto/test_kmip_keymaster.py" between
swift-2.19.0.tar.gz and swift-2.19.1.tar.gz

About: OpenStack swift is software for creating redundant, scalable object storage using clusters of commodity servers to store terabytes or even petabytes of accessible data (now supporting storage policies).
The "Rocky" series (latest release).

test_kmip_keymaster.py  (swift-2.19.0):test_kmip_keymaster.py  (swift-2.19.1)
skipping to change at line 17 skipping to change at line 17
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. # implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging
import mock import mock
import os import os
import unittest import unittest
from tempfile import mkdtemp from tempfile import mkdtemp
from textwrap import dedent from textwrap import dedent
from shutil import rmtree from shutil import rmtree
import sys import sys
sys.modules['kmip'] = mock.Mock() sys.modules['kmip'] = mock.Mock()
sys.modules['kmip.pie'] = mock.Mock() sys.modules['kmip.pie'] = mock.Mock()
sys.modules['kmip.pie.client'] = mock.Mock() sys.modules['kmip.pie.client'] = mock.Mock()
skipping to change at line 61 skipping to change at line 62
value=value) value=value)
return secret return secret
def create_mock_client(secrets, calls): def create_mock_client(secrets, calls):
def mock_client(*args, **kwargs): def mock_client(*args, **kwargs):
if args: if args:
raise Exception('unexpected args provided: %r' % (args,)) raise Exception('unexpected args provided: %r' % (args,))
return MockProxyKmipClient(secrets, calls, kwargs) return MockProxyKmipClient(secrets, calls, kwargs)
return mock_client return mock_client
class InMemoryHandler(logging.Handler):
def __init__(self):
self.messages = []
super(InMemoryHandler, self).__init__()
def handle(self, record):
self.messages.append(record.msg)
class TestKmipKeymaster(unittest.TestCase): class TestKmipKeymaster(unittest.TestCase):
def setUp(self): def setUp(self):
self.tempdir = mkdtemp() self.tempdir = mkdtemp()
def tearDown(self): def tearDown(self):
rmtree(self.tempdir) rmtree(self.tempdir)
def test_config_in_filter_section(self): def test_config_in_filter_section(self):
conf = {'__file__': '/etc/swift/proxy-server.conf', conf = {'__file__': '/etc/swift/proxy-server.conf',
skipping to change at line 267 skipping to change at line 276
('__init__', {'config_file': '/etc/swift/proxy-server.conf', ('__init__', {'config_file': '/etc/swift/proxy-server.conf',
'config': 'filter:kmip_keymaster'}), 'config': 'filter:kmip_keymaster'}),
('get', '1234')]) ('get', '1234')])
def test_missing_key_id(self): def test_missing_key_id(self):
conf = {'__file__': '/etc/swift/proxy-server.conf', conf = {'__file__': '/etc/swift/proxy-server.conf',
'__name__': 'filter:kmip_keymaster'} '__name__': 'filter:kmip_keymaster'}
with self.assertRaises(ValueError) as cm: with self.assertRaises(ValueError) as cm:
KmipKeyMaster(None, conf) KmipKeyMaster(None, conf)
self.assertIn('key_id option is required', str(cm.exception)) self.assertIn('key_id option is required', str(cm.exception))
def test_logger_manipulations(self):
root_logger = logging.getLogger()
old_level = root_logger.getEffectiveLevel()
handler = InMemoryHandler()
try:
root_logger.setLevel(logging.DEBUG)
root_logger.addHandler(handler)
conf = {'__file__': '/etc/swift/proxy-server.conf',
'__name__': 'kmip_keymaster'}
with self.assertRaises(ValueError):
# missing key_id, as above, but that's not the interesting bit
KmipKeyMaster(None, conf)
self.assertEqual(handler.messages, [])
logger = logging.getLogger('kmip.services.server.kmip_protocol')
logger.debug('Something secret!')
logger.info('Something useful')
self.assertNotIn('Something secret!', handler.messages)
self.assertIn('Something useful', handler.messages)
logger = logging.getLogger('kmip.core.config_helper')
logger.debug('Also secret')
logger.warning('Also useful')
self.assertNotIn('Also secret', handler.messages)
self.assertIn('Also useful', handler.messages)
logger = logging.getLogger('kmip')
logger.debug('Boring, but not secret')
self.assertIn('Boring, but not secret', handler.messages)
finally:
root_logger.setLevel(old_level)
root_logger.removeHandler(handler)
 End of changes. 3 change blocks. 
0 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)