{"action":"created","comment":{"url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/comments/84188102","pull_request_review_id":4977964,"id":84188102,"diff_hunk":"@@ -907,6 +921,145 @@ def sleep_source(arg):\n         self.assertEquals([60 - 6], sleeps)\n \n \n+class AuthenticatingRequestTest(unittest.TestCase):\n+    def test_adds_token_to_headers(self):\n+\n+        # given\n+        req = MockReq()\n+        token = 'token'\n+        uri = '/path/to/resource'\n+        body = 'this is the body'\n+        ap = AuthenticatingRequest(request=req, user=NullUser())\n+\n+        # when\n+        ap.GET(uri, body)\n+\n+        # then\n+        self.assertEqual(uri, req.get_url)\n+        self.assertTrue(req.headers is not None)\n+        self.assertEqual(1, len(req.headers))\n+        self.assertTrue(req.headers[0] is not None)\n+        header = req.headers[0]\n+        self.assertTrue(isinstance(header, NVPair))\n+        self.assertEqual('X-Auth-Token', header.getName())\n+        self.assertEqual(token, header.getValue())\n+\n+\n+class UserTest(TestCaseBase):\n+\n+    token = 'this-is-the-token'\n+    tenant = 'this-is-the-tenant'\n+    auth_url = 'https://example.com/v2.0/tokens'\n+    username = 'user123'\n+    api_key = '0123456789abcdef0123456789abcdef'\n+\n+    class DummyResponse(object):","path":"scripts/tests.py","position":90,"original_position":90,"commit_id":"4b9b088285dabaafe3521495078c05404d99dc57","original_commit_id":"4b9b088285dabaafe3521495078c05404d99dc57","user":{"login":"glyph","id":716529,"avatar_url":"https://avatars.githubusercontent.com/u/716529?v=3","gravatar_id":"","url":"https://api.github.com/users/glyph","html_url":"https://github.com/glyph","followers_url":"https://api.github.com/users/glyph/followers","following_url":"https://api.github.com/users/glyph/following{/other_user}","gists_url":"https://api.github.com/users/glyph/gists{/gist_id}","starred_url":"https://api.github.com/users/glyph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glyph/subscriptions","organizations_url":"https://api.github.com/users/glyph/orgs","repos_url":"https://api.github.com/users/glyph/repos","events_url":"https://api.github.com/users/glyph/events{/privacy}","received_events_url":"https://api.github.com/users/glyph/received_events","type":"User","site_admin":false},"body":"This should clearly link to which exact \"response\" object it is a dummy for.\r\n\r\nIf possible, you should try to re-use an existing mock object somewhere in your code rather than making a new one.  If not, you should, make sure that you have a tech debt / backlog task to unify some of your fakes and mocks.\r\n\r\nAdding a new fake object for every test like this eventually becomes a significant maintenance burden, for two reasons.\r\n\r\nFor starters, a proliferation of different types like this just means more lines of code to maintain and understand.  And that by itself is bad.\r\n\r\nBut, worse yet, many different mock types means more different (and undocumented!) places that need to be updated if you make any change to the object that these are fakes for.  It means that your tests have less value as regression tests, since they're not going to notice any issues with changes in the system you're testing against.\r\n\r\nThat doesn't mean you should be doing full-bore integration tests.  That would make your tests non-deterministic; just that you should have a single funnel through which you control all your mocks of a certain type.\r\n\r\nThis is a pretty good article on the subject: https://codewithoutrules.com/2016/07/31/verified-fakes/","created_at":"2016-10-19T23:23:39Z","updated_at":"2016-10-19T23:26:10Z","html_url":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts/pull/5#discussion_r84188102","pull_request_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/comments/84188102"},"html":{"href":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts/pull/5#discussion_r84188102"},"pull_request":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5","id":89690519,"html_url":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts/pull/5","diff_url":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts/pull/5.diff","patch_url":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts/pull/5.patch","issue_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/issues/5","number":5,"state":"open","locked":false,"title":"Perf test auth","user":{"login":"izrik","id":1711679,"avatar_url":"https://avatars.githubusercontent.com/u/1711679?v=3","gravatar_id":"","url":"https://api.github.com/users/izrik","html_url":"https://github.com/izrik","followers_url":"https://api.github.com/users/izrik/followers","following_url":"https://api.github.com/users/izrik/following{/other_user}","gists_url":"https://api.github.com/users/izrik/gists{/gist_id}","starred_url":"https://api.github.com/users/izrik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/izrik/subscriptions","organizations_url":"https://api.github.com/users/izrik/orgs","repos_url":"https://api.github.com/users/izrik/repos","events_url":"https://api.github.com/users/izrik/events{/privacy}","received_events_url":"https://api.github.com/users/izrik/received_events","type":"User","site_admin":false},"body":"This PR adds the ability to authenticate against an identity service when running tests, so as to use a real tenant id instead of just `\"tenantId\"`. It adds the `User` and `AuthenticatingRequest` classes, the `auth_*` configuration properties, and a dependency on jasypt.\r\n\r\nThis PR is a little large. I could easily split it into two to make it easier to review.\r\n\r\nTODO: Only `IngestThread` has been modified to use the authenticated tenant in the url. The other thread and query types need to be modified as well.","created_at":"2016-10-17T19:53:05Z","updated_at":"2016-10-19T23:26:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"684d9c51dc5f81a6dfd6ac2ff82e7fe50503c501","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5/commits","review_comments_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5/comments","review_comment_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/issues/5/comments","statuses_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/statuses/4b9b088285dabaafe3521495078c05404d99dc57","head":{"label":"izrik:perf-test-auth","ref":"perf-test-auth","sha":"4b9b088285dabaafe3521495078c05404d99dc57","user":{"login":"izrik","id":1711679,"avatar_url":"https://avatars.githubusercontent.com/u/1711679?v=3","gravatar_id":"","url":"https://api.github.com/users/izrik","html_url":"https://github.com/izrik","followers_url":"https://api.github.com/users/izrik/followers","following_url":"https://api.github.com/users/izrik/following{/other_user}","gists_url":"https://api.github.com/users/izrik/gists{/gist_id}","starred_url":"https://api.github.com/users/izrik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/izrik/subscriptions","organizations_url":"https://api.github.com/users/izrik/orgs","repos_url":"https://api.github.com/users/izrik/repos","events_url":"https://api.github.com/users/izrik/events{/privacy}","received_events_url":"https://api.github.com/users/izrik/received_events","type":"User","site_admin":false},"repo":{"id":70745386,"name":"raxmetrics-perf-test-scripts","full_name":"izrik/raxmetrics-perf-test-scripts","owner":{"login":"izrik","id":1711679,"avatar_url":"https://avatars.githubusercontent.com/u/1711679?v=3","gravatar_id":"","url":"https://api.github.com/users/izrik","html_url":"https://github.com/izrik","followers_url":"https://api.github.com/users/izrik/followers","following_url":"https://api.github.com/users/izrik/following{/other_user}","gists_url":"https://api.github.com/users/izrik/gists{/gist_id}","starred_url":"https://api.github.com/users/izrik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/izrik/subscriptions","organizations_url":"https://api.github.com/users/izrik/orgs","repos_url":"https://api.github.com/users/izrik/repos","events_url":"https://api.github.com/users/izrik/events{/privacy}","received_events_url":"https://api.github.com/users/izrik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/izrik/raxmetrics-perf-test-scripts","description":"Grinder scripts for performance testing of Rackspace Metrics https://one.rackspace.com/display/cloudmetrics/Rackspace+Metrics","fork":true,"url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts","forks_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/forks","keys_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/teams","hooks_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/hooks","issue_events_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/events","assignees_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/tags","blobs_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/languages","stargazers_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/stargazers","contributors_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/contributors","subscribers_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/subscribers","subscription_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/subscription","commits_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/merges","archive_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/downloads","issues_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/labels{/name}","releases_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/izrik/raxmetrics-perf-test-scripts/deployments","created_at":"2016-10-12T22:01:55Z","updated_at":"2016-10-12T22:01:56Z","pushed_at":"2016-10-17T19:44:53Z","git_url":"git://github.com/izrik/raxmetrics-perf-test-scripts.git","ssh_url":"git@github.com:izrik/raxmetrics-perf-test-scripts.git","clone_url":"https://github.com/izrik/raxmetrics-perf-test-scripts.git","svn_url":"https://github.com/izrik/raxmetrics-perf-test-scripts","homepage":null,"size":245,"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":"master"}},"base":{"label":"rackerlabs:master","ref":"master","sha":"35782901e78cfd6bdc23dde6f9c1fe83e6ed06d5","user":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":64854159,"name":"raxmetrics-perf-test-scripts","full_name":"rackerlabs/raxmetrics-perf-test-scripts","owner":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts","description":"Grinder scripts for performance testing of Rackspace Metrics https://one.rackspace.com/display/cloudmetrics/Rackspace+Metrics","fork":false,"url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts","forks_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/forks","keys_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/teams","hooks_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/hooks","issue_events_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/events","assignees_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/tags","blobs_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/languages","stargazers_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/stargazers","contributors_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/contributors","subscribers_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/subscribers","subscription_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/subscription","commits_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/merges","archive_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/downloads","issues_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/labels{/name}","releases_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/deployments","created_at":"2016-08-03T14:50:08Z","updated_at":"2016-09-16T20:02:33Z","pushed_at":"2016-10-17T19:53:05Z","git_url":"git://github.com/rackerlabs/raxmetrics-perf-test-scripts.git","ssh_url":"git@github.com:rackerlabs/raxmetrics-perf-test-scripts.git","clone_url":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts.git","svn_url":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts","homepage":null,"size":236,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":1,"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5"},"html":{"href":"https://github.com/rackerlabs/raxmetrics-perf-test-scripts/pull/5"},"issue":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/issues/5"},"comments":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/rackerlabs/raxmetrics-perf-test-scripts/statuses/4b9b088285dabaafe3521495078c05404d99dc57"}}}}
{"actor":{"display_login":"glyph"}}