Skip to content
Snippets Groups Projects
Commit 947b30e1 authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

XWIKI-12771: Add support for list value in LDAP sync

* add test
parent 840e5a4b
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@
import com.xpn.xwiki.XWikiException;
import com.xpn.xwiki.doc.XWikiDocument;
import com.xpn.xwiki.objects.BaseObject;
import com.xpn.xwiki.objects.classes.BaseClass;
import com.xpn.xwiki.plugin.ldap.XWikiLDAPUtils;
import com.xpn.xwiki.user.impl.LDAP.LDAPProfileXClass;
import com.xpn.xwiki.user.impl.LDAP.XWikiLDAPAuthServiceImpl;
......@@ -99,7 +100,15 @@ public void before() throws Exception
this.mocker.getMockXWikiCfg().setProperty("xwiki.authentication.ldap.try_local", "0");
this.mocker.getMockXWikiCfg().setProperty("xwiki.authentication.ldap.update_user", "1");
this.mocker.getMockXWikiCfg().setProperty("xwiki.authentication.ldap.fields_mapping",
"last_name=sn,first_name=givenName,fullname=cn,email=mail");
"last_name=sn,first_name=givenName,fullname=cn,email=mail,listfield=description");
// Add a list field to user class
this.mocker.getMockXWiki().getUserClass(this.mocker.getXWikiContext());
XWikiDocument userDocument =
this.mocker.getMockXWiki().getDocument(USER_XCLASS_REFERENCE, this.mocker.getXWikiContext());
BaseClass userClass = userDocument.getXClass();
userClass.addStaticListField("listfield", "List field", 30, true, "");
this.mocker.getMockXWiki().saveDocument(userDocument, this.mocker.getXWikiContext());
this.ldapAuth = new XWikiLDAPAuthServiceImpl();
}
......@@ -359,6 +368,7 @@ public void testAuthenticateUserSync() throws XWikiException
assertEquals(LDAPTestSetup.HORATIOHORNBLOWER_SN, userProfileObj.getStringValue("last_name"));
assertEquals(LDAPTestSetup.HORATIOHORNBLOWER_GIVENNAME, userProfileObj.getStringValue("first_name"));
assertEquals(LDAPTestSetup.HORATIOHORNBLOWER_MAIL, userProfileObj.getStringValue("email"));
assertEquals(LDAPTestSetup.HORATIOHORNBLOWER_DESCRIPTION, userProfileObj.getListValue("listfield"));
// Check non mapped properties are not touched
......
......@@ -19,7 +19,9 @@
*/
package org.xwiki.ldap.framework;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
......@@ -92,6 +94,8 @@ public class LDAPTestSetup
*/
public static final String HORATIOHORNBLOWER_MAIL = "hhornblo@royalnavy.mod.uk";
public static final List<String> HORATIOHORNBLOWER_DESCRIPTION = Arrays.<String>asList("Capt. Horatio Hornblower, R.N", "value2", "value3");
/**
* The LDAP DN of user Thomas Quist.
*/
......
......@@ -57,6 +57,8 @@ sn: Hornblower
uid: hhornblo
mail: hhornblo@royalnavy.mod.uk
userpassword: {SHA}nU4eI71bcnBGqeO0t9tXvY1u5oQ=
description: value2
description: value3
dn: cn=William Bush,ou=people,o=sevenSeas
objectclass: person
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment