Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Boto credentials might cause tests to fail #1485

Closed
lleontop opened this issue Feb 19, 2018 · 3 comments
Closed

Boto credentials might cause tests to fail #1485

lleontop opened this issue Feb 19, 2018 · 3 comments

Comments

@lleontop
Copy link
Contributor

I came across a behavior today that I am not sure if it's expected or can be solved in some way. I was running locally the tests and there was one failing (test_amis.test_ami_filter_wildcard/1/). The problem was that when creating the image it was created under the wrong owner. This was because I had forgotten I had some default profile credentials in ~/.aws/credentials so boto was using them and context.get_current_user() in create_image backend was returning my real AWS key and secret as the user. After removing the credentials from ~/.aws/credentials the test passed. Also changing the describe_images with Owners=['self'] made the test pass but I am not sure if we want for boto to use the real credentials either in ENV vars or shared-credentials files. What do you guys think?

/1/

def test_ami_filter_wildcard():
    ec2_resource = boto3.resource('ec2', region_name='us-west-1')
    ec2_client = boto3.client('ec2', region_name='us-west-1')

    instance = ec2_resource.create_instances(ImageId='ami-1234abcd', MinCount=1, MaxCount=1)[0]
    instance.create_image(Name='test-image')

    # create an image with the same owner but will not match the filter
    instance.create_image(Name='not-matching-image')

    my_images = ec2_client.describe_images(
        Owners=['111122223333'],
        Filters=[{'Name': 'name', 'Values': ['test*']}]
    )['Images']
    my_images.should.have.length_of(1)
@bpandola
Copy link
Collaborator

bpandola commented Mar 3, 2018

I encountered this as well. I'm not sure what, if anything, should be done about it, but I'll add my voice as someone who was confused by this unexpected behavior.

@drorata
Copy link

drorata commented Nov 7, 2018

Could this be related to #889 ?
What about #1793?

@spulec
Copy link
Collaborator

spulec commented Dec 29, 2018

This should be fixed with #1952, but let me know if there are still issues

@spulec spulec closed this as completed Dec 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants