Fixes Bug 1273 - aiokafka>0.7.0 needs extra dependency for python < 3.7.0
[osm/common.git] / osm_common / tests / test_dbbase.py
index 33b8782..1abd1c7 100644 (file)
@@ -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):