{"action":"created","comment":{"url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments/69647665","id":69647665,"diff_hunk":"@@ -75,22 +77,55 @@ func TestWritingToAuditLog(t *testing.T) {\n \t\tif len(tokens) != (commonAuditLogEntryFieldCount + getCredentialsEntryFieldCount) {\n \n \t\t}\n-\t\tverifyAuditLogEntryResult(logLine, t)\n-\t\tverifyCommonAuditLogEntryFieldResult(strings.Join(tokens[:commonAuditLogEntryFieldCount], \" \"), t)\n+\t\tverifyAuditLogEntryResult(logLine, taskArn, t)\n+\t\tverifyCommonAuditLogEntryFieldResult(strings.Join(tokens[:commonAuditLogEntryFieldCount], \" \"), taskArn, t)\n \t\tverifyConstructAuditLogEntryGetCredentialsResult(strings.Join(tokens[commonAuditLogEntryFieldCount:], \" \"), t)\n \t})\n \n-\tauditLogger.Log(req, dummyResponseCode, GetCredentialsEventType())\n+\tauditLogger.Log(request.LogRequest{Request: req, Arn: taskArn}, dummyResponseCode, GetCredentialsEventType())\n }\n \n-func verifyAuditLogEntryResult(logLine string, t *testing.T) {\n-\ttokens := strings.Split(logLine, \" \")\n-\tif len(tokens) != (commonAuditLogEntryFieldCount + getCredentialsEntryFieldCount) {\n-\t\tt.Fatalf(\"Incorrect number of tokens in audit log entry. Expected %d.\",\n-\t\t\tcommonAuditLogEntryFieldCount+getCredentialsEntryFieldCount)\n+func TestWritingErrorsToAuditLog(t *testing.T) {\n+\tctrl := gomock.NewController(t)\n+\tdefer ctrl.Finish()\n+\n+\tmockInfoLogger := mock_infologger.NewMockInfoLogger(ctrl)\n+\n+\treq, _ := http.NewRequest(\"GET\", \"foo\", nil)\n+\treq.RemoteAddr = dummyRemoteAddress\n+\tparsedUrl, err := url.Parse(dummyUrl)\n+\tif err != nil {\n+\t\tt.Fatal(\"error parsing dummyUrl\")\n \t}\n-\tverifyCommonAuditLogEntryFieldResult(strings.Join(tokens[:commonAuditLogEntryFieldCount], \" \"), t)\n-\tverifyConstructAuditLogEntryGetCredentialsResult(strings.Join(tokens[commonAuditLogEntryFieldCount:], \" \"), t)\n+\treq.URL = parsedUrl\n+\treq.Header.Set(\"User-Agent\", dummyUserAgent)\n+\n+\tcfg := &config.Config{\n+\t\tCluster:                 dummyCluster,\n+\t\tCredentialsAuditLogFile: \"foo.txt\",\n+\t}\n+\n+\tauditLogger := NewAuditLog(dummyContainerInstanceArn, cfg, mockInfoLogger)\n+\n+\tif auditLogger.GetCluster() != dummyCluster {\n+\t\tt.Fatal(\"Cluster is not initialized properly\")\n+\t}\n+\n+\tif auditLogger.GetContainerInstanceArn() != dummyContainerInstanceArn {\n+\t\tt.Fatal(\"ContainerInstanceArn is not initialized properly\")\n+\t}\n+\n+\tmockInfoLogger.EXPECT().Info(gomock.Any()).Do(func(logLine string) {\n+\t\ttokens := strings.Split(logLine, \" \")\n+\t\tif len(tokens) != (commonAuditLogEntryFieldCount + getCredentialsEntryFieldCount) {","path":"agent/logger/audit/audit_log_test.go","position":73,"original_position":73,"commit_id":"ed48acd3c90cb6bff55058a9b36e428819ff57b9","original_commit_id":"ed48acd3c90cb6bff55058a9b36e428819ff57b9","user":{"login":"aaithal","id":1183359,"avatar_url":"https://avatars.githubusercontent.com/u/1183359?v=3","gravatar_id":"","url":"https://api.github.com/users/aaithal","html_url":"https://github.com/aaithal","followers_url":"https://api.github.com/users/aaithal/followers","following_url":"https://api.github.com/users/aaithal/following{/other_user}","gists_url":"https://api.github.com/users/aaithal/gists{/gist_id}","starred_url":"https://api.github.com/users/aaithal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaithal/subscriptions","organizations_url":"https://api.github.com/users/aaithal/orgs","repos_url":"https://api.github.com/users/aaithal/repos","events_url":"https://api.github.com/users/aaithal/events{/privacy}","received_events_url":"https://api.github.com/users/aaithal/received_events","type":"User","site_admin":false},"body":"Ah, test code copied from an existing test. I'll fix both of those to not have this repeated validation code. ","created_at":"2016-07-05T22:16:08Z","updated_at":"2016-07-05T22:16:08Z","html_url":"https://github.com/aws/amazon-ecs-agent/pull/444#discussion_r69647665","pull_request_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444","_links":{"self":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments/69647665"},"html":{"href":"https://github.com/aws/amazon-ecs-agent/pull/444#discussion_r69647665"},"pull_request":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444"}}},"pull_request":{"url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444","id":76347873,"html_url":"https://github.com/aws/amazon-ecs-agent/pull/444","diff_url":"https://github.com/aws/amazon-ecs-agent/pull/444.diff","patch_url":"https://github.com/aws/amazon-ecs-agent/pull/444.patch","issue_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/444","number":444,"state":"open","locked":false,"title":"Log Task Arn in credentials access log.","user":{"login":"aaithal","id":1183359,"avatar_url":"https://avatars.githubusercontent.com/u/1183359?v=3","gravatar_id":"","url":"https://api.github.com/users/aaithal","html_url":"https://github.com/aaithal","followers_url":"https://api.github.com/users/aaithal/followers","following_url":"https://api.github.com/users/aaithal/following{/other_user}","gists_url":"https://api.github.com/users/aaithal/gists{/gist_id}","starred_url":"https://api.github.com/users/aaithal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaithal/subscriptions","organizations_url":"https://api.github.com/users/aaithal/orgs","repos_url":"https://api.github.com/users/aaithal/repos","events_url":"https://api.github.com/users/aaithal/events{/privacy}","received_events_url":"https://api.github.com/users/aaithal/received_events","type":"User","site_admin":false},"body":"* Modify credentials.Manager interface to set and get taks credentials. Task\r\n  credentials include the IAMRoleCredentials object and the task arn.\r\n* Modify audit logger interface to accept custom LogRequest type instead of\r\n  http Requests. This is useful for passing additional metadata fields to\r\n  the logger and wraps the http Request in a custom Request type. This is\r\n  also used to log the arn that is associated with the credentials request\r\n  in the access log.","created_at":"2016-07-05T21:41:10Z","updated_at":"2016-07-05T22:16:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5b03b6e643462f90cebab89bdc4907450fc5d868","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444/commits","review_comments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444/comments","review_comment_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/444/comments","statuses_url":"https://api.github.com/repos/aws/amazon-ecs-agent/statuses/ed48acd3c90cb6bff55058a9b36e428819ff57b9","head":{"label":"aaithal:TaskIAMRolesTaskArnInAccessLog","ref":"TaskIAMRolesTaskArnInAccessLog","sha":"ed48acd3c90cb6bff55058a9b36e428819ff57b9","user":{"login":"aaithal","id":1183359,"avatar_url":"https://avatars.githubusercontent.com/u/1183359?v=3","gravatar_id":"","url":"https://api.github.com/users/aaithal","html_url":"https://github.com/aaithal","followers_url":"https://api.github.com/users/aaithal/followers","following_url":"https://api.github.com/users/aaithal/following{/other_user}","gists_url":"https://api.github.com/users/aaithal/gists{/gist_id}","starred_url":"https://api.github.com/users/aaithal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaithal/subscriptions","organizations_url":"https://api.github.com/users/aaithal/orgs","repos_url":"https://api.github.com/users/aaithal/repos","events_url":"https://api.github.com/users/aaithal/events{/privacy}","received_events_url":"https://api.github.com/users/aaithal/received_events","type":"User","site_admin":false},"repo":{"id":30386191,"name":"amazon-ecs-agent","full_name":"aaithal/amazon-ecs-agent","owner":{"login":"aaithal","id":1183359,"avatar_url":"https://avatars.githubusercontent.com/u/1183359?v=3","gravatar_id":"","url":"https://api.github.com/users/aaithal","html_url":"https://github.com/aaithal","followers_url":"https://api.github.com/users/aaithal/followers","following_url":"https://api.github.com/users/aaithal/following{/other_user}","gists_url":"https://api.github.com/users/aaithal/gists{/gist_id}","starred_url":"https://api.github.com/users/aaithal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaithal/subscriptions","organizations_url":"https://api.github.com/users/aaithal/orgs","repos_url":"https://api.github.com/users/aaithal/repos","events_url":"https://api.github.com/users/aaithal/events{/privacy}","received_events_url":"https://api.github.com/users/aaithal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aaithal/amazon-ecs-agent","description":"Amazon EC2 Container Service Agent","fork":true,"url":"https://api.github.com/repos/aaithal/amazon-ecs-agent","forks_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/forks","keys_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/teams","hooks_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/hooks","issue_events_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/issues/events{/number}","events_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/events","assignees_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/assignees{/user}","branches_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/branches{/branch}","tags_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/tags","blobs_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/languages","stargazers_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/stargazers","contributors_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/contributors","subscribers_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/subscribers","subscription_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/subscription","commits_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/contents/{+path}","compare_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/merges","archive_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/downloads","issues_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/issues{/number}","pulls_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/labels{/name}","releases_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/releases{/id}","deployments_url":"https://api.github.com/repos/aaithal/amazon-ecs-agent/deployments","created_at":"2015-02-06T00:24:31Z","updated_at":"2015-04-27T22:13:41Z","pushed_at":"2016-07-05T21:36:21Z","git_url":"git://github.com/aaithal/amazon-ecs-agent.git","ssh_url":"git@github.com:aaithal/amazon-ecs-agent.git","clone_url":"https://github.com/aaithal/amazon-ecs-agent.git","svn_url":"https://github.com/aaithal/amazon-ecs-agent","homepage":"http://aws.amazon.com/ecs/","size":3822,"stargazers_count":2,"watchers_count":2,"language":"Go","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":2,"default_branch":"master"}},"base":{"label":"aws:dev","ref":"dev","sha":"48e66eb40037735ce84a914e53da305c643546cc","user":{"login":"aws","id":2232217,"avatar_url":"https://avatars.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"repo":{"id":27551774,"name":"amazon-ecs-agent","full_name":"aws/amazon-ecs-agent","owner":{"login":"aws","id":2232217,"avatar_url":"https://avatars.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aws/amazon-ecs-agent","description":"Amazon EC2 Container Service Agent","fork":false,"url":"https://api.github.com/repos/aws/amazon-ecs-agent","forks_url":"https://api.github.com/repos/aws/amazon-ecs-agent/forks","keys_url":"https://api.github.com/repos/aws/amazon-ecs-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aws/amazon-ecs-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aws/amazon-ecs-agent/teams","hooks_url":"https://api.github.com/repos/aws/amazon-ecs-agent/hooks","issue_events_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/events{/number}","events_url":"https://api.github.com/repos/aws/amazon-ecs-agent/events","assignees_url":"https://api.github.com/repos/aws/amazon-ecs-agent/assignees{/user}","branches_url":"https://api.github.com/repos/aws/amazon-ecs-agent/branches{/branch}","tags_url":"https://api.github.com/repos/aws/amazon-ecs-agent/tags","blobs_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aws/amazon-ecs-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/aws/amazon-ecs-agent/languages","stargazers_url":"https://api.github.com/repos/aws/amazon-ecs-agent/stargazers","contributors_url":"https://api.github.com/repos/aws/amazon-ecs-agent/contributors","subscribers_url":"https://api.github.com/repos/aws/amazon-ecs-agent/subscribers","subscription_url":"https://api.github.com/repos/aws/amazon-ecs-agent/subscription","commits_url":"https://api.github.com/repos/aws/amazon-ecs-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/aws/amazon-ecs-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/aws/amazon-ecs-agent/contents/{+path}","compare_url":"https://api.github.com/repos/aws/amazon-ecs-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aws/amazon-ecs-agent/merges","archive_url":"https://api.github.com/repos/aws/amazon-ecs-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aws/amazon-ecs-agent/downloads","issues_url":"https://api.github.com/repos/aws/amazon-ecs-agent/issues{/number}","pulls_url":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/aws/amazon-ecs-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/aws/amazon-ecs-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aws/amazon-ecs-agent/labels{/name}","releases_url":"https://api.github.com/repos/aws/amazon-ecs-agent/releases{/id}","deployments_url":"https://api.github.com/repos/aws/amazon-ecs-agent/deployments","created_at":"2014-12-04T17:31:49Z","updated_at":"2016-07-04T09:33:10Z","pushed_at":"2016-07-05T21:41:10Z","git_url":"git://github.com/aws/amazon-ecs-agent.git","ssh_url":"git@github.com:aws/amazon-ecs-agent.git","clone_url":"https://github.com/aws/amazon-ecs-agent.git","svn_url":"https://github.com/aws/amazon-ecs-agent","homepage":"http://aws.amazon.com/ecs/","size":7259,"stargazers_count":592,"watchers_count":592,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":155,"mirror_url":null,"open_issues_count":53,"forks":155,"open_issues":53,"watchers":592,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444"},"html":{"href":"https://github.com/aws/amazon-ecs-agent/pull/444"},"issue":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/444"},"comments":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/issues/444/comments"},"review_comments":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444/comments"},"review_comment":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/pulls/444/commits"},"statuses":{"href":"https://api.github.com/repos/aws/amazon-ecs-agent/statuses/ed48acd3c90cb6bff55058a9b36e428819ff57b9"}}}}
{"actor":{"display_login":"aaithal"}}