{"action":"created","comment":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/29326099","id":29326099,"diff_hunk":"@@ -0,0 +1,86 @@\n+# Copyright Hybrid Logic Ltd.  See LICENSE file for details.\n+\n+\"\"\"\n+Tests for :module:`flocker.provision._ssh._keys`.\n+\"\"\"\n+\n+import os\n+\n+from twisted.internet import reactor\n+from twisted.python.filepath import FilePath\n+from twisted.trial.unittest import TestCase\n+\n+from flocker.testtools.ssh import create_ssh_agent, generate_ssh_key\n+\n+from .._ssh._keys import ensure_agent_has_ssh_key, KeyNotFound, AgentNotFound\n+\n+\n+class EnsureKeyTests(TestCase):\n+    \"\"\"\n+    Tests for ``ensure_agent_has_ssh_key``.\n+    \"\"\"\n+    def test_public_key_in_agent(self):\n+        \"\"\"\n+        If the running ssh-agent has the private key, assoicated to the\n+        provided public key, then ``ssh_agent_has_ssh_key`` returns a succesful\n+        deferred.\n+        \"\"\"\n+        key_file = FilePath(self.mktemp())\n+        key = generate_ssh_key(key_file).public()\n+\n+        create_ssh_agent(key_file, self)\n+\n+        result = ensure_agent_has_ssh_key(reactor, key)\n+        # No assertion, since the deferred should fire with a\n+        # succesful result.\n+        return result\n+\n+    def test_private_key_in_agent(self):\n+        \"\"\"\n+        If the running ssh-agent has the provided private key, then\n+        ``ssh_agent_has_ssh_key`` returns a succesful deferred.\n+        \"\"\"\n+        key_file = FilePath(self.mktemp())\n+        key = generate_ssh_key(key_file)\n+\n+        create_ssh_agent(key_file, self)\n+\n+        result = ensure_agent_has_ssh_key(reactor, key)\n+        # No assertion, since the deferred should fire with a\n+        # succesful result.\n+        return result\n+\n+    def test_public_key_not_in_agent(self):\n+        \"\"\"\n+        If the running ssh-agent does not have a key assoicated to the given\n+        public key, then ``ssh_agent_has_ssh_key`` returns ``False``.\n+        a deferred that fails with ``KeyNotFound``.\n+        \"\"\"\n+        key_file = FilePath(self.mktemp())\n+        generate_ssh_key(key_file)\n+        create_ssh_agent(key_file, self)\n+\n+        other_key = generate_ssh_key(FilePath(self.mktemp())).public()\n+\n+        result = ensure_agent_has_ssh_key(reactor, other_key)\n+        return self.assertFailure(result, KeyNotFound)\n+\n+    def test_agent_not_found(self):\n+        \"\"\"\n+        If there is not a running ssh-agent, ``ssh_agent_has_ssh_key returns","path":"flocker/provision/test/test_ssh_keys.py","position":70,"original_position":70,"commit_id":"8243130e20120567f02ad05e9c81e2778897d7f3","original_commit_id":"8243130e20120567f02ad05e9c81e2778897d7f3","user":{"login":"adamtheturtle","id":797801,"avatar_url":"https://avatars.githubusercontent.com/u/797801?v=3","gravatar_id":"","url":"https://api.github.com/users/adamtheturtle","html_url":"https://github.com/adamtheturtle","followers_url":"https://api.github.com/users/adamtheturtle/followers","following_url":"https://api.github.com/users/adamtheturtle/following{/other_user}","gists_url":"https://api.github.com/users/adamtheturtle/gists{/gist_id}","starred_url":"https://api.github.com/users/adamtheturtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamtheturtle/subscriptions","organizations_url":"https://api.github.com/users/adamtheturtle/orgs","repos_url":"https://api.github.com/users/adamtheturtle/repos","events_url":"https://api.github.com/users/adamtheturtle/events{/privacy}","received_events_url":"https://api.github.com/users/adamtheturtle/received_events","type":"User","site_admin":false},"body":"Closing backticks","created_at":"2015-04-29T11:00:03Z","updated_at":"2015-04-29T11:00:03Z","html_url":"https://github.com/ClusterHQ/flocker/pull/1351#discussion_r29326099","pull_request_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351","_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments/29326099"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/1351#discussion_r29326099"},"pull_request":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351"}}},"pull_request":{"url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351","id":34334651,"html_url":"https://github.com/ClusterHQ/flocker/pull/1351","diff_url":"https://github.com/ClusterHQ/flocker/pull/1351.diff","patch_url":"https://github.com/ClusterHQ/flocker/pull/1351.patch","issue_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/1351","number":1351,"state":"open","locked":false,"title":"[FLOC-1776] Check ssh-keys from cloud provider is availble in agent.","user":{"login":"tomprince","id":283816,"avatar_url":"https://avatars.githubusercontent.com/u/283816?v=3","gravatar_id":"","url":"https://api.github.com/users/tomprince","html_url":"https://github.com/tomprince","followers_url":"https://api.github.com/users/tomprince/followers","following_url":"https://api.github.com/users/tomprince/following{/other_user}","gists_url":"https://api.github.com/users/tomprince/gists{/gist_id}","starred_url":"https://api.github.com/users/tomprince/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomprince/subscriptions","organizations_url":"https://api.github.com/users/tomprince/orgs","repos_url":"https://api.github.com/users/tomprince/repos","events_url":"https://api.github.com/users/tomprince/events{/privacy}","received_events_url":"https://api.github.com/users/tomprince/received_events","type":"User","site_admin":false},"body":"https://clusterhq.atlassian.net/browse/FLOC-1776","created_at":"2015-04-29T05:38:22Z","updated_at":"2015-04-29T11:00:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9fc4f843ab8b6f96d4851bee5fb7ddfb4349fc10","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351/commits","review_comments_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351/comments","review_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/1351/comments","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/8243130e20120567f02ad05e9c81e2778897d7f3","head":{"label":"ClusterHQ:check-cloud-ssh-keys-FLOC-1776","ref":"check-cloud-ssh-keys-FLOC-1776","sha":"8243130e20120567f02ad05e9c81e2778897d7f3","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Easily manage Docker containers & their data","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-04-29T09:04:59Z","pushed_at":"2015-04-29T10:43:32Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":54546,"stargazers_count":1377,"watchers_count":1377,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":22,"forks":76,"open_issues":22,"watchers":1377,"default_branch":"master"}},"base":{"label":"ClusterHQ:master","ref":"master","sha":"acd02521cab1b7a1e6fb7220d3b59b1ff2ce42b8","user":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"repo":{"id":19248542,"name":"flocker","full_name":"ClusterHQ/flocker","owner":{"login":"ClusterHQ","id":7913449,"avatar_url":"https://avatars.githubusercontent.com/u/7913449?v=3","gravatar_id":"","url":"https://api.github.com/users/ClusterHQ","html_url":"https://github.com/ClusterHQ","followers_url":"https://api.github.com/users/ClusterHQ/followers","following_url":"https://api.github.com/users/ClusterHQ/following{/other_user}","gists_url":"https://api.github.com/users/ClusterHQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ClusterHQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ClusterHQ/subscriptions","organizations_url":"https://api.github.com/users/ClusterHQ/orgs","repos_url":"https://api.github.com/users/ClusterHQ/repos","events_url":"https://api.github.com/users/ClusterHQ/events{/privacy}","received_events_url":"https://api.github.com/users/ClusterHQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ClusterHQ/flocker","description":"Easily manage Docker containers & their data","fork":false,"url":"https://api.github.com/repos/ClusterHQ/flocker","forks_url":"https://api.github.com/repos/ClusterHQ/flocker/forks","keys_url":"https://api.github.com/repos/ClusterHQ/flocker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ClusterHQ/flocker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ClusterHQ/flocker/teams","hooks_url":"https://api.github.com/repos/ClusterHQ/flocker/hooks","issue_events_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/events{/number}","events_url":"https://api.github.com/repos/ClusterHQ/flocker/events","assignees_url":"https://api.github.com/repos/ClusterHQ/flocker/assignees{/user}","branches_url":"https://api.github.com/repos/ClusterHQ/flocker/branches{/branch}","tags_url":"https://api.github.com/repos/ClusterHQ/flocker/tags","blobs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ClusterHQ/flocker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ClusterHQ/flocker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ClusterHQ/flocker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ClusterHQ/flocker/statuses/{sha}","languages_url":"https://api.github.com/repos/ClusterHQ/flocker/languages","stargazers_url":"https://api.github.com/repos/ClusterHQ/flocker/stargazers","contributors_url":"https://api.github.com/repos/ClusterHQ/flocker/contributors","subscribers_url":"https://api.github.com/repos/ClusterHQ/flocker/subscribers","subscription_url":"https://api.github.com/repos/ClusterHQ/flocker/subscription","commits_url":"https://api.github.com/repos/ClusterHQ/flocker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ClusterHQ/flocker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ClusterHQ/flocker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ClusterHQ/flocker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ClusterHQ/flocker/contents/{+path}","compare_url":"https://api.github.com/repos/ClusterHQ/flocker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ClusterHQ/flocker/merges","archive_url":"https://api.github.com/repos/ClusterHQ/flocker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ClusterHQ/flocker/downloads","issues_url":"https://api.github.com/repos/ClusterHQ/flocker/issues{/number}","pulls_url":"https://api.github.com/repos/ClusterHQ/flocker/pulls{/number}","milestones_url":"https://api.github.com/repos/ClusterHQ/flocker/milestones{/number}","notifications_url":"https://api.github.com/repos/ClusterHQ/flocker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ClusterHQ/flocker/labels{/name}","releases_url":"https://api.github.com/repos/ClusterHQ/flocker/releases{/id}","created_at":"2014-04-28T18:02:14Z","updated_at":"2015-04-29T09:04:59Z","pushed_at":"2015-04-29T10:43:32Z","git_url":"git://github.com/ClusterHQ/flocker.git","ssh_url":"git@github.com:ClusterHQ/flocker.git","clone_url":"https://github.com/ClusterHQ/flocker.git","svn_url":"https://github.com/ClusterHQ/flocker","homepage":"https://clusterhq.com","size":54546,"stargazers_count":1377,"watchers_count":1377,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":22,"forks":76,"open_issues":22,"watchers":1377,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351"},"html":{"href":"https://github.com/ClusterHQ/flocker/pull/1351"},"issue":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/1351"},"comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/issues/1351/comments"},"review_comments":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351/comments"},"review_comment":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ClusterHQ/flocker/pulls/1351/commits"},"statuses":{"href":"https://api.github.com/repos/ClusterHQ/flocker/statuses/8243130e20120567f02ad05e9c81e2778897d7f3"}}}}