X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_common%2Ftests%2Ftest_dbbase.py;h=ca1336d20d6264aafd5197b49b3c3d1d4a338144;hb=refs%2Fchanges%2F13%2F8613%2F2;hp=3a8861de3dbcd328080116b5332c4f6c99ae6a77;hpb=eef7cb7a4f704bf0d29e6d8ece5195dc3faabb69;p=osm%2Fcommon.git diff --git a/osm_common/tests/test_dbbase.py b/osm_common/tests/test_dbbase.py index 3a8861d..ca1336d 100644 --- a/osm_common/tests/test_dbbase.py +++ b/osm_common/tests/test_dbbase.py @@ -1,8 +1,28 @@ +# Copyright 2018 Whitestack, LLC +# Copyright 2018 Telefonica S.A. +# +# 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. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact: esousa@whitestack.com or alfonso.tiernosepulveda@telefonica.com +## + import http import pytest import unittest from osm_common.dbbase import DbBase, DbException, deep_update from os import urandom +from http import HTTPStatus def exception_message(message): @@ -118,6 +138,13 @@ class TestEncryption(unittest.TestCase): for j in range(i+1, len(encrypted)): self.assertNotEqual(encrypted[i], encrypted[j], "encryption with different salt must contain different result") + # decrypt with a different master key + try: + decrypted = self.db_bases[-1].decrypt(encrypted[0], schema_version='1.1', salt=None) + self.assertNotEqual(encrypted[0], decrypted, "Decryption with different KEY must generate different result") + except DbException as e: + self.assertEqual(e.http_code, HTTPStatus.INTERNAL_SERVER_ERROR, + "Decryption with different KEY does not provide expected http_code") class TestDeepUpdate(unittest.TestCase):