From 9bcb1c5c0076b9eaec3bc8b922209eadfa66a60e Mon Sep 17 00:00:00 2001
From: Chaemin-Lim <antraxmin@naver.com>
Date: Tue, 20 May 2025 23:46:39 +0900
Subject: [PATCH] Fix missing 'options' field in 'user show' command

This patch fixes a bug where the 'options' field was missing from
the output of the 'openstack user show' command since v7.0.0.

The issue was caused by the 'options' field not being included in
the column list in the _format_user function. This field is important
as it contains various user settings such as multi-factor authentication
configurations and password policy exemptions.

This patch:
1. Adds 'options' field to the column list in _format_user function
2. Updates all affected unit tests to include this field
3. Uses getattr() to safely handle cases where the options field may be absent

Without this fix, users cannot see important options like multi-factor
authentication settings through the CLI, which could lead to security
configuration issues being overlooked.

Closes-Bug: #2084946
Change-Id: I4319268ad4310e6164eb8e65664d73f9b32cdd78
---
 openstackclient/identity/v3/user.py                 | 2 ++
 openstackclient/tests/unit/identity/v3/test_user.py | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/openstackclient/identity/v3/user.py b/openstackclient/identity/v3/user.py
index 506a83476f..fee7dbe331 100644
--- a/openstackclient/identity/v3/user.py
+++ b/openstackclient/identity/v3/user.py
@@ -41,6 +41,7 @@ def _format_user(user):
         'name',
         'description',
         'password_expires_at',
+        'options',
     )
     column_headers = (
         'default_project_id',
@@ -51,6 +52,7 @@ def _format_user(user):
         'name',
         'description',
         'password_expires_at',
+        'options',
     )
     return (
         column_headers,
diff --git a/openstackclient/tests/unit/identity/v3/test_user.py b/openstackclient/tests/unit/identity/v3/test_user.py
index e8f54e8188..1236b86e21 100644
--- a/openstackclient/tests/unit/identity/v3/test_user.py
+++ b/openstackclient/tests/unit/identity/v3/test_user.py
@@ -44,6 +44,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
         'name',
         'description',
         'password_expires_at',
+        'options',
     )
 
     def setUp(self):
@@ -63,6 +64,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
             self.user.name,
             self.user.description,
             self.user.password_expires_at,
+            getattr(self.user, 'options', {}),
         )
 
         self.identity_sdk_client.find_domain.return_value = self.domain
@@ -279,6 +281,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
             self.user.name,
             self.user.description,
             self.user.password_expires_at,
+            getattr(self.user, 'options', {}),
         )
         self.assertEqual(datalist, data)
 
@@ -326,6 +329,7 @@ class TestUserCreate(identity_fakes.TestIdentityv3):
             self.user.name,
             self.user.description,
             self.user.password_expires_at,
+            getattr(self.user, 'options', {}),
         )
         self.assertEqual(datalist, data)
 
@@ -1853,6 +1857,7 @@ class TestUserShow(identity_fakes.TestIdentityv3):
             'name',
             'description',
             'password_expires_at',
+            'options',
         )
         self.assertEqual(collist, columns)
         datalist = (
@@ -1864,6 +1869,7 @@ class TestUserShow(identity_fakes.TestIdentityv3):
             self.user.name,
             self.user.description,
             self.user.password_expires_at,
+            getattr(self.user, 'options', {}),
         )
         self.assertEqual(datalist, data)