0

I try to write tests for my AWS libraries and I use moto for it. For example, for s3 service I use @mock_s3() decarator above the test and it works. My libraries require AWS profile name as an argument in init method.

So in tests Whenever I provide a real profile name that exists on my local machine the test is passed. Whenever I provide an non-existing profile name to it, it fails with the corresponding exception like profile wasn't found. All these 2 cases are totally fine I think. But what if I want to test a scenrio when I HAVE a profile but some of its keys are invalid? Is there a way to configure somehow the mock so it would require SPECIFIC aws credentials (for example something like aws_access_key_id=testing and aws_secret_access_key=testing but if in my profile that I passed it will be like:

[test]
aws_access_key_id=testing
aws_secret_access_key=nottesting

It will fail like my actual code will fail with a real boto3.client thing.

Maxim1110
  • 1
  • 1

0 Answers0