{"action":"created","comment":{"url":"https://api.github.com/repos/docker/notary/pulls/comments/34207713","id":34207713,"diff_hunk":"@@ -0,0 +1,116 @@\n+package client\n+\n+import (\n+\t\"io/ioutil\"\n+\t\"os\"\n+\t\"path/filepath\"\n+\t\"testing\"\n+\n+\t\"github.com/docker/notary/trustmanager\"\n+\t\"github.com/endophage/gotuf/data\"\n+)\n+\n+// TestInitRepo runs through the process of initializing a repository and makes\n+// sure the repository looks correct on disk.\n+func TestInitRepo(t *testing.T) {\n+\t// Temporary directory where test files will be created\n+\ttempBaseDir, err := ioutil.TempDir(\"\", \"notary-test-\")\n+\tif err != nil {\n+\t\tt.Fatalf(\"failed to create a temporary directory: %s\", err)\n+\t}\n+\n+\tclient, err := NewClient(tempBaseDir)\n+\tif err != nil {\n+\t\tt.Fatalf(\"error creating client: %s\", err)\n+\t}\n+\n+\trootKeyID, err := client.GenRootKey(\"passphrase\")\n+\tif err != nil {\n+\t\tt.Fatalf(\"error generating root key: %s\", err)\n+\t}\n+\n+\trootKey, err := client.GetRootKey(rootKeyID, \"passphrase\")\n+\tif err != nil {\n+\t\tt.Fatalf(\"error retreiving root key: %s\", err)\n+\t}\n+\n+\tgun := \"docker.com/notary\"\n+\trepo, err := client.InitRepository(gun, \"\", nil, rootKey)\n+\tif err != nil {\n+\t\tt.Fatalf(\"error creating repository: %s\", err)\n+\t}\n+\n+\t// Inspect contents of the temporary directory\n+\texpectedDirs := []string{\n+\t\t\"private\",\n+\t\tfilepath.Join(\"private\", gun),\n+\t\tfilepath.Join(\"private\", \"root_keys\"),\n+\t\t\"trusted_certificates\",\n+\t\tfilepath.Join(\"trusted_certificates\", gun),\n+\t\t\"tuf\",\n+\t\tfilepath.Join(\"tuf\", gun, \"metadata\"),\n+\t\tfilepath.Join(\"tuf\", gun, \"targets\"),\n+\t}\n+\tfor _, dir := range expectedDirs {\n+\t\tfi, err := os.Stat(filepath.Join(tempBaseDir, dir))\n+\t\tif err != nil {\n+\t\t\tt.Fatalf(\"missing directory in base directory: %s\", dir)\n+\t\t}\n+\t\tif !fi.Mode().IsDir() {\n+\t\t\tt.Fatalf(\"%s is not a directory\", dir)\n+\t\t}\n+\t}\n+\n+\t// Look for keys in private. The filenames should match the key IDs\n+\t// in the private key store.\n+\tprivKeyList := repo.privKeyStore.ListAll()\n+\tfor _, privKeyName := range privKeyList {\n+\t\tif _, err := os.Stat(privKeyName); err != nil {\n+\t\t\tt.Fatalf(\"missing private key: %s\", privKeyName)\n+\t\t}\n+\t}\n+\n+\t// Look for keys in root_keys\n+\t// There should be a file named after the key ID of the root key we\n+\t// passed in.\n+\trootKeyFilename := rootKey.ID() + \".key\"\n+\tif _, err := os.Stat(filepath.Join(tempBaseDir, \"private\", \"root_keys\", rootKeyFilename)); err != nil {\n+\t\tt.Fatal(\"missing root key\")\n+\t}\n+\n+\t// Also expect a symlink from the key ID of the certificate key to this\n+\t// root key\n+\tcertificates := client.certificateStore.GetCertificates()\n+\tif len(certificates) != 1 {\n+\t\tt.Fatalf(\"unexpected number of certificates (%d)\", len(certificates))\n+\t}\n+\n+\tcertID := data.NewPublicKey(\"RSA\", trustmanager.CertToPEM(certificates[0])).ID()\n+\n+\tactualDest, err := os.Readlink(filepath.Join(tempBaseDir, \"private\", \"root_keys\", certID+\".key\"))","path":"client/client_test.go","position":90,"original_position":90,"commit_id":"9e6540a63d55fac773245b0d4f4bc2fe75f6adb9","original_commit_id":"9e6540a63d55fac773245b0d4f4bc2fe75f6adb9","user":{"login":"diogomonica","id":55332,"avatar_url":"https://avatars.githubusercontent.com/u/55332?v=3","gravatar_id":"","url":"https://api.github.com/users/diogomonica","html_url":"https://github.com/diogomonica","followers_url":"https://api.github.com/users/diogomonica/followers","following_url":"https://api.github.com/users/diogomonica/following{/other_user}","gists_url":"https://api.github.com/users/diogomonica/gists{/gist_id}","starred_url":"https://api.github.com/users/diogomonica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diogomonica/subscriptions","organizations_url":"https://api.github.com/users/diogomonica/orgs","repos_url":"https://api.github.com/users/diogomonica/repos","events_url":"https://api.github.com/users/diogomonica/events{/privacy}","received_events_url":"https://api.github.com/users/diogomonica/received_events","type":"User","site_admin":false},"body":"Maybe refactor `\".key\"` into `expectedExt` in the beginning of the test?","created_at":"2015-07-08T22:48:28Z","updated_at":"2015-07-08T22:48:28Z","html_url":"https://github.com/docker/notary/pull/33#discussion_r34207713","pull_request_url":"https://api.github.com/repos/docker/notary/pulls/33","_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/comments/34207713"},"html":{"href":"https://github.com/docker/notary/pull/33#discussion_r34207713"},"pull_request":{"href":"https://api.github.com/repos/docker/notary/pulls/33"}}},"pull_request":{"url":"https://api.github.com/repos/docker/notary/pulls/33","id":39531603,"html_url":"https://github.com/docker/notary/pull/33","diff_url":"https://github.com/docker/notary/pull/33.diff","patch_url":"https://github.com/docker/notary/pull/33.patch","issue_url":"https://api.github.com/repos/docker/notary/issues/33","number":33,"state":"open","locked":false,"title":"Test improvements","user":{"login":"diogomonica","id":55332,"avatar_url":"https://avatars.githubusercontent.com/u/55332?v=3","gravatar_id":"","url":"https://api.github.com/users/diogomonica","html_url":"https://github.com/diogomonica","followers_url":"https://api.github.com/users/diogomonica/followers","following_url":"https://api.github.com/users/diogomonica/following{/other_user}","gists_url":"https://api.github.com/users/diogomonica/gists{/gist_id}","starred_url":"https://api.github.com/users/diogomonica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diogomonica/subscriptions","organizations_url":"https://api.github.com/users/diogomonica/orgs","repos_url":"https://api.github.com/users/diogomonica/repos","events_url":"https://api.github.com/users/diogomonica/events{/privacy}","received_events_url":"https://api.github.com/users/diogomonica/received_events","type":"User","site_admin":false},"body":"@aaronlehmann ","created_at":"2015-07-08T22:42:17Z","updated_at":"2015-07-08T22:48:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7432a52e43200e6b8e2698549b64a9396e5a10c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/notary/pulls/33/commits","review_comments_url":"https://api.github.com/repos/docker/notary/pulls/33/comments","review_comment_url":"https://api.github.com/repos/docker/notary/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/notary/issues/33/comments","statuses_url":"https://api.github.com/repos/docker/notary/statuses/9e6540a63d55fac773245b0d4f4bc2fe75f6adb9","head":{"label":"docker:test-improvements","ref":"test-improvements","sha":"9e6540a63d55fac773245b0d4f4bc2fe75f6adb9","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":37743436,"name":"notary","full_name":"docker/notary","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/notary","description":"","fork":false,"url":"https://api.github.com/repos/docker/notary","forks_url":"https://api.github.com/repos/docker/notary/forks","keys_url":"https://api.github.com/repos/docker/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/notary/teams","hooks_url":"https://api.github.com/repos/docker/notary/hooks","issue_events_url":"https://api.github.com/repos/docker/notary/issues/events{/number}","events_url":"https://api.github.com/repos/docker/notary/events","assignees_url":"https://api.github.com/repos/docker/notary/assignees{/user}","branches_url":"https://api.github.com/repos/docker/notary/branches{/branch}","tags_url":"https://api.github.com/repos/docker/notary/tags","blobs_url":"https://api.github.com/repos/docker/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/notary/languages","stargazers_url":"https://api.github.com/repos/docker/notary/stargazers","contributors_url":"https://api.github.com/repos/docker/notary/contributors","subscribers_url":"https://api.github.com/repos/docker/notary/subscribers","subscription_url":"https://api.github.com/repos/docker/notary/subscription","commits_url":"https://api.github.com/repos/docker/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/notary/contents/{+path}","compare_url":"https://api.github.com/repos/docker/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/notary/merges","archive_url":"https://api.github.com/repos/docker/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/notary/downloads","issues_url":"https://api.github.com/repos/docker/notary/issues{/number}","pulls_url":"https://api.github.com/repos/docker/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/notary/labels{/name}","releases_url":"https://api.github.com/repos/docker/notary/releases{/id}","created_at":"2015-06-19T20:07:53Z","updated_at":"2015-07-08T19:26:29Z","pushed_at":"2015-07-08T22:42:17Z","git_url":"git://github.com/docker/notary.git","ssh_url":"git@github.com:docker/notary.git","clone_url":"https://github.com/docker/notary.git","svn_url":"https://github.com/docker/notary","homepage":null,"size":19144,"stargazers_count":293,"watchers_count":293,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":17,"forks":17,"open_issues":17,"watchers":293,"default_branch":"master"}},"base":{"label":"docker:tuf_rebase","ref":"tuf_rebase","sha":"515e7484f4e68400b2500a54b57f8907d1f3cb4f","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":37743436,"name":"notary","full_name":"docker/notary","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/notary","description":"","fork":false,"url":"https://api.github.com/repos/docker/notary","forks_url":"https://api.github.com/repos/docker/notary/forks","keys_url":"https://api.github.com/repos/docker/notary/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/notary/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/notary/teams","hooks_url":"https://api.github.com/repos/docker/notary/hooks","issue_events_url":"https://api.github.com/repos/docker/notary/issues/events{/number}","events_url":"https://api.github.com/repos/docker/notary/events","assignees_url":"https://api.github.com/repos/docker/notary/assignees{/user}","branches_url":"https://api.github.com/repos/docker/notary/branches{/branch}","tags_url":"https://api.github.com/repos/docker/notary/tags","blobs_url":"https://api.github.com/repos/docker/notary/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/notary/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/notary/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/notary/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/notary/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/notary/languages","stargazers_url":"https://api.github.com/repos/docker/notary/stargazers","contributors_url":"https://api.github.com/repos/docker/notary/contributors","subscribers_url":"https://api.github.com/repos/docker/notary/subscribers","subscription_url":"https://api.github.com/repos/docker/notary/subscription","commits_url":"https://api.github.com/repos/docker/notary/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/notary/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/notary/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/notary/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/notary/contents/{+path}","compare_url":"https://api.github.com/repos/docker/notary/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/notary/merges","archive_url":"https://api.github.com/repos/docker/notary/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/notary/downloads","issues_url":"https://api.github.com/repos/docker/notary/issues{/number}","pulls_url":"https://api.github.com/repos/docker/notary/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/notary/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/notary/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/notary/labels{/name}","releases_url":"https://api.github.com/repos/docker/notary/releases{/id}","created_at":"2015-06-19T20:07:53Z","updated_at":"2015-07-08T19:26:29Z","pushed_at":"2015-07-08T22:42:17Z","git_url":"git://github.com/docker/notary.git","ssh_url":"git@github.com:docker/notary.git","clone_url":"https://github.com/docker/notary.git","svn_url":"https://github.com/docker/notary","homepage":null,"size":19144,"stargazers_count":293,"watchers_count":293,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":17,"forks":17,"open_issues":17,"watchers":293,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/notary/pulls/33"},"html":{"href":"https://github.com/docker/notary/pull/33"},"issue":{"href":"https://api.github.com/repos/docker/notary/issues/33"},"comments":{"href":"https://api.github.com/repos/docker/notary/issues/33/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/notary/pulls/33/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/notary/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/notary/pulls/33/commits"},"statuses":{"href":"https://api.github.com/repos/docker/notary/statuses/9e6540a63d55fac773245b0d4f4bc2fe75f6adb9"}}}}