test_image.py (ec2-api-14.0.1) | : | test_image.py (ec2-api-15.0.0) | ||
---|---|---|---|---|
skipping to change at line 18 | skipping to change at line 18 | |||
# | # | |||
# 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 implied. | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 os | import os | |||
from unittest import mock | from unittest import mock | |||
import six | ||||
import tempfile | import tempfile | |||
from cinderclient import exceptions as cinder_exception | from cinderclient import exceptions as cinder_exception | |||
import eventlet | import eventlet | |||
from oslo_concurrency import processutils | from oslo_concurrency import processutils | |||
from oslo_serialization import jsonutils | from oslo_serialization import jsonutils | |||
from ec2api.api import image as image_api | from ec2api.api import image as image_api | |||
from ec2api import exception | from ec2api import exception | |||
from ec2api.tests.unit import base | from ec2api.tests.unit import base | |||
skipping to change at line 970 | skipping to change at line 969 | |||
private_key = os.path.join(os.path.dirname(__file__), | private_key = os.path.join(os.path.dirname(__file__), | |||
'test_private_key.pem') | 'test_private_key.pem') | |||
subject = "/C=RU/ST=Moscow/L=Moscow/O=Progmatic/CN=RootCA" | subject = "/C=RU/ST=Moscow/L=Moscow/O=Progmatic/CN=RootCA" | |||
certificate_file = processutils.execute('openssl', | certificate_file = processutils.execute('openssl', | |||
'req', '-x509', '-new', | 'req', '-x509', '-new', | |||
'-key', private_key, | '-key', private_key, | |||
'-days', '365', | '-days', '365', | |||
'-out', public_key, | '-out', public_key, | |||
'-subj', subject) | '-subj', subject) | |||
text = "some @#!%^* test text" | text = "some @#!%^* test text" | |||
process_input = text.encode("ascii") if six.PY3 else text | process_input = text.encode("ascii") | |||
enc, _err = processutils.execute('openssl', | enc, _err = processutils.execute('openssl', | |||
'rsautl', | 'rsautl', | |||
'-certin', | '-certin', | |||
'-encrypt', | '-encrypt', | |||
'-inkey', public_key, | '-inkey', public_key, | |||
process_input=process_input, | process_input=process_input, | |||
binary=True) | binary=True) | |||
self.assertRaises(exception.EC2Exception, image_api._decrypt_text, enc) | self.assertRaises(exception.EC2Exception, image_api._decrypt_text, enc) | |||
self.configure(x509_root_private_key=private_key) | self.configure(x509_root_private_key=private_key) | |||
dec = image_api._decrypt_text(enc) | dec = image_api._decrypt_text(enc) | |||
self.assertIsInstance(dec, bytes) | self.assertIsInstance(dec, bytes) | |||
if six.PY3: | dec = dec.decode('ascii') | |||
dec = dec.decode('ascii') | ||||
self.assertEqual(text, dec) | self.assertEqual(text, dec) | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 2 lines changed or added |