forked from boto/boto3
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add environment variable to override endpoint_url (boto#2099)
- Loading branch information
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import unittest | ||
|
||
import boto3 | ||
|
||
class TestEndpointUrl(unittest.TestCase): | ||
def test_default_session_does_not_require_endpoint_url_env_var(self): | ||
boto3.setup_default_session( | ||
aws_access_key_id='key', | ||
aws_secret_access_key='secret') | ||
client = boto3.DEFAULT_SESSION.client('s3') | ||
self.assertTrue(client._endpoint.host.endswith("amazonaws.com"), | ||
"AWS_ENDPOINT_URL env var should not be required") | ||
|
||
def test_default_session_uses_endpoint_url_env_var(self): | ||
ENDPOINT_URL = "http://endpoint.url" | ||
os.environ["AWS_ENDPOINT_URL"] = ENDPOINT_URL | ||
boto3.setup_default_session( | ||
aws_access_key_id='key', | ||
aws_secret_access_key='secret') | ||
client = boto3.DEFAULT_SESSION.client('s3') | ||
self.assertTrue(client._endpoint.host == ENDPOINT_URL, 'AWS_ENDPOINT_URL env var not used when set') | ||
|
||
# eof |