{"action":"created","comment":{"url":"https://api.github.com/repos/boto/botocore/pulls/comments/26531884","id":26531884,"diff_hunk":"@@ -0,0 +1,106 @@\n+# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n+# may not use this file except in compliance with the License. A copy of\n+# the License is located at\n+#\n+# http://aws.amazon.com/apache2.0/\n+#\n+# or in the \"license\" file accompanying this file. This file is\n+# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n+# ANY KIND, either express or implied. See the License for the specific\n+# language governing permissions and limitations under the License.\n+\n+import os\n+import mock\n+\n+from botocore.session import Session\n+from tests import unittest\n+\n+\n+class TestCredentialPrecedence(unittest.TestCase):\n+    def setUp(self):\n+        # Clean up any existing environment\n+        for name in ['AWS_ACCESS_KEY_ID',\n+                     'AWS_SECRET_ACCESS_KEY',\n+                     'BOTO_DEFAULT_PROFILE']:\n+            if name in os.environ:\n+                del os.environ[name]\n+\n+        # Set the config file to something that doesn't exist, then\n+        # set the shared credential file to our test config.\n+        os.environ['AWS_CONFIG_FILE'] = '~/.aws/config-missing'\n+        Session.SessionVariables['credentials_file'] = (\n+            None, None,\n+            os.path.join(os.path.dirname(__file__), 'test-credentials'))\n+\n+    def test_access_secret_vs_profile_env(self):\n+        # If all three are given, then the access/secret keys should\n+        # take precedence.\n+        os.environ['AWS_ACCESS_KEY_ID'] = 'env'\n+        os.environ['AWS_SECRET_ACCESS_KEY'] = 'env-secret'\n+        os.environ['BOTO_DEFAULT_PROFILE'] = 'test'\n+\n+        s = Session()\n+        credentials = s.get_credentials()\n+\n+        self.assertEqual(credentials.access_key, 'env')\n+        self.assertEqual(credentials.secret_key, 'env-secret')\n+\n+    @mock.patch('botocore.credentials.Credentials')","path":"tests/integration/test_credentials.py","position":50,"original_position":50,"commit_id":"856eaec5586599b136f770076951428167d822e3","original_commit_id":"856eaec5586599b136f770076951428167d822e3","user":{"login":"jamesls","id":368057,"avatar_url":"https://avatars.githubusercontent.com/u/368057?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesls","html_url":"https://github.com/jamesls","followers_url":"https://api.github.com/users/jamesls/followers","following_url":"https://api.github.com/users/jamesls/following{/other_user}","gists_url":"https://api.github.com/users/jamesls/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesls/subscriptions","organizations_url":"https://api.github.com/users/jamesls/orgs","repos_url":"https://api.github.com/users/jamesls/repos","events_url":"https://api.github.com/users/jamesls/events{/privacy}","received_events_url":"https://api.github.com/users/jamesls/received_events","type":"User","site_admin":false},"body":"I'm not really a fan of unnecessary patching, *especially* when it's not necessary.  Why can't we just check the credential object directly?","created_at":"2015-03-16T21:58:42Z","updated_at":"2015-03-16T21:58:42Z","html_url":"https://github.com/boto/botocore/pull/486#discussion_r26531884","pull_request_url":"https://api.github.com/repos/boto/botocore/pulls/486","_links":{"self":{"href":"https://api.github.com/repos/boto/botocore/pulls/comments/26531884"},"html":{"href":"https://github.com/boto/botocore/pull/486#discussion_r26531884"},"pull_request":{"href":"https://api.github.com/repos/boto/botocore/pulls/486"}}},"pull_request":{"url":"https://api.github.com/repos/boto/botocore/pulls/486","id":30888832,"html_url":"https://github.com/boto/botocore/pull/486","diff_url":"https://github.com/boto/botocore/pull/486.diff","patch_url":"https://github.com/boto/botocore/pull/486.patch","issue_url":"https://api.github.com/repos/boto/botocore/issues/486","number":486,"state":"open","locked":false,"title":"Explicit profile overrides environment variables","user":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"body":"This changes the behavior of environment variable credential loading to\r\nfunction as described in aws/aws-cli#113. Here is what this looks like\r\nfor both the CLI and Botocore/Boto 3:\r\n\r\nCLI:\r\n```bash\r\n# Use the environment variables\r\n$ AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar aws s3 ls\r\n\r\n# Ignore the environment variables and use a profile from the config instead\r\n$ AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar aws --profile dev s3 ls\r\n```\r\n\r\nPython:\r\n```python\r\n$ AWS_ACCESS_KEY_ID=foo AWS_SECRET_ACCESS_KEY=bar python\r\n>>> import boto3\r\n>>> boto3.setup_default_session(profile_name='dev')\r\n>>> # The following will use the profile, not the env vars!\r\n>>> s3dev = boto3.resource('s3')\r\n```\r\n\r\nAdded a test and a new log message to ensure it's obvious what is happening.\r\n\r\ncc @jamesls @kyleknap ","created_at":"2015-03-10T20:24:59Z","updated_at":"2015-03-16T21:58:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"40e234b93484efc8acd88b007b333fffb9ae5f20","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/boto/botocore/pulls/486/commits","review_comments_url":"https://api.github.com/repos/boto/botocore/pulls/486/comments","review_comment_url":"https://api.github.com/repos/boto/botocore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/boto/botocore/issues/486/comments","statuses_url":"https://api.github.com/repos/boto/botocore/statuses/856eaec5586599b136f770076951428167d822e3","head":{"label":"danielgtaylor:explicit-profile","ref":"explicit-profile","sha":"856eaec5586599b136f770076951428167d822e3","user":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"repo":{"id":12009958,"name":"botocore","full_name":"danielgtaylor/botocore","owner":{"login":"danielgtaylor","id":106826,"avatar_url":"https://avatars.githubusercontent.com/u/106826?v=3","gravatar_id":"","url":"https://api.github.com/users/danielgtaylor","html_url":"https://github.com/danielgtaylor","followers_url":"https://api.github.com/users/danielgtaylor/followers","following_url":"https://api.github.com/users/danielgtaylor/following{/other_user}","gists_url":"https://api.github.com/users/danielgtaylor/gists{/gist_id}","starred_url":"https://api.github.com/users/danielgtaylor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielgtaylor/subscriptions","organizations_url":"https://api.github.com/users/danielgtaylor/orgs","repos_url":"https://api.github.com/users/danielgtaylor/repos","events_url":"https://api.github.com/users/danielgtaylor/events{/privacy}","received_events_url":"https://api.github.com/users/danielgtaylor/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danielgtaylor/botocore","description":"The low-level, core functionality of boto 3.","fork":true,"url":"https://api.github.com/repos/danielgtaylor/botocore","forks_url":"https://api.github.com/repos/danielgtaylor/botocore/forks","keys_url":"https://api.github.com/repos/danielgtaylor/botocore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danielgtaylor/botocore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danielgtaylor/botocore/teams","hooks_url":"https://api.github.com/repos/danielgtaylor/botocore/hooks","issue_events_url":"https://api.github.com/repos/danielgtaylor/botocore/issues/events{/number}","events_url":"https://api.github.com/repos/danielgtaylor/botocore/events","assignees_url":"https://api.github.com/repos/danielgtaylor/botocore/assignees{/user}","branches_url":"https://api.github.com/repos/danielgtaylor/botocore/branches{/branch}","tags_url":"https://api.github.com/repos/danielgtaylor/botocore/tags","blobs_url":"https://api.github.com/repos/danielgtaylor/botocore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danielgtaylor/botocore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danielgtaylor/botocore/git/refs{/sha}","trees_url":"https://api.github.com/repos/danielgtaylor/botocore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danielgtaylor/botocore/statuses/{sha}","languages_url":"https://api.github.com/repos/danielgtaylor/botocore/languages","stargazers_url":"https://api.github.com/repos/danielgtaylor/botocore/stargazers","contributors_url":"https://api.github.com/repos/danielgtaylor/botocore/contributors","subscribers_url":"https://api.github.com/repos/danielgtaylor/botocore/subscribers","subscription_url":"https://api.github.com/repos/danielgtaylor/botocore/subscription","commits_url":"https://api.github.com/repos/danielgtaylor/botocore/commits{/sha}","git_commits_url":"https://api.github.com/repos/danielgtaylor/botocore/git/commits{/sha}","comments_url":"https://api.github.com/repos/danielgtaylor/botocore/comments{/number}","issue_comment_url":"https://api.github.com/repos/danielgtaylor/botocore/issues/comments{/number}","contents_url":"https://api.github.com/repos/danielgtaylor/botocore/contents/{+path}","compare_url":"https://api.github.com/repos/danielgtaylor/botocore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danielgtaylor/botocore/merges","archive_url":"https://api.github.com/repos/danielgtaylor/botocore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danielgtaylor/botocore/downloads","issues_url":"https://api.github.com/repos/danielgtaylor/botocore/issues{/number}","pulls_url":"https://api.github.com/repos/danielgtaylor/botocore/pulls{/number}","milestones_url":"https://api.github.com/repos/danielgtaylor/botocore/milestones{/number}","notifications_url":"https://api.github.com/repos/danielgtaylor/botocore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danielgtaylor/botocore/labels{/name}","releases_url":"https://api.github.com/repos/danielgtaylor/botocore/releases{/id}","created_at":"2013-08-09T20:23:13Z","updated_at":"2015-01-13T22:05:35Z","pushed_at":"2015-03-16T20:18:20Z","git_url":"git://github.com/danielgtaylor/botocore.git","ssh_url":"git@github.com:danielgtaylor/botocore.git","clone_url":"https://github.com/danielgtaylor/botocore.git","svn_url":"https://github.com/danielgtaylor/botocore","homepage":null,"size":15620,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"boto:develop","ref":"develop","sha":"73b59f1a35588dade0662ae0d7f000e94eb3a2e7","user":{"login":"boto","id":327752,"avatar_url":"https://avatars.githubusercontent.com/u/327752?v=3","gravatar_id":"","url":"https://api.github.com/users/boto","html_url":"https://github.com/boto","followers_url":"https://api.github.com/users/boto/followers","following_url":"https://api.github.com/users/boto/following{/other_user}","gists_url":"https://api.github.com/users/boto/gists{/gist_id}","starred_url":"https://api.github.com/users/boto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boto/subscriptions","organizations_url":"https://api.github.com/users/boto/orgs","repos_url":"https://api.github.com/users/boto/repos","events_url":"https://api.github.com/users/boto/events{/privacy}","received_events_url":"https://api.github.com/users/boto/received_events","type":"Organization","site_admin":false},"repo":{"id":6670942,"name":"botocore","full_name":"boto/botocore","owner":{"login":"boto","id":327752,"avatar_url":"https://avatars.githubusercontent.com/u/327752?v=3","gravatar_id":"","url":"https://api.github.com/users/boto","html_url":"https://github.com/boto","followers_url":"https://api.github.com/users/boto/followers","following_url":"https://api.github.com/users/boto/following{/other_user}","gists_url":"https://api.github.com/users/boto/gists{/gist_id}","starred_url":"https://api.github.com/users/boto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boto/subscriptions","organizations_url":"https://api.github.com/users/boto/orgs","repos_url":"https://api.github.com/users/boto/repos","events_url":"https://api.github.com/users/boto/events{/privacy}","received_events_url":"https://api.github.com/users/boto/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/boto/botocore","description":"The low-level, core functionality of boto 3.","fork":false,"url":"https://api.github.com/repos/boto/botocore","forks_url":"https://api.github.com/repos/boto/botocore/forks","keys_url":"https://api.github.com/repos/boto/botocore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/boto/botocore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/boto/botocore/teams","hooks_url":"https://api.github.com/repos/boto/botocore/hooks","issue_events_url":"https://api.github.com/repos/boto/botocore/issues/events{/number}","events_url":"https://api.github.com/repos/boto/botocore/events","assignees_url":"https://api.github.com/repos/boto/botocore/assignees{/user}","branches_url":"https://api.github.com/repos/boto/botocore/branches{/branch}","tags_url":"https://api.github.com/repos/boto/botocore/tags","blobs_url":"https://api.github.com/repos/boto/botocore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/boto/botocore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/boto/botocore/git/refs{/sha}","trees_url":"https://api.github.com/repos/boto/botocore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/boto/botocore/statuses/{sha}","languages_url":"https://api.github.com/repos/boto/botocore/languages","stargazers_url":"https://api.github.com/repos/boto/botocore/stargazers","contributors_url":"https://api.github.com/repos/boto/botocore/contributors","subscribers_url":"https://api.github.com/repos/boto/botocore/subscribers","subscription_url":"https://api.github.com/repos/boto/botocore/subscription","commits_url":"https://api.github.com/repos/boto/botocore/commits{/sha}","git_commits_url":"https://api.github.com/repos/boto/botocore/git/commits{/sha}","comments_url":"https://api.github.com/repos/boto/botocore/comments{/number}","issue_comment_url":"https://api.github.com/repos/boto/botocore/issues/comments{/number}","contents_url":"https://api.github.com/repos/boto/botocore/contents/{+path}","compare_url":"https://api.github.com/repos/boto/botocore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/boto/botocore/merges","archive_url":"https://api.github.com/repos/boto/botocore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/boto/botocore/downloads","issues_url":"https://api.github.com/repos/boto/botocore/issues{/number}","pulls_url":"https://api.github.com/repos/boto/botocore/pulls{/number}","milestones_url":"https://api.github.com/repos/boto/botocore/milestones{/number}","notifications_url":"https://api.github.com/repos/boto/botocore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/boto/botocore/labels{/name}","releases_url":"https://api.github.com/repos/boto/botocore/releases{/id}","created_at":"2012-11-13T13:25:36Z","updated_at":"2015-03-16T16:41:18Z","pushed_at":"2015-03-16T19:55:28Z","git_url":"git://github.com/boto/botocore.git","ssh_url":"git@github.com:boto/botocore.git","clone_url":"https://github.com/boto/botocore.git","svn_url":"https://github.com/boto/botocore","homepage":null,"size":21718,"stargazers_count":147,"watchers_count":147,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":78,"mirror_url":null,"open_issues_count":19,"forks":78,"open_issues":19,"watchers":147,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/boto/botocore/pulls/486"},"html":{"href":"https://github.com/boto/botocore/pull/486"},"issue":{"href":"https://api.github.com/repos/boto/botocore/issues/486"},"comments":{"href":"https://api.github.com/repos/boto/botocore/issues/486/comments"},"review_comments":{"href":"https://api.github.com/repos/boto/botocore/pulls/486/comments"},"review_comment":{"href":"https://api.github.com/repos/boto/botocore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/boto/botocore/pulls/486/commits"},"statuses":{"href":"https://api.github.com/repos/boto/botocore/statuses/856eaec5586599b136f770076951428167d822e3"}}}}