boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

Stubber stubbing iam get_policy_version

Open animaxcg opened this issue 4 years ago • 3 comments

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 avatar Jul 12 '20 00:07 animaxcg

@animaxcg - Thank you for your post. I am able to reproduce the issue.

swetashre avatar Jul 14 '20 18:07 swetashre

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.

swetashre avatar Nov 12 '20 19:11 swetashre

Any updates? The bug still exists. Okay, escaping helps, but "key: value" notation would be a better solution

mitrakov avatar Jun 29 '21 18:06 mitrakov