X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_common%2Ftests%2Ftest_dbbase.py;h=1abd1c7a1a1a8824785ca302797093694f702cbd;hb=4ce854c2cfcdddf4d049ee312182c65832b3f5d4;hp=33b8782f2b6fcb8aaf2801395cab62071c6a24d3;hpb=a011781b5b422a023bc0b7c4955cf438a1f05839;p=osm%2Fcommon.git diff --git a/osm_common/tests/test_dbbase.py b/osm_common/tests/test_dbbase.py index 33b8782..1abd1c7 100644 --- a/osm_common/tests/test_dbbase.py +++ b/osm_common/tests/test_dbbase.py @@ -22,6 +22,7 @@ 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): @@ -70,6 +71,13 @@ def test_create(db_base): assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND +def test_create_list(db_base): + with pytest.raises(DbException) as excinfo: + db_base.create_list(None, None) + assert str(excinfo.value).startswith(exception_message("Method 'create_list' not implemented")) + assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND + + def test_del_list(db_base): with pytest.raises(DbException) as excinfo: db_base.del_list(None, None) @@ -137,6 +145,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):