{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/comments/67373736","id":67373736,"diff_hunk":"@@ -1703,4 +1709,125 @@ var _ = Describe(\"RDS Broker\", func() {\n \t\t\t})\n \t\t})\n \t})\n+\n+\tvar _ = Describe(\"CheckAndRotateCredentials\", func() {\n+\t\tContext(\"when there is no DB instance\", func() {\n+\t\t\tIt(\"shouldn't try to connect to databases\", func() {\n+\t\t\t\terr := rdsBroker.CheckAndRotateCredentials()\n+\t\t\t\tExpect(err).ToNot(HaveOccurred())\n+\t\t\t\tExpect(sqlProvider.GetSQLEngineCalled).To(BeFalse())\n+\t\t\t\tExpect(sqlEngine.OpenCalled).To(BeFalse())\n+\t\t\t})\n+\t\t})\n+\n+\t\tContext(\"when there are DB instances\", func() {\n+\t\t\tBeforeEach(func() {\n+\t\t\t\tdbInstance.DescribeByTagDBInstanceDetails = []*awsrds.DBInstanceDetails{\n+\t\t\t\t\t&awsrds.DBInstanceDetails{\n+\t\t\t\t\t\tIdentifier:     dbInstanceIdentifier,\n+\t\t\t\t\t\tAddress:        \"endpoint-address\",\n+\t\t\t\t\t\tPort:           3306,\n+\t\t\t\t\t\tDBName:         \"test-db\",\n+\t\t\t\t\t\tMasterUsername: \"master-username\",\n+\t\t\t\t\t\tEngine:         \"fake-engine\",\n+\t\t\t\t\t},\n+\t\t\t\t}\n+\t\t\t})\n+\n+\t\t\tIt(\"should try to connect to databases\", func() {\n+\t\t\t\terr := rdsBroker.CheckAndRotateCredentials()\n+\t\t\t\tExpect(err).ToNot(HaveOccurred())\n+\t\t\t\tExpect(dbInstance.DescribeByTagCalled).To(BeTrue())\n+\t\t\t\tExpect(dbInstance.DescribeByTagKey).To(BeEquivalentTo(\"Broker Name\"))\n+\t\t\t\tExpect(dbInstance.DescribeByTagValue).To(BeEquivalentTo(brokerName))\n+\t\t\t\tExpect(sqlProvider.GetSQLEngineCalled).To(BeTrue())\n+\t\t\t\tExpect(sqlProvider.GetSQLEngineEngine).To(BeEquivalentTo(\"fake-engine\"))\n+\t\t\t\tExpect(sqlEngine.OpenCalled).To(BeTrue())\n+\t\t\t\tExpect(sqlEngine.OpenAddress).To(BeEquivalentTo(\"endpoint-address\"))\n+\t\t\t\tExpect(sqlEngine.OpenPort).To(BeEquivalentTo(3306))\n+\t\t\t\tExpect(sqlEngine.OpenDBName).To(BeEquivalentTo(\"test-db\"))\n+\t\t\t\tExpect(sqlEngine.OpenUsername).To(BeEquivalentTo(\"master-username\"))\n+\t\t\t})\n+\n+\t\t\tContext(\"and the passwords work\", func() {\n+\t\t\t\tIt(\"should not try to change the master password\", func() {\n+\t\t\t\t\terr := rdsBroker.CheckAndRotateCredentials()\n+\t\t\t\t\tExpect(err).ToNot(HaveOccurred())\n+\t\t\t\t\tExpect(dbInstance.ModifyCalled).To(BeFalse())\n+\t\t\t\t})\n+\t\t\t})\n+\n+\t\t\tContext(\"and the passwords don't work\", func() {\n+\t\t\t\tBeforeEach(func() {\n+\t\t\t\t\tsqlEngine.PingError = errors.New(\"Login failed\")\n+\t\t\t\t})\n+\n+\t\t\t\tIt(\"should try to change the master password\", func() {\n+\t\t\t\t\terr := rdsBroker.CheckAndRotateCredentials()\n+\t\t\t\t\tExpect(err).ToNot(HaveOccurred())\n+\n+\t\t\t\t\tExpect(dbInstance.ModifyCalled).To(BeTrue())\n+\t\t\t\t\tExpect(dbInstance.ModifyID).To(BeEquivalentTo(dbInstanceIdentifier))\n+\t\t\t\t\tExpect(dbInstance.ModifyDBInstanceDetails.MasterUserPassword).To(BeEquivalentTo(sqlEngine.OpenPassword))\n+\t\t\t\t})\n+\t\t\t})\n+\n+\t\t\tContext(\"and there is an unkown ping error\", func() {\n+\t\t\t\tBeforeEach(func() {\n+\t\t\t\t\tsqlEngine.PingError = errors.New(\"Unknown ping error\")\n+\t\t\t\t})\n+\n+\t\t\t\tIt(\"should not try to change the master password\", func() {\n+\t\t\t\t\terr := rdsBroker.CheckAndRotateCredentials()\n+\t\t\t\t\tExpect(err).To(HaveOccurred())","path":"rdsbroker/broker_test.go","position":119,"original_position":119,"commit_id":"632e8076d4544eae1110111c36563dc2e5491387","original_commit_id":"632e8076d4544eae1110111c36563dc2e5491387","user":{"login":"dcarley","id":260438,"avatar_url":"https://avatars.githubusercontent.com/u/260438?v=3","gravatar_id":"","url":"https://api.github.com/users/dcarley","html_url":"https://github.com/dcarley","followers_url":"https://api.github.com/users/dcarley/followers","following_url":"https://api.github.com/users/dcarley/following{/other_user}","gists_url":"https://api.github.com/users/dcarley/gists{/gist_id}","starred_url":"https://api.github.com/users/dcarley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcarley/subscriptions","organizations_url":"https://api.github.com/users/dcarley/orgs","repos_url":"https://api.github.com/users/dcarley/repos","events_url":"https://api.github.com/users/dcarley/events{/privacy}","received_events_url":"https://api.github.com/users/dcarley/received_events","type":"User","site_admin":false},"body":"Can we be more specific about the error we're expecting?","created_at":"2016-06-16T16:05:48Z","updated_at":"2016-06-16T16:05:48Z","html_url":"https://github.com/alphagov/paas-rds-broker/pull/11#discussion_r67373736","pull_request_url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/comments/67373736"},"html":{"href":"https://github.com/alphagov/paas-rds-broker/pull/11#discussion_r67373736"},"pull_request":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11","id":73935328,"html_url":"https://github.com/alphagov/paas-rds-broker/pull/11","diff_url":"https://github.com/alphagov/paas-rds-broker/pull/11.diff","patch_url":"https://github.com/alphagov/paas-rds-broker/pull/11.patch","issue_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/11","number":11,"state":"open","locked":false,"title":"[#118479861] Seed and rotate RDS master password","user":{"login":"saliceti","id":8416694,"avatar_url":"https://avatars.githubusercontent.com/u/8416694?v=3","gravatar_id":"","url":"https://api.github.com/users/saliceti","html_url":"https://github.com/saliceti","followers_url":"https://api.github.com/users/saliceti/followers","following_url":"https://api.github.com/users/saliceti/following{/other_user}","gists_url":"https://api.github.com/users/saliceti/gists{/gist_id}","starred_url":"https://api.github.com/users/saliceti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saliceti/subscriptions","organizations_url":"https://api.github.com/users/saliceti/orgs","repos_url":"https://api.github.com/users/saliceti/repos","events_url":"https://api.github.com/users/saliceti/events{/privacy}","received_events_url":"https://api.github.com/users/saliceti/received_events","type":"User","site_admin":false},"body":"# What\r\nStory: [Generating secure master password for Postgres Instances](https://www.pivotaltracker.com/story/show/118479861)\r\n\r\nWe want to add a seed to generate the DB instances master passwords so they can't easily be guessed. The seed is set using a broker property.\r\nAs a consequence, we need to be able to rotate the passwords when the seed is changed. This is implemented by checking the connection on all instances at startup and resetting the password if necessary.\r\nThis relies on tags being applied on broker created instances. A temporary task was added to the pipeline to tag existing instances.\r\n\r\nThis should be tested with PRs on paas-aws-broker-boshrelease, paas-cf and paas-docker-cloudfoundry-tools.\r\n\r\n# How to review\r\n* Deploy on an existing environment. It should detect the RDS passwords have changed and reset the passwords.\r\n* Check the rds broker logs to confirm\r\n* Bind an existing DB\r\n* Create and bind a new DB\r\n* Unbind\r\n* Run autodelete\r\n\r\n### Expected error when the password is wrong\r\nThis should no happen:\r\n```\r\n$ cf bind-service mtest healthcheck-db\r\nBinding service healthcheck-db to app mtest in org testers / space healthcheck as admin...\r\nFAILED\r\nServer error, status code: 502, error code: 10001, message: Service broker error: pq: password authentication failed for user \"DJ4YDF83aJXWxX26\"\r\n```\r\n# Who can review\r\nAnyone but @saliceti, @mtekel, @keymon\r\n","created_at":"2016-06-15T15:42:05Z","updated_at":"2016-06-16T16:05:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"362fbbe6c7a7d2c9df890b97d80c51bb12264744","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11/commits","review_comments_url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11/comments","review_comment_url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/11/comments","statuses_url":"https://api.github.com/repos/alphagov/paas-rds-broker/statuses/632e8076d4544eae1110111c36563dc2e5491387","head":{"label":"alphagov:seed_master_passwords_118479861_2_godep","ref":"seed_master_passwords_118479861_2_godep","sha":"632e8076d4544eae1110111c36563dc2e5491387","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":58362897,"name":"paas-rds-broker","full_name":"alphagov/paas-rds-broker","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/paas-rds-broker","description":"","fork":false,"url":"https://api.github.com/repos/alphagov/paas-rds-broker","forks_url":"https://api.github.com/repos/alphagov/paas-rds-broker/forks","keys_url":"https://api.github.com/repos/alphagov/paas-rds-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/paas-rds-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/paas-rds-broker/teams","hooks_url":"https://api.github.com/repos/alphagov/paas-rds-broker/hooks","issue_events_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/paas-rds-broker/events","assignees_url":"https://api.github.com/repos/alphagov/paas-rds-broker/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/paas-rds-broker/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/paas-rds-broker/tags","blobs_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/paas-rds-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/paas-rds-broker/languages","stargazers_url":"https://api.github.com/repos/alphagov/paas-rds-broker/stargazers","contributors_url":"https://api.github.com/repos/alphagov/paas-rds-broker/contributors","subscribers_url":"https://api.github.com/repos/alphagov/paas-rds-broker/subscribers","subscription_url":"https://api.github.com/repos/alphagov/paas-rds-broker/subscription","commits_url":"https://api.github.com/repos/alphagov/paas-rds-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/paas-rds-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/paas-rds-broker/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/paas-rds-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/paas-rds-broker/merges","archive_url":"https://api.github.com/repos/alphagov/paas-rds-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/paas-rds-broker/downloads","issues_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/paas-rds-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/paas-rds-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/paas-rds-broker/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/paas-rds-broker/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/paas-rds-broker/deployments","created_at":"2016-05-09T08:59:29Z","updated_at":"2016-05-09T08:59:51Z","pushed_at":"2016-06-16T15:04:26Z","git_url":"git://github.com/alphagov/paas-rds-broker.git","ssh_url":"git@github.com:alphagov/paas-rds-broker.git","clone_url":"https://github.com/alphagov/paas-rds-broker.git","svn_url":"https://github.com/alphagov/paas-rds-broker","homepage":null,"size":4334,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"73d2b88af73894de0767fe36192716d836034ffb","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":58362897,"name":"paas-rds-broker","full_name":"alphagov/paas-rds-broker","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/paas-rds-broker","description":"","fork":false,"url":"https://api.github.com/repos/alphagov/paas-rds-broker","forks_url":"https://api.github.com/repos/alphagov/paas-rds-broker/forks","keys_url":"https://api.github.com/repos/alphagov/paas-rds-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/paas-rds-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/paas-rds-broker/teams","hooks_url":"https://api.github.com/repos/alphagov/paas-rds-broker/hooks","issue_events_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/paas-rds-broker/events","assignees_url":"https://api.github.com/repos/alphagov/paas-rds-broker/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/paas-rds-broker/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/paas-rds-broker/tags","blobs_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/paas-rds-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/paas-rds-broker/languages","stargazers_url":"https://api.github.com/repos/alphagov/paas-rds-broker/stargazers","contributors_url":"https://api.github.com/repos/alphagov/paas-rds-broker/contributors","subscribers_url":"https://api.github.com/repos/alphagov/paas-rds-broker/subscribers","subscription_url":"https://api.github.com/repos/alphagov/paas-rds-broker/subscription","commits_url":"https://api.github.com/repos/alphagov/paas-rds-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/paas-rds-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/paas-rds-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/alphagov/paas-rds-broker/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/paas-rds-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/paas-rds-broker/merges","archive_url":"https://api.github.com/repos/alphagov/paas-rds-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/paas-rds-broker/downloads","issues_url":"https://api.github.com/repos/alphagov/paas-rds-broker/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/paas-rds-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/paas-rds-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/paas-rds-broker/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/paas-rds-broker/releases{/id}","deployments_url":"https://api.github.com/repos/alphagov/paas-rds-broker/deployments","created_at":"2016-05-09T08:59:29Z","updated_at":"2016-05-09T08:59:51Z","pushed_at":"2016-06-16T15:04:26Z","git_url":"git://github.com/alphagov/paas-rds-broker.git","ssh_url":"git@github.com:alphagov/paas-rds-broker.git","clone_url":"https://github.com/alphagov/paas-rds-broker.git","svn_url":"https://github.com/alphagov/paas-rds-broker","homepage":null,"size":4334,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11"},"html":{"href":"https://github.com/alphagov/paas-rds-broker/pull/11"},"issue":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/11"},"comments":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/paas-rds-broker/statuses/632e8076d4544eae1110111c36563dc2e5491387"}}}}
{"actor":{"display_login":"dcarley"}}