{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/presto/pulls/comments/77237260","id":77237260,"diff_hunk":"@@ -0,0 +1,242 @@\n+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+package com.facebook.presto.tests.jdbc;\n+\n+import com.facebook.presto.tests.ImmutableTpchTablesRequirements;\n+import com.google.inject.Inject;\n+import com.google.inject.name.Named;\n+import com.teradata.tempto.BeforeTestWithContext;\n+import com.teradata.tempto.ProductTest;\n+import com.teradata.tempto.Requirement;\n+import com.teradata.tempto.RequirementsProvider;\n+import com.teradata.tempto.Requires;\n+import com.teradata.tempto.configuration.Configuration;\n+import com.teradata.tempto.fulfillment.ldap.LdapObjectRequirement;\n+import com.teradata.tempto.query.QueryResult;\n+import org.slf4j.LoggerFactory;\n+import org.testng.TestException;\n+import org.testng.annotations.Test;\n+\n+import java.io.IOException;\n+import java.sql.Connection;\n+import java.sql.DriverManager;\n+import java.sql.ResultSet;\n+import java.sql.SQLException;\n+import java.sql.Statement;\n+import java.util.Arrays;\n+\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.AMERICA_ORG;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.ASIA_ORG;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.CHILD_GROUP;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.CHILD_GROUP_USER;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.DEFAULT_GROUP;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.DEFAULT_GROUP_USER;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.ORPHAN_USER;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.PARENT_GROUP;\n+import static com.facebook.presto.tests.ImmutableLdapObjectDefinitions.PARENT_GROUP_USER;\n+import static com.facebook.presto.tests.TestGroups.LDAP;\n+import static com.facebook.presto.tests.TestGroups.PROFILE_SPECIFIC_TESTS;\n+import static com.facebook.presto.tests.TestGroups.SIMBA_JDBC;\n+import static com.facebook.presto.tests.TpchTableResults.PRESTO_NATION_RESULT;\n+import static com.teradata.tempto.assertions.QueryAssert.assertThat;\n+import static org.testng.Assert.assertTrue;\n+\n+public class LdapTests\n+        extends ProductTest\n+        implements RequirementsProvider\n+\n+{\n+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(JdbcTests.class);\n+    private static final long TIMEOUT = 300 * 1000; // 30 secs per test\n+\n+    private static final String SELECT_QUERY = \"select * from tpch.tiny.nation\";\n+    private static final String JDBC_URL_FORMAT = \"jdbc:presto://%s:%s;AuthenticationType=LDAP Authentication;\" +\n+            \"SSLTrustStorePath=%s;SSLTrustStorePwd=%s;AllowSelfSignedServerCert=1;AllowHostNameCNMismatch=1\";\n+\n+    private static final String DEFAULT_SSL_PORT = \"8443\";\n+\n+    @Inject(optional = true)\n+    @Named(\"databases.presto.cli_ldap_truststore_path\")\n+    private String ldapTruststorePath;\n+\n+    @Inject(optional = true)\n+    @Named(\"databases.presto.cli_ldap_truststore_password\")\n+    private String ldapTruststorePassword;\n+\n+    @Inject(optional = true)\n+    @Named(\"databases.presto.cli_ldap_user_name\")\n+    private String ldapUserName;\n+\n+    @Inject(optional = true)\n+    @Named(\"databases.presto.cli_ldap_user_password\")\n+    private String ldapUserPassword;\n+\n+    @Inject(optional = true)\n+    @Named(\"databases.presto.host\")\n+    private String prestoHost;\n+\n+    // TODO: Find out why this doesn't bring in the value from the config file.\n+    @Inject(optional = true)\n+    @Named(\"databases.presto.ssl_port\")\n+    private String prestoSslPort;\n+\n+    private static final String INVALID_CREDENTIALS = \"Invalid credentials\";\n+\n+    @BeforeTestWithContext\n+    public void setup()\n+            throws SQLException\n+    {\n+        if (prestoSslPort == null) {\n+            prestoSslPort = DEFAULT_SSL_PORT;\n+        }\n+\n+        LOGGER.debug(\"Using Presto server SSL port: \" + prestoSslPort);\n+    }\n+\n+    @Override\n+    public Requirement getRequirements(Configuration configuration)\n+    {\n+        return new LdapObjectRequirement(\n+                Arrays.asList(\n+                        AMERICA_ORG, ASIA_ORG,\n+                        DEFAULT_GROUP, PARENT_GROUP, CHILD_GROUP,\n+                        DEFAULT_GROUP_USER, PARENT_GROUP_USER, CHILD_GROUP_USER, ORPHAN_USER\n+                ));\n+    }\n+\n+    @Requires(ImmutableTpchTablesRequirements.ImmutableNationTable.class)\n+    @Test(groups = {LDAP, SIMBA_JDBC, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)\n+    public void shouldRunQueryWithLdap()\n+            throws InterruptedException, SQLException\n+    {\n+        assertThat(executeQuery(SELECT_QUERY, ldapUserName, ldapUserPassword)).matches(PRESTO_NATION_RESULT);\n+    }\n+\n+    @Test(groups = {LDAP, SIMBA_JDBC, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)\n+    public void shouldFailQueryForLdapUserInChildGroup()\n+            throws InterruptedException\n+    {\n+        String name = CHILD_GROUP_USER.getAttributes().get(\"cn\");\n+        expectQueryToFailForUserNotInGroup(name);\n+    }\n+\n+    @Test(groups = {LDAP, SIMBA_JDBC, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)\n+    public void shouldFailQueryForLdapUserInParentGroup()\n+            throws InterruptedException\n+    {\n+        String name = PARENT_GROUP_USER.getAttributes().get(\"cn\");\n+        expectQueryToFailForUserNotInGroup(name);\n+    }\n+\n+    @Test(groups = {LDAP, SIMBA_JDBC, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)\n+    public void shouldFailQueryForOrphanLdapUser()\n+            throws InterruptedException\n+    {\n+        String name = ORPHAN_USER.getAttributes().get(\"cn\");\n+        expectQueryToFailForUserNotInGroup(name);\n+    }\n+\n+    @Test(groups = {LDAP, SIMBA_JDBC, PROFILE_SPECIFIC_TESTS}, timeOut = TIMEOUT)\n+    public void shouldFailQueryForWrongLdapPassword()\n+            throws IOException, InterruptedException\n+    {\n+        expectQueryToFail(ldapUserName, \"wrong_password\", INVALID_CREDENTIALS);","path":"presto-product-tests/src/main/java/com/facebook/presto/tests/jdbc/LdapTests.java","position":154,"original_position":154,"commit_id":"839cdf98099ac346d9528133ab80f4ceabcaaa8d","original_commit_id":"839cdf98099ac346d9528133ab80f4ceabcaaa8d","user":{"login":"anusudarsan","id":10963707,"avatar_url":"https://avatars.githubusercontent.com/u/10963707?v=3","gravatar_id":"","url":"https://api.github.com/users/anusudarsan","html_url":"https://github.com/anusudarsan","followers_url":"https://api.github.com/users/anusudarsan/followers","following_url":"https://api.github.com/users/anusudarsan/following{/other_user}","gists_url":"https://api.github.com/users/anusudarsan/gists{/gist_id}","starred_url":"https://api.github.com/users/anusudarsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anusudarsan/subscriptions","organizations_url":"https://api.github.com/users/anusudarsan/orgs","repos_url":"https://api.github.com/users/anusudarsan/repos","events_url":"https://api.github.com/users/anusudarsan/events{/privacy}","received_events_url":"https://api.github.com/users/anusudarsan/received_events","type":"User","site_admin":false},"body":"could you also add credentials with special characters test? like what we have in cli tests","created_at":"2016-09-01T19:22:51Z","updated_at":"2016-09-01T19:22:51Z","html_url":"https://github.com/Teradata/presto/pull/333#discussion_r77237260","pull_request_url":"https://api.github.com/repos/Teradata/presto/pulls/333","_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments/77237260"},"html":{"href":"https://github.com/Teradata/presto/pull/333#discussion_r77237260"},"pull_request":{"href":"https://api.github.com/repos/Teradata/presto/pulls/333"}}},"pull_request":{"url":"https://api.github.com/repos/Teradata/presto/pulls/333","id":83685523,"html_url":"https://github.com/Teradata/presto/pull/333","diff_url":"https://github.com/Teradata/presto/pull/333.diff","patch_url":"https://github.com/Teradata/presto/pull/333.patch","issue_url":"https://api.github.com/repos/Teradata/presto/issues/333","number":333,"state":"open","locked":false,"title":"Simba jdbc ldap tests","user":{"login":"brian-rickman","id":12533044,"avatar_url":"https://avatars.githubusercontent.com/u/12533044?v=3","gravatar_id":"","url":"https://api.github.com/users/brian-rickman","html_url":"https://github.com/brian-rickman","followers_url":"https://api.github.com/users/brian-rickman/followers","following_url":"https://api.github.com/users/brian-rickman/following{/other_user}","gists_url":"https://api.github.com/users/brian-rickman/gists{/gist_id}","starred_url":"https://api.github.com/users/brian-rickman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brian-rickman/subscriptions","organizations_url":"https://api.github.com/users/brian-rickman/orgs","repos_url":"https://api.github.com/users/brian-rickman/repos","events_url":"https://api.github.com/users/brian-rickman/events{/privacy}","received_events_url":"https://api.github.com/users/brian-rickman/received_events","type":"User","site_admin":false},"body":"Ported the CLI LDAP tests to JDBC so we can test Simba's JDBC driver.","created_at":"2016-09-01T18:45:00Z","updated_at":"2016-09-01T19:22:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c4e9c27be0d5df5d008ad4e9d49fad447951f73b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/presto/pulls/333/commits","review_comments_url":"https://api.github.com/repos/Teradata/presto/pulls/333/comments","review_comment_url":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/presto/issues/333/comments","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/839cdf98099ac346d9528133ab80f4ceabcaaa8d","head":{"label":"Teradata:simba-jdbc-ldap-tests-2","ref":"simba-jdbc-ldap-tests-2","sha":"839cdf98099ac346d9528133ab80f4ceabcaaa8d","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata Distribution of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-08-29T16:52:50Z","pushed_at":"2016-09-01T18:45:00Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":156837,"stargazers_count":56,"watchers_count":56,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":19,"forks":10,"open_issues":19,"watchers":56,"default_branch":"master"}},"base":{"label":"Teradata:run-tests-openldap-docker","ref":"run-tests-openldap-docker","sha":"37f543e0cb28871508ba9ac114c66e99dd348bc6","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata Distribution of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-08-29T16:52:50Z","pushed_at":"2016-09-01T18:45:00Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":156837,"stargazers_count":56,"watchers_count":56,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"open_issues_count":19,"forks":10,"open_issues":19,"watchers":56,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/333"},"html":{"href":"https://github.com/Teradata/presto/pull/333"},"issue":{"href":"https://api.github.com/repos/Teradata/presto/issues/333"},"comments":{"href":"https://api.github.com/repos/Teradata/presto/issues/333/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/presto/pulls/333/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/presto/pulls/333/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/presto/statuses/839cdf98099ac346d9528133ab80f4ceabcaaa8d"}}}}
{"actor":{"display_login":"anusudarsan"}}