You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@submarine.apache.org by li...@apache.org on 2020/07/04 14:32:18 UTC

[submarine] branch master updated: SUBMARINE-551. Add a test of user identity verification

This is an automated email from the ASF dual-hosted git repository.

liuxun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git


The following commit(s) were added to refs/heads/master by this push:
     new b85d409  SUBMARINE-551. Add a test of user identity verification
b85d409 is described below

commit b85d4099bf0634f99691fd5d80a5e9408561f678
Author: Eroschang <sa...@gmail.com>
AuthorDate: Fri Jul 3 14:41:03 2020 +0800

    SUBMARINE-551. Add a test of user identity verification
    
    ### What is this PR for?
    To test the LDAP for user verification.
    The user in this open LDAP server can be verified successfully.
    
    ### What type of PR is it?
    Improvement
    
    ### Todos
    * [ ] - Task
    
    ### What is the Jira issue?
    https://issues.apache.org/jira/browse/SUBMARINE-551
    
    ### How should this be tested?
    * First time? Setup Travis CI as described on https://submarine.apache.org/contribution/contributions.html#continuous-integration
    * Strongly recommended: add automated unit tests for any new or changed behavior
    * Outline any manual steps to test the PR here.
    https://travis-ci.org/github/Eroschang/submarine/builds/703852786
    
    ### Screenshots (if appropriate)
    ![image](https://user-images.githubusercontent.com/43379142/86231254-d92fe400-bbc4-11ea-8000-ed12af7a2f3e.png)
    
    ### Questions:
    * Does the licenses files need update? /No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    Author: Eroschang <sa...@gmail.com>
    
    Closes #337 from Eroschang/SUBMARINE-551 and squashes the following commits:
    
    ff78c95 [Eroschang] Add a test of user identity verification.
    cbb9d28 [Eroschang] Add a test of user identity verification.
    0fca95a [Eroschang] Add a test of user identity verification.
---
 .../commons/unixusersync/EmbeddedLdapRuleTest.java | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/submarine-commons/commons-unixusersync/src/test/java/org/apache/submarine/commons/unixusersync/EmbeddedLdapRuleTest.java b/submarine-commons/commons-unixusersync/src/test/java/org/apache/submarine/commons/unixusersync/EmbeddedLdapRuleTest.java
index 7727a8d..42f2ce9 100644
--- a/submarine-commons/commons-unixusersync/src/test/java/org/apache/submarine/commons/unixusersync/EmbeddedLdapRuleTest.java
+++ b/submarine-commons/commons-unixusersync/src/test/java/org/apache/submarine/commons/unixusersync/EmbeddedLdapRuleTest.java
@@ -35,13 +35,16 @@ import org.slf4j.LoggerFactory;
 import org.zapodot.junit.ldap.EmbeddedLdapRule;
 import org.zapodot.junit.ldap.EmbeddedLdapRuleBuilder;
 
+import javax.naming.AuthenticationException;
 import javax.naming.Context;
 import javax.naming.NameClassPair;
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
 import javax.naming.directory.SearchControls;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Hashtable;
 import java.util.StringTokenizer;
 
 import static org.junit.Assert.assertEquals;
@@ -134,6 +137,36 @@ public class EmbeddedLdapRuleTest {
   }
 
   @Test
+  public void testauth() throws Exception {
+    DirContext ctx = null;
+    Hashtable<String, String> HashEnv = new Hashtable<String, String>();
+
+    String loginId = "uid=curie,dc=example,dc=com";
+    String password = "password";
+
+    HashEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
+    HashEnv.put(Context.SECURITY_PRINCIPAL, loginId);
+    HashEnv.put(Context.SECURITY_CREDENTIALS, password);
+    HashEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
+    HashEnv.put("com.sun.jndi.ldap.connect.timeout", "3000");
+    HashEnv.put(Context.PROVIDER_URL, "ldap://ldap.forumsys.com:389");
+
+    try {
+      ctx = new InitialDirContext(HashEnv);
+      LOG.info("Pass");
+    }
+    catch (AuthenticationException e) {
+      LOG.error(e.getMessage(), e);
+    }
+    catch (javax.naming.CommunicationException e) {
+      LOG.error(e.getMessage(), e);
+    }
+    catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+    }
+  }
+
+  @Test
   public void testContextClose() throws Exception {
     final Context context = embeddedLdapRule.context();
     context.close();


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@submarine.apache.org
For additional commands, e-mail: dev-help@submarine.apache.org