From 743a430732ab053f8c120d703649cb49ae4cd7b2 Mon Sep 17 00:00:00 2001 From: lorygold Date: Fri, 20 Oct 2023 12:00:25 +0200 Subject: [PATCH 1/2] Fixed alert description format --- CHANGELOG.md | 3 +++ buffalogs/impossible_travel/modules/impossible_travel.py | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60ff325..b370b87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ ## 1.2.x +### 1.2.7 +#### Bugfix +* Fixed alert description format ### 1.2.6 #### Bugfix * Removed linters from the setup app requirements diff --git a/buffalogs/impossible_travel/modules/impossible_travel.py b/buffalogs/impossible_travel/modules/impossible_travel.py index c936bc6..975e3f7 100644 --- a/buffalogs/impossible_travel/modules/impossible_travel.py +++ b/buffalogs/impossible_travel/modules/impossible_travel.py @@ -47,8 +47,7 @@ def calc_distance(self, db_user, prev_login, last_login_user_fields): alert_info["alert_name"] = Alert.ruleNameEnum.IMP_TRAVEL alert_info[ "alert_desc" - ] = f"{alert_info['alert_name']} for User: {db_user.username},\ - at: {last_timestamp_datetimeObj_aware}, from: {last_login_user_fields['country']}, previous country: {prev_login.country}, distance covered at {int(vel)} Km/h" + ] = f"{alert_info['alert_name']} for User: {db_user.username}, at: {last_timestamp_datetimeObj_aware}, from: {last_login_user_fields['country']}, previous country: {prev_login.country}, distance covered at {int(vel)} Km/h" return alert_info, int(vel) def update_model(self, db_user, new_login): From 48c45f785471dec7e6285961bdf45b7f66f707c1 Mon Sep 17 00:00:00 2001 From: lorygold Date: Fri, 20 Oct 2023 12:08:46 +0200 Subject: [PATCH 2/2] fixed test --- buffalogs/impossible_travel/tests/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buffalogs/impossible_travel/tests/test_views.py b/buffalogs/impossible_travel/tests/test_views.py index 35844a5..bc09c0c 100644 --- a/buffalogs/impossible_travel/tests/test_views.py +++ b/buffalogs/impossible_travel/tests/test_views.py @@ -218,8 +218,8 @@ def test_alerts_api(self): start = creation_mock_time end = creation_mock_time + timedelta(minutes=10) list_expected_result = [ - {"timestamp": "2023-05-20T11:45:01.229Z", "username": "Lorena Goldoni", "rule_name": "Login from new device"}, {"timestamp": "2023-06-20T10:17:33.358Z", "username": "Lorena Goldoni", "rule_name": "Impossible Travel detected"}, + {"timestamp": "2023-05-20T11:45:01.229Z", "username": "Lorena Goldoni", "rule_name": "Login from new device"}, ] response = self.client.get(f"{reverse('alerts_api')}?start={start.strftime('%Y-%m-%dT%H:%M:%SZ')}&end={end.strftime('%Y-%m-%dT%H:%M:%SZ')}") self.assertEqual(response.status_code, 200)