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

ensure notification message integrity is encoded as base64 #484

Merged
merged 2 commits into from
Aug 17, 2023
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
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
Loading