{"action":"created","comment":{"url":"https://api.github.com/repos/capitalone/Hygieia/pulls/comments/48069738","id":48069738,"diff_hunk":"@@ -24,89 +24,134 @@\n import java.net.MalformedURLException;\n import java.net.Proxy;\n import java.net.URL;\n+import java.net.Authenticator;\n+import java.net.PasswordAuthentication;\n+import java.util.StringTokenizer;\n \n /**\n  *\n  */\n+@SuppressWarnings(\"deprecation\")\n public class EmbeddedMongoDBRule extends ExternalResource {\n-    private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedMongoDBRule.class);\n-    private static final String MONGO_PORT_PROP = \"MONGO_PORT\";\n-    private MongodExecutable mongoExec;\n-    private MongodProcess mongoProc;\n-    private MongoClient client;\n-\n-    static class SystemProxy implements IProxyFactory {\n-        @Override\n-        public Proxy createProxy() {\n-\n-            String proxy = System.getenv(\"HTTP_PROXY\");\n-            if (proxy == null || proxy.isEmpty()) {\n-                proxy = System.getProperty(\"HTTP_PROXY\");\n-            }\n-            try {\n-                if (proxy != null && !proxy.isEmpty()) {\n-                    URL proxyUrl = new URL(proxy);\n-                    return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyUrl.getHost(), proxyUrl.getPort()));\n-                }\n-            } catch (MalformedURLException ex) {\n-                LOGGER.error(\"Malformed HTTP Proxy\", ex);\n-            }\n-            return Proxy.NO_PROXY;\n-        }\n-    }\n-\n-    @Override\n-    public void before() throws Throwable {\n-\n-        int port = Network.getFreeServerPort();\n-        String portProp = System.getProperty(MONGO_PORT_PROP);\n-        if (portProp != null && !portProp.isEmpty()) {\n-            port = Integer.valueOf(portProp);\n-        }\n-\n-        IMongodConfig conf =\n-                new MongodConfigBuilder().version(Version.Main.PRODUCTION)\n-                    .net(new Net(port, Network.localhostIsIPv6())).build();\n-\n-        Command command = Command.MongoD;\n-        IRuntimeConfig runtimeConfig =\n-                new RuntimeConfigBuilder()\n-                    .defaultsWithLogger(command, LOGGER)\n-                    .artifactStore(\n-                            new ArtifactStoreBuilder().defaults(command).download(\n-                                    new DownloadConfigBuilder().defaultsForCommand(command).proxyFactory(new SystemProxy())))\n-                    .build();\n-\n-        MongodStarter runtime = MongodStarter.getInstance(runtimeConfig);\n-        mongoExec = runtime.prepare(conf);\n-\n-        mongoProc = mongoExec.start();\n-\n-        client = new MongoClient(new ServerAddress(conf.net().getServerAddress(), conf.net().getPort()));\n-\n-        // set the property for our config...\n-        System.setProperty(\"dbhost\", conf.net().getServerAddress().getHostAddress());\n-        System.setProperty(\"dbport\", Integer.toString(conf.net().getPort()));\n-    }\n-\n-    @Override\n-    public void after() {\n-        if (client != null) {\n-            client.close();\n-            client = null;\n-        }\n-\n-        if (mongoProc != null) {\n-            mongoProc.stop();\n-            mongoProc = null;\n-        }\n-        if (mongoExec != null) {\n-            mongoExec.stop();\n-            mongoExec = null;\n-        }\n-    }\n-\n-    public MongoClient client() {\n-        return client;\n-    }\n+\tprivate static final Logger LOGGER = LoggerFactory\n+\t\t\t.getLogger(EmbeddedMongoDBRule.class);\n+\tprivate static final String MONGO_PORT_PROP = \"MONGO_PORT\";\n+\tprivate MongodExecutable mongoExec;\n+\tprivate MongodProcess mongoProc;\n+\tprivate MongoClient client;\n+\n+\tstatic class SystemProxy implements IProxyFactory {\n+\t\t@Override\n+\t\tpublic Proxy createProxy() {\n+\n+\t\t\tString proxy = System.getenv(\"HTTP_PROXY\");\n+\n+\t\t\tif (proxy == null || proxy.isEmpty()) {\n+\t\t\t\tproxy = System.getProperty(\"HTTP_PROXY\");\n+\t\t\t}\n+\t\t\ttry {\n+\t\t\t\tURL proxyUrl = new URL(proxy);\n+\n+\t\t\t\t// Case for Proxy authentication required\n+\t\t\t\ttry {\n+\t\t\t\t\tStringTokenizer tokenizedUrl = new StringTokenizer(proxyUrl\n+\t\t\t\t\t\t\t.getUserInfo().toString(), \":\");\n+\t\t\t\t\tfinal String authUser = tokenizedUrl.nextToken();\n+\t\t\t\t\tfinal String authPassword = tokenizedUrl.nextToken();\n+\t\t\t\t\t\n+\t\t\t\t\tif ((proxy != null && !proxy.isEmpty())\n+\t\t\t\t\t\t\t&& (authUser != null && !authUser.isEmpty())\n+\t\t\t\t\t\t\t&& (authUser != null && !authPassword.isEmpty())) {\n+\n+\t\t\t\t\t\tAuthenticator.setDefault(new Authenticator() {\n+\t\t\t\t\t\t\tpublic PasswordAuthentication getPasswordAuthentication() {\n+\t\t\t\t\t\t\t\treturn new PasswordAuthentication(authUser,\n+\t\t\t\t\t\t\t\t\t\tauthPassword.toCharArray());\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t});\n+\n+\t\t\t\t\t\tSystem.setProperty(\"http.proxyUser\", authUser);\n+\t\t\t\t\t\tSystem.setProperty(\"http.proxyPassword\", authPassword);\n+\n+\t\t\t\t\t}\n+\t\t\t\t} catch (NullPointerException | IllegalArgumentException e) {","path":"core/src/test/java/com/capitalone/dashboard/repository/EmbeddedMongoDBRule.java","position":134,"original_position":134,"commit_id":"6cc219cb119038f5a6d359f4e248665c529244b9","original_commit_id":"6cc219cb119038f5a6d359f4e248665c529244b9","user":{"login":"jdamick","id":12317,"avatar_url":"https://avatars.githubusercontent.com/u/12317?v=3","gravatar_id":"","url":"https://api.github.com/users/jdamick","html_url":"https://github.com/jdamick","followers_url":"https://api.github.com/users/jdamick/followers","following_url":"https://api.github.com/users/jdamick/following{/other_user}","gists_url":"https://api.github.com/users/jdamick/gists{/gist_id}","starred_url":"https://api.github.com/users/jdamick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdamick/subscriptions","organizations_url":"https://api.github.com/users/jdamick/orgs","repos_url":"https://api.github.com/users/jdamick/repos","events_url":"https://api.github.com/users/jdamick/events{/privacy}","received_events_url":"https://api.github.com/users/jdamick/received_events","type":"User","site_admin":false},"body":"dont catch NPEs, this is one of those code smells..  so revert back to way it was but just see if \thasMoreTokens() is true before trying to nextToken(), that way it will support if there is a username and no pass cases too.","created_at":"2015-12-18T21:03:21Z","updated_at":"2015-12-18T21:03:21Z","html_url":"https://github.com/capitalone/Hygieia/pull/233#discussion_r48069738","pull_request_url":"https://api.github.com/repos/capitalone/Hygieia/pulls/233","_links":{"self":{"href":"https://api.github.com/repos/capitalone/Hygieia/pulls/comments/48069738"},"html":{"href":"https://github.com/capitalone/Hygieia/pull/233#discussion_r48069738"},"pull_request":{"href":"https://api.github.com/repos/capitalone/Hygieia/pulls/233"}}},"pull_request":{"url":"https://api.github.com/repos/capitalone/Hygieia/pulls/233","id":54032228,"html_url":"https://github.com/capitalone/Hygieia/pull/233","diff_url":"https://github.com/capitalone/Hygieia/pull/233.diff","patch_url":"https://github.com/capitalone/Hygieia/pull/233.patch","issue_url":"https://api.github.com/repos/capitalone/Hygieia/issues/233","number":233,"state":"open","locked":false,"title":"Enabled authenticated proxy configuration for embedded MongoDB tests","user":{"login":"amp5208","id":8902343,"avatar_url":"https://avatars.githubusercontent.com/u/8902343?v=3","gravatar_id":"","url":"https://api.github.com/users/amp5208","html_url":"https://github.com/amp5208","followers_url":"https://api.github.com/users/amp5208/followers","following_url":"https://api.github.com/users/amp5208/following{/other_user}","gists_url":"https://api.github.com/users/amp5208/gists{/gist_id}","starred_url":"https://api.github.com/users/amp5208/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amp5208/subscriptions","organizations_url":"https://api.github.com/users/amp5208/orgs","repos_url":"https://api.github.com/users/amp5208/repos","events_url":"https://api.github.com/users/amp5208/events{/privacy}","received_events_url":"https://api.github.com/users/amp5208/received_events","type":"User","site_admin":false},"body":"This enhancement enables the use and running of tests leveraging the embedded MongoDB test packages when an authenticated proxy is required.  This will also work with existing, non-authenticated proxy settings, as the logic for that option will run independent of the logic for authenticated proxies.\r\n\r\nI also updated the Setup.md readme to include explicit instructions for how to configure both an authenticated and non-authenticated proxy.","created_at":"2015-12-17T21:12:06Z","updated_at":"2015-12-18T21:03:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ae8f79134cf7c3a284b407e356d76937a8447c02","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/capitalone/Hygieia/pulls/233/commits","review_comments_url":"https://api.github.com/repos/capitalone/Hygieia/pulls/233/comments","review_comment_url":"https://api.github.com/repos/capitalone/Hygieia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/capitalone/Hygieia/issues/233/comments","statuses_url":"https://api.github.com/repos/capitalone/Hygieia/statuses/6cc219cb119038f5a6d359f4e248665c529244b9","head":{"label":"amp5208:master","ref":"master","sha":"6cc219cb119038f5a6d359f4e248665c529244b9","user":{"login":"amp5208","id":8902343,"avatar_url":"https://avatars.githubusercontent.com/u/8902343?v=3","gravatar_id":"","url":"https://api.github.com/users/amp5208","html_url":"https://github.com/amp5208","followers_url":"https://api.github.com/users/amp5208/followers","following_url":"https://api.github.com/users/amp5208/following{/other_user}","gists_url":"https://api.github.com/users/amp5208/gists{/gist_id}","starred_url":"https://api.github.com/users/amp5208/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amp5208/subscriptions","organizations_url":"https://api.github.com/users/amp5208/orgs","repos_url":"https://api.github.com/users/amp5208/repos","events_url":"https://api.github.com/users/amp5208/events{/privacy}","received_events_url":"https://api.github.com/users/amp5208/received_events","type":"User","site_admin":false},"repo":{"id":48197660,"name":"Hygieia","full_name":"amp5208/Hygieia","owner":{"login":"amp5208","id":8902343,"avatar_url":"https://avatars.githubusercontent.com/u/8902343?v=3","gravatar_id":"","url":"https://api.github.com/users/amp5208","html_url":"https://github.com/amp5208","followers_url":"https://api.github.com/users/amp5208/followers","following_url":"https://api.github.com/users/amp5208/following{/other_user}","gists_url":"https://api.github.com/users/amp5208/gists{/gist_id}","starred_url":"https://api.github.com/users/amp5208/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amp5208/subscriptions","organizations_url":"https://api.github.com/users/amp5208/orgs","repos_url":"https://api.github.com/users/amp5208/repos","events_url":"https://api.github.com/users/amp5208/events{/privacy}","received_events_url":"https://api.github.com/users/amp5208/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amp5208/Hygieia","description":"CapitalOne  DevOps Dashboard","fork":true,"url":"https://api.github.com/repos/amp5208/Hygieia","forks_url":"https://api.github.com/repos/amp5208/Hygieia/forks","keys_url":"https://api.github.com/repos/amp5208/Hygieia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amp5208/Hygieia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amp5208/Hygieia/teams","hooks_url":"https://api.github.com/repos/amp5208/Hygieia/hooks","issue_events_url":"https://api.github.com/repos/amp5208/Hygieia/issues/events{/number}","events_url":"https://api.github.com/repos/amp5208/Hygieia/events","assignees_url":"https://api.github.com/repos/amp5208/Hygieia/assignees{/user}","branches_url":"https://api.github.com/repos/amp5208/Hygieia/branches{/branch}","tags_url":"https://api.github.com/repos/amp5208/Hygieia/tags","blobs_url":"https://api.github.com/repos/amp5208/Hygieia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amp5208/Hygieia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amp5208/Hygieia/git/refs{/sha}","trees_url":"https://api.github.com/repos/amp5208/Hygieia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amp5208/Hygieia/statuses/{sha}","languages_url":"https://api.github.com/repos/amp5208/Hygieia/languages","stargazers_url":"https://api.github.com/repos/amp5208/Hygieia/stargazers","contributors_url":"https://api.github.com/repos/amp5208/Hygieia/contributors","subscribers_url":"https://api.github.com/repos/amp5208/Hygieia/subscribers","subscription_url":"https://api.github.com/repos/amp5208/Hygieia/subscription","commits_url":"https://api.github.com/repos/amp5208/Hygieia/commits{/sha}","git_commits_url":"https://api.github.com/repos/amp5208/Hygieia/git/commits{/sha}","comments_url":"https://api.github.com/repos/amp5208/Hygieia/comments{/number}","issue_comment_url":"https://api.github.com/repos/amp5208/Hygieia/issues/comments{/number}","contents_url":"https://api.github.com/repos/amp5208/Hygieia/contents/{+path}","compare_url":"https://api.github.com/repos/amp5208/Hygieia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amp5208/Hygieia/merges","archive_url":"https://api.github.com/repos/amp5208/Hygieia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amp5208/Hygieia/downloads","issues_url":"https://api.github.com/repos/amp5208/Hygieia/issues{/number}","pulls_url":"https://api.github.com/repos/amp5208/Hygieia/pulls{/number}","milestones_url":"https://api.github.com/repos/amp5208/Hygieia/milestones{/number}","notifications_url":"https://api.github.com/repos/amp5208/Hygieia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amp5208/Hygieia/labels{/name}","releases_url":"https://api.github.com/repos/amp5208/Hygieia/releases{/id}","created_at":"2015-12-17T20:51:21Z","updated_at":"2015-12-17T20:51:23Z","pushed_at":"2015-12-18T19:18:58Z","git_url":"git://github.com/amp5208/Hygieia.git","ssh_url":"git@github.com:amp5208/Hygieia.git","clone_url":"https://github.com/amp5208/Hygieia.git","svn_url":"https://github.com/amp5208/Hygieia","homepage":"http://www.capitalone.io","size":6277,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"capitalone:master","ref":"master","sha":"4a9329783499e625b80cd619b38e663f316275a2","user":{"login":"capitalone","id":8644615,"avatar_url":"https://avatars.githubusercontent.com/u/8644615?v=3","gravatar_id":"","url":"https://api.github.com/users/capitalone","html_url":"https://github.com/capitalone","followers_url":"https://api.github.com/users/capitalone/followers","following_url":"https://api.github.com/users/capitalone/following{/other_user}","gists_url":"https://api.github.com/users/capitalone/gists{/gist_id}","starred_url":"https://api.github.com/users/capitalone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capitalone/subscriptions","organizations_url":"https://api.github.com/users/capitalone/orgs","repos_url":"https://api.github.com/users/capitalone/repos","events_url":"https://api.github.com/users/capitalone/events{/privacy}","received_events_url":"https://api.github.com/users/capitalone/received_events","type":"Organization","site_admin":false},"repo":{"id":39237460,"name":"Hygieia","full_name":"capitalone/Hygieia","owner":{"login":"capitalone","id":8644615,"avatar_url":"https://avatars.githubusercontent.com/u/8644615?v=3","gravatar_id":"","url":"https://api.github.com/users/capitalone","html_url":"https://github.com/capitalone","followers_url":"https://api.github.com/users/capitalone/followers","following_url":"https://api.github.com/users/capitalone/following{/other_user}","gists_url":"https://api.github.com/users/capitalone/gists{/gist_id}","starred_url":"https://api.github.com/users/capitalone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/capitalone/subscriptions","organizations_url":"https://api.github.com/users/capitalone/orgs","repos_url":"https://api.github.com/users/capitalone/repos","events_url":"https://api.github.com/users/capitalone/events{/privacy}","received_events_url":"https://api.github.com/users/capitalone/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/capitalone/Hygieia","description":"CapitalOne  DevOps Dashboard","fork":false,"url":"https://api.github.com/repos/capitalone/Hygieia","forks_url":"https://api.github.com/repos/capitalone/Hygieia/forks","keys_url":"https://api.github.com/repos/capitalone/Hygieia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/capitalone/Hygieia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/capitalone/Hygieia/teams","hooks_url":"https://api.github.com/repos/capitalone/Hygieia/hooks","issue_events_url":"https://api.github.com/repos/capitalone/Hygieia/issues/events{/number}","events_url":"https://api.github.com/repos/capitalone/Hygieia/events","assignees_url":"https://api.github.com/repos/capitalone/Hygieia/assignees{/user}","branches_url":"https://api.github.com/repos/capitalone/Hygieia/branches{/branch}","tags_url":"https://api.github.com/repos/capitalone/Hygieia/tags","blobs_url":"https://api.github.com/repos/capitalone/Hygieia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/capitalone/Hygieia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/capitalone/Hygieia/git/refs{/sha}","trees_url":"https://api.github.com/repos/capitalone/Hygieia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/capitalone/Hygieia/statuses/{sha}","languages_url":"https://api.github.com/repos/capitalone/Hygieia/languages","stargazers_url":"https://api.github.com/repos/capitalone/Hygieia/stargazers","contributors_url":"https://api.github.com/repos/capitalone/Hygieia/contributors","subscribers_url":"https://api.github.com/repos/capitalone/Hygieia/subscribers","subscription_url":"https://api.github.com/repos/capitalone/Hygieia/subscription","commits_url":"https://api.github.com/repos/capitalone/Hygieia/commits{/sha}","git_commits_url":"https://api.github.com/repos/capitalone/Hygieia/git/commits{/sha}","comments_url":"https://api.github.com/repos/capitalone/Hygieia/comments{/number}","issue_comment_url":"https://api.github.com/repos/capitalone/Hygieia/issues/comments{/number}","contents_url":"https://api.github.com/repos/capitalone/Hygieia/contents/{+path}","compare_url":"https://api.github.com/repos/capitalone/Hygieia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/capitalone/Hygieia/merges","archive_url":"https://api.github.com/repos/capitalone/Hygieia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/capitalone/Hygieia/downloads","issues_url":"https://api.github.com/repos/capitalone/Hygieia/issues{/number}","pulls_url":"https://api.github.com/repos/capitalone/Hygieia/pulls{/number}","milestones_url":"https://api.github.com/repos/capitalone/Hygieia/milestones{/number}","notifications_url":"https://api.github.com/repos/capitalone/Hygieia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/capitalone/Hygieia/labels{/name}","releases_url":"https://api.github.com/repos/capitalone/Hygieia/releases{/id}","created_at":"2015-07-17T05:55:06Z","updated_at":"2015-12-17T11:40:13Z","pushed_at":"2015-12-18T19:18:58Z","git_url":"git://github.com/capitalone/Hygieia.git","ssh_url":"git@github.com:capitalone/Hygieia.git","clone_url":"https://github.com/capitalone/Hygieia.git","svn_url":"https://github.com/capitalone/Hygieia","homepage":"http://www.capitalone.io","size":6594,"stargazers_count":446,"watchers_count":446,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":153,"mirror_url":null,"open_issues_count":58,"forks":153,"open_issues":58,"watchers":446,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/capitalone/Hygieia/pulls/233"},"html":{"href":"https://github.com/capitalone/Hygieia/pull/233"},"issue":{"href":"https://api.github.com/repos/capitalone/Hygieia/issues/233"},"comments":{"href":"https://api.github.com/repos/capitalone/Hygieia/issues/233/comments"},"review_comments":{"href":"https://api.github.com/repos/capitalone/Hygieia/pulls/233/comments"},"review_comment":{"href":"https://api.github.com/repos/capitalone/Hygieia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/capitalone/Hygieia/pulls/233/commits"},"statuses":{"href":"https://api.github.com/repos/capitalone/Hygieia/statuses/6cc219cb119038f5a6d359f4e248665c529244b9"}}}}