boto3
boto3 copied to clipboard
Stubber stubbing iam get_policy_version
Describe the bug Stubber when stubbing iam get_policy_version expects the document value to be a string but boto3 returns a dict. this blocks the stubbing of the get_policy_version via stubber and causes tests to fail. Steps to reproduce stub iam get_policy_version with a valid response and then stub it and it will throw the followin error:Invalid type for parameter PolicyVersion.Document, value: {'Version': '2012-10-17', 'Statement': [{'Sid': '', 'Effect': 'Allow', 'Action': 'sts:AssumeRole', 'Resource': 'arn:aws:iam::1111111111111:role/dod_ro'}]}, type: <class 'dict'>, valid types: <class 'str'> Expected behavior to handle the expected dict for the document key: value
@animaxcg - Thank you for your post. I am able to reproduce the issue.
Here the issue is that any time an IAM operation returns a policy document it is a string that is json that has been url encoded. To give users something more useful, we will url decode this value and json.loads() the result so that they have the policy document as a dictionary. But while using stubber , it validates the parameter type against the input schema and then it will throw error as we have changed it type from json string to dict.
Any updates? The bug still exists. Okay, escaping helps, but "key: value" notation would be a better solution