You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The test fails during the Bitbucket pipeline execution with a NoCredentialsError, even though I have mocked the AWS credentials using Moto and followed AWS's guidance for generating presigned URLs. Locally, the test works as expected, but in the pipeline, it consistently fails to locate the credentials.
What should happen?
The test should pass, as the credentials are properly mocked. The presigned URL generation should work with the mocked S3 client, just as it does in the local environment. The issue seems to be related to either the way the mocks are applied or an inconsistency in the pipeline environment, but the test logic should allow for proper mock resolution and successful URL generation.
Everything
I'm encountering an issue when running tests involving create_presigned_url in the Bitbucket pipeline. The presigned URL generation works locally, but it fails during the pipeline execution with a NoCredentialsError, even though I’ve mocked the AWS credentials and S3 client using Moto as suggested by the AWS documentation.
I’ve already tried with setup_default_session and also tried yielding boto3.client("s3", region_name="us-east-1"). Maybe I'm confused about how it works, but either way, it might not be a problem with the library, but rather me mixing solutions.
Hi @c137santos, welcome to Moto! One potential problem that I can think of: if boto3 is instantiated before the aws_credentials-fixture is called, then it doesn't have access to any credentials - hence the error. That problem will not occur when running it locally, because it uses whatever credentials you have configured locally.
Two possible solutions:
Move the imports in the app/test around, so that you're absolutely sure that aws_credentials is invoked before anything else
Set some fake credentials as part of the pipeline run itself. I'm not familiar with BitBucket, so I don't know how - but I'm sure there's a way to configure environment variables
What happens?
The test fails during the Bitbucket pipeline execution with a NoCredentialsError, even though I have mocked the AWS credentials using Moto and followed AWS's guidance for generating presigned URLs. Locally, the test works as expected, but in the pipeline, it consistently fails to locate the credentials.
What should happen?
The test should pass, as the credentials are properly mocked. The presigned URL generation should work with the mocked S3 client, just as it does in the local environment. The issue seems to be related to either the way the mocks are applied or an inconsistency in the pipeline environment, but the test logic should allow for proper mock resolution and successful URL generation.
Everything
I'm encountering an issue when running tests involving create_presigned_url in the Bitbucket pipeline. The presigned URL generation works locally, but it fails during the pipeline execution with a NoCredentialsError, even though I’ve mocked the AWS credentials and S3 client using Moto as suggested by the AWS documentation.
AWS Boto3 documentation on presigned URLs, and I’ve tried mocking everything I could related to AWS, but the issue persists in the Bitbucket pipeline.
Here’s the function that generates the presigned URL:
When I run my test in the pipeline, it throws the following error:
I have that model.
TESTS:
That error is:
My setup and conftest:
I’m using pytest with Moto to mock the S3 bucket and presigned URL.
The AWS credentials are mocked using the following fixture:
I’ve already tried with setup_default_session and also tried yielding boto3.client("s3", region_name="us-east-1"). Maybe I'm confused about how it works, but either way, it might not be a problem with the library, but rather me mixing solutions.
I'm using
The text was updated successfully, but these errors were encountered: