[] Fix iam_list_virtual_mfa_devices
Some checks failed
DCO action / DCO (pull_request) Has been cancelled

Signed-off-by: Roman Chernykh <r.chernykh@yadro.com>
This commit is contained in:
Roman Chernykh 2024-10-28 19:14:15 +03:00
parent 44bda557d3
commit 06a4416f10
3 changed files with 6 additions and 8 deletions

View file

@ -1308,16 +1308,14 @@ class AwsCliClient(S3ClientWrapper):
return response
@reporter.step("Lists the MFA devices for an IAM user")
def iam_list_virtual_mfa_devices(self, user_name: Optional[str] = None) -> dict:
def iam_list_virtual_mfa_devices(self) -> dict:
cmd = f"aws {self.common_flags} iam list-virtual-mfa-devices --endpoint {self.iam_endpoint}"
if user_name:
cmd += f" --user-name {user_name}"
if self.profile:
cmd += f" --profile {self.profile}"
output = self.local_shell.exec(cmd).stdout
response = self._to_json(output)
assert response.get("MFADevices"), f"Expected MFADevices in response:\n{response}"
assert response.get("VirtualMFADevices"), f"Expected VirtualMFADevices in response:\n{response}"
return response

View file

@ -976,9 +976,9 @@ class Boto3ClientWrapper(S3ClientWrapper):
return response
@reporter.step("Lists the MFA devices for an IAM user")
def iam_list_virtual_mfa_devices(self, user_name: Optional[str] = None) -> dict:
response = self.boto3_iam_client.list_virtual_mfa_devices(UserName="/")
assert response.get("MFADevices"), f"Expected MFADevices in response:\n{response}"
def iam_list_virtual_mfa_devices(self) -> dict:
response = self.boto3_iam_client.list_virtual_mfa_devices()
assert response.get("VirtualMFADevices"), f"Expected VirtualMFADevices in response:\n{response}"
return response

View file

@ -583,7 +583,7 @@ class S3ClientWrapper(HumanReadableABC):
"""Enables the specified MFA device and associates it with the specified IAM user"""
@abstractmethod
def iam_list_virtual_mfa_devices(self, user_name: Optional[str] = None) -> dict:
def iam_list_virtual_mfa_devices(self) -> dict:
"""Lists the MFA devices for an IAM user"""
@abstractmethod