From: Adurti Date: Wed, 8 Nov 2023 11:16:32 +0000 (+0000) Subject: Fix Bug 2308: Incorrect status update for user update X-Git-Tag: release-v16.0-start~19 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=0c9b0108fde07156eeeea19c280a4f0c2f3dc17f;p=osm%2FNBI.git Fix Bug 2308: Incorrect status update for user update Change-Id: I54169c0975fdf15ee0e474b3351893d68591c20f Signed-off-by: Adurti --- diff --git a/osm_nbi/authconn_internal.py b/osm_nbi/authconn_internal.py index 0f414b1..8b94a4c 100644 --- a/osm_nbi/authconn_internal.py +++ b/osm_nbi/authconn_internal.py @@ -550,6 +550,7 @@ class AuthconnInternal(Authconn): unlock = user_info.get("unlock") renew = user_info.get("renew") permission_id = user_info.get("system_admin_id") + now = time() user_data = self.db.get_one( self.users_collection, {BaseTopic.id_field("users", uid): uid} @@ -591,7 +592,10 @@ class AuthconnInternal(Authconn): if role_assigned.get("permissions")["admin"]: if role_assigned.get("permissions")["default"]: user_data["_admin"]["retry_count"] = 0 - user_data["_admin"]["user_status"] = "active" + if now > user_data["_admin"]["account_expire_time"]: + user_data["_admin"]["user_status"] = "expired" + else: + user_data["_admin"]["user_status"] = "active" unlock_state = True break if not unlock_state: @@ -634,7 +638,13 @@ class AuthconnInternal(Authconn): ) user_data["_admin"]["modified"] = present user_data["_admin"]["account_expire_time"] = account_expire - user_data["_admin"]["user_status"] = "active" + if ( + user_data["_admin"]["retry_count"] + >= self.config["max_pwd_attempt"] + ): + user_data["_admin"]["user_status"] = "locked" + else: + user_data["_admin"]["user_status"] = "active" renew_state = True break if not renew_state: diff --git a/osm_nbi/tests/test_admin_topics.py b/osm_nbi/tests/test_admin_topics.py index 6a44365..0aeed61 100755 --- a/osm_nbi/tests/test_admin_topics.py +++ b/osm_nbi/tests/test_admin_topics.py @@ -1289,7 +1289,7 @@ class Test_UserTopicAuth(TestCase): "salt": "560a5d51b1d64bb4b9cae0ccff3f1102", "user_status": "locked", "password_expire_time": 1667207552.2191815, - "account_expire_time": 1674983552.2191815, + "account_expire_time": now + 60, "retry_count": 5, "last_token_time": 1667207552.2191815, },