
Python 3.6/3.7 are no longer supported for the latest releasese of the OpenStack packages like oslo or coverage, thus switching to the Zed OpenStack release gates, which have support for 3.8/3.9/3.10 Python versions. For gates to pass, the docs required a defined language to be set ("en"), while the crypto unit tests required a method signature fix when running on Python 3.9/3.10. The version test__check_latest_version* unit tests started failing in a transient pattern because of the pbr.version.VersionInfo().release_string() throwing the following error: "NotImplementedError: cannot instantiate 'WindowsPath' on your system". This required to have the cloudbaseinit.version.get_version mocked for a reliable unit test run on Linux. Change-Id: I4748d1258c072c377825474e1116347b0a085c56
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
# Copyright 2016 Cloudbase Solutions Srl
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import unittest
|
|
|
|
from cloudbaseinit.utils import crypt
|
|
|
|
|
|
class TestOpenSSLException(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
self._openssl = crypt.OpenSSLException()
|
|
|
|
def test_get_openssl_error_msg(self):
|
|
expected_err_msg = u'error:00000000:lib(0):func(0):reason(0)'
|
|
expected_err_msg_py10 = u'error:00000000:lib(0)::reason(0)'
|
|
err_msg = self._openssl._get_openssl_error_msg()
|
|
self.assertIn(err_msg, [expected_err_msg, expected_err_msg_py10])
|
|
|
|
|
|
class TestCryptManager(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
self._crypt_manager = crypt.CryptManager()
|
|
|
|
def test_load_ssh_rsa_public_key_invalid(self):
|
|
ssh_pub_key = "ssh"
|
|
exc = Exception
|
|
self.assertRaises(exc, self._crypt_manager.load_ssh_rsa_public_key,
|
|
ssh_pub_key)
|