Skip to content

Commit

Permalink
ensure notification message integrity is encoded as base64 (#484)
Browse files Browse the repository at this point in the history
* ensure notification message integrity is encoded as base64

* use centre-id for testing message queries
  • Loading branch information
tomkralidis committed Aug 17, 2023
1 parent 4c3912e commit c991011
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/integration/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ def test_message_api():

# test messages per test dataset
counts = {
'mwi': 24,
'ita': 33,
'dza': 29,
'rou': 185
'mwi_met_centre': 24,
'roma_met_centre': 33,
'alger_met_centre': 29,
'rnimh': 185
}
for key, value in counts.items():
url = f'{API_URL}/collections/messages/items?sortby=-datetime&q={key}&limit=1' # noqa
Expand Down
3 changes: 2 additions & 1 deletion wis2box-management/wis2box/pubsub/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#
###############################################################################

import base64
from datetime import datetime
from enum import Enum
import json
Expand Down Expand Up @@ -120,7 +121,7 @@ def _generate_checksum(self, bytes, algorithm: SecureHashAlgorithms) -> str: #

sh = getattr(hashlib, algorithm)()
sh.update(bytes)
return sh.hexdigest()
return base64.b64encode(sh.digest()).decode()


class WISNotificationMessage(PubSubMessage):
Expand Down

0 comments on commit c991011

Please sign in to comment.