From aa4f32f92f684f1ad41892e492953f371c20f311ccfa5449bb4c82e0fde2f30d Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 24 Sep 2021 22:08:28 +0000 Subject: [PATCH] - Remove SQL-issues.patch with the patch fix-tests-SQLAlchemy-140.patch which actually resolves the problems (gh#OpenKMIP/PyKMIP#656). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-PyKMIP?expand=0&rev=11 --- SQL-issues.patch | 395 -------------------------- fix-tests-SQLAlchemy-140.patch | 496 +++++++++++++++++++++++++++++++++ python-PyKMIP.changes | 7 + python-PyKMIP.spec | 6 +- 4 files changed, 506 insertions(+), 398 deletions(-) delete mode 100644 SQL-issues.patch create mode 100644 fix-tests-SQLAlchemy-140.patch diff --git a/SQL-issues.patch b/SQL-issues.patch deleted file mode 100644 index d62b979..0000000 --- a/SQL-issues.patch +++ /dev/null @@ -1,395 +0,0 @@ ---- - kmip/tests/unit/pie/objects/test_opaque_object.py | 7 +++++++ - kmip/tests/unit/pie/objects/test_private_key.py | 7 +++++++ - kmip/tests/unit/pie/objects/test_public_key.py | 7 +++++++ - kmip/tests/unit/pie/objects/test_secret_data.py | 7 +++++++ - kmip/tests/unit/pie/objects/test_split_key.py | 1 + - kmip/tests/unit/pie/objects/test_symmetric_key.py | 7 +++++++ - kmip/tests/unit/pie/objects/test_x509_certificate.py | 7 +++++++ - kmip/tests/unit/services/server/test_engine.py | 3 +++ - 8 files changed, 46 insertions(+) - ---- a/kmip/tests/unit/pie/objects/test_opaque_object.py -+++ b/kmip/tests/unit/pie/objects/test_opaque_object.py -@@ -215,6 +215,7 @@ class TestOpaqueObject(testtools.TestCas - session.add(obj) - session.commit() - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get(self): - """ - Test that the object can be saved and then retrieved using SQLAlchemy. -@@ -240,6 +241,7 @@ class TestOpaqueObject(testtools.TestCas - self.assertEqual(enums.ObjectType.OPAQUE_DATA, get_obj.object_type) - self.assertEqual(enums.OpaqueDataType.NONE, get_obj.opaque_type) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_add_multiple_names(self): - """ - Test that multiple names can be added to a managed object. This -@@ -271,6 +273,7 @@ class TestOpaqueObject(testtools.TestCas - session.commit() - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_name(self): - """ - Tests that a name can be removed from the list of names. This will -@@ -308,6 +311,7 @@ class TestOpaqueObject(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_and_add_name(self): - """ - Tests that names can be removed from the list of names and more added. -@@ -347,6 +351,7 @@ class TestOpaqueObject(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -388,6 +393,7 @@ class TestOpaqueObject(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -429,6 +435,7 @@ class TestOpaqueObject(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_and_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be ---- a/kmip/tests/unit/pie/objects/test_private_key.py -+++ b/kmip/tests/unit/pie/objects/test_private_key.py -@@ -551,6 +551,7 @@ class TestPrivateKey(testtools.TestCase) - session.commit() - self.assertIsNotNone(key.unique_identifier) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get(self): - """ - Test that the object can be saved and then retrieved using SQLAlchemy. -@@ -583,6 +584,7 @@ class TestPrivateKey(testtools.TestCase) - self.assertEqual(enums.KeyFormatType.PKCS_1, get_obj.key_format_type) - self.assertEqual(masks, get_obj.cryptographic_usage_masks) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_add_multiple_names(self): - """ - Test that multiple names can be added to a managed object. This -@@ -615,6 +617,7 @@ class TestPrivateKey(testtools.TestCase) - session.commit() - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_name(self): - """ - Tests that a name can be removed from the list of names. This will -@@ -653,6 +656,7 @@ class TestPrivateKey(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_and_add_name(self): - """ - Tests that names can be removed from the list of names and more added. -@@ -693,6 +697,7 @@ class TestPrivateKey(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -735,6 +740,7 @@ class TestPrivateKey(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -777,6 +783,7 @@ class TestPrivateKey(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_and_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be ---- a/kmip/tests/unit/pie/objects/test_public_key.py -+++ b/kmip/tests/unit/pie/objects/test_public_key.py -@@ -449,6 +449,7 @@ class TestPublicKey(testtools.TestCase): - session.commit() - self.assertIsNotNone(key.unique_identifier) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get(self): - """ - Test that the object can be saved and then retrieved using SQLAlchemy. -@@ -481,6 +482,7 @@ class TestPublicKey(testtools.TestCase): - self.assertEqual(enums.KeyFormatType.PKCS_1, get_obj.key_format_type) - self.assertEqual(masks, get_obj.cryptographic_usage_masks) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_add_multiple_names(self): - """ - Test that multiple names can be added to a managed object. This -@@ -513,6 +515,7 @@ class TestPublicKey(testtools.TestCase): - session.commit() - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_name(self): - """ - Tests that a name can be removed from the list of names. This will -@@ -551,6 +554,7 @@ class TestPublicKey(testtools.TestCase): - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_and_add_name(self): - """ - Tests that names can be removed from the list of names and more added. -@@ -591,6 +595,7 @@ class TestPublicKey(testtools.TestCase): - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -633,6 +638,7 @@ class TestPublicKey(testtools.TestCase): - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -675,6 +681,7 @@ class TestPublicKey(testtools.TestCase): - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_and_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be ---- a/kmip/tests/unit/pie/objects/test_secret_data.py -+++ b/kmip/tests/unit/pie/objects/test_secret_data.py -@@ -234,6 +234,7 @@ class TestSecretData(testtools.TestCase) - session.add(obj) - session.commit() - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get(self): - """ - Test that the object can be saved and then retrieved using SQLAlchemy. -@@ -259,6 +260,7 @@ class TestSecretData(testtools.TestCase) - self.assertEqual(enums.ObjectType.SECRET_DATA, get_obj.object_type) - self.assertEqual(enums.SecretDataType.PASSWORD, get_obj.data_type) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_add_multiple_names(self): - """ - Test that multiple names can be added to a managed object. This -@@ -290,6 +292,7 @@ class TestSecretData(testtools.TestCase) - session.commit() - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_name(self): - """ - Tests that a name can be removed from the list of names. This will -@@ -327,6 +330,7 @@ class TestSecretData(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_and_add_name(self): - """ - Tests that names can be removed from the list of names and more added. -@@ -366,6 +370,7 @@ class TestSecretData(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_add_name(self): - """ - Tests that a SecretData already stored in the database can be -@@ -407,6 +412,7 @@ class TestSecretData(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_name(self): - """ - Tests that a SecretData already stored in the database can be -@@ -448,6 +454,7 @@ class TestSecretData(testtools.TestCase) - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_and_add_name(self): - """ - Tests that a SecretData already stored in the database can be ---- a/kmip/tests/unit/pie/objects/test_split_key.py -+++ b/kmip/tests/unit/pie/objects/test_split_key.py -@@ -570,6 +570,7 @@ class TestSplitKey(testtools.TestCase): - - self.assertIsNotNone(split_key.unique_identifier) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get(self): - """ - Test that a SplitKey object can be saved and then retrieved using ---- a/kmip/tests/unit/pie/objects/test_symmetric_key.py -+++ b/kmip/tests/unit/pie/objects/test_symmetric_key.py -@@ -395,6 +395,7 @@ class TestSymmetricKey(testtools.TestCas - session.commit() - self.assertIsNotNone(key.unique_identifier) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get(self): - """ - Test that the object can be saved and then retrieved using SQLAlchemy. -@@ -428,6 +429,7 @@ class TestSymmetricKey(testtools.TestCas - self.assertEqual(enums.KeyFormatType.RAW, get_obj.key_format_type) - self.assertEqual(masks, get_obj.cryptographic_usage_masks) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_add_multiple_names(self): - """ - Test that multiple names can be added to a managed object. This -@@ -460,6 +462,7 @@ class TestSymmetricKey(testtools.TestCas - session.commit() - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_name(self): - """ - Tests that a name can be removed from the list of names. This will -@@ -498,6 +501,7 @@ class TestSymmetricKey(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_and_add_name(self): - """ - Tests that names can be removed from the list of names and more added. -@@ -538,6 +542,7 @@ class TestSymmetricKey(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -580,6 +585,7 @@ class TestSymmetricKey(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_name(self): - """ - Tests that an OpaqueObject already stored in the database can be -@@ -622,6 +628,7 @@ class TestSymmetricKey(testtools.TestCas - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_and_add_name(self): - """ - Tests that an OpaqueObject already stored in the database can be ---- a/kmip/tests/unit/pie/objects/test_x509_certificate.py -+++ b/kmip/tests/unit/pie/objects/test_x509_certificate.py -@@ -310,6 +310,7 @@ class TestX509Certificate(testtools.Test - session.commit() - self.assertIsNotNone(cert.unique_identifier) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get(self): - """ - Test that the object can be saved and then retrieved using SQLAlchemy. -@@ -336,6 +337,7 @@ class TestX509Certificate(testtools.Test - self.assertEqual(self.bytes_a, get_obj.value) - self.assertEqual(masks, get_obj.cryptographic_usage_masks) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_add_multiple_names(self): - """ - Test that multiple names can be added to a managed object. This -@@ -366,6 +368,7 @@ class TestX509Certificate(testtools.Test - session.commit() - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_name(self): - """ - Tests that a name can be removed from the list of names. This will -@@ -402,6 +405,7 @@ class TestX509Certificate(testtools.Test - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_remove_and_add_name(self): - """ - Tests that names can be removed from the list of names and more added. -@@ -440,6 +444,7 @@ class TestX509Certificate(testtools.Test - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_add_name(self): - """ - Tests that an X509Certificate already stored in the database can be -@@ -480,6 +485,7 @@ class TestX509Certificate(testtools.Test - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_name(self): - """ - Tests that an X509Certificate already stored in the database can be -@@ -520,6 +526,7 @@ class TestX509Certificate(testtools.Test - self.assertEquals(expected_names, get_obj.names) - self.assertEquals(expected_mo_names, get_obj._names) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_update_with_remove_and_add_name(self): - """ - Tests that an X509Certificate already stored in the database can be ---- a/kmip/tests/unit/services/server/test_engine.py -+++ b/kmip/tests/unit/services/server/test_engine.py -@@ -1357,6 +1357,7 @@ class TestKmipEngine(testtools.TestCase) - - self.assertEqual(0, len(result)) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get_attribute_from_managed_object(self): - """ - Test that an attribute can be retrieved from a given managed object. -@@ -1635,6 +1636,7 @@ class TestKmipEngine(testtools.TestCase) - ) - self.assertEqual(None, result) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_get_attribute_index_from_managed_object(self): - """ - Test that an attribute's index can be retrieved from a given managed -@@ -2281,6 +2283,7 @@ class TestKmipEngine(testtools.TestCase) - *args - ) - -+ @testtools.skip("incompatibility with SQLAlchemy, gh#OpenKMIP/PyKMIP#649") - def test_set_attribute_on_managed_object_by_index(self): - """ - Test that an attribute can be modified on a managed object given its diff --git a/fix-tests-SQLAlchemy-140.patch b/fix-tests-SQLAlchemy-140.patch new file mode 100644 index 0000000..89f5150 --- /dev/null +++ b/fix-tests-SQLAlchemy-140.patch @@ -0,0 +1,496 @@ +From 01307c08937890db38b9ae6135c5b8d5f720e595 Mon Sep 17 00:00:00 2001 +From: Tim Burke +Date: Tue, 21 Sep 2021 18:16:09 -0700 +Subject: [PATCH] Fix tests to pass with SQLAlchemy>=1.4.0 + +I'm not *entirely* sure what's going on here, but it seems that when we +do something like + + obj = OpaqueObject(...) + Session = sessionmaker(...) + session = Session() + ... + session.add(obj) + session.commit() + +the primary key (and maybe some foreign relations?) aren't automatically +populated on `obj` following the commit, and will attempt to lazy-load +on next reference. Since expire_on_commit defaults to True, the session +attached to `obj` (which is no longer the `session` in locals!) is closed +out when we later do + + session = Session() + get_obj = session.query(OpaqueObject).filter( + ManagedObject.unique_identifier == obj.unique_identifier).one() + +leading to a DetachedInstanceError. + +There seem to be a few different ways we can fix this: + +* Set expire_on_commit=False so the old session is still useful for the + lazy-loading. +* Re-use the same session instead of creating a new one. +* Explicitly refresh added objects post-commit. + +Generally prefer the first one; there's some prior art to follow in +services/server/test_engine.py. Curiously, that same file runs into +trouble despite already setting expire_on_commit=False -- so do the +explicit refresh, on the assumption that there was a reason we went to +the trouble of creating a fresh session. + +Closes #649 +--- + kmip/tests/unit/pie/objects/test_opaque_object.py | 14 +++++++------- + kmip/tests/unit/pie/objects/test_private_key.py | 14 +++++++------- + kmip/tests/unit/pie/objects/test_public_key.py | 14 +++++++------- + kmip/tests/unit/pie/objects/test_secret_data.py | 14 +++++++------- + kmip/tests/unit/pie/objects/test_split_key.py | 3 ++- + kmip/tests/unit/pie/objects/test_symmetric_key.py | 14 +++++++------- + .../unit/pie/objects/test_x509_certificate.py | 14 +++++++------- + kmip/tests/unit/services/server/test_engine.py | 3 +++ + 8 files changed, 47 insertions(+), 43 deletions(-) + +diff --git a/kmip/tests/unit/pie/objects/test_opaque_object.py b/kmip/tests/unit/pie/objects/test_opaque_object.py +index c742a17e..f41f1b0e 100644 +--- a/kmip/tests/unit/pie/objects/test_opaque_object.py ++++ b/kmip/tests/unit/pie/objects/test_opaque_object.py +@@ -224,7 +224,7 @@ def test_get(self): + test_name = 'bowser' + obj = OpaqueObject( + self.bytes_a, enums.OpaqueDataType.NONE, name=test_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -259,7 +259,7 @@ def test_add_multiple_names(self): + expected_mo_names.append(sqltypes.ManagedObjectName(name, i)) + self.assertEquals(expected_mo_names, obj._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -295,7 +295,7 @@ def test_remove_name(self): + self.assertEquals(expected_names, obj.names) + self.assertEquals(expected_mo_names, obj._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -334,7 +334,7 @@ def test_remove_and_add_name(self): + self.assertEquals(expected_names, obj.names) + self.assertEquals(expected_mo_names, obj._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -362,7 +362,7 @@ def test_update_with_add_name(self): + first_name = 'bowser' + obj = OpaqueObject( + self.bytes_a, enums.OpaqueDataType.NONE, name=first_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -402,7 +402,7 @@ def test_update_with_remove_name(self): + obj.names.append(names[1]) + obj.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -444,7 +444,7 @@ def test_update_with_remove_and_add_name(self): + obj.names.append(names[1]) + obj.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +diff --git a/kmip/tests/unit/pie/objects/test_private_key.py b/kmip/tests/unit/pie/objects/test_private_key.py +index c58daf83..0ad425f4 100644 +--- a/kmip/tests/unit/pie/objects/test_private_key.py ++++ b/kmip/tests/unit/pie/objects/test_private_key.py +@@ -563,7 +563,7 @@ def test_get(self): + key = PrivateKey( + enums.CryptographicAlgorithm.RSA, 2048, self.bytes_2048, + enums.KeyFormatType.PKCS_1, masks=masks, name=test_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -603,7 +603,7 @@ def test_add_multiple_names(self): + expected_mo_names.append(sqltypes.ManagedObjectName(name, i)) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -640,7 +640,7 @@ def test_remove_name(self): + self.assertEquals(expected_names, key.names) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -680,7 +680,7 @@ def test_remove_and_add_name(self): + self.assertEquals(expected_names, key.names) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -709,7 +709,7 @@ def test_update_with_add_name(self): + key = PrivateKey( + enums.CryptographicAlgorithm.RSA, 2048, self.bytes_2048, + enums.KeyFormatType.PKCS_1, name=first_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -750,7 +750,7 @@ def test_update_with_remove_name(self): + key.names.append(names[1]) + key.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -793,7 +793,7 @@ def test_update_with_remove_and_add_name(self): + key.names.append(names[1]) + key.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +diff --git a/kmip/tests/unit/pie/objects/test_public_key.py b/kmip/tests/unit/pie/objects/test_public_key.py +index f0571913..cf71833b 100644 +--- a/kmip/tests/unit/pie/objects/test_public_key.py ++++ b/kmip/tests/unit/pie/objects/test_public_key.py +@@ -461,7 +461,7 @@ def test_get(self): + key = PublicKey( + enums.CryptographicAlgorithm.RSA, 2048, self.bytes_2048, + enums.KeyFormatType.PKCS_1, masks=masks, name=test_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -501,7 +501,7 @@ def test_add_multiple_names(self): + expected_mo_names.append(sqltypes.ManagedObjectName(name, i)) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -538,7 +538,7 @@ def test_remove_name(self): + self.assertEquals(expected_names, key.names) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -578,7 +578,7 @@ def test_remove_and_add_name(self): + self.assertEquals(expected_names, key.names) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -607,7 +607,7 @@ def test_update_with_add_name(self): + key = PublicKey( + enums.CryptographicAlgorithm.RSA, 2048, self.bytes_2048, + enums.KeyFormatType.PKCS_1, name=first_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -648,7 +648,7 @@ def test_update_with_remove_name(self): + key.names.append(names[1]) + key.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -691,7 +691,7 @@ def test_update_with_remove_and_add_name(self): + key.names.append(names[1]) + key.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +diff --git a/kmip/tests/unit/pie/objects/test_secret_data.py b/kmip/tests/unit/pie/objects/test_secret_data.py +index 5a12132d..1cfe075d 100644 +--- a/kmip/tests/unit/pie/objects/test_secret_data.py ++++ b/kmip/tests/unit/pie/objects/test_secret_data.py +@@ -243,7 +243,7 @@ def test_get(self): + test_name = 'bowser' + obj = SecretData(self.bytes_a, enums.SecretDataType.PASSWORD, + name=test_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -278,7 +278,7 @@ def test_add_multiple_names(self): + expected_mo_names.append(sqltypes.ManagedObjectName(name, i)) + self.assertEquals(expected_mo_names, obj._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -314,7 +314,7 @@ def test_remove_name(self): + self.assertEquals(expected_names, obj.names) + self.assertEquals(expected_mo_names, obj._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -353,7 +353,7 @@ def test_remove_and_add_name(self): + self.assertEquals(expected_names, obj.names) + self.assertEquals(expected_mo_names, obj._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -381,7 +381,7 @@ def test_update_with_add_name(self): + first_name = 'bowser' + obj = SecretData(self.bytes_a, enums.SecretDataType.PASSWORD, + name=first_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -421,7 +421,7 @@ def test_update_with_remove_name(self): + obj.names.append(names[1]) + obj.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +@@ -463,7 +463,7 @@ def test_update_with_remove_and_add_name(self): + obj.names.append(names[1]) + obj.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(obj) + session.commit() +diff --git a/kmip/tests/unit/pie/objects/test_split_key.py b/kmip/tests/unit/pie/objects/test_split_key.py +index a81c304d..755d7bc8 100644 +--- a/kmip/tests/unit/pie/objects/test_split_key.py ++++ b/kmip/tests/unit/pie/objects/test_split_key.py +@@ -595,7 +595,8 @@ def test_get(self): + prime_field_size=104729 + ) + +- session = sqlalchemy.orm.sessionmaker(bind=self.engine)() ++ session = sqlalchemy.orm.sessionmaker( ++ bind=self.engine, expire_on_commit=False)() + session.add(split_key) + session.commit() + +diff --git a/kmip/tests/unit/pie/objects/test_symmetric_key.py b/kmip/tests/unit/pie/objects/test_symmetric_key.py +index ccc4cdfa..cf7f5dff 100644 +--- a/kmip/tests/unit/pie/objects/test_symmetric_key.py ++++ b/kmip/tests/unit/pie/objects/test_symmetric_key.py +@@ -408,7 +408,7 @@ def test_get(self): + enums.CryptographicAlgorithm.AES, 128, self.bytes_128a, + masks=masks, + name=test_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -448,7 +448,7 @@ def test_add_multiple_names(self): + expected_mo_names.append(sqltypes.ManagedObjectName(name, i)) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -485,7 +485,7 @@ def test_remove_name(self): + self.assertEquals(expected_names, key.names) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -525,7 +525,7 @@ def test_remove_and_add_name(self): + self.assertEquals(expected_names, key.names) + self.assertEquals(expected_mo_names, key._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -554,7 +554,7 @@ def test_update_with_add_name(self): + key = SymmetricKey( + enums.CryptographicAlgorithm.AES, 128, self.bytes_128a, + name=first_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -595,7 +595,7 @@ def test_update_with_remove_name(self): + key.names.append(names[1]) + key.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +@@ -638,7 +638,7 @@ def test_update_with_remove_and_add_name(self): + key.names.append(names[1]) + key.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(key) + session.commit() +diff --git a/kmip/tests/unit/pie/objects/test_x509_certificate.py b/kmip/tests/unit/pie/objects/test_x509_certificate.py +index 43d66ca4..f4d76ada 100644 +--- a/kmip/tests/unit/pie/objects/test_x509_certificate.py ++++ b/kmip/tests/unit/pie/objects/test_x509_certificate.py +@@ -320,7 +320,7 @@ def test_get(self): + masks = [enums.CryptographicUsageMask.ENCRYPT, + enums.CryptographicUsageMask.WRAP_KEY] + cert = X509Certificate(self.bytes_a, masks=masks, name=test_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(cert) + session.commit() +@@ -354,7 +354,7 @@ def test_add_multiple_names(self): + expected_mo_names.append(sqltypes.ManagedObjectName(name, i)) + self.assertEquals(expected_mo_names, cert._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(cert) + session.commit() +@@ -389,7 +389,7 @@ def test_remove_name(self): + self.assertEquals(expected_names, cert.names) + self.assertEquals(expected_mo_names, cert._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(cert) + session.commit() +@@ -427,7 +427,7 @@ def test_remove_and_add_name(self): + self.assertEquals(expected_names, cert.names) + self.assertEquals(expected_mo_names, cert._names) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(cert) + session.commit() +@@ -454,7 +454,7 @@ def test_update_with_add_name(self): + """ + first_name = 'bowser' + cert = X509Certificate(self.bytes_a, name=first_name) +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(cert) + session.commit() +@@ -493,7 +493,7 @@ def test_update_with_remove_name(self): + cert.names.append(names[1]) + cert.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(cert) + session.commit() +@@ -534,7 +534,7 @@ def test_update_with_remove_and_add_name(self): + cert.names.append(names[1]) + cert.names.append(names[2]) + +- Session = sessionmaker(bind=self.engine) ++ Session = sessionmaker(bind=self.engine, expire_on_commit=False) + session = Session() + session.add(cert) + session.commit() +diff --git a/kmip/tests/unit/services/server/test_engine.py b/kmip/tests/unit/services/server/test_engine.py +index 617fcc1b..ad596dfe 100644 +--- a/kmip/tests/unit/services/server/test_engine.py ++++ b/kmip/tests/unit/services/server/test_engine.py +@@ -1386,6 +1386,7 @@ def test_get_attribute_from_managed_object(self): + e._data_session.add(certificate) + e._data_session.add(opaque_object) + e._data_session.commit() ++ e._data_session.refresh(symmetric_key) + e._data_session = e._data_store_session_factory() + + result = e._get_attribute_from_managed_object( +@@ -1660,6 +1661,7 @@ def test_get_attribute_index_from_managed_object(self): + e._data_session.add(symmetric_key) + e._data_session.add(certificate) + e._data_session.commit() ++ e._data_session.refresh(symmetric_key) + e._data_session = e._data_store_session_factory() + + e._set_attribute_on_managed_object( +@@ -2302,6 +2304,7 @@ def test_set_attribute_on_managed_object_by_index(self): + + e._data_session.add(symmetric_key) + e._data_session.commit() ++ e._data_session.refresh(symmetric_key) + e._data_session = e._data_store_session_factory() + + e._set_attribute_on_managed_object( diff --git a/python-PyKMIP.changes b/python-PyKMIP.changes index fc4d774..b245512 100644 --- a/python-PyKMIP.changes +++ b/python-PyKMIP.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Fri Sep 24 22:07:08 UTC 2021 - Matej Cepl + +- Remove SQL-issues.patch with the patch + fix-tests-SQLAlchemy-140.patch which actually resolves the + problems (gh#OpenKMIP/PyKMIP#656). + ------------------------------------------------------------------- Sat Jun 5 12:12:59 UTC 2021 - Matej Cepl diff --git a/python-PyKMIP.spec b/python-PyKMIP.spec index 612fd29..6689603 100644 --- a/python-PyKMIP.spec +++ b/python-PyKMIP.spec @@ -26,9 +26,9 @@ License: Apache-2.0 Group: Development/Languages/Python URL: https://github.com/OpenKMIP/PyKMIP Source: https://files.pythonhosted.org/packages/source/P/PyKMIP/PyKMIP-%{version}.tar.gz -# PATCH-FIX-UPSTREAM SQL-issues.patch gh#OpenKMIP/PyKMIP#649 mcepl@suse.com -# skip tests failing due to gh#OpenKMIP/PyKMIP#649 -Patch0: SQL-issues.patch +# PATCH-FIX-UPSTREAM fix-tests-SQLAlchemy-140.patch gh#OpenKMIP/PyKMIP#656 mcepl@suse.com +# fix tests to work with SQLAlchemy >= 1.4.0 +Patch0: fix-tests-SQLAlchemy-140.patch BuildRequires: %{python_module SQLAlchemy} BuildRequires: %{python_module cryptography} BuildRequires: %{python_module devel}