FAQ
Repository: hive
Updated Branches:
   refs/heads/branch-1 9b8fbd486 -> 4cb3b11e2


HIVE-13055: Add unit tests for HIVE-11512 (Naveen Gangam via Aihua Xu)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/4cb3b11e
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/4cb3b11e
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/4cb3b11e

Branch: refs/heads/branch-1
Commit: 4cb3b11e2d260458bd36aefed6ef3ebd339cae27
Parents: 9b8fbd4
Author: Aihua Xu <aihuaxu@apache.org>
Authored: Thu Feb 18 09:17:32 2016 -0500
Committer: Aihua Xu <aihuaxu@apache.org>
Committed: Thu Feb 18 15:09:54 2016 -0500

----------------------------------------------------------------------
  .../auth/TestLdapAtnProviderWithMiniDS.java | 227 +++++++++++++++++++
  1 file changed, 227 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/4cb3b11e/service/src/test/org/apache/hive/service/auth/TestLdapAtnProviderWithMiniDS.java
----------------------------------------------------------------------
diff --git a/service/src/test/org/apache/hive/service/auth/TestLdapAtnProviderWithMiniDS.java b/service/src/test/org/apache/hive/service/auth/TestLdapAtnProviderWithMiniDS.java
index 934b207..e5cee37 100644
--- a/service/src/test/org/apache/hive/service/auth/TestLdapAtnProviderWithMiniDS.java
+++ b/service/src/test/org/apache/hive/service/auth/TestLdapAtnProviderWithMiniDS.java
@@ -308,4 +308,231 @@ public class TestLdapAtnProviderWithMiniDS extends AbstractLdapTestUnit {
        assertTrue("testUserBindNegative: Authentication failed for user2 as expected", true);
      }
    }
+
+ @Test
+ public void testUserBindPositiveWithDN() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+
+ ldapProperties.put("hive.server2.authentication.ldap.userDNPattern", "uid=%s,ou=People,dc=example,dc=com");
+ ldapProperties.put("hive.server2.authentication.ldap.groupDNPattern", "uid=%s,ou=Groups,dc=example,dc=com");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user1");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user1, expected to succeed:" + e.getMessage());
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " user as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user2, expected to succeed:" + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testUserBindPositiveWithDNOldConfig() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+
+ ldapProperties.put("hive.server2.authentication.ldap.baseDN", "ou=People,dc=example,dc=com");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user1");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user1, expected to succeed");
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user2, expected to succeed");
+ }
+ }
+
+ @Test
+ public void testUserBindPositiveWithDNWrongOldConfig() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+
+ ldapProperties.put("hive.server2.authentication.ldap.baseDN", "ou=DummyPeople,dc=example,dc=com");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user1");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user1, expected to succeed");
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user2, expected to succeed");
+ }
+ }
+
+ @Test
+ public void testUserBindPositiveWithDNWrongConfig() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+
+ ldapProperties.put("hive.server2.authentication.ldap.userDNPattern", "uid=%s,ou=DummyPeople,dc=example,dc=com");
+ ldapProperties.put("hive.server2.authentication.ldap.groupDNPattern", "uid=%s,ou=DummyGroups,dc=example,dc=com");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user1");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user1, expected to succeed");
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user2, expected to succeed");
+ }
+ }
+
+ @Test
+ public void testUserBindPositiveWithDNBlankConfig() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+
+ ldapProperties.put("hive.server2.authentication.ldap.userDNPattern", " ");
+ ldapProperties.put("hive.server2.authentication.ldap.groupDNPattern", " ");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user1");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user1, expected to succeed");
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user2, expected to succeed");
+ }
+ }
+
+ @Test
+ public void testUserBindPositiveWithDNBlankOldConfig() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+
+ ldapProperties.put("hive.server2.authentication.ldap.baseDN", "");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user1");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user1, expected to succeed");
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ assertTrue("testUserBindPositive: Authentication succeeded for " + user + " as expected", true);
+ } catch (AuthenticationException e) {
+ Assert.fail("testUserBindPositive: Authentication failed for user:" + user +
+ " with password user2, expected to succeed");
+ }
+ }
+
+ @Test
+ public void testUserBindNegativeWithDN() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+ ldapProperties.put("hive.server2.authentication.ldap.userDNPattern", "uid=%s,ou=People,dc=example,dc=com");
+ ldapProperties.put("hive.server2.authentication.ldap.groupDNPattern", "uid=%s,ou=Groups,dc=example,dc=com");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ Assert.fail("testUserBindNegative: Authentication succeeded for " + user + " with password " +
+ "user2, expected to fail");
+ } catch (AuthenticationException e) {
+ assertTrue("testUserBindNegative: Authentication failed for " + user + " as expected", true);
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user");
+ Assert.fail("testUserBindNegative: Authentication failed for " + user + " with password user, " +
+ "expected to fail");
+ } catch (AuthenticationException e) {
+ assertTrue("testUserBindNegative: Authentication failed for " + user + " as expected", true);
+ }
+ }
+
+ @Test
+ public void testUserBindNegativeWithDNOldConfig() throws Exception {
+ String user;
+ Map<String, String> ldapProperties = new HashMap<String, String>();
+ ldapProperties.put("hive.server2.authentication.ldap.baseDN", "ou=People,dc=example,dc=com");
+ initLdapAtn(ldapProperties);
+ assertTrue(ldapServer.getPort() > 0);
+
+ user = "uid=user1,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user2");
+ Assert.fail("testUserBindNegative: Authentication succeeded for " + user + " with password " +
+ "user2, expected to fail");
+ } catch (AuthenticationException e) {
+ assertTrue("testUserBindNegative: Authentication failed for " + user + " as expected", true);
+ }
+
+ user = "uid=user2,ou=People,dc=example,dc=com";
+ try {
+ ldapProvider.Authenticate(user, "user");
+ Assert.fail("testUserBindNegative: Authentication failed for " + user + " with password user, " +
+ "expected to fail");
+ } catch (AuthenticationException e) {
+ assertTrue("testUserBindNegative: Authentication failed for " + user + " as expected", true);
+ }
+ }
+
  }

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedFeb 18, '16 at 2:19p
activeFeb 18, '16 at 8:11p
posts2
users1
websitehive.apache.org

1 user in discussion

Aihuaxu: 2 posts

People

Translate

site design / logo © 2021 Grokbase