Fix Bug 2308: Incorrect status update for user update 95/13995/4
authorAdurti <adurti.v@tataelxsi.co.in>
Wed, 8 Nov 2023 11:16:32 +0000 (11:16 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 2 Jul 2024 14:38:26 +0000 (16:38 +0200)
Change-Id: I54169c0975fdf15ee0e474b3351893d68591c20f
Signed-off-by: Adurti <adurti.v@tataelxsi.co.in>
osm_nbi/authconn_internal.py
osm_nbi/tests/test_admin_topics.py

index 0f414b1..8b94a4c 100644 (file)
@@ -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:
index 6a44365..0aeed61 100755 (executable)
@@ -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,
                 },