Skip to content

[v2] Adjust format of table for accessibility #9547

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 2 commits into
base: cli-accessibility
Choose a base branch
from
Draft
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
29 changes: 11 additions & 18 deletions awscli/customizations/configure/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,23 @@ class ConfigureListCommand(BasicCommand):
'To show your current configuration values::\n'
'\n'
' $ aws configure list\n'
' Name Value Type Location\n'
' ---- ----- ---- --------\n'
' profile <not set> None None\n'
' access_key ****************ABCD config_file ~/.aws/config\n'
' secret_key ****************ABCD config_file ~/.aws/config\n'
' region us-west-2 env AWS_DEFAULT_REGION\n'
' NAME : VALUE : TYPE : LOCATION\n'
' profile : <not set> : None : None\n'
' access_key : ****************ABCD : config_file : ~/.aws/config\n'
' secret_key : ****************ABCD : config_file : ~/.aws/config\n'
' region : us-west-2 : env : AWS_DEFAULT_REGION\n'
'\n'
)

def __init__(self, session, stream=None):
super(ConfigureListCommand, self).__init__(session)
super().__init__(session)
if stream is None:
stream = sys.stdout
self._stream = stream

def _run_main(self, args, parsed_globals):
self._display_config_value(
ConfigValue('Value', 'Type', 'Location'), 'Name'
)
self._display_config_value(
ConfigValue('-----', '----', '--------'), '----'
ConfigValue('VALUE', 'TYPE', 'LOCATION'), 'NAME'
)

if parsed_globals and parsed_globals.profile is not None:
Expand All @@ -80,13 +76,10 @@ def _run_main(self, args, parsed_globals):

def _display_config_value(self, config_value, config_name):
self._stream.write(
'%10s %24s %16s %s\n'
% (
config_name,
config_value.value,
config_value.config_type,
config_value.config_variable,
)
f'{config_name:<10} : '
f'{config_value.value:<24} : '
f'{str(config_value.config_type):<16} : '
f'{str(config_value.config_variable)}\n'
)

def _lookup_credentials(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/configure/test_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_list_command(self):
stdout, _, _ = self.run_cmd("configure list")
self.assertRegex(stdout, r"access_key.+config-file")
self.assertRegex(stdout, r"secret_key.+config-file")
self.assertRegex(stdout, r"region\s+us-west-2\s+config-file")
self.assertRegex(stdout, r"region\s+:\sus-west-2\s+:\sconfig-file")

def test_get_command(self):
self.set_config_file_contents(
Expand Down
27 changes: 15 additions & 12 deletions tests/unit/customizations/configure/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ def test_configure_list_command_nothing_set(self):
self.configure_list = ConfigureListCommand(session, stream)
self.configure_list(args=[], parsed_globals=None)
rendered = stream.getvalue()
self.assertRegex(rendered, r'profile\s+<not set>')
self.assertRegex(rendered, r'access_key\s+<not set>')
self.assertRegex(rendered, r'secret_key\s+<not set>')
self.assertRegex(rendered, r'region\s+<not set>')
self.assertRegex(rendered, r'profile\s+: <not set>')
self.assertRegex(rendered, r'access_key\s+: <not set>')
self.assertRegex(rendered, r'secret_key\s+: <not set>')
self.assertRegex(rendered, r'region\s+: <not set>')

def test_configure_from_env(self):
env_vars = {'profile': 'myprofilename'}
Expand All @@ -52,7 +52,7 @@ def test_configure_from_env(self):
self.configure_list(args=[], parsed_globals=None)
rendered = stream.getvalue()
self.assertRegex(
rendered, r'profile\s+myprofilename\s+env\s+PROFILE_ENV_VAR'
rendered, r'profile\s+: myprofilename\s+: env\s+: PROFILE_ENV_VAR'
)

def test_configure_from_config_file(self):
Expand All @@ -70,7 +70,8 @@ def test_configure_from_config_file(self):
self.configure_list(args=[], parsed_globals=None)
rendered = stream.getvalue()
self.assertRegex(
rendered, r'region\s+us-west-2\s+config-file\s+/config/location'
rendered,
r'region\s+: us-west-2\s+: config-file\s+: /config/location',
)

def test_configure_from_multiple_sources(self):
Expand Down Expand Up @@ -102,25 +103,27 @@ def test_configure_from_multiple_sources(self):
rendered = stream.getvalue()
# The profile came from an env var.
self.assertRegex(
rendered, r'profile\s+myprofilename\s+env\s+AWS_DEFAULT_PROFILE'
rendered,
r'profile\s+: myprofilename\s+: env\s+: AWS_DEFAULT_PROFILE',
)
# The region came from the config file.
self.assertRegex(
rendered, r'region\s+us-west-2\s+config-file\s+/config/location'
rendered,
r'region\s+: us-west-2\s+: config-file\s+: /config/location',
)
# The credentials came from an IAM role. Note how we're
# also checking that the access_key/secret_key are masked
# with '*' chars except for the last 4 chars.
self.assertRegex(rendered, r'access_key\s+\*+_key\s+iam-role')
self.assertRegex(rendered, r'secret_key\s+\*+_key\s+iam-role')
self.assertRegex(rendered, r'access_key\s+: \*+_key\s+: iam-role')
self.assertRegex(rendered, r'secret_key\s+: \*+_key\s+: iam-role')

def test_configure_region_from_imds(self):
session = FakeSession(all_variables={'region': 'from-imds'})
stream = StringIO()
self.configure_list = ConfigureListCommand(session, stream)
self.configure_list(args=[], parsed_globals=None)
rendered = stream.getvalue()
self.assertRegex(rendered, r'region\s+from-imds\s+imds')
self.assertRegex(rendered, r'region\s+: from-imds\s+: imds')

def test_configure_from_args(self):
parsed_globals = Namespace(profile='foo')
Expand All @@ -136,4 +139,4 @@ def test_configure_from_args(self):
self.configure_list = ConfigureListCommand(session, stream)
self.configure_list(args=[], parsed_globals=parsed_globals)
rendered = stream.getvalue()
self.assertRegex(rendered, r'profile\s+foo\s+manual\s+--profile')
self.assertRegex(rendered, r'profile\s+: foo\s+: manual\s+: --profile')
Loading