Skip to content

Commit

Permalink
Fix the authentication issue
Browse files Browse the repository at this point in the history
Anitya is currently expects either `None` or `hex` as `UUID` values returned during
authentication. This is solving the case when `UUID` object is returned directly.

Fixes #1727

Signed-off-by: Michal Konecny <[email protected]>
  • Loading branch information
Zlopez committed Mar 8, 2024
1 parent 24a56f4 commit dd94596
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions anitya/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ def process_result_value(self, value, dialect):
"""
if value is None:
return value
if isinstance(value, uuid.UUID):
return value
else:
return uuid.UUID(value)

Expand Down
10 changes: 10 additions & 0 deletions anitya/tests/db/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,16 @@ def test_process_result_short_string(self):
self.assertTrue(isinstance(result, UUID))
self.assertEqual(uuid, result)

def test_process_result_uuid(self):
"""Assert when the result value is a UUID it is returned."""
guid = models.GUID()
uuid = uuid4()

result = guid.process_result_value(uuid, sqlite.dialect())

self.assertTrue(isinstance(result, UUID))
self.assertEqual(uuid, result)


class UserTests(DatabaseTestCase):
"""UserTests class"""
Expand Down
1 change: 1 addition & 0 deletions news/1727.bug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Error when uuid object is returned from Fedora Account System

0 comments on commit dd94596

Please sign in to comment.