Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging 0.13.x into central-develop to get latest bug fix #3498

Merged
merged 6 commits into from
Apr 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kalite/facility/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FacilityGroup(DeferredCountSyncedModel):

def __init__(self, *args, **kwargs):
super(FacilityGroup, self).__init__(*args, **kwargs)
self._unhashable_fields.append("description") # since it's being stripped out by minversion, we can't include it in the signature
self._unhashable_fields += ("description",) # since it's being stripped out by minversion, we can't include it in the signature

class Meta:
app_label = "securesync" # for back-compat reasons
Expand Down
7 changes: 3 additions & 4 deletions python-packages/securesync/engine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,9 @@ class SyncedModel(ExtendedModel):
objects = SyncedModelManager()
all_objects = SyncedModelManager(show_deleted=True)

_unhashable_fields = ["signature", "signed_by"] # fields of this class to avoid serializing
_always_hash_fields = ["signed_version", "id"] # fields of this class to always serialize (see note above for signed_version)
_import_excluded_validation_fields = [] # fields that should not be validated upon import

_unhashable_fields = ("signature", "signed_by") # fields of this class to avoid serializing
_always_hash_fields = ("signed_version", "id") # fields of this class to always serialize (see note above for signed_version)
_import_excluded_validation_fields = tuple() # fields that should not be validated upon import

__metaclass__ = SyncedModelMetaclass

Expand Down
15 changes: 15 additions & 0 deletions python-packages/securesync/tests/crypto_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,18 @@ def test_facility_group_save(self):
group.save()
assert group.zone_fallback is not None, "Centrally created FacilityGroup was not assigned a zone."


class TestHashableFieldsAndSerialization(unittest.TestCase):

def test_description_exclusion_regression_bug_2470(self):
"""FacilityGroup.__init__ used to append "description" to _unhashable_fields, which affected other classes as well.
This test ensures that the description is not being excluded from Device._hashable_representation, even after
instantiating a FacilityGroup."""

d = Device(name="Test", description="Test")
possibly_bad_serialization = d._hashable_representation()
self.assertIn("description=Test", possibly_bad_serialization, "Hashable representation of Device did not include description")

g = FacilityGroup()
possibly_worse_serialization = d._hashable_representation()
self.assertIn("description=Test", possibly_worse_serialization, "Instantiating a FacilityGroup changed hashable representation of Device")