{"action":"created","comment":{"url":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments/25124958","id":25124958,"diff_hunk":"@@ -107,6 +108,161 @@ func TestNewSignerFromFileNoUsageInPolicy(t *testing.T) {\n \t}\n }\n \n+func TestNewSignerFromFileEdgeCases(t *testing.T) {\n+\n+\tres, err := NewSignerFromFile(\"nil\", \"nil\", nil)\n+\tif res != nil && err == nil {\n+\t\tt.Fatal(\"Incorrect inputs failed to produce correct results\")\n+\t}\n+\n+\tres, err = NewSignerFromFile(testCaFile, \"nil\", nil)\n+\tif res != nil && err == nil {\n+\t\tt.Fatal(\"Incorrect inputs failed to produce correct results\")\n+\t}\n+\n+\tres, err = NewSignerFromFile(\"../../helpers/testdata/messedupcert.pem\", \"local.go\", nil)\n+\tif res != nil && err == nil {\n+\t\tt.Fatal(\"Incorrect inputs failed to produce correct results\")\n+\t}\n+\n+\tres, err = NewSignerFromFile(\"../../helpers/testdata/cert.pem\", \"../../helpers/testdata/messed_up_priv_key.pem\", nil)\n+\tif res != nil && err == nil {\n+\t\tt.Fatal(\"Incorrect inputs failed to produce correct results\")\n+\t}\n+}\n+\n+// test the private method\n+func testSign(t *testing.T) {\n+\tsigner, err := NewSignerFromFile(\"testdata/ca.pem\", \"testdata/ca_key.pem\", nil)\n+\tif signer == nil || err != nil {\n+\t\tt.Fatal(\"Failed to produce signer\")\n+\t}\n+\n+\tpem, err := ioutil.ReadFile(\"../../helpers/testdata/cert.pem\")\n+\tif err != nil {\n+\t\tt.Fatal(\"srsly?\")\n+\t}\n+\tcert, err := helpers.ParseCertificatePEM(pem)\n+\tif err != nil {\n+\t\tt.Fatal(\"srsly?\")\n+\t}\n+\n+\tbadcert := *cert\n+\tbadcert.PublicKey = nil\n+\tprofl := config.SigningProfile{Usage: []string{\"FUCK\", \"YOU\"}}\n+\t_, err = signer.sign(&badcert, &profl)\n+\n+\tif err == nil {\n+\t\tt.Fatal(\"Improper input failed to raise an error\")\n+\t}\n+\n+\t// nil profile\n+\t_, err = signer.sign(cert, &profl)\n+\tif err == nil {\n+\t\tt.Fatal(\"Nil profile failed to raise an error\")\n+\t}\n+\n+\t// empty profile\n+\t_, err = signer.sign(cert, &config.SigningProfile{})\n+\tif err == nil {\n+\t\tt.Fatal(\"Empty profile failed to raise an error\")\n+\t}\n+\n+\t// empty expiry\n+\tprof := signer.policy.Default\n+\tprof.Expiry = 0\n+\t_, err = signer.sign(cert, prof)\n+\tif err != nil {\n+\t\tt.Fatal(\"nil expiry raised an error\")\n+\t}\n+\n+\t// non empty urls\n+\tprof = signer.policy.Default\n+\tprof.CRL = \"poop\"\n+\tprof.OCSP = \"poop\"\n+\tprof.IssuerURL = []string{\"poop\"}\n+\t_, err = signer.sign(cert, prof)\n+\tif err != nil {\n+\t\tt.Fatal(\"non nil urls raised an error\")\n+\t}\n+\n+\t// nil ca\n+\tnilca := *signer\n+\tprof = signer.policy.Default\n+\tprof.CA = false\n+\tnilca.ca = nil\n+\t_, err = nilca.sign(cert, prof)\n+\tif err == nil {\n+\t\tt.Fatal(\"nil ca with isca false raised an error\")\n+\t}\n+\tprof.CA = true\n+\t_, err = nilca.sign(cert, prof)\n+\tif err != nil {\n+\t\tt.Fatal(\"nil ca with CA true raised an error\")\n+\t}\n+}\n+\n+func TestSign(t *testing.T) {\n+\ttestSign(t)\n+\ts, err := NewSignerFromFile(\"testdata/ca.pem\", \"testdata/ca_key.pem\", nil)\n+\tif err != nil {\n+\t\tt.Fatal(\"Failed to produce signer\")\n+\t}\n+\n+\t//pem, _ := ioutil.ReadFile(\"../helpers/testdata/cert.pem\")\n+\t//cert, _ := helpers.ParseCertificatePEM(pem)\n+\n+\t// test the empty request\n+\t_, err = s.Sign(signer.SignRequest{})\n+\tif err == nil {\n+\t\tt.Fatalf(\"Empty request failed to produce an error\")\n+\t}\n+\n+\tpem, err := ioutil.ReadFile(\"../../helpers/testdata/cert.pem\")\n+\tif err != nil {\n+\t\tt.Fatal(err)\n+\t}\n+\n+\tvalidReq := signer.SignRequest{Hostname: testHostName, Request: string(pem)}\n+\t_, err = s.Sign(validReq)\n+\tif err == nil {\n+\t\tt.Fatal(\"A bad case failed to raise an error\")\n+\t}\n+\n+\tvalidReq = signer.SignRequest{Hostname: \"74.67.211.31\", Request: string(pem)}","path":"signer/local/local_test.go","position":133,"original_position":133,"commit_id":"93b3b79e1f6e1b36ed5678b2e78cf366c5d0c358","original_commit_id":"93b3b79e1f6e1b36ed5678b2e78cf366c5d0c358","user":{"login":"grittygrease","id":5125095,"avatar_url":"https://avatars.githubusercontent.com/u/5125095?v=3","gravatar_id":"","url":"https://api.github.com/users/grittygrease","html_url":"https://github.com/grittygrease","followers_url":"https://api.github.com/users/grittygrease/followers","following_url":"https://api.github.com/users/grittygrease/following{/other_user}","gists_url":"https://api.github.com/users/grittygrease/gists{/gist_id}","starred_url":"https://api.github.com/users/grittygrease/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grittygrease/subscriptions","organizations_url":"https://api.github.com/users/grittygrease/orgs","repos_url":"https://api.github.com/users/grittygrease/repos","events_url":"https://api.github.com/users/grittygrease/events{/privacy}","received_events_url":"https://api.github.com/users/grittygrease/received_events","type":"User","site_admin":false},"body":"This is the signer.SignRequest with an IP. Try creating a CSR with an IP as a hostname, here you're using the testdata/cert.pem.","created_at":"2015-02-21T19:34:15Z","updated_at":"2015-02-21T19:34:15Z","html_url":"https://github.com/cloudflare/cfssl/pull/108#discussion_r25124958","pull_request_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/108","_links":{"self":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments/25124958"},"html":{"href":"https://github.com/cloudflare/cfssl/pull/108#discussion_r25124958"},"pull_request":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/108"}}},"pull_request":{"url":"https://api.github.com/repos/cloudflare/cfssl/pulls/108","id":29664775,"html_url":"https://github.com/cloudflare/cfssl/pull/108","diff_url":"https://github.com/cloudflare/cfssl/pull/108.diff","patch_url":"https://github.com/cloudflare/cfssl/pull/108.patch","issue_url":"https://api.github.com/repos/cloudflare/cfssl/issues/108","number":108,"state":"open","locked":false,"title":"Test local signer","user":{"login":"dr107","id":3991437,"avatar_url":"https://avatars.githubusercontent.com/u/3991437?v=3","gravatar_id":"","url":"https://api.github.com/users/dr107","html_url":"https://github.com/dr107","followers_url":"https://api.github.com/users/dr107/followers","following_url":"https://api.github.com/users/dr107/following{/other_user}","gists_url":"https://api.github.com/users/dr107/gists{/gist_id}","starred_url":"https://api.github.com/users/dr107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dr107/subscriptions","organizations_url":"https://api.github.com/users/dr107/orgs","repos_url":"https://api.github.com/users/dr107/repos","events_url":"https://api.github.com/users/dr107/events{/privacy}","received_events_url":"https://api.github.com/users/dr107/received_events","type":"User","site_admin":false},"body":"Bring test coverage for local signer from ~60% to 92%\r\n\r\nThere's a few lines in local.go that I've been struggling to hit. I'd appreciate some tips on how I might hit them.\r\n\r\n![coverage-0](https://cloud.githubusercontent.com/assets/3991437/6279557/0aa83d1e-b871-11e4-8e39-757adaf4efac.png)\r\n![coverage-1](https://cloud.githubusercontent.com/assets/3991437/6279559/0aab3230-b871-11e4-8f10-7a4364493703.png)\r\n![coverage-2](https://cloud.githubusercontent.com/assets/3991437/6279558/0aaa62a6-b871-11e4-948f-9fc4b0487d29.png)\r\n\r\n","created_at":"2015-02-20T00:54:41Z","updated_at":"2015-02-21T19:34:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"931c230be126ac01d2f50fe3be7fd4d453e2b80e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/108/commits","review_comments_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/108/comments","review_comment_url":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments/{number}","comments_url":"https://api.github.com/repos/cloudflare/cfssl/issues/108/comments","statuses_url":"https://api.github.com/repos/cloudflare/cfssl/statuses/93b3b79e1f6e1b36ed5678b2e78cf366c5d0c358","head":{"label":"dr107:dan/test_local","ref":"dan/test_local","sha":"93b3b79e1f6e1b36ed5678b2e78cf366c5d0c358","user":{"login":"dr107","id":3991437,"avatar_url":"https://avatars.githubusercontent.com/u/3991437?v=3","gravatar_id":"","url":"https://api.github.com/users/dr107","html_url":"https://github.com/dr107","followers_url":"https://api.github.com/users/dr107/followers","following_url":"https://api.github.com/users/dr107/following{/other_user}","gists_url":"https://api.github.com/users/dr107/gists{/gist_id}","starred_url":"https://api.github.com/users/dr107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dr107/subscriptions","organizations_url":"https://api.github.com/users/dr107/orgs","repos_url":"https://api.github.com/users/dr107/repos","events_url":"https://api.github.com/users/dr107/events{/privacy}","received_events_url":"https://api.github.com/users/dr107/received_events","type":"User","site_admin":false},"repo":{"id":30153690,"name":"cfssl","full_name":"dr107/cfssl","owner":{"login":"dr107","id":3991437,"avatar_url":"https://avatars.githubusercontent.com/u/3991437?v=3","gravatar_id":"","url":"https://api.github.com/users/dr107","html_url":"https://github.com/dr107","followers_url":"https://api.github.com/users/dr107/followers","following_url":"https://api.github.com/users/dr107/following{/other_user}","gists_url":"https://api.github.com/users/dr107/gists{/gist_id}","starred_url":"https://api.github.com/users/dr107/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dr107/subscriptions","organizations_url":"https://api.github.com/users/dr107/orgs","repos_url":"https://api.github.com/users/dr107/repos","events_url":"https://api.github.com/users/dr107/events{/privacy}","received_events_url":"https://api.github.com/users/dr107/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dr107/cfssl","description":"CFSSL: CloudFlare's PKI toolkit","fork":true,"url":"https://api.github.com/repos/dr107/cfssl","forks_url":"https://api.github.com/repos/dr107/cfssl/forks","keys_url":"https://api.github.com/repos/dr107/cfssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dr107/cfssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dr107/cfssl/teams","hooks_url":"https://api.github.com/repos/dr107/cfssl/hooks","issue_events_url":"https://api.github.com/repos/dr107/cfssl/issues/events{/number}","events_url":"https://api.github.com/repos/dr107/cfssl/events","assignees_url":"https://api.github.com/repos/dr107/cfssl/assignees{/user}","branches_url":"https://api.github.com/repos/dr107/cfssl/branches{/branch}","tags_url":"https://api.github.com/repos/dr107/cfssl/tags","blobs_url":"https://api.github.com/repos/dr107/cfssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dr107/cfssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dr107/cfssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/dr107/cfssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dr107/cfssl/statuses/{sha}","languages_url":"https://api.github.com/repos/dr107/cfssl/languages","stargazers_url":"https://api.github.com/repos/dr107/cfssl/stargazers","contributors_url":"https://api.github.com/repos/dr107/cfssl/contributors","subscribers_url":"https://api.github.com/repos/dr107/cfssl/subscribers","subscription_url":"https://api.github.com/repos/dr107/cfssl/subscription","commits_url":"https://api.github.com/repos/dr107/cfssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/dr107/cfssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/dr107/cfssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/dr107/cfssl/issues/comments/{number}","contents_url":"https://api.github.com/repos/dr107/cfssl/contents/{+path}","compare_url":"https://api.github.com/repos/dr107/cfssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dr107/cfssl/merges","archive_url":"https://api.github.com/repos/dr107/cfssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dr107/cfssl/downloads","issues_url":"https://api.github.com/repos/dr107/cfssl/issues{/number}","pulls_url":"https://api.github.com/repos/dr107/cfssl/pulls{/number}","milestones_url":"https://api.github.com/repos/dr107/cfssl/milestones{/number}","notifications_url":"https://api.github.com/repos/dr107/cfssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dr107/cfssl/labels{/name}","releases_url":"https://api.github.com/repos/dr107/cfssl/releases{/id}","created_at":"2015-02-01T17:39:59Z","updated_at":"2015-02-20T00:49:26Z","pushed_at":"2015-02-20T00:50:26Z","git_url":"git://github.com/dr107/cfssl.git","ssh_url":"git@github.com:dr107/cfssl.git","clone_url":"https://github.com/dr107/cfssl.git","svn_url":"https://github.com/dr107/cfssl","homepage":"https://blog.cloudflare.com/introducing-cfssl","size":1360,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"cloudflare:master","ref":"master","sha":"1249efdc0c75b43921bcbe2de8198e34e3f7bf05","user":{"login":"cloudflare","id":314135,"avatar_url":"https://avatars.githubusercontent.com/u/314135?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudflare","html_url":"https://github.com/cloudflare","followers_url":"https://api.github.com/users/cloudflare/followers","following_url":"https://api.github.com/users/cloudflare/following{/other_user}","gists_url":"https://api.github.com/users/cloudflare/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudflare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudflare/subscriptions","organizations_url":"https://api.github.com/users/cloudflare/orgs","repos_url":"https://api.github.com/users/cloudflare/repos","events_url":"https://api.github.com/users/cloudflare/events{/privacy}","received_events_url":"https://api.github.com/users/cloudflare/received_events","type":"Organization","site_admin":false},"repo":{"id":21591001,"name":"cfssl","full_name":"cloudflare/cfssl","owner":{"login":"cloudflare","id":314135,"avatar_url":"https://avatars.githubusercontent.com/u/314135?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudflare","html_url":"https://github.com/cloudflare","followers_url":"https://api.github.com/users/cloudflare/followers","following_url":"https://api.github.com/users/cloudflare/following{/other_user}","gists_url":"https://api.github.com/users/cloudflare/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudflare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudflare/subscriptions","organizations_url":"https://api.github.com/users/cloudflare/orgs","repos_url":"https://api.github.com/users/cloudflare/repos","events_url":"https://api.github.com/users/cloudflare/events{/privacy}","received_events_url":"https://api.github.com/users/cloudflare/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cloudflare/cfssl","description":"CFSSL: CloudFlare's PKI toolkit","fork":false,"url":"https://api.github.com/repos/cloudflare/cfssl","forks_url":"https://api.github.com/repos/cloudflare/cfssl/forks","keys_url":"https://api.github.com/repos/cloudflare/cfssl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cloudflare/cfssl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cloudflare/cfssl/teams","hooks_url":"https://api.github.com/repos/cloudflare/cfssl/hooks","issue_events_url":"https://api.github.com/repos/cloudflare/cfssl/issues/events{/number}","events_url":"https://api.github.com/repos/cloudflare/cfssl/events","assignees_url":"https://api.github.com/repos/cloudflare/cfssl/assignees{/user}","branches_url":"https://api.github.com/repos/cloudflare/cfssl/branches{/branch}","tags_url":"https://api.github.com/repos/cloudflare/cfssl/tags","blobs_url":"https://api.github.com/repos/cloudflare/cfssl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cloudflare/cfssl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cloudflare/cfssl/git/refs{/sha}","trees_url":"https://api.github.com/repos/cloudflare/cfssl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cloudflare/cfssl/statuses/{sha}","languages_url":"https://api.github.com/repos/cloudflare/cfssl/languages","stargazers_url":"https://api.github.com/repos/cloudflare/cfssl/stargazers","contributors_url":"https://api.github.com/repos/cloudflare/cfssl/contributors","subscribers_url":"https://api.github.com/repos/cloudflare/cfssl/subscribers","subscription_url":"https://api.github.com/repos/cloudflare/cfssl/subscription","commits_url":"https://api.github.com/repos/cloudflare/cfssl/commits{/sha}","git_commits_url":"https://api.github.com/repos/cloudflare/cfssl/git/commits{/sha}","comments_url":"https://api.github.com/repos/cloudflare/cfssl/comments{/number}","issue_comment_url":"https://api.github.com/repos/cloudflare/cfssl/issues/comments/{number}","contents_url":"https://api.github.com/repos/cloudflare/cfssl/contents/{+path}","compare_url":"https://api.github.com/repos/cloudflare/cfssl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cloudflare/cfssl/merges","archive_url":"https://api.github.com/repos/cloudflare/cfssl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cloudflare/cfssl/downloads","issues_url":"https://api.github.com/repos/cloudflare/cfssl/issues{/number}","pulls_url":"https://api.github.com/repos/cloudflare/cfssl/pulls{/number}","milestones_url":"https://api.github.com/repos/cloudflare/cfssl/milestones{/number}","notifications_url":"https://api.github.com/repos/cloudflare/cfssl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cloudflare/cfssl/labels{/name}","releases_url":"https://api.github.com/repos/cloudflare/cfssl/releases{/id}","created_at":"2014-07-07T23:49:12Z","updated_at":"2015-02-21T05:27:09Z","pushed_at":"2015-02-21T02:10:44Z","git_url":"git://github.com/cloudflare/cfssl.git","ssh_url":"git@github.com:cloudflare/cfssl.git","clone_url":"https://github.com/cloudflare/cfssl.git","svn_url":"https://github.com/cloudflare/cfssl","homepage":"https://blog.cloudflare.com/introducing-cfssl","size":4773,"stargazers_count":450,"watchers_count":450,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":22,"forks":33,"open_issues":22,"watchers":450,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/108"},"html":{"href":"https://github.com/cloudflare/cfssl/pull/108"},"issue":{"href":"https://api.github.com/repos/cloudflare/cfssl/issues/108"},"comments":{"href":"https://api.github.com/repos/cloudflare/cfssl/issues/108/comments"},"review_comments":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/108/comments"},"review_comment":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/cloudflare/cfssl/pulls/108/commits"},"statuses":{"href":"https://api.github.com/repos/cloudflare/cfssl/statuses/93b3b79e1f6e1b36ed5678b2e78cf366c5d0c358"}}}}