[prev in list] [next in list] [prev in thread] [next in thread]
List: forgerock-openicf-commit
Subject: [Commitopenicf] [6874] tags: Tag openicf-ldap-connector-1.4.1.0-RC3
From: anonymous () forgerock ! org
Date: 2015-09-11 13:00:13
Message-ID: 20150911130013.4C1E940926 () sources ! internal ! forgerock ! com
[Download RAW message or body]
[Attachment #2 (text/html)]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[6874] tags: Tag openicf-ldap-connector-1.4.1.0-RC3</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: \
verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: \
bold} #msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: \
bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: \
6px; } #logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em \
0; } #logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg \
h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; } \
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; \
} #logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: \
-1.5em; padding-left: 1.5em; } #logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em \
1em 0 1em; background: white;} #logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid \
#fa0; border-bottom: 1px solid #fa0; background: #fff; } #logmsg table th { \
text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted \
#fa0; } #logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: \
0.2em 0.5em; } #logmsg table thead th { text-align: center; border-bottom: 1px solid \
#fa0; } #logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: \
6px; } #patch { width: 100%; }
#patch h4 {font-family: \
verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, \
#patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins \
{background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del \
{background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, \
.info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a \
href="http://sources.forgerock.org/changelog/openicf/?cs=6874">6874</a></dd> \
<dt>Author</dt> <dd>Laszlo</dd> <dt>Date</dt> <dd>2015-09-11 14:00:13 +0100 (Fri, 11 \
Sep 2015)</dd> </dl>
<h3>Log Message</h3>
<pre>Tag openicf-ldap-connector-1.4.1.0-RC3</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#tagsopenicfldapconnector1410RC3pomxml">tags/openicf-ldap-connector-1.4.1.0-RC3/pom.xml</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/</li>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/opends/</li>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/src/</li>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/</li>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/identityconnectors/</li>
<li><a href="#tagsopenicfldapconnector1410RC3srcmainjavaorgidentityconnectorsldapsync \
timestampsTimestampsSyncStrategyjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/main \
/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestconfigorgidentityconnectorsldapLd \
apConnectorconfigconfiggroovy">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAdap \
terCompatibilityTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAppe \
ndingAttributesTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
AuthenticateTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
ConfigurationTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
ConnectionTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
ConnectorTestBasejava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
EntryTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapSunD \
STestBasejava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodi \
fyLdapCreateTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodi \
fyLdapDeleteTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodi \
fyLdapUpdateTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsche \
maGuardedPasswordAttributeTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/ \
java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java</a></li> \
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapschem \
aLdapSchemaMappingTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsear \
chLdapFilterTranslatorTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsear \
chLdapSearchTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsync \
sundsLdapModifyForTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsync \
sundsLdifParserTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsync \
sundsSunDSChangeLogSyncStrategyTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/ \
test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java</a></li>
</ul>
<h3>Removed Paths</h3>
<ul>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/opends/</li>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/src/</li>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/</li>
<li>tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/identityconnectors/</li>
<li><a href="#tagsopenicfldapconnector1410RC3srcmainjavaorgidentityconnectorsldapsync \
timestampsTimestampsSyncStrategyjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/main \
/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestconfigorgidentityconnectorsldapLd \
apConnectorconfigconfiggroovy">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAdap \
terCompatibilityTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAppe \
ndingAttributesTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
AuthenticateTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
ConfigurationTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
ConnectionTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
ConnectorTestBasejava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdap \
EntryTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapSunD \
STestBasejava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodi \
fyLdapCreateTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodi \
fyLdapDeleteTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodi \
fyLdapUpdateTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsche \
maGuardedPasswordAttributeTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/ \
java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java</a></li> \
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapschem \
aLdapSchemaMappingTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsear \
chLdapFilterTranslatorTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsear \
chLdapSearchTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsync \
sundsLdapModifyForTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsync \
sundsLdifParserTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java</a></li>
<li><a href="#tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsync \
sundsSunDSChangeLogSyncStrategyTestsjava">tags/openicf-ldap-connector-1.4.1.0-RC3/src/ \
test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="tagsopenicfldapconnector1410RC3pomxml"></a>
<div class="modfile"><h4>Modified: tags/openicf-ldap-connector-1.4.1.0-RC3/pom.xml \
(6872 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- branches/openicf-ldap-connector-1.4.1.x/pom.xml 2015-09-11 \
09:53:21 UTC (rev 6872)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/pom.xml 2015-09-11 13:00:13 UTC (rev \
6874) </span><span class="lines">@@ -32,15 +32,15 @@
</span><span class="cx"> </parent>
</span><span class="cx"> \
<groupId>org.forgerock.openicf.connectors</groupId> </span><span \
class="cx"> <artifactId>ldap-connector</artifactId> </span><del>- \
<version>1.4.1.1-SNAPSHOT</version> </del><ins>+ \
<version>1.4.1.0-RC3</version> </ins><span class="cx"> \
<packaging>bundle</packaging> </span><span class="cx"> \
<name>Generic JNDI based LDAP Connector</name> </span><span class="cx"> \
<description>Connector for Sun DSEE and OpenDJ and Generic \
LDAP</description> </span><span class="cx"> \
<url>http://openicf.forgerock.org/connectors/ldap-connector</url> \
</span><span class="cx"> <scm> </span><del>- \
<connection>scm:svn:https://svn.forgerock.org/openicf/branches/openicf-ldap-connector-1.4.1.x</connection>
- <developerConnection>scm:svn:https://svn.forgerock.org/openicf/branches/openicf-ldap-connector-1.4.1.x</developerConnection>
- <url>http://sources.forgerock.org/browse/openicf/branches/openicf-ldap-connector-1.4.1.x</url>
</del><ins>+ \
<connection>scm:svn:https://svn.forgerock.org/openicf/tags/openicf-ldap-connector-1.4.1.0-RC3</connection>
+ <developerConnection>scm:svn:https://svn.forgerock.org/openicf/tags/openicf-ldap-connector-1.4.1.0-RC3</developerConnection>
+ <url>http://sources.forgerock.org/browse/openicf/tags/openicf-ldap-connector-1.4.1.0-RC3</url>
</ins><span class="cx"> </scm>
</span><span class="cx"> <issueManagement>
</span><span class="cx"> <system>jira</system>
</span></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srcmainjavaorgidentityconnectorsldapsynctimestampsTimestampsSyncStrategyjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/main/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,323 +0,0 @@
</span><del>-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright (c) 2013-2015 ForgeRock AS. All Rights Reserved
- *
- * The contents of this file are subject to the terms
- * of the Common Development and Distribution License
- * (the License). You may not use this file except in
- * compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://forgerock.org/license/CDDLv1.0.html
- * See the License for the specific language governing
- * permission and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL
- * Header Notice in each file and include the License file
- * at http://forgerock.org/license/CDDLv1.0.html
- * If applicable, add the following below the CDDL Header,
- * with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- */
-package org.identityconnectors.ldap.sync.timestamps;
-
-import static org.identityconnectors.ldap.ADLdapUtil.fetchGroupMembersByRange;
-import static org.identityconnectors.ldap.ADLdapUtil.objectGUIDtoString;
-import static org.identityconnectors.ldap.LdapUtil.buildMemberIdAttribute;
-import static org.identityconnectors.ldap.LdapConstants.OBJECTCLASS_ATTR;
-import static org.identityconnectors.ldap.LdapUtil.getObjectClassFilter;
-import static org.identityconnectors.ldap.LdapUtil.guessObjectClass;
-
-import java.text.SimpleDateFormat;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.TimeZone;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.PartialResultException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.PagedResultsControl;
-
-import org.identityconnectors.common.logging.Log;
-import org.identityconnectors.framework.common.exceptions.ConnectorException;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.identityconnectors.framework.common.objects.ConnectorObjectBuilder;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.OperationOptions;
-import org.identityconnectors.framework.common.objects.SyncDeltaBuilder;
-import org.identityconnectors.framework.common.objects.SyncDeltaType;
-import org.identityconnectors.framework.common.objects.SyncResultsHandler;
-import org.identityconnectors.framework.common.objects.SyncToken;
-import org.identityconnectors.framework.common.objects.Uid;
-import org.identityconnectors.framework.spi.SyncTokenResultsHandler;
-import org.identityconnectors.ldap.ADGroupType;
-import org.identityconnectors.ldap.ADLdapUtil;
-import org.identityconnectors.ldap.ADUserAccountControl;
-import org.identityconnectors.ldap.LdapConnection;
-import org.identityconnectors.ldap.LdapConstants.ServerType;
-import org.identityconnectors.ldap.LdapConstants;
-import org.identityconnectors.ldap.LdapEntry;
-import org.identityconnectors.ldap.search.DefaultSearchStrategy;
-import org.identityconnectors.ldap.search.LdapInternalSearch;
-import org.identityconnectors.ldap.search.LdapSearchStrategy;
-import org.identityconnectors.ldap.search.LdapSearchResultsHandler;
-import org.identityconnectors.ldap.search.SimplePagedSearchStrategy;
-import org.identityconnectors.ldap.sync.LdapSyncStrategy;
-
-/**
- * An implementation of the sync operation based on the generic timestamps
- * attribute present in any LDAP directory.
- */
-public class TimestampsSyncStrategy implements LdapSyncStrategy {
-
- private final String createTimestamp = "createTimestamp";
- private final String modifyTimestamp = "modifyTimestamp";
- private final LdapConnection conn;
- private final ObjectClass oclass;
- private final ServerType server;
- private static final Log logger = Log.getLog(TimestampsSyncStrategy.class);
-
- public TimestampsSyncStrategy(LdapConnection conn, ObjectClass oclass) {
- this.conn = conn;
- this.oclass = oclass;
- this.server = conn.getServerType();
- }
-
- public SyncToken getLatestSyncToken() {
- return new SyncToken(getNowTime());
- }
-
- public void sync(SyncToken token, final SyncResultsHandler handler, final \
OperationOptions options) {
- // ldapsearch -h host -p 389 -b "dc=example,dc=com" -D \
"cn=administrator,cn=users,dc=example,dc=com" -w xxx \
"whenchanged>=20130214130642.0Z"
- // on AD
- // ldapsearch -h host -p 389 -b 'dc=example,dc=com' -S modifytimestamp -D \
'cn=directory manager' -w xxx \
"createTimestamp>=20120424080554Z"
- // on other directories
-
- final String now = getNowTime();
- LdapSearchStrategy strategy;
- SearchControls controls = LdapInternalSearch.createDefaultSearchControls();
- controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- controls.setDerefLinkFlag(false);
- if (ADLdapUtil.isServerMSADFamily(server)) {
- controls.setReturningAttributes(getAttributesToGet(new \
String[]{createTimestamp, modifyTimestamp,
- ADUserAccountControl.MSDS_USR_ACCT_CTRL_ATTR,
- conn.getConfiguration().getUidAttribute()}, \
options.getAttributesToGet()));
- } else {
- controls.setReturningAttributes(getAttributesToGet(new \
String[]{createTimestamp, modifyTimestamp,
- conn.getConfiguration().getUidAttribute()}, \
options.getAttributesToGet()));
- }
-
- if (conn.getConfiguration().isUseBlocks() && \
conn.supportsControl(PagedResultsControl.OID)) {
- strategy = new \
SimplePagedSearchStrategy(conn.getConfiguration().getBlockSize());
- } else {
- strategy = new DefaultSearchStrategy(false);
- }
-
- LdapInternalSearch search = new LdapInternalSearch(conn,
- generateFilter(oclass, token),
- Arrays.asList(conn.getConfiguration().getBaseContextsToSynchronize()),
- strategy, controls);
-
- try {
- search.execute(new LdapSearchResultsHandler() {
- public boolean handle(String baseDN, SearchResult result) throws \
NamingException {
- LdapEntry entry = LdapEntry.create(baseDN, result);
- Attributes attrs = result.getAttributes();
- Uid uid = conn.getSchemaMapping().createUid(oclass, entry);
- // build the object first
- ConnectorObjectBuilder cob = new ConnectorObjectBuilder();
- cob.setUid(uid);
- if (ObjectClass.ALL.equals(oclass)) {
- cob.setObjectClass(guessObjectClass(conn, \
attrs.get(OBJECTCLASS_ATTR)));
- } else {
- cob.setObjectClass(oclass);
- }
- cob.setName(result.getNameInNamespace());
-
- // Let's process AD specifics...
- if (ADLdapUtil.isServerMSADFamily(server)) {
- if (ObjectClass.ACCOUNT.equals(oclass)) {
- if (ServerType.MSAD_LDS.equals(server)) {
- if \
(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_DISABLED) != null) {
- \
cob.addAttribute(AttributeBuilder.buildEnabled(!Boolean.parseBoolean(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_DISABLED).get().toString())));
- } else if \
(attrs.get(LdapConstants.MS_DS_USER_PASSWORD_EXPIRED) != null) {
- \
cob.addAttribute(AttributeBuilder.buildPasswordExpired(Boolean.parseBoolean(attrs.get(LdapConstants.MS_DS_USER_PASSWORD_EXPIRED).get().toString())));
- } else if \
(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_AUTOLOCKED) != null) {
- \
cob.addAttribute(AttributeBuilder.buildLockOut(Boolean.parseBoolean(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_AUTOLOCKED).get().toString())));
- }
- } else {
- if \
(attrs.get(ADUserAccountControl.MS_USR_ACCT_CTRL_ATTR) != null) {
- String uac = \
attrs.get(ADUserAccountControl.MS_USR_ACCT_CTRL_ATTR).get().toString();
- \
cob.addAttribute(AttributeBuilder.buildEnabled(!ADUserAccountControl.isAccountDisabled(uac)));
- \
cob.addAttribute(AttributeBuilder.build(ADUserAccountControl.DONT_EXPIRE_PASSWORD_NAME, \
ADUserAccountControl.isDontExpirePassword(uac)));
- \
cob.addAttribute(AttributeBuilder.build(ADUserAccountControl.PASSWORD_NOTREQD_NAME, \
ADUserAccountControl.isPasswordNotReq(uac)));
- \
cob.addAttribute(AttributeBuilder.build(ADUserAccountControl.SMARTCARD_REQUIRED_NAME, \
ADUserAccountControl.isSmartCardRequired(uac)));
- }
- if \
(attrs.get(ADUserAccountControl.MSDS_USR_ACCT_CTRL_ATTR) != null) {
- String uac2 = \
attrs.get(ADUserAccountControl.MSDS_USR_ACCT_CTRL_ATTR).get().toString();
- \
cob.addAttribute(AttributeBuilder.buildLockOut(ADUserAccountControl.isAccountLockOut(uac2)));
- \
cob.addAttribute(AttributeBuilder.buildPasswordExpired(ADUserAccountControl.isPasswordExpired(uac2)));
- }
- }
- if (attrs.get(ADUserAccountControl.ACCOUNT_EXPIRES) != \
null) {
- \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.ACCOUNT_EXPIRES)));
- attrs.remove(ADUserAccountControl.ACCOUNT_EXPIRES);
- }
- if (attrs.get(ADUserAccountControl.PWD_LAST_SET) != \
null) {
- \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.PWD_LAST_SET)));
- attrs.remove(ADUserAccountControl.PWD_LAST_SET);
- }
- if (attrs.get(ADUserAccountControl.LAST_LOGON) != null) \
{
- \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.LAST_LOGON)));
- attrs.remove(ADUserAccountControl.LAST_LOGON);
- }
- if (attrs.get(ADUserAccountControl.LOCKOUT_TIME) != \
null) {
- \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.LOCKOUT_TIME)));
- attrs.remove(ADUserAccountControl.LOCKOUT_TIME);
- }
- }
- if (ObjectClass.GROUP.equals(oclass)) {
- // Make sure we're not hitting AD large group issue
- // see: \
http://msdn.microsoft.com/en-us/library/ms817827.aspx
- if (attrs.get("member;range=0-1499") != null) \
{
- // we're in the limitation
- Attribute range = \
AttributeBuilder.build("member", \
fetchGroupMembersByRange(conn, result));
- cob.addAttribute(range);
- if (conn.getConfiguration().isGetGroupMemberId()) {
- cob.addAttribute(buildMemberIdAttribute(conn, \
range));
- }
- attrs.remove("member;range=0-1499");
- attrs.remove("member");
- }
- try {
- if (attrs.get(ADGroupType.GROUPTYPE) != null) {
- String groupType = \
attrs.get(ADGroupType.GROUPTYPE).get().toString();
- \
cob.addAttribute(AttributeBuilder.build(ADGroupType.GROUP_SCOPE_NAME, \
ADGroupType.getScope(groupType)));
- \
cob.addAttribute(AttributeBuilder.build(ADGroupType.GROUP_TYPE_NAME, \
ADGroupType.getType(groupType)));
- }
- } catch (NamingException e) {
- logger.warn(e, "Can't read groupType attribute: \
" + e.getExplanation());
- }
- }
- javax.naming.directory.Attribute guid = \
attrs.get(LdapConstants.MS_GUID_ATTR);
- if (guid != null) {
- \
cob.addAttribute(AttributeBuilder.build(LdapConstants.MS_GUID_ATTR, \
objectGUIDtoString(guid)));
- attrs.remove(LdapConstants.MS_GUID_ATTR);
- }
- }
- // Set all Attributes
- NamingEnumeration<? extends \
javax.naming.directory.Attribute> attrsEnum = attrs.getAll();
- while (attrsEnum.hasMore()) {
- javax.naming.directory.Attribute attr = attrsEnum.next();
- String id = attr.getID();
- NamingEnumeration vals = attr.getAll();
- ArrayList values = new ArrayList();
- while (vals.hasMore()) {
- values.add(vals.next());
- }
- if (conn.getConfiguration().isGetGroupMemberId() && \
ObjectClass.GROUP.equals(oclass)
- && \
id.equalsIgnoreCase(conn.getConfiguration().getGroupMemberAttribute())) \
{
- cob.addAttribute(buildMemberIdAttribute(conn, attr));
- }
- cob.addAttribute(AttributeBuilder.build(id, values));
- }
-
- SyncDeltaBuilder syncDeltaBuilder = new SyncDeltaBuilder();
- syncDeltaBuilder.setToken(new SyncToken(now));
- syncDeltaBuilder.setDeltaType(SyncDeltaType.CREATE_OR_UPDATE);
- syncDeltaBuilder.setUid(uid);
- syncDeltaBuilder.setObject(cob.build());
-
- return handler.handle(syncDeltaBuilder.build());
- }
- });
- // ICF 1.4 now allows us to send the Token even if no entries were \
actually processed
- ((SyncTokenResultsHandler) handler).handleResult(new SyncToken(now));
- } catch (ConnectorException e) {
- if (e.getCause() instanceof PartialResultException) {
- logger.warn("PartialResultException has been caught");
- } else {
- throw e;
- }
- }
- }
-
- @SuppressWarnings("fallthrough")
- private String getNowTime() {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
-
- switch (server) {
- case MSAD_GC:
- case MSAD:
- case MSAD_LDS:
- return sdf.format(new Date()) + ".0Z";
- default:
- return sdf.format(new Date()) + "Z";
- }
- }
-
- private String generateFilter(ObjectClass oc, SyncToken token) {
- StringBuilder filter;
- filter = new StringBuilder();
-
- if (token == null) {
- token = this.getLatestSyncToken();
- }
- if (ObjectClass.ACCOUNT.equals(oc)) {
- filter.append(getObjectClassFilter(conn.getConfiguration().getAccountObjectClasses()));
- if (conn.getConfiguration().getAccountSynchronizationFilter() != null) {
- filter.append(conn.getConfiguration().getAccountSynchronizationFilter());
- }
- } else if (ObjectClass.GROUP.equals(oc)) {
- filter.append(getObjectClassFilter(conn.getConfiguration().getGroupObjectClasses()));
- if (conn.getConfiguration().getGroupSynchronizationFilter() != null) {
- filter.append(conn.getConfiguration().getGroupSynchronizationFilter());
- }
- } else if (ObjectClass.ALL.equals(oc)) {
- filter.append(getObjectClassFilter(conn.getConfiguration().getObjectClassesToSynchronize()));
- } else { // we use the ObjectClass value as the filter...
- filter.append("(objectClass=");
- filter.append(oc.getObjectClassValue());
- filter.append(")");
- }
-
- filter.append("(|(");
- filter.append(modifyTimestamp);
- filter.append(">=");
- filter.append(token.getValue().toString());
- filter.append(")(");
- filter.append(createTimestamp);
- filter.append(">=");
- filter.append(token.getValue().toString());
- filter.append("))");
- filter.insert(0, "(&");
- filter.append(")");
- logger.info("Using timestamp filter {0}", filter.toString());
- return filter.toString();
- }
-
- static String[] getAttributesToGet(String[]... attrsLists) {
- int len = 0;
- for (String[] attrs : attrsLists) {
- len += attrs.length;
- }
- String[] attrsToGet = new String[len];
- int idx = 0;
- for (String[] attrs : attrsLists) {
- for (String attr : attrs) {
- attrsToGet[idx] = attr;
- idx++;
- }
- }
- return attrsToGet;
-}
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srcmainjavaorgidentityconnectorsldapsynctimestam \
psTimestampsSyncStrategyjavafromrev6872branchesopenicfldapconnector141xsrcmainjavaorgidentityconnectorsldapsynctimestampsTimestampsSyncStrategyjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/main/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/main/java/org/identityconnectors/ldap/sync/timestamps/TimestampsSyncStrategy.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,328 @@
</span><ins>+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2013-2015 ForgeRock AS. All Rights Reserved
+ *
+ * The contents of this file are subject to the terms
+ * of the Common Development and Distribution License
+ * (the License). You may not use this file except in
+ * compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://forgerock.org/license/CDDLv1.0.html
+ * See the License for the specific language governing
+ * permission and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL
+ * Header Notice in each file and include the License file
+ * at http://forgerock.org/license/CDDLv1.0.html
+ * If applicable, add the following below the CDDL Header,
+ * with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ */
+package org.identityconnectors.ldap.sync.timestamps;
+
+import static org.identityconnectors.ldap.ADLdapUtil.fetchGroupMembersByRange;
+import static org.identityconnectors.ldap.ADLdapUtil.objectGUIDtoString;
+import static org.identityconnectors.ldap.LdapUtil.buildMemberIdAttribute;
+import static org.identityconnectors.ldap.LdapConstants.OBJECTCLASS_ATTR;
+import static org.identityconnectors.ldap.LdapUtil.getObjectClassFilter;
+import static org.identityconnectors.ldap.LdapUtil.guessObjectClass;
+
+import java.text.SimpleDateFormat;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.TimeZone;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.PartialResultException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.PagedResultsControl;
+
+import org.identityconnectors.common.logging.Log;
+import org.identityconnectors.framework.common.exceptions.ConnectorException;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.ConnectorObjectBuilder;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.SyncDeltaBuilder;
+import org.identityconnectors.framework.common.objects.SyncDeltaType;
+import org.identityconnectors.framework.common.objects.SyncResultsHandler;
+import org.identityconnectors.framework.common.objects.SyncToken;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.framework.spi.SyncTokenResultsHandler;
+import org.identityconnectors.ldap.ADGroupType;
+import org.identityconnectors.ldap.ADLdapUtil;
+import org.identityconnectors.ldap.ADUserAccountControl;
+import org.identityconnectors.ldap.LdapConnection;
+import org.identityconnectors.ldap.LdapConstants.ServerType;
+import org.identityconnectors.ldap.LdapConstants;
+import org.identityconnectors.ldap.LdapEntry;
+import org.identityconnectors.ldap.search.DefaultSearchStrategy;
+import org.identityconnectors.ldap.search.LdapInternalSearch;
+import org.identityconnectors.ldap.search.LdapSearchStrategy;
+import org.identityconnectors.ldap.search.LdapSearchResultsHandler;
+import org.identityconnectors.ldap.search.SimplePagedSearchStrategy;
+import org.identityconnectors.ldap.sync.LdapSyncStrategy;
+
+/**
+ * An implementation of the sync operation based on the generic timestamps
+ * attribute present in any LDAP directory.
+ */
+public class TimestampsSyncStrategy implements LdapSyncStrategy {
+
+ private final String createTimestamp = "createTimestamp";
+ private final String modifyTimestamp = "modifyTimestamp";
+ private final LdapConnection conn;
+ private final ObjectClass oclass;
+ private final ServerType server;
+ private static final Log logger = Log.getLog(TimestampsSyncStrategy.class);
+
+ public TimestampsSyncStrategy(LdapConnection conn, ObjectClass oclass) {
+ this.conn = conn;
+ this.oclass = oclass;
+ this.server = conn.getServerType();
+ }
+
+ public SyncToken getLatestSyncToken() {
+ return new SyncToken(getNowTime());
+ }
+
+ public void sync(SyncToken token, final SyncResultsHandler handler, final \
OperationOptions options) { + // ldapsearch -h host -p 389 -b \
"dc=example,dc=com" -D \
"cn=administrator,cn=users,dc=example,dc=com" -w xxx \
"whenchanged>=20130214130642.0Z" + // on AD
+ // ldapsearch -h host -p 389 -b 'dc=example,dc=com' -S modifytimestamp -D \
'cn=directory manager' -w xxx "createTimestamp>=20120424080554Z" + \
// on other directories +
+ final String now = getNowTime();
+ LdapSearchStrategy strategy;
+ String[] attrsToGet = new String[]{"*"};
+ SearchControls controls = LdapInternalSearch.createDefaultSearchControls();
+ controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
+ controls.setDerefLinkFlag(false);
+
+ if (null != options.getAttributesToGet() && \
options.getAttributesToGet().length != 0){ + attrsToGet = \
options.getAttributesToGet(); + }
+ if (ADLdapUtil.isServerMSADFamily(server)) {
+ controls.setReturningAttributes(getAttributesToGet(new \
String[]{createTimestamp, modifyTimestamp, + \
ADUserAccountControl.MSDS_USR_ACCT_CTRL_ATTR, + \
conn.getConfiguration().getUidAttribute()}, attrsToGet)); + } else {
+ controls.setReturningAttributes(getAttributesToGet(new \
String[]{createTimestamp, modifyTimestamp, + \
conn.getConfiguration().getUidAttribute()}, attrsToGet)); + }
+
+ if (conn.getConfiguration().isUseBlocks() && \
conn.supportsControl(PagedResultsControl.OID)) { + strategy = new \
SimplePagedSearchStrategy(conn.getConfiguration().getBlockSize()); + } else {
+ strategy = new DefaultSearchStrategy(false);
+ }
+
+ LdapInternalSearch search = new LdapInternalSearch(conn,
+ generateFilter(oclass, token),
+ Arrays.asList(conn.getConfiguration().getBaseContextsToSynchronize()),
+ strategy, controls);
+
+ try {
+ search.execute(new LdapSearchResultsHandler() {
+ public boolean handle(String baseDN, SearchResult result) throws \
NamingException { + LdapEntry entry = LdapEntry.create(baseDN, \
result); + Attributes attrs = result.getAttributes();
+ Uid uid = conn.getSchemaMapping().createUid(oclass, entry);
+ // build the object first
+ ConnectorObjectBuilder cob = new ConnectorObjectBuilder();
+ cob.setUid(uid);
+ if (ObjectClass.ALL.equals(oclass)) {
+ cob.setObjectClass(guessObjectClass(conn, \
attrs.get(OBJECTCLASS_ATTR))); + } else {
+ cob.setObjectClass(oclass);
+ }
+ cob.setName(result.getNameInNamespace());
+
+ // Let's process AD specifics...
+ if (ADLdapUtil.isServerMSADFamily(server)) {
+ if (ObjectClass.ACCOUNT.equals(oclass)) {
+ if (ServerType.MSAD_LDS.equals(server)) {
+ if \
(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_DISABLED) != null) { + \
cob.addAttribute(AttributeBuilder.buildEnabled(!Boolean.parseBoolean(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_DISABLED).get().toString())));
+ } else if \
(attrs.get(LdapConstants.MS_DS_USER_PASSWORD_EXPIRED) != null) { + \
cob.addAttribute(AttributeBuilder.buildPasswordExpired(Boolean.parseBoolean(attrs.get(LdapConstants.MS_DS_USER_PASSWORD_EXPIRED).get().toString())));
+ } else if \
(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_AUTOLOCKED) != null) { + \
cob.addAttribute(AttributeBuilder.buildLockOut(Boolean.parseBoolean(attrs.get(LdapConstants.MS_DS_USER_ACCOUNT_AUTOLOCKED).get().toString())));
+ }
+ } else {
+ if \
(attrs.get(ADUserAccountControl.MS_USR_ACCT_CTRL_ATTR) != null) { + \
String uac = attrs.get(ADUserAccountControl.MS_USR_ACCT_CTRL_ATTR).get().toString(); \
+ \
cob.addAttribute(AttributeBuilder.buildEnabled(!ADUserAccountControl.isAccountDisabled(uac)));
+ \
cob.addAttribute(AttributeBuilder.build(ADUserAccountControl.DONT_EXPIRE_PASSWORD_NAME, \
ADUserAccountControl.isDontExpirePassword(uac))); + \
cob.addAttribute(AttributeBuilder.build(ADUserAccountControl.PASSWORD_NOTREQD_NAME, \
ADUserAccountControl.isPasswordNotReq(uac))); + \
cob.addAttribute(AttributeBuilder.build(ADUserAccountControl.SMARTCARD_REQUIRED_NAME, \
ADUserAccountControl.isSmartCardRequired(uac))); + }
+ if \
(attrs.get(ADUserAccountControl.MSDS_USR_ACCT_CTRL_ATTR) != null) { + \
String uac2 = attrs.get(ADUserAccountControl.MSDS_USR_ACCT_CTRL_ATTR).get().toString();
+ \
cob.addAttribute(AttributeBuilder.buildLockOut(ADUserAccountControl.isAccountLockOut(uac2)));
+ \
cob.addAttribute(AttributeBuilder.buildPasswordExpired(ADUserAccountControl.isPasswordExpired(uac2)));
+ }
+ }
+ if (attrs.get(ADUserAccountControl.ACCOUNT_EXPIRES) != \
null) { + \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.ACCOUNT_EXPIRES)));
+ attrs.remove(ADUserAccountControl.ACCOUNT_EXPIRES);
+ }
+ if (attrs.get(ADUserAccountControl.PWD_LAST_SET) != \
null) { + \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.PWD_LAST_SET)));
+ attrs.remove(ADUserAccountControl.PWD_LAST_SET);
+ }
+ if (attrs.get(ADUserAccountControl.LAST_LOGON) != null) \
{ + \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.LAST_LOGON)));
+ attrs.remove(ADUserAccountControl.LAST_LOGON);
+ }
+ if (attrs.get(ADUserAccountControl.LOCKOUT_TIME) != \
null) { + \
cob.addAttribute(ADLdapUtil.convertMSEpochToISO8601(attrs.get(ADUserAccountControl.LOCKOUT_TIME)));
+ attrs.remove(ADUserAccountControl.LOCKOUT_TIME);
+ }
+ }
+ if (ObjectClass.GROUP.equals(oclass)) {
+ // Make sure we're not hitting AD large group issue
+ // see: \
http://msdn.microsoft.com/en-us/library/ms817827.aspx + if \
(attrs.get("member;range=0-1499") != null) { + \
// we're in the limitation + Attribute range = \
AttributeBuilder.build("member", fetchGroupMembersByRange(conn, result)); + \
cob.addAttribute(range); + if \
(conn.getConfiguration().isGetGroupMemberId()) { + \
cob.addAttribute(buildMemberIdAttribute(conn, range)); + \
} + attrs.remove("member;range=0-1499");
+ attrs.remove("member");
+ }
+ try {
+ if (attrs.get(ADGroupType.GROUPTYPE) != null) {
+ String groupType = \
attrs.get(ADGroupType.GROUPTYPE).get().toString(); + \
cob.addAttribute(AttributeBuilder.build(ADGroupType.GROUP_SCOPE_NAME, \
ADGroupType.getScope(groupType))); + \
cob.addAttribute(AttributeBuilder.build(ADGroupType.GROUP_TYPE_NAME, \
ADGroupType.getType(groupType))); + }
+ } catch (NamingException e) {
+ logger.warn(e, "Can't read groupType attribute: \
" + e.getExplanation()); + }
+ }
+ javax.naming.directory.Attribute guid = \
attrs.get(LdapConstants.MS_GUID_ATTR); + if (guid != null) {
+ \
cob.addAttribute(AttributeBuilder.build(LdapConstants.MS_GUID_ATTR, \
objectGUIDtoString(guid))); + \
attrs.remove(LdapConstants.MS_GUID_ATTR); + }
+ }
+ // Set all Attributes
+ NamingEnumeration<? extends \
javax.naming.directory.Attribute> attrsEnum = attrs.getAll(); + \
while (attrsEnum.hasMore()) { + \
javax.naming.directory.Attribute attr = attrsEnum.next(); + \
String id = attr.getID(); + NamingEnumeration vals = \
attr.getAll(); + ArrayList values = new ArrayList();
+ while (vals.hasMore()) {
+ values.add(vals.next());
+ }
+ if (conn.getConfiguration().isGetGroupMemberId() && \
ObjectClass.GROUP.equals(oclass) + && \
id.equalsIgnoreCase(conn.getConfiguration().getGroupMemberAttribute())) { + \
cob.addAttribute(buildMemberIdAttribute(conn, attr)); + }
+ cob.addAttribute(AttributeBuilder.build(id, values));
+ }
+
+ SyncDeltaBuilder syncDeltaBuilder = new SyncDeltaBuilder();
+ syncDeltaBuilder.setToken(new SyncToken(now));
+ syncDeltaBuilder.setDeltaType(SyncDeltaType.CREATE_OR_UPDATE);
+ syncDeltaBuilder.setUid(uid);
+ syncDeltaBuilder.setObject(cob.build());
+
+ return handler.handle(syncDeltaBuilder.build());
+ }
+ });
+ // ICF 1.4 now allows us to send the Token even if no entries were \
actually processed + ((SyncTokenResultsHandler) handler).handleResult(new \
SyncToken(now)); + } catch (ConnectorException e) {
+ if (e.getCause() instanceof PartialResultException) {
+ logger.warn("PartialResultException has been caught");
+ } else {
+ throw e;
+ }
+ }
+ }
+
+ @SuppressWarnings("fallthrough")
+ private String getNowTime() {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ switch (server) {
+ case MSAD_GC:
+ case MSAD:
+ case MSAD_LDS:
+ return sdf.format(new Date()) + ".0Z";
+ default:
+ return sdf.format(new Date()) + "Z";
+ }
+ }
+
+ private String generateFilter(ObjectClass oc, SyncToken token) {
+ StringBuilder filter;
+ filter = new StringBuilder();
+
+ if (token == null) {
+ token = this.getLatestSyncToken();
+ }
+ if (ObjectClass.ACCOUNT.equals(oc)) {
+ filter.append(getObjectClassFilter(conn.getConfiguration().getAccountObjectClasses()));
+ if (conn.getConfiguration().getAccountSynchronizationFilter() != null) \
{ + filter.append(conn.getConfiguration().getAccountSynchronizationFilter());
+ }
+ } else if (ObjectClass.GROUP.equals(oc)) {
+ filter.append(getObjectClassFilter(conn.getConfiguration().getGroupObjectClasses()));
+ if (conn.getConfiguration().getGroupSynchronizationFilter() != null) {
+ filter.append(conn.getConfiguration().getGroupSynchronizationFilter());
+ }
+ } else if (ObjectClass.ALL.equals(oc)) {
+ filter.append(getObjectClassFilter(conn.getConfiguration().getObjectClassesToSynchronize()));
+ } else { // we use the ObjectClass value as the filter...
+ filter.append("(objectClass=");
+ filter.append(oc.getObjectClassValue());
+ filter.append(")");
+ }
+
+ filter.append("(|(");
+ filter.append(modifyTimestamp);
+ filter.append(">=");
+ filter.append(token.getValue().toString());
+ filter.append(")(");
+ filter.append(createTimestamp);
+ filter.append(">=");
+ filter.append(token.getValue().toString());
+ filter.append("))");
+ filter.insert(0, "(&");
+ filter.append(")");
+ logger.info("Using timestamp filter {0}", filter.toString());
+ return filter.toString();
+ }
+
+ static String[] getAttributesToGet(String[]... attrsLists) {
+ int len = 0;
+ for (String[] attrs : attrsLists) {
+ len += attrs.length;
+ }
+ String[] attrsToGet = new String[len];
+ int idx = 0;
+ for (String[] attrs : attrsLists) {
+ for (String attr : attrs) {
+ attrsToGet[idx] = attr;
+ idx++;
+ }
+ }
+ return attrsToGet;
+}
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestconfigorgidentityconnectorsldapLdapConnectorconfigconfiggroovy"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,285 +0,0 @@
</span><del>-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- *
- * U.S. Government Rights - Commercial software. Government users
- * are subject to the Sun Microsystems, Inc. standard license agreement
- * and applicable provisions of the FAR and its supplements.
- *
- * Use is subject to license terms.
- *
- * This distribution may include materials developed by third parties.
- * Sun, Sun Microsystems, the Sun logo, Java and Project Identity
- * Connectors are trademarks or registered trademarks of Sun
- * Microsystems, Inc. or its subsidiaries in the U.S. and other
- * countries.
- *
- * UNIX is a registered trademark in the U.S. and other countries,
- * exclusively licensed through X/Open Company, Ltd.
- *
- * -----------
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License(CDDL) (the License). You may not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://identityconnectors.dev.java.net/CDDLv1.0.html
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each
- * file and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * -----------
- */
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.contract.data.groovy.Lazy;
-import org.identityconnectors.contract.exceptions.ObjectNotFoundException;
-
-// Unit tests.
-
-sunds.host = '__configureme__'
-sunds.port = 389
-sunds.principal = '__configureme__'
-sunds.credentials = '__configureme__'
-sunds.baseContext = '__configureme__'
-
-// Contract tests.
-
-Object telephoneNumber() {
- return Lazy.random('### ### ####');
-}
-
-bundleJar = System.getProperty('bundleJar')
-bundleName = System.getProperty('bundleName')
-bundleVersion = System.getProperty('bundleVersion')
-connectorName='org.identityconnectors.ldap.LdapConnector'
-
-baseContext = '__configureme__'
-
-connector {
- host = '__configureme__'
- port = 389
- principal = '__configureme__'
- credentials = new GuardedString('__configureme__'.toCharArray())
- baseContexts = [ baseContext ] as String[]
- usePagedResultControl = true // We do not have a VLV index.
- uidAttribute = 'entryDN' // Sun DSEE 6.3 does not support entryUUID
-}
-
-Validate.invalidConfig = [
- [ host : '' ],
- [ port : 100000 ],
- [ baseContexts : [] as String[] ]
-]
-
-Test.invalidConfig = [
- [ principal : 'cn=Nobody' ],
- [ credentials : 'bogus' ]
-]
-
-Schema {
- strictCheck = false
-
- oclasses = [ '__ACCOUNT__', '__GROUP__' ]
-
- operations = [
- GetApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- SchemaApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- ValidateApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- CreateApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- SearchApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- DeleteApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- ScriptOnConnectorApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- UpdateApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- AuthenticationApiOp: [ '__ACCOUNT__' ],
- TestApiOp: [ '__ACCOUNT__', '__GROUP__' ],
- SyncApiOp: [ ]
- ]
-
- attributes.__ACCOUNT__.oclasses = [ '__NAME__', 'cn', 'sn', 'jpegPhoto' ]
- __NAME__.attribute.__ACCOUNT__.oclasses = [
- type: java.lang.String.class,
- readable: true,
- createable: true,
- updateable: true,
- required: true,
- multiValue: false,
- returnedByDefault: true
- ]
- cn.attribute.__ACCOUNT__.oclasses = [
- type: java.lang.String.class,
- readable: true,
- createable: true,
- updateable: true,
- required: true,
- multiValue: true,
- returnedByDefault: true
- ]
- jpegPhoto.attribute.__ACCOUNT__.oclasses = [
- type: byte[].class,
- readable: true,
- createable: true,
- updateable: true,
- required: false,
- multiValue: true,
- returnedByDefault: true
- ]
-
- attributes.__GROUP__.oclasses = [ '__NAME__', 'cn' ]
- __NAME__.attribute.__ACCOUNT__.oclasses = [
- type: java.lang.String.class,
- readable: true,
- createable: true,
- updateable: true,
- required: true,
- multiValue: false,
- returnedByDefault: true
- ]
- cn.attribute.__ACCOUNT__.oclasses = [
- type: java.lang.String.class,
- readable: true,
- createable: true,
- updateable: true,
- required: true,
- multiValue: true,
- returnedByDefault: true
- ]
-}
-
-objectClasses = [ '__ACCOUNT__', '__GROUP__' ]
-
-Search.disable.caseinsensitive = true
-
-Authentication {
- __ACCOUNT__ {
- __NAME__ = 'uid=Bugs Bunny,' + Lazy.get('baseContext')
- __PASSWORD__ = new GuardedString('password'.toCharArray())
- username = 'Bugs Bunny'
- modified.__PASSWORD__ = new GuardedString('newpassword'.toCharArray())
- wrong.password = new GuardedString('bogus'.toCharArray())
- }
-}
-
-__ACCOUNT__.__NAME__ = 'uid=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext')
-__ACCOUNT__.uid = new ObjectNotFoundException() // Since 'uid', as the naming \
attribute, already has a value.
-
-__ACCOUNT__.homePhone = telephoneNumber()
-__ACCOUNT__.mobile = telephoneNumber()
-__ACCOUNT__.pager = telephoneNumber()
-__ACCOUNT__.telephoneNumber = telephoneNumber()
-
-__ACCOUNT__.x500UniqueIdentifier = new ObjectNotFoundException()
-__ACCOUNT__.manager = new ObjectNotFoundException()
-__ACCOUNT__.internationaliSDNNumber = new ObjectNotFoundException()
-__ACCOUNT__.x121Address = new ObjectNotFoundException()
-__ACCOUNT__.preferredDeliveryMethod = new ObjectNotFoundException()
-__ACCOUNT__.telexNumber = new ObjectNotFoundException()
-__ACCOUNT__.owner = new ObjectNotFoundException()
-__ACCOUNT__.secretary = new ObjectNotFoundException()
-__ACCOUNT__.seeAlso = new ObjectNotFoundException()
-__ACCOUNT__.userPassword = new ObjectNotFoundException()
-__ACCOUNT__.__PASSWORD__ = new ObjectNotFoundException()
-
-__ACCOUNT__.modified.__NAME__ = 'cn=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext')
-__ACCOUNT__.modified.cn = new ObjectNotFoundException() // Since 'cn', as the naming \
attribute, already has a value.
-__ACCOUNT__.modified.uid = new ObjectNotFoundException() // Since 'uid', as the \
previous naming attribute, already has a value.
-
-__ACCOUNT__.modified.homePhone = telephoneNumber()
-__ACCOUNT__.modified.mobile = telephoneNumber()
-__ACCOUNT__.modified.pager = telephoneNumber()
-__ACCOUNT__.modified.telephoneNumber = telephoneNumber()
-
-__ACCOUNT__.modified.x500UniqueIdentifier = new ObjectNotFoundException()
-__ACCOUNT__.modified.manager = new ObjectNotFoundException()
-__ACCOUNT__.modified.internationaliSDNNumber = new ObjectNotFoundException()
-__ACCOUNT__.modified.x121Address = new ObjectNotFoundException()
-__ACCOUNT__.modified.preferredDeliveryMethod = new ObjectNotFoundException()
-__ACCOUNT__.modified.telexNumber = new ObjectNotFoundException()
-__ACCOUNT__.modified.owner = new ObjectNotFoundException()
-__ACCOUNT__.modified.secretary = new ObjectNotFoundException()
-__ACCOUNT__.modified.seeAlso = new ObjectNotFoundException()
-__ACCOUNT__.modified.userPassword = new ObjectNotFoundException()
-__ACCOUNT__.modified.__PASSWORD__ = new ObjectNotFoundException()
-
-__GROUP__.__NAME__ = 'ou=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext')
-__GROUP__.ou = new ObjectNotFoundException() // Since 'ou', as the naming attribute, \
already has a value.
-
-__GROUP__.seeAlso = new ObjectNotFoundException()
-__GROUP__.uniqueMember = new ObjectNotFoundException()
-__GROUP__.owner = new ObjectNotFoundException()
-
-__GROUP__.modified.__NAME__ = 'cn=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext')
-__GROUP__.modified.cn = new ObjectNotFoundException() // Since 'cn', as the naming \
attribute, already has a value.
-__GROUP__.modified.ou = new ObjectNotFoundException() // Since 'ou', as the previous \
naming attribute, already has a value.
-
-__GROUP__.modified.seeAlso = new ObjectNotFoundException()
-__GROUP__.modified.uniqueMember = new ObjectNotFoundException()
-__GROUP__.modified.owner = new ObjectNotFoundException()
-
-// Workaround for issue 599.
-added.audio = new ObjectNotFoundException()
-added.businessCategory = new ObjectNotFoundException()
-added.carLicense = new ObjectNotFoundException()
-added.cn = new ObjectNotFoundException()
-added.departmentNumber = new ObjectNotFoundException()
-added.description = new ObjectNotFoundException()
-added.destinationIndicator = new ObjectNotFoundException()
-added.displayName = new ObjectNotFoundException()
-added.employeeNumber = new ObjectNotFoundException()
-added.employeeType = new ObjectNotFoundException()
-added.facsimileTelephoneNumber = new ObjectNotFoundException()
-added.givenName = new ObjectNotFoundException()
-added.homePhone = new ObjectNotFoundException()
-added.homePostalAddress = new ObjectNotFoundException()
-added.initials = new ObjectNotFoundException()
-added.internationaliSDNNumber = new ObjectNotFoundException()
-added.jpegPhoto = new ObjectNotFoundException()
-added.l = new ObjectNotFoundException()
-added.labeledUri = new ObjectNotFoundException()
-added.mail = new ObjectNotFoundException()
-added.manager = new ObjectNotFoundException()
-added.mobile = new ObjectNotFoundException()
-added.o = new ObjectNotFoundException()
-added.ou = new ObjectNotFoundException()
-added.owner = new ObjectNotFoundException()
-added.pager = new ObjectNotFoundException()
-added.photo = new ObjectNotFoundException()
-added.physicalDeliveryOfficeName = new ObjectNotFoundException()
-added.postOfficeBox = new ObjectNotFoundException()
-added.postalAddress = new ObjectNotFoundException()
-added.postalCode = new ObjectNotFoundException()
-added.preferredLanguage = new ObjectNotFoundException()
-added.registeredAddress = new ObjectNotFoundException()
-added.roomNumber = new ObjectNotFoundException()
-added.secretary = new ObjectNotFoundException()
-added.seeAlso = new ObjectNotFoundException()
-added.sn = new ObjectNotFoundException()
-added.st = new ObjectNotFoundException()
-added.street = new ObjectNotFoundException()
-added.telephoneNumber = new ObjectNotFoundException()
-added.teletexTerminalIdentifier = new ObjectNotFoundException()
-added.telexNumber = new ObjectNotFoundException()
-added.title = new ObjectNotFoundException()
-added.uid = new ObjectNotFoundException()
-added.uniqueMember = new ObjectNotFoundException()
-added.userCertificate = new ObjectNotFoundException()
-added.userPKCS12 = new ObjectNotFoundException()
-added.userPassword = new ObjectNotFoundException()
-added.userSMIMECertificate = new ObjectNotFoundException()
-added.x121Address = new ObjectNotFoundException()
-added.x500UniqueIdentifier = new ObjectNotFoundException()
-
-// Workaround for issue 489. This will cause the server to reject the request, so \
the connector
-// will throw an exception, making the contract tests happy.
-Update.unsupportedAttributeName = 'cn'
-
-// Workaround for issue XXX.
-Sync.disable.create = true
-Sync.disable.update = true
-Sync.disable.delete = true
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestconfigorgidentityconnectorsldapLdapConnec \
torconfigconfiggroovyfromrev6872branchesopenicfldapconnector141xsrctestconfigorgidentityconnectorsldapLdapConnectorconfigconfiggroovy"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/config/org.identityconnectors.ldap.LdapConnector/config/config.groovy 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,285 @@
</span><ins>+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * U.S. Government Rights - Commercial software. Government users
+ * are subject to the Sun Microsystems, Inc. standard license agreement
+ * and applicable provisions of the FAR and its supplements.
+ *
+ * Use is subject to license terms.
+ *
+ * This distribution may include materials developed by third parties.
+ * Sun, Sun Microsystems, the Sun logo, Java and Project Identity
+ * Connectors are trademarks or registered trademarks of Sun
+ * Microsystems, Inc. or its subsidiaries in the U.S. and other
+ * countries.
+ *
+ * UNIX is a registered trademark in the U.S. and other countries,
+ * exclusively licensed through X/Open Company, Ltd.
+ *
+ * -----------
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License(CDDL) (the License). You may not use this file
+ * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://identityconnectors.dev.java.net/CDDLv1.0.html
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each
+ * file and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * -----------
+ */
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.contract.data.groovy.Lazy;
+import org.identityconnectors.contract.exceptions.ObjectNotFoundException;
+
+// Unit tests.
+
+sunds.host = '__configureme__'
+sunds.port = 389
+sunds.principal = '__configureme__'
+sunds.credentials = '__configureme__'
+sunds.baseContext = '__configureme__'
+
+// Contract tests.
+
+Object telephoneNumber() {
+ return Lazy.random('### ### ####');
+}
+
+bundleJar = System.getProperty('bundleJar')
+bundleName = System.getProperty('bundleName')
+bundleVersion = System.getProperty('bundleVersion')
+connectorName='org.identityconnectors.ldap.LdapConnector'
+
+baseContext = '__configureme__'
+
+connector {
+ host = '__configureme__'
+ port = 389
+ principal = '__configureme__'
+ credentials = new GuardedString('__configureme__'.toCharArray())
+ baseContexts = [ baseContext ] as String[]
+ usePagedResultControl = true // We do not have a VLV index.
+ uidAttribute = 'entryDN' // Sun DSEE 6.3 does not support entryUUID
+}
+
+Validate.invalidConfig = [
+ [ host : '' ],
+ [ port : 100000 ],
+ [ baseContexts : [] as String[] ]
+]
+
+Test.invalidConfig = [
+ [ principal : 'cn=Nobody' ],
+ [ credentials : 'bogus' ]
+]
+
+Schema {
+ strictCheck = false
+
+ oclasses = [ '__ACCOUNT__', '__GROUP__' ]
+
+ operations = [
+ GetApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ SchemaApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ ValidateApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ CreateApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ SearchApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ DeleteApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ ScriptOnConnectorApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ UpdateApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ AuthenticationApiOp: [ '__ACCOUNT__' ],
+ TestApiOp: [ '__ACCOUNT__', '__GROUP__' ],
+ SyncApiOp: [ ]
+ ]
+
+ attributes.__ACCOUNT__.oclasses = [ '__NAME__', 'cn', 'sn', 'jpegPhoto' ]
+ __NAME__.attribute.__ACCOUNT__.oclasses = [
+ type: java.lang.String.class,
+ readable: true,
+ createable: true,
+ updateable: true,
+ required: true,
+ multiValue: false,
+ returnedByDefault: true
+ ]
+ cn.attribute.__ACCOUNT__.oclasses = [
+ type: java.lang.String.class,
+ readable: true,
+ createable: true,
+ updateable: true,
+ required: true,
+ multiValue: true,
+ returnedByDefault: true
+ ]
+ jpegPhoto.attribute.__ACCOUNT__.oclasses = [
+ type: byte[].class,
+ readable: true,
+ createable: true,
+ updateable: true,
+ required: false,
+ multiValue: true,
+ returnedByDefault: true
+ ]
+
+ attributes.__GROUP__.oclasses = [ '__NAME__', 'cn' ]
+ __NAME__.attribute.__ACCOUNT__.oclasses = [
+ type: java.lang.String.class,
+ readable: true,
+ createable: true,
+ updateable: true,
+ required: true,
+ multiValue: false,
+ returnedByDefault: true
+ ]
+ cn.attribute.__ACCOUNT__.oclasses = [
+ type: java.lang.String.class,
+ readable: true,
+ createable: true,
+ updateable: true,
+ required: true,
+ multiValue: true,
+ returnedByDefault: true
+ ]
+}
+
+objectClasses = [ '__ACCOUNT__', '__GROUP__' ]
+
+Search.disable.caseinsensitive = true
+
+Authentication {
+ __ACCOUNT__ {
+ __NAME__ = 'uid=Bugs Bunny,' + Lazy.get('baseContext')
+ __PASSWORD__ = new GuardedString('password'.toCharArray())
+ username = 'Bugs Bunny'
+ modified.__PASSWORD__ = new GuardedString('newpassword'.toCharArray())
+ wrong.password = new GuardedString('bogus'.toCharArray())
+ }
+}
+
+__ACCOUNT__.__NAME__ = 'uid=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext') +__ACCOUNT__.uid = new ObjectNotFoundException() // Since \
'uid', as the naming attribute, already has a value. +
+__ACCOUNT__.homePhone = telephoneNumber()
+__ACCOUNT__.mobile = telephoneNumber()
+__ACCOUNT__.pager = telephoneNumber()
+__ACCOUNT__.telephoneNumber = telephoneNumber()
+
+__ACCOUNT__.x500UniqueIdentifier = new ObjectNotFoundException()
+__ACCOUNT__.manager = new ObjectNotFoundException()
+__ACCOUNT__.internationaliSDNNumber = new ObjectNotFoundException()
+__ACCOUNT__.x121Address = new ObjectNotFoundException()
+__ACCOUNT__.preferredDeliveryMethod = new ObjectNotFoundException()
+__ACCOUNT__.telexNumber = new ObjectNotFoundException()
+__ACCOUNT__.owner = new ObjectNotFoundException()
+__ACCOUNT__.secretary = new ObjectNotFoundException()
+__ACCOUNT__.seeAlso = new ObjectNotFoundException()
+__ACCOUNT__.userPassword = new ObjectNotFoundException()
+__ACCOUNT__.__PASSWORD__ = new ObjectNotFoundException()
+
+__ACCOUNT__.modified.__NAME__ = 'cn=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext') +__ACCOUNT__.modified.cn = new ObjectNotFoundException() // \
Since 'cn', as the naming attribute, already has a value. +__ACCOUNT__.modified.uid = \
new ObjectNotFoundException() // Since 'uid', as the previous naming attribute, \
already has a value. +
+__ACCOUNT__.modified.homePhone = telephoneNumber()
+__ACCOUNT__.modified.mobile = telephoneNumber()
+__ACCOUNT__.modified.pager = telephoneNumber()
+__ACCOUNT__.modified.telephoneNumber = telephoneNumber()
+
+__ACCOUNT__.modified.x500UniqueIdentifier = new ObjectNotFoundException()
+__ACCOUNT__.modified.manager = new ObjectNotFoundException()
+__ACCOUNT__.modified.internationaliSDNNumber = new ObjectNotFoundException()
+__ACCOUNT__.modified.x121Address = new ObjectNotFoundException()
+__ACCOUNT__.modified.preferredDeliveryMethod = new ObjectNotFoundException()
+__ACCOUNT__.modified.telexNumber = new ObjectNotFoundException()
+__ACCOUNT__.modified.owner = new ObjectNotFoundException()
+__ACCOUNT__.modified.secretary = new ObjectNotFoundException()
+__ACCOUNT__.modified.seeAlso = new ObjectNotFoundException()
+__ACCOUNT__.modified.userPassword = new ObjectNotFoundException()
+__ACCOUNT__.modified.__PASSWORD__ = new ObjectNotFoundException()
+
+__GROUP__.__NAME__ = 'ou=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext') +__GROUP__.ou = new ObjectNotFoundException() // Since 'ou', \
as the naming attribute, already has a value. +
+__GROUP__.seeAlso = new ObjectNotFoundException()
+__GROUP__.uniqueMember = new ObjectNotFoundException()
+__GROUP__.owner = new ObjectNotFoundException()
+
+__GROUP__.modified.__NAME__ = 'cn=' + Lazy.random('Aaaa Aaaa') + ',' + \
Lazy.get('baseContext') +__GROUP__.modified.cn = new ObjectNotFoundException() // \
Since 'cn', as the naming attribute, already has a value. +__GROUP__.modified.ou = \
new ObjectNotFoundException() // Since 'ou', as the previous naming attribute, \
already has a value. +
+__GROUP__.modified.seeAlso = new ObjectNotFoundException()
+__GROUP__.modified.uniqueMember = new ObjectNotFoundException()
+__GROUP__.modified.owner = new ObjectNotFoundException()
+
+// Workaround for issue 599.
+added.audio = new ObjectNotFoundException()
+added.businessCategory = new ObjectNotFoundException()
+added.carLicense = new ObjectNotFoundException()
+added.cn = new ObjectNotFoundException()
+added.departmentNumber = new ObjectNotFoundException()
+added.description = new ObjectNotFoundException()
+added.destinationIndicator = new ObjectNotFoundException()
+added.displayName = new ObjectNotFoundException()
+added.employeeNumber = new ObjectNotFoundException()
+added.employeeType = new ObjectNotFoundException()
+added.facsimileTelephoneNumber = new ObjectNotFoundException()
+added.givenName = new ObjectNotFoundException()
+added.homePhone = new ObjectNotFoundException()
+added.homePostalAddress = new ObjectNotFoundException()
+added.initials = new ObjectNotFoundException()
+added.internationaliSDNNumber = new ObjectNotFoundException()
+added.jpegPhoto = new ObjectNotFoundException()
+added.l = new ObjectNotFoundException()
+added.labeledUri = new ObjectNotFoundException()
+added.mail = new ObjectNotFoundException()
+added.manager = new ObjectNotFoundException()
+added.mobile = new ObjectNotFoundException()
+added.o = new ObjectNotFoundException()
+added.ou = new ObjectNotFoundException()
+added.owner = new ObjectNotFoundException()
+added.pager = new ObjectNotFoundException()
+added.photo = new ObjectNotFoundException()
+added.physicalDeliveryOfficeName = new ObjectNotFoundException()
+added.postOfficeBox = new ObjectNotFoundException()
+added.postalAddress = new ObjectNotFoundException()
+added.postalCode = new ObjectNotFoundException()
+added.preferredLanguage = new ObjectNotFoundException()
+added.registeredAddress = new ObjectNotFoundException()
+added.roomNumber = new ObjectNotFoundException()
+added.secretary = new ObjectNotFoundException()
+added.seeAlso = new ObjectNotFoundException()
+added.sn = new ObjectNotFoundException()
+added.st = new ObjectNotFoundException()
+added.street = new ObjectNotFoundException()
+added.telephoneNumber = new ObjectNotFoundException()
+added.teletexTerminalIdentifier = new ObjectNotFoundException()
+added.telexNumber = new ObjectNotFoundException()
+added.title = new ObjectNotFoundException()
+added.uid = new ObjectNotFoundException()
+added.uniqueMember = new ObjectNotFoundException()
+added.userCertificate = new ObjectNotFoundException()
+added.userPKCS12 = new ObjectNotFoundException()
+added.userPassword = new ObjectNotFoundException()
+added.userSMIMECertificate = new ObjectNotFoundException()
+added.x121Address = new ObjectNotFoundException()
+added.x500UniqueIdentifier = new ObjectNotFoundException()
+
+// Workaround for issue 489. This will cause the server to reject the request, so \
the connector +// will throw an exception, making the contract tests happy.
+Update.unsupportedAttributeName = 'cn'
+
+// Workaround for issue XXX.
+Sync.disable.create = true
+Sync.disable.update = true
+Sync.disable.delete = true
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAdapterCompatibilityTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,545 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.singleton;
-import static org.identityconnectors.common.CollectionUtil.newList;
-import static org.identityconnectors.common.CollectionUtil.newSet;
-import static org.identityconnectors.ldap.LdapUtil.checkedListByFilter;
-import java.io.UnsupportedEncodingException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.common.exceptions.ConnectorException;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.identityconnectors.framework.common.objects.AttributeInfo;
-import org.identityconnectors.framework.common.objects.AttributeInfoUtil;
-import org.identityconnectors.framework.common.objects.AttributeUtil;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.ObjectClassInfo;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.OperationalAttributes;
-import org.identityconnectors.framework.common.objects.Uid;
-import org.identityconnectors.framework.common.objects.filter.Filter;
-import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
-import org.identityconnectors.ldap.schema.LdapSchemaMapping;
-import org.identityconnectors.test.common.TestHelpers;
-
-public class AdapterCompatibilityTests extends LdapConnectorTestBase {
-
- // TODO test authenticate.
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return true;
- }
-
- @Test
- public void testAccountOperationalAttributes() {
- ConnectorFacade facade = newFacade();
- ObjectClassInfo oci = \
facade.schema().findObjectClassInfo(ObjectClass.ACCOUNT_NAME);
-
- AttributeInfo info = \
AttributeInfoUtil.find(OperationalAttributes.PASSWORD_NAME, \
oci.getAttributeInfo());
- assertEquals(LdapConstants.PASSWORD, info);
- }
-
- @Test
- public void testAccountAttributes() {
- ConnectorFacade facade = newFacade();
- ConnectorObject user0 = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(USER_0_DN), "uid", "cn", "givenName", \
"sn");
-
- assertEquals(USER_0_DN, user0.getName().getNameValue());
- assertEquals(USER_0_UID, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("uid")));
- assertEquals(USER_0_CN, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("cn")));
- assertEquals(USER_0_GIVEN_NAME, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("givenName")));
- assertEquals(USER_0_SN, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("sn")));
- }
-
- @Test
- public void testGroupAttributes() {
- ConnectorFacade facade = newFacade();
- ConnectorObject object = searchByAttribute(facade, ObjectClass.GROUP, new \
Name(UNIQUE_BUGS_AND_FRIENDS_DN), "cn", \
"uniqueMember");
-
- assertEquals(UNIQUE_BUGS_AND_FRIENDS_CN, \
AttributeUtil.getAsStringValue(object.getAttributeByName("cn")));
- Attribute uniqueMember = \
object.getAttributeByName("uniqueMember");
- assertTrue(uniqueMember.getValue().contains(BUGS_BUNNY_DN));
- }
-
- @Test
- public void testOrganizationAttributes() {
- ConnectorFacade facade = newFacade();
- ConnectorObject object = searchByAttribute(facade, new \
ObjectClass("organization"), new Name(ACME_DN), "dn", \
"o", "objectClass");
-
- assertEquals(ACME_DN, object.getName().getNameValue());
- assertEquals(ACME_DN, \
AttributeUtil.getAsStringValue(object.getAttributeByName("dn")));
- assertEquals(ACME_O, \
AttributeUtil.getAsStringValue(object.getAttributeByName("o")));
- }
-
- @Test
- public void testInetOrgPersonAttributes() {
- // The LDAP edit group form does exactly this operation.
-
- LdapConfiguration config = newConfiguration();
- config.setBaseContexts(ACME_DN);
- ConnectorFacade facade = newFacade(config);
-
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("cn", "dn");
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, new \
ObjectClass("inetOrgPerson"), null, builder.build());
-
- ConnectorObject object = findByAttribute(objects, "dn", \
BUGS_BUNNY_DN);
- assertEquals(BUGS_BUNNY_CN, \
AttributeUtil.getStringValue(object.getAttributeByName("cn")));
- }
-
- @Test
- public void testCreateGroupOfUniqueNamesWithoutMembers() {
- LdapConfiguration config = newConfiguration();
- ConnectorFacade facade = newFacade(config);
-
- ObjectClass oclass = new ObjectClass("groupOfUniqueNames");
- Set<Attribute> attributes = new HashSet<Attribute>();
- Name name = new Name("cn=Another Group," + ACME_DN);
- attributes.add(name);
- attributes.add(AttributeBuilder.build("cn", "Another \
Group"));
- // If "uniqueMember" is sent to the server as an empty attribute, \
the server complains.
- // The test makes sure it is not sent at all.
- attributes.add(AttributeBuilder.build("uniqueMember", \
emptyList()));
- Uid uid = facade.create(oclass, attributes, null);
-
- ConnectorObject newGroup = facade.getObject(oclass, uid, null);
- assertEquals(name, newGroup.getName());
- }
-
- @Test
- public void testRetriveLdapGroups() {
- ConnectorFacade facade = newFacade();
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), LdapConstants.LDAP_GROUPS_NAME);
- assertAttributeValue(newList(UNIQUE_BUGS_AND_FRIENDS_DN, \
UNIQUE_EXTERNAL_PEERS_DN),
- object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME));
-
- LdapConfiguration config = newConfiguration();
- config.setGroupMemberAttribute("member");
- facade = newFacade(config);
- object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), LdapConstants.LDAP_GROUPS_NAME);
- assertAttributeValue(newList(BUGS_AND_FRIENDS_DN, EXTERNAL_PEERS_DN),
- object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME));
- }
-
- @Test
- public void testRetrivePosixGroups() {
- ConnectorFacade facade = newFacade();
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), LdapConstants.POSIX_GROUPS_NAME);
- assertAttributeValue(newList(POSIX_BUGS_AND_FRIENDS_DN, \
POSIX_EXTERNAL_PEERS_DN),
- object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME));
- }
-
- @Test
- public void testCreateWithUniqueLdapGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME,
- UNIQUE_BUGS_AND_FRIENDS_DN, UNIQUE_EXTERNAL_PEERS_DN);
- doTestCreateWithGroups(facade, groupsAttr);
- }
-
- @Test
- public void testCreateWithLdapGroups() {
- ConnectorFacade facade = newFacade();
- LdapConfiguration config = newConfiguration();
- config.setGroupMemberAttribute("member"); // For groupOfNames.
- facade = newFacade(config);
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME,
- BUGS_AND_FRIENDS_DN, EXTERNAL_PEERS_DN);
- doTestCreateWithGroups(facade, groupsAttr);
- }
-
- @Test
- public void testCreateWithPosixGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME,
- POSIX_BUGS_AND_FRIENDS_DN, POSIX_EXTERNAL_PEERS_DN);
- doTestCreateWithGroups(facade, groupsAttr);
- }
-
- private void doTestCreateWithGroups(ConnectorFacade facade, Attribute \
groupsAttr) {
- Set<Attribute> attributes = new HashSet<Attribute>();
- attributes.add(new Name("uid=porky.pig," + ACME_USERS_DN));
- attributes.add(AttributeBuilder.build("uid", \
"porky.pig"));
- attributes.add(AttributeBuilder.build("cn", "Porky \
Pig"));
- attributes.add(AttributeBuilder.build("givenName", \
"Porky"));
- attributes.add(AttributeBuilder.build("sn", "Pig"));
- attributes.add(groupsAttr);
- Uid uid = facade.create(ObjectClass.ACCOUNT, attributes, null);
-
- assertAttributeValue(groupsAttr.getValue(), facade, ObjectClass.ACCOUNT, \
uid, groupsAttr.getName());
- }
-
- @Test
- public void testAddLdapGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, \
UNIQUE_EMPTY_GROUP_DN);
- doTestAddGroups(facade, groupsAttr);
- }
-
- @Test
- public void testAddPosixGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME, \
POSIX_EMPTY_GROUP_DN);
- doTestAddGroups(facade, groupsAttr);
- }
-
- private void doTestAddGroups(ConnectorFacade facade, Attribute groupsAttr) {
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN), groupsAttr.getName());
- List<Object> oldGroups = \
newList(object.getAttributeByName(groupsAttr.getName()).getValue());
-
- Uid uid = facade.addAttributeValues(ObjectClass.ACCOUNT, object.getUid(), \
singleton(groupsAttr), null);
-
- oldGroups.addAll(groupsAttr.getValue());
- assertAttributeValue(oldGroups, facade, ObjectClass.ACCOUNT, uid, \
groupsAttr.getName());
- }
-
- @Test
- public void testUpdateUniqueLdapGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, \
UNIQUE_EXTERNAL_PEERS_DN);
- doTestUpdateGroups(facade, groupsAttr);
- }
-
- @Test
- public void testUpdatePosixGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, \
UNIQUE_EXTERNAL_PEERS_DN);
- doTestUpdateGroups(facade, groupsAttr);
- }
-
- private void doTestUpdateGroups(ConnectorFacade facade, Attribute groupsAttr) {
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), groupsAttr.getName());
-
- Uid uid = facade.update(ObjectClass.ACCOUNT, object.getUid(), \
singleton(groupsAttr), null);
-
- assertAttributeValue(groupsAttr.getValue(), facade, ObjectClass.ACCOUNT, \
uid, groupsAttr.getName());
- }
-
- @Test
- public void testRemoveUniqueLdapGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, \
UNIQUE_EXTERNAL_PEERS_DN);
- doTestRemoveGroups(facade, groupsAttr);
- }
-
- @Test
- public void testRemovePosixGroups() {
- ConnectorFacade facade = newFacade();
-
- Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME, \
POSIX_EXTERNAL_PEERS_DN);
- doTestRemoveGroups(facade, groupsAttr);
- }
-
- private void doTestRemoveGroups(ConnectorFacade facade, Attribute groupsAttr) {
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), groupsAttr.getName());
- List<Object> oldGroups = \
newList(object.getAttributeByName(groupsAttr.getName()).getValue());
-
- Uid uid = facade.removeAttributeValues(ObjectClass.ACCOUNT, object.getUid(), \
singleton(groupsAttr), null);
-
- oldGroups.removeAll(groupsAttr.getValue());
- assertAttributeValue(oldGroups, facade, ObjectClass.ACCOUNT, uid, \
groupsAttr.getName());
- }
-
- @Test(expectedExceptions = ConnectorException.class)
- public void testCannotRemoveUidWhenInPosixGroups() {
- ConnectorFacade facade = newFacade();
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- Attribute uidAttr = AttributeBuilder.build("uid", BBUNNY_UID);
- facade.removeAttributeValues(ObjectClass.ACCOUNT, object.getUid(), \
singleton(uidAttr), null);
- }
-
- @Test(expectedExceptions = ConnectorException.class)
- public void testCannotUpdateUidToNoneWhenInPosixGroups() {
- LdapConfiguration config = newConfiguration();
- config.setBaseContexts(ACME_DN, SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(OWNER_DN));
- Attribute uidAttr = AttributeBuilder.build("uid");
- facade.update(ObjectClass.ACCOUNT, object.getUid(), singleton(uidAttr), \
null);
- }
-
- @Test
- public void testRenameMaintainsGroupMemberships() {
- LdapConfiguration config = newConfiguration();
- config.setMaintainLdapGroupMembership(true);
- config.setMaintainPosixGroupMembership(true);
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN),
- LdapConstants.LDAP_GROUPS_NAME, LdapConstants.POSIX_GROUPS_NAME);
- List<String> oldLdapGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME).getValue(), \
String.class);
- List<String> oldPosixGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME).getValue(), \
String.class);
-
- Name newName = new Name("uid=sylvester.the.cat," + ACME_USERS_DN);
- Uid uid = facade.update(ObjectClass.ACCOUNT, object.getUid(), \
singleton((Attribute) newName), null);
-
- object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
LdapConstants.LDAP_GROUPS_NAME, LdapConstants.POSIX_GROUPS_NAME);
- assertAttributeValue(newList(UNIQUE_BUGS_AND_FRIENDS_DN, \
UNIQUE_EXTERNAL_PEERS_DN),
- object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME));
- assertAttributeValue(newList(POSIX_BUGS_AND_FRIENDS_DN, \
POSIX_EXTERNAL_PEERS_DN),
- object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME));
-
- // Also need to test that the old entries were actually removed from the old \
groups.
- for (String group : oldLdapGroups) {
- object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(group), \
"uniqueMember");
- List<Object> members = \
object.getAttributeByName("uniqueMember").getValue();
- assertFalse("Group " + group + " should not contain \
" + SYLVESTER_DN, members.contains(SYLVESTER_DN));
- }
- for (String group : oldPosixGroups) {
- object = searchByAttribute(facade, new \
ObjectClass("posixGroup"), new Name(group), \
"memberUid");
- List<Object> members = \
object.getAttributeByName("memberUid").getValue();
- assertFalse("Group " + group + " should not contain \
" + SYLVESTER_UID, members.contains(SYLVESTER_UID));
- }
- }
-
- @Test
- public void testRenameAndUpdateGroupMemberships() {
- LdapConfiguration config = newConfiguration();
- config.setMaintainLdapGroupMembership(true);
- config.setMaintainPosixGroupMembership(true);
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN),
- LdapConstants.LDAP_GROUPS_NAME, LdapConstants.POSIX_GROUPS_NAME);
- List<String> oldLdapGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME).getValue(), \
String.class);
- List<String> oldPosixGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME).getValue(), \
String.class);
-
- Name newName = new Name("uid=sylvester.the.cat," + ACME_USERS_DN);
- Attribute ldapGroupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME,
- UNIQUE_EXTERNAL_PEERS_DN, UNIQUE_EMPTY_GROUP_DN);
- Attribute posixGroupsAttr = \
AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME,
- POSIX_EXTERNAL_PEERS_DN, POSIX_EMPTY_GROUP_DN);
- Uid uid = facade.update(ObjectClass.ACCOUNT, object.getUid(), \
newSet(newName, ldapGroupsAttr, posixGroupsAttr), null);
-
- object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
LdapConstants.LDAP_GROUPS_NAME, LdapConstants.POSIX_GROUPS_NAME);
- assertAttributeValue(ldapGroupsAttr.getValue(), \
object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME));
- assertAttributeValue(posixGroupsAttr.getValue(), \
object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME));
-
- // Also need to test that the old entries were actually removed from the old \
groups.
- for (String group : oldLdapGroups) {
- object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(group), \
"uniqueMember");
- List<Object> members = \
object.getAttributeByName("uniqueMember").getValue();
- assertFalse("Group " + group + " should not contain \
" + SYLVESTER_DN, members.contains(SYLVESTER_DN));
- }
- for (String group : oldPosixGroups) {
- object = searchByAttribute(facade, new \
ObjectClass("posixGroup"), new Name(group), \
"memberUid");
- List<Object> members = \
object.getAttributeByName("memberUid").getValue();
- assertFalse("Group " + group + " should not contain \
" + SYLVESTER_UID, members.contains(SYLVESTER_UID));
- }
- }
-
- @Test
- public void testRenameDoesNotMaintainGroupMembershipsUnlessConfigured() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.isMaintainLdapGroupMembership());
- assertFalse(config.isMaintainPosixGroupMembership());
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN));
- String newUid = "sylvester.the.cat";
- String newEntryDN = "uid=" + newUid + "," + \
ACME_USERS_DN;
- facade.update(ObjectClass.ACCOUNT, object.getUid(), singleton((Attribute) \
new Name(newEntryDN)), null);
-
- object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_BUGS_AND_FRIENDS_DN), \
"uniqueMember");
- List<Object> members = \
object.getAttributeByName("uniqueMember").getValue();
- assertTrue(members.contains(SYLVESTER_DN));
- assertFalse(members.contains(newEntryDN));
-
- object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_EXTERNAL_PEERS_DN), \
"uniqueMember");
- members = object.getAttributeByName("uniqueMember").getValue();
- assertTrue(members.contains(SYLVESTER_DN));
- assertFalse(members.contains(newEntryDN));
-
- object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_BUGS_AND_FRIENDS_DN), "memberUid");
- members = object.getAttributeByName("memberUid").getValue();
- assertTrue(members.contains(SYLVESTER_UID));
- assertFalse(members.contains(newUid));
-
- object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_EXTERNAL_PEERS_DN), "memberUid");
- members = object.getAttributeByName("memberUid").getValue();
- assertTrue(members.contains(SYLVESTER_UID));
- assertFalse(members.contains(newUid));
- }
-
- @Test
- public void testDeleteMaintainsGroupMemberships() {
- LdapConfiguration config = newConfiguration();
- config.setMaintainLdapGroupMembership(true);
- config.setMaintainPosixGroupMembership(true);
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN),
- LdapConstants.LDAP_GROUPS_NAME, LdapConstants.POSIX_GROUPS_NAME);
- List<String> oldLdapGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME).getValue(), \
String.class);
- List<String> oldPosixGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME).getValue(), \
String.class);
-
- facade.delete(ObjectClass.ACCOUNT, object.getUid(), null);
-
- // Need to test that the old entries were actually removed from the old \
groups.
- for (String group : oldLdapGroups) {
- object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(group), \
"uniqueMember");
- List<Object> members = \
object.getAttributeByName("uniqueMember").getValue();
- assertFalse("Group " + group + " should not contain \
" + SYLVESTER_DN, members.contains(SYLVESTER_DN));
- }
- for (String group : oldPosixGroups) {
- object = searchByAttribute(facade, new \
ObjectClass("posixGroup"), new Name(group), \
"memberUid");
- List<Object> members = \
object.getAttributeByName("memberUid").getValue();
- assertFalse("Group " + group + " should not contain \
" + SYLVESTER_UID, members.contains(SYLVESTER_UID));
- }
- }
-
- @Test
- public void testDeleteDoesNotMaintainGroupMembershipsUnlessConfigured() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.isMaintainLdapGroupMembership());
- assertFalse(config.isMaintainPosixGroupMembership());
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN));
- facade.delete(ObjectClass.ACCOUNT, object.getUid(), null);
-
- object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_BUGS_AND_FRIENDS_DN), \
"uniqueMember");
- List<Object> members = \
object.getAttributeByName("uniqueMember").getValue();
- assertTrue(members.contains(SYLVESTER_DN));
-
- object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_EXTERNAL_PEERS_DN), \
"uniqueMember");
- members = object.getAttributeByName("uniqueMember").getValue();
- assertTrue(members.contains(SYLVESTER_DN));
-
- object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_BUGS_AND_FRIENDS_DN), "memberUid");
- members = object.getAttributeByName("memberUid").getValue();
- assertTrue(members.contains(SYLVESTER_UID));
-
- object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_EXTERNAL_PEERS_DN), "memberUid");
- members = object.getAttributeByName("memberUid").getValue();
- assertTrue(members.contains(SYLVESTER_UID));
- }
-
- @Test
- public void testPasswordHashing() throws Exception {
- LdapConfiguration config = newConfiguration();
- config.setPasswordHashAlgorithm("SHA");
- ConnectorFacade facade = newFacade(config);
-
- doTestPasswordHashing(facade, "SHA");
- }
-
- @Test
- public void testSaltedPasswordHashing() throws Exception {
- LdapConfiguration config = newConfiguration();
- config.setPasswordHashAlgorithm("SSHA");
- ConnectorFacade facade = newFacade(config);
-
- doTestPasswordHashing(facade, "SSHA");
- }
-
- private void doTestPasswordHashing(ConnectorFacade facade, String algorithm) \
throws UnsupportedEncodingException {
- String algorithmLabel = "{" + algorithm + "}";
-
- Set<Attribute> attrs = new HashSet<Attribute>();
- attrs.add(new Name("uid=daffy.duck," + ACME_USERS_DN));
- attrs.add(AttributeBuilder.build("uid", "daffy.duck"));
- attrs.add(AttributeBuilder.build("cn", "Daffy Duck"));
- attrs.add(AttributeBuilder.build("sn", "Duck"));
- attrs.add(AttributeBuilder.build("ds-pwp-password-policy-dn", \
"cn=Clear Text Password Policy,cn=Password \
Policies,cn=config"));
- GuardedString password = new \
GuardedString("foobar".toCharArray());
- attrs.add(AttributeBuilder.buildPassword(password));
- Uid uid = facade.create(ObjectClass.ACCOUNT, attrs, null);
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
"userPassword");
- byte[] passwordBytes = (byte[]) \
object.getAttributeByName("userPassword").getValue().get(0);
- assertTrue(new String(passwordBytes, \
"UTF-8").startsWith(algorithmLabel));
- facade.authenticate(ObjectClass.ACCOUNT, "daffy.duck", password, \
null);
-
- password = new GuardedString("newpassword".toCharArray());
- facade.update(ObjectClass.ACCOUNT, object.getUid(), \
singleton(AttributeBuilder.buildPassword(password)), null);
-
- object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
"userPassword");
- passwordBytes = (byte[]) \
object.getAttributeByName("userPassword").getValue().get(0);
- assertTrue(new String(passwordBytes, \
"UTF-8").startsWith(algorithmLabel));
- facade.authenticate(ObjectClass.ACCOUNT, "daffy.duck", password, \
null);
- }
-
- @Test
- public void testSearchAnyObjectClass() {
- ConnectorFacade facade = newFacade();
-
- Filter filter = FilterBuilder.equalTo(AttributeBuilder.build(Name.NAME, \
BUGS_BUNNY_DN));
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("cn", "dn");
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
LdapSchemaMapping.ANY_OBJECT_CLASS, filter, builder.build());
-
- ConnectorObject bunny = objects.get(0);
- assertEquals(LdapSchemaMapping.ANY_OBJECT_CLASS, bunny.getObjectClass());
- assertEquals(BUGS_BUNNY_DN, bunny.getName().getNameValue());
- assertEquals(BUGS_BUNNY_CN, \
bunny.getAttributeByName("cn").getValue().get(0));
- }
-
- @Test
- public void testSearchFilter() {
- ConnectorFacade facade = newFacade();
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setOption(LdapConstants.SEARCH_FILTER_NAME, "(uid=" + \
BUGS_BUNNY_UID + ")");
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null, builder.build());
-
- assertEquals(1, objects.size());
- ConnectorObject bunny = objects.get(0);
- assertEquals(BUGS_BUNNY_DN, bunny.getName().getNameValue());
- }
-
- private static void assertAttributeValue(List<?> expected, ConnectorFacade \
facade, ObjectClass oclass, Uid uid, String attrName) {
- ConnectorObject object = searchByAttribute(facade, oclass, uid, attrName);
- assertAttributeValue(expected, object.getAttributeByName(attrName));
- }
-
- private static void assertAttributeValue(List<?> expected, Attribute attr) \
{
- Set<?> attrValue = newSet(attr.getValue());
- Set<?> expectedValue = newSet(expected);
- assertEquals(expectedValue, attrValue);
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAdapterCompa \
tibilityTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapAdapterCompatibilityTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AdapterCompatibilityTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,545 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singleton;
+import static org.identityconnectors.common.CollectionUtil.newList;
+import static org.identityconnectors.common.CollectionUtil.newSet;
+import static org.identityconnectors.ldap.LdapUtil.checkedListByFilter;
+import java.io.UnsupportedEncodingException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.exceptions.ConnectorException;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.AttributeInfo;
+import org.identityconnectors.framework.common.objects.AttributeInfoUtil;
+import org.identityconnectors.framework.common.objects.AttributeUtil;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.ObjectClassInfo;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
+import org.identityconnectors.framework.common.objects.OperationalAttributes;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.framework.common.objects.filter.Filter;
+import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
+import org.identityconnectors.ldap.schema.LdapSchemaMapping;
+import org.identityconnectors.test.common.TestHelpers;
+
+public class AdapterCompatibilityTests extends LdapConnectorTestBase {
+
+ // TODO test authenticate.
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return true;
+ }
+
+ @Test
+ public void testAccountOperationalAttributes() {
+ ConnectorFacade facade = newFacade();
+ ObjectClassInfo oci = \
facade.schema().findObjectClassInfo(ObjectClass.ACCOUNT_NAME); +
+ AttributeInfo info = \
AttributeInfoUtil.find(OperationalAttributes.PASSWORD_NAME, oci.getAttributeInfo()); \
+ assertEquals(LdapConstants.PASSWORD, info); + }
+
+ @Test
+ public void testAccountAttributes() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject user0 = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(USER_0_DN), "uid", "cn", "givenName", \
"sn"); +
+ assertEquals(USER_0_DN, user0.getName().getNameValue());
+ assertEquals(USER_0_UID, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("uid"))); + \
assertEquals(USER_0_CN, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("cn"))); + \
assertEquals(USER_0_GIVEN_NAME, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("givenName"))); + \
assertEquals(USER_0_SN, \
AttributeUtil.getAsStringValue(user0.getAttributeByName("sn"))); + }
+
+ @Test
+ public void testGroupAttributes() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.GROUP, new \
Name(UNIQUE_BUGS_AND_FRIENDS_DN), "cn", "uniqueMember"); +
+ assertEquals(UNIQUE_BUGS_AND_FRIENDS_CN, \
AttributeUtil.getAsStringValue(object.getAttributeByName("cn"))); + \
Attribute uniqueMember = object.getAttributeByName("uniqueMember"); + \
assertTrue(uniqueMember.getValue().contains(BUGS_BUNNY_DN)); + }
+
+ @Test
+ public void testOrganizationAttributes() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject object = searchByAttribute(facade, new \
ObjectClass("organization"), new Name(ACME_DN), "dn", \
"o", "objectClass"); +
+ assertEquals(ACME_DN, object.getName().getNameValue());
+ assertEquals(ACME_DN, \
AttributeUtil.getAsStringValue(object.getAttributeByName("dn"))); + \
assertEquals(ACME_O, \
AttributeUtil.getAsStringValue(object.getAttributeByName("o"))); + }
+
+ @Test
+ public void testInetOrgPersonAttributes() {
+ // The LDAP edit group form does exactly this operation.
+
+ LdapConfiguration config = newConfiguration();
+ config.setBaseContexts(ACME_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("cn", "dn");
+ List<ConnectorObject> objects = TestHelpers.searchToList(facade, new \
ObjectClass("inetOrgPerson"), null, builder.build()); +
+ ConnectorObject object = findByAttribute(objects, "dn", \
BUGS_BUNNY_DN); + assertEquals(BUGS_BUNNY_CN, \
AttributeUtil.getStringValue(object.getAttributeByName("cn"))); + }
+
+ @Test
+ public void testCreateGroupOfUniqueNamesWithoutMembers() {
+ LdapConfiguration config = newConfiguration();
+ ConnectorFacade facade = newFacade(config);
+
+ ObjectClass oclass = new ObjectClass("groupOfUniqueNames");
+ Set<Attribute> attributes = new HashSet<Attribute>();
+ Name name = new Name("cn=Another Group," + ACME_DN);
+ attributes.add(name);
+ attributes.add(AttributeBuilder.build("cn", "Another \
Group")); + // If "uniqueMember" is sent to the server as an \
empty attribute, the server complains. + // The test makes sure it is not sent \
at all. + attributes.add(AttributeBuilder.build("uniqueMember", \
emptyList())); + Uid uid = facade.create(oclass, attributes, null);
+
+ ConnectorObject newGroup = facade.getObject(oclass, uid, null);
+ assertEquals(name, newGroup.getName());
+ }
+
+ @Test
+ public void testRetriveLdapGroups() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), LdapConstants.LDAP_GROUPS_NAME); + \
assertAttributeValue(newList(UNIQUE_BUGS_AND_FRIENDS_DN, UNIQUE_EXTERNAL_PEERS_DN), + \
object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME)); +
+ LdapConfiguration config = newConfiguration();
+ config.setGroupMemberAttribute("member");
+ facade = newFacade(config);
+ object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), LdapConstants.LDAP_GROUPS_NAME); + \
assertAttributeValue(newList(BUGS_AND_FRIENDS_DN, EXTERNAL_PEERS_DN), + \
object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME)); + }
+
+ @Test
+ public void testRetrivePosixGroups() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), LdapConstants.POSIX_GROUPS_NAME); + \
assertAttributeValue(newList(POSIX_BUGS_AND_FRIENDS_DN, POSIX_EXTERNAL_PEERS_DN), + \
object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME)); + }
+
+ @Test
+ public void testCreateWithUniqueLdapGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, + \
UNIQUE_BUGS_AND_FRIENDS_DN, UNIQUE_EXTERNAL_PEERS_DN); + \
doTestCreateWithGroups(facade, groupsAttr); + }
+
+ @Test
+ public void testCreateWithLdapGroups() {
+ ConnectorFacade facade = newFacade();
+ LdapConfiguration config = newConfiguration();
+ config.setGroupMemberAttribute("member"); // For groupOfNames.
+ facade = newFacade(config);
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, + \
BUGS_AND_FRIENDS_DN, EXTERNAL_PEERS_DN); + doTestCreateWithGroups(facade, \
groupsAttr); + }
+
+ @Test
+ public void testCreateWithPosixGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME, + \
POSIX_BUGS_AND_FRIENDS_DN, POSIX_EXTERNAL_PEERS_DN); + \
doTestCreateWithGroups(facade, groupsAttr); + }
+
+ private void doTestCreateWithGroups(ConnectorFacade facade, Attribute \
groupsAttr) { + Set<Attribute> attributes = new \
HashSet<Attribute>(); + attributes.add(new \
Name("uid=porky.pig," + ACME_USERS_DN)); + \
attributes.add(AttributeBuilder.build("uid", "porky.pig")); + \
attributes.add(AttributeBuilder.build("cn", "Porky Pig")); + \
attributes.add(AttributeBuilder.build("givenName", "Porky")); + \
attributes.add(AttributeBuilder.build("sn", "Pig")); + \
attributes.add(groupsAttr); + Uid uid = facade.create(ObjectClass.ACCOUNT, \
attributes, null); +
+ assertAttributeValue(groupsAttr.getValue(), facade, ObjectClass.ACCOUNT, \
uid, groupsAttr.getName()); + }
+
+ @Test
+ public void testAddLdapGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, UNIQUE_EMPTY_GROUP_DN); + \
doTestAddGroups(facade, groupsAttr); + }
+
+ @Test
+ public void testAddPosixGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME, POSIX_EMPTY_GROUP_DN); + \
doTestAddGroups(facade, groupsAttr); + }
+
+ private void doTestAddGroups(ConnectorFacade facade, Attribute groupsAttr) {
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN), groupsAttr.getName()); + List<Object> oldGroups = \
newList(object.getAttributeByName(groupsAttr.getName()).getValue()); +
+ Uid uid = facade.addAttributeValues(ObjectClass.ACCOUNT, object.getUid(), \
singleton(groupsAttr), null); +
+ oldGroups.addAll(groupsAttr.getValue());
+ assertAttributeValue(oldGroups, facade, ObjectClass.ACCOUNT, uid, \
groupsAttr.getName()); + }
+
+ @Test
+ public void testUpdateUniqueLdapGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, UNIQUE_EXTERNAL_PEERS_DN); + \
doTestUpdateGroups(facade, groupsAttr); + }
+
+ @Test
+ public void testUpdatePosixGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, UNIQUE_EXTERNAL_PEERS_DN); + \
doTestUpdateGroups(facade, groupsAttr); + }
+
+ private void doTestUpdateGroups(ConnectorFacade facade, Attribute groupsAttr) {
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), groupsAttr.getName()); +
+ Uid uid = facade.update(ObjectClass.ACCOUNT, object.getUid(), \
singleton(groupsAttr), null); +
+ assertAttributeValue(groupsAttr.getValue(), facade, ObjectClass.ACCOUNT, \
uid, groupsAttr.getName()); + }
+
+ @Test
+ public void testRemoveUniqueLdapGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, UNIQUE_EXTERNAL_PEERS_DN); + \
doTestRemoveGroups(facade, groupsAttr); + }
+
+ @Test
+ public void testRemovePosixGroups() {
+ ConnectorFacade facade = newFacade();
+
+ Attribute groupsAttr = \
AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME, POSIX_EXTERNAL_PEERS_DN); + \
doTestRemoveGroups(facade, groupsAttr); + }
+
+ private void doTestRemoveGroups(ConnectorFacade facade, Attribute groupsAttr) {
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), groupsAttr.getName()); + List<Object> oldGroups = \
newList(object.getAttributeByName(groupsAttr.getName()).getValue()); +
+ Uid uid = facade.removeAttributeValues(ObjectClass.ACCOUNT, object.getUid(), \
singleton(groupsAttr), null); +
+ oldGroups.removeAll(groupsAttr.getValue());
+ assertAttributeValue(oldGroups, facade, ObjectClass.ACCOUNT, uid, \
groupsAttr.getName()); + }
+
+ @Test(expectedExceptions = ConnectorException.class)
+ public void testCannotRemoveUidWhenInPosixGroups() {
+ ConnectorFacade facade = newFacade();
+
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + Attribute uidAttr = \
AttributeBuilder.build("uid", BBUNNY_UID); + \
facade.removeAttributeValues(ObjectClass.ACCOUNT, object.getUid(), \
singleton(uidAttr), null); + }
+
+ @Test(expectedExceptions = ConnectorException.class)
+ public void testCannotUpdateUidToNoneWhenInPosixGroups() {
+ LdapConfiguration config = newConfiguration();
+ config.setBaseContexts(ACME_DN, SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(OWNER_DN)); + Attribute uidAttr = \
AttributeBuilder.build("uid"); + facade.update(ObjectClass.ACCOUNT, \
object.getUid(), singleton(uidAttr), null); + }
+
+ @Test
+ public void testRenameMaintainsGroupMemberships() {
+ LdapConfiguration config = newConfiguration();
+ config.setMaintainLdapGroupMembership(true);
+ config.setMaintainPosixGroupMembership(true);
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), + LdapConstants.LDAP_GROUPS_NAME, \
LdapConstants.POSIX_GROUPS_NAME); + List<String> oldLdapGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME).getValue(), \
String.class); + List<String> oldPosixGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME).getValue(), \
String.class); +
+ Name newName = new Name("uid=sylvester.the.cat," + ACME_USERS_DN);
+ Uid uid = facade.update(ObjectClass.ACCOUNT, object.getUid(), \
singleton((Attribute) newName), null); +
+ object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
LdapConstants.LDAP_GROUPS_NAME, LdapConstants.POSIX_GROUPS_NAME); + \
assertAttributeValue(newList(UNIQUE_BUGS_AND_FRIENDS_DN, UNIQUE_EXTERNAL_PEERS_DN), + \
object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME)); + \
assertAttributeValue(newList(POSIX_BUGS_AND_FRIENDS_DN, POSIX_EXTERNAL_PEERS_DN), + \
object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME)); +
+ // Also need to test that the old entries were actually removed from the old \
groups. + for (String group : oldLdapGroups) {
+ object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(group), \
"uniqueMember"); + List<Object> members = \
object.getAttributeByName("uniqueMember").getValue(); + \
assertFalse("Group " + group + " should not contain " + \
SYLVESTER_DN, members.contains(SYLVESTER_DN)); + }
+ for (String group : oldPosixGroups) {
+ object = searchByAttribute(facade, new \
ObjectClass("posixGroup"), new Name(group), "memberUid"); + \
List<Object> members = \
object.getAttributeByName("memberUid").getValue(); + \
assertFalse("Group " + group + " should not contain " + \
SYLVESTER_UID, members.contains(SYLVESTER_UID)); + }
+ }
+
+ @Test
+ public void testRenameAndUpdateGroupMemberships() {
+ LdapConfiguration config = newConfiguration();
+ config.setMaintainLdapGroupMembership(true);
+ config.setMaintainPosixGroupMembership(true);
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), + LdapConstants.LDAP_GROUPS_NAME, \
LdapConstants.POSIX_GROUPS_NAME); + List<String> oldLdapGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME).getValue(), \
String.class); + List<String> oldPosixGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME).getValue(), \
String.class); +
+ Name newName = new Name("uid=sylvester.the.cat," + ACME_USERS_DN);
+ Attribute ldapGroupsAttr = \
AttributeBuilder.build(LdapConstants.LDAP_GROUPS_NAME, + \
UNIQUE_EXTERNAL_PEERS_DN, UNIQUE_EMPTY_GROUP_DN); + Attribute posixGroupsAttr \
= AttributeBuilder.build(LdapConstants.POSIX_GROUPS_NAME, + \
POSIX_EXTERNAL_PEERS_DN, POSIX_EMPTY_GROUP_DN); + Uid uid = \
facade.update(ObjectClass.ACCOUNT, object.getUid(), newSet(newName, ldapGroupsAttr, \
posixGroupsAttr), null); +
+ object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
LdapConstants.LDAP_GROUPS_NAME, LdapConstants.POSIX_GROUPS_NAME); + \
assertAttributeValue(ldapGroupsAttr.getValue(), \
object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME)); + \
assertAttributeValue(posixGroupsAttr.getValue(), \
object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME)); +
+ // Also need to test that the old entries were actually removed from the old \
groups. + for (String group : oldLdapGroups) {
+ object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(group), \
"uniqueMember"); + List<Object> members = \
object.getAttributeByName("uniqueMember").getValue(); + \
assertFalse("Group " + group + " should not contain " + \
SYLVESTER_DN, members.contains(SYLVESTER_DN)); + }
+ for (String group : oldPosixGroups) {
+ object = searchByAttribute(facade, new \
ObjectClass("posixGroup"), new Name(group), "memberUid"); + \
List<Object> members = \
object.getAttributeByName("memberUid").getValue(); + \
assertFalse("Group " + group + " should not contain " + \
SYLVESTER_UID, members.contains(SYLVESTER_UID)); + }
+ }
+
+ @Test
+ public void testRenameDoesNotMaintainGroupMembershipsUnlessConfigured() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.isMaintainLdapGroupMembership());
+ assertFalse(config.isMaintainPosixGroupMembership());
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN)); + String newUid = "sylvester.the.cat";
+ String newEntryDN = "uid=" + newUid + "," + \
ACME_USERS_DN; + facade.update(ObjectClass.ACCOUNT, object.getUid(), \
singleton((Attribute) new Name(newEntryDN)), null); +
+ object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_BUGS_AND_FRIENDS_DN), \
"uniqueMember"); + List<Object> members = \
object.getAttributeByName("uniqueMember").getValue(); + \
assertTrue(members.contains(SYLVESTER_DN)); + \
assertFalse(members.contains(newEntryDN)); +
+ object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_EXTERNAL_PEERS_DN), \
"uniqueMember"); + members = \
object.getAttributeByName("uniqueMember").getValue(); + \
assertTrue(members.contains(SYLVESTER_DN)); + \
assertFalse(members.contains(newEntryDN)); +
+ object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_BUGS_AND_FRIENDS_DN), "memberUid"); + members = \
object.getAttributeByName("memberUid").getValue(); + \
assertTrue(members.contains(SYLVESTER_UID)); + \
assertFalse(members.contains(newUid)); +
+ object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_EXTERNAL_PEERS_DN), "memberUid"); + members = \
object.getAttributeByName("memberUid").getValue(); + \
assertTrue(members.contains(SYLVESTER_UID)); + \
assertFalse(members.contains(newUid)); + }
+
+ @Test
+ public void testDeleteMaintainsGroupMemberships() {
+ LdapConfiguration config = newConfiguration();
+ config.setMaintainLdapGroupMembership(true);
+ config.setMaintainPosixGroupMembership(true);
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN), + LdapConstants.LDAP_GROUPS_NAME, \
LdapConstants.POSIX_GROUPS_NAME); + List<String> oldLdapGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.LDAP_GROUPS_NAME).getValue(), \
String.class); + List<String> oldPosixGroups = \
checkedListByFilter(object.getAttributeByName(LdapConstants.POSIX_GROUPS_NAME).getValue(), \
String.class); +
+ facade.delete(ObjectClass.ACCOUNT, object.getUid(), null);
+
+ // Need to test that the old entries were actually removed from the old \
groups. + for (String group : oldLdapGroups) {
+ object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(group), \
"uniqueMember"); + List<Object> members = \
object.getAttributeByName("uniqueMember").getValue(); + \
assertFalse("Group " + group + " should not contain " + \
SYLVESTER_DN, members.contains(SYLVESTER_DN)); + }
+ for (String group : oldPosixGroups) {
+ object = searchByAttribute(facade, new \
ObjectClass("posixGroup"), new Name(group), "memberUid"); + \
List<Object> members = \
object.getAttributeByName("memberUid").getValue(); + \
assertFalse("Group " + group + " should not contain " + \
SYLVESTER_UID, members.contains(SYLVESTER_UID)); + }
+ }
+
+ @Test
+ public void testDeleteDoesNotMaintainGroupMembershipsUnlessConfigured() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.isMaintainLdapGroupMembership());
+ assertFalse(config.isMaintainPosixGroupMembership());
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(SYLVESTER_DN)); + facade.delete(ObjectClass.ACCOUNT, object.getUid(), \
null); +
+ object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_BUGS_AND_FRIENDS_DN), \
"uniqueMember"); + List<Object> members = \
object.getAttributeByName("uniqueMember").getValue(); + \
assertTrue(members.contains(SYLVESTER_DN)); +
+ object = searchByAttribute(facade, new \
ObjectClass("groupOfUniqueNames"), new Name(UNIQUE_EXTERNAL_PEERS_DN), \
"uniqueMember"); + members = \
object.getAttributeByName("uniqueMember").getValue(); + \
assertTrue(members.contains(SYLVESTER_DN)); +
+ object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_BUGS_AND_FRIENDS_DN), "memberUid"); + members = \
object.getAttributeByName("memberUid").getValue(); + \
assertTrue(members.contains(SYLVESTER_UID)); +
+ object = searchByAttribute(facade, new ObjectClass("posixGroup"), \
new Name(POSIX_EXTERNAL_PEERS_DN), "memberUid"); + members = \
object.getAttributeByName("memberUid").getValue(); + \
assertTrue(members.contains(SYLVESTER_UID)); + }
+
+ @Test
+ public void testPasswordHashing() throws Exception {
+ LdapConfiguration config = newConfiguration();
+ config.setPasswordHashAlgorithm("SHA");
+ ConnectorFacade facade = newFacade(config);
+
+ doTestPasswordHashing(facade, "SHA");
+ }
+
+ @Test
+ public void testSaltedPasswordHashing() throws Exception {
+ LdapConfiguration config = newConfiguration();
+ config.setPasswordHashAlgorithm("SSHA");
+ ConnectorFacade facade = newFacade(config);
+
+ doTestPasswordHashing(facade, "SSHA");
+ }
+
+ private void doTestPasswordHashing(ConnectorFacade facade, String algorithm) \
throws UnsupportedEncodingException { + String algorithmLabel = "{" \
+ algorithm + "}"; +
+ Set<Attribute> attrs = new HashSet<Attribute>();
+ attrs.add(new Name("uid=daffy.duck," + ACME_USERS_DN));
+ attrs.add(AttributeBuilder.build("uid", "daffy.duck"));
+ attrs.add(AttributeBuilder.build("cn", "Daffy Duck"));
+ attrs.add(AttributeBuilder.build("sn", "Duck"));
+ attrs.add(AttributeBuilder.build("ds-pwp-password-policy-dn", \
"cn=Clear Text Password Policy,cn=Password Policies,cn=config")); + \
GuardedString password = new GuardedString("foobar".toCharArray()); + \
attrs.add(AttributeBuilder.buildPassword(password)); + Uid uid = \
facade.create(ObjectClass.ACCOUNT, attrs, null); +
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
"userPassword"); + byte[] passwordBytes = (byte[]) \
object.getAttributeByName("userPassword").getValue().get(0); + \
assertTrue(new String(passwordBytes, "UTF-8").startsWith(algorithmLabel)); \
+ facade.authenticate(ObjectClass.ACCOUNT, "daffy.duck", password, \
null); +
+ password = new GuardedString("newpassword".toCharArray());
+ facade.update(ObjectClass.ACCOUNT, object.getUid(), \
singleton(AttributeBuilder.buildPassword(password)), null); +
+ object = searchByAttribute(facade, ObjectClass.ACCOUNT, uid, \
"userPassword"); + passwordBytes = (byte[]) \
object.getAttributeByName("userPassword").getValue().get(0); + \
assertTrue(new String(passwordBytes, "UTF-8").startsWith(algorithmLabel)); \
+ facade.authenticate(ObjectClass.ACCOUNT, "daffy.duck", password, \
null); + }
+
+ @Test
+ public void testSearchAnyObjectClass() {
+ ConnectorFacade facade = newFacade();
+
+ Filter filter = FilterBuilder.equalTo(AttributeBuilder.build(Name.NAME, \
BUGS_BUNNY_DN)); + OperationOptionsBuilder builder = new \
OperationOptionsBuilder(); + builder.setAttributesToGet("cn", \
"dn"); + List<ConnectorObject> objects = \
TestHelpers.searchToList(facade, LdapSchemaMapping.ANY_OBJECT_CLASS, filter, \
builder.build()); +
+ ConnectorObject bunny = objects.get(0);
+ assertEquals(LdapSchemaMapping.ANY_OBJECT_CLASS, bunny.getObjectClass());
+ assertEquals(BUGS_BUNNY_DN, bunny.getName().getNameValue());
+ assertEquals(BUGS_BUNNY_CN, \
bunny.getAttributeByName("cn").getValue().get(0)); + }
+
+ @Test
+ public void testSearchFilter() {
+ ConnectorFacade facade = newFacade();
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setOption(LdapConstants.SEARCH_FILTER_NAME, "(uid=" + \
BUGS_BUNNY_UID + ")"); + List<ConnectorObject> objects = \
TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null, builder.build()); +
+ assertEquals(1, objects.size());
+ ConnectorObject bunny = objects.get(0);
+ assertEquals(BUGS_BUNNY_DN, bunny.getName().getNameValue());
+ }
+
+ private static void assertAttributeValue(List<?> expected, ConnectorFacade \
facade, ObjectClass oclass, Uid uid, String attrName) { + ConnectorObject \
object = searchByAttribute(facade, oclass, uid, attrName); + \
assertAttributeValue(expected, object.getAttributeByName(attrName)); + }
+
+ private static void assertAttributeValue(List<?> expected, Attribute attr) \
{ + Set<?> attrValue = newSet(attr.getValue());
+ Set<?> expectedValue = newSet(expected);
+ assertEquals(expectedValue, attrValue);
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAppendingAttributesTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,200 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.testng.AssertJUnit;
-import org.testng.Assert;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-
-public class AppendingAttributesTests {
-
- private Attribute foo, existingFoo, existingCapitalFoo;
- private Attribute bar, existingBar;
-
- @BeforeMethod
- public void before() {
- foo = new BasicAttribute("foo", "Foo");
- existingFoo = new BasicAttribute("foo", "Existing Foo");
- existingCapitalFoo = new BasicAttribute("FOO", "EXISTING \
FOO");
- bar = new BasicAttribute("bar", "Bar");
- existingBar = new BasicAttribute("bar", "Existing Bar");
- }
-
- @Test
- public void testAppending() throws Exception {
- BasicAttributes existingAttrs = new BasicAttributes(true);
- AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar);
- AssertJUnit.assertEquals(2, appendingAttrs.size());
- assertHasAttribute(foo, "foo", appendingAttrs);
- assertHasAttribute(bar, "bar", appendingAttrs);
- AssertJUnit.assertEquals(foo, appendingAttrs.get("FOO"));
- Assert.assertNull(existingAttrs.get("inexistent"));
- }
-
- @Test
- public void testAppendAndReplaceCaseInsensitive() throws Exception {
- BasicAttributes existingAttrs = new BasicAttributes(true);
- existingAttrs.put(existingCapitalFoo);
- AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar);
- AssertJUnit.assertEquals(2, appendingAttrs.size());
- assertHasAttribute(foo, "foo", appendingAttrs);
- assertHasAttribute(bar, "bar", appendingAttrs);
- AssertJUnit.assertEquals(foo, appendingAttrs.get("FOO"));
- Assert.assertNull(existingAttrs.get("inexistent"));
- }
-
- @Test
- public void testAppendCaseInsensitive() throws Exception {
- BasicAttributes existingAttrs = new BasicAttributes(false);
- existingAttrs.put(existingCapitalFoo);
- AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar);
- AssertJUnit.assertEquals(3, appendingAttrs.size());
- assertHasAttribute(foo, "foo", appendingAttrs);
- assertHasAttribute(existingCapitalFoo, "FOO", appendingAttrs);
- assertHasAttribute(bar, "bar", appendingAttrs);
- Assert.assertNull(existingAttrs.get("inexistent"));
- }
-
- @Test
- public void testReplace() throws Exception {
- BasicAttributes existingAttrs = new BasicAttributes(true);
- existingAttrs.put(existingFoo);
- existingAttrs.put(existingBar);
- AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar);
- AssertJUnit.assertEquals(2, appendingAttrs.size());
- assertHasAttribute(foo, "foo", appendingAttrs);
- assertHasAttribute(bar, "bar", appendingAttrs);
- Assert.assertNull(existingAttrs.get("inexistent"));
- }
-
- private void assertHasAttribute(Attribute expected, String attrID, Attributes \
attrs) throws NamingException {
- AssertJUnit.assertEquals(expected, attrs.get(attrID));
-
- AssertJUnit.assertEquals(expected, findAttrUsingEnumMore(attrs.getAll(), \
attrID));
- AssertJUnit.assertEquals(expected, \
findAttrUsingEnumMoreElements(attrs.getAll(), attrID));
- AssertJUnit.assertEquals(attrID, findAttrIDUsingEnumMore(attrs.getIDs(), \
attrID));
- AssertJUnit.assertEquals(attrID, \
findAttrIDUsingEnumMoreElements(attrs.getIDs(), attrID));
- }
-
- private static Attribute findAttrUsingEnumMore(NamingEnumeration<? extends \
Attribute> attrEnum, String attrID) throws NamingException {
- Attribute attr = null;
- int found = 0;
- while (attrEnum.hasMore()) {
- Attribute nextAttr = attrEnum.next();
- if (nextAttr.getID().equals(attrID)) {
- attr = nextAttr;
- found++;
- }
- }
- AssertJUnit.assertEquals(1, found);
- return attr;
- }
-
- private static Attribute findAttrUsingEnumMoreElements(NamingEnumeration<? \
extends Attribute> attrEnum, String attrID) {
- Attribute attr = null;
- int found = 0;
- while (attrEnum.hasMoreElements()) {
- Attribute nextAttr = attrEnum.nextElement();
- if (nextAttr.getID().equals(attrID)) {
- attr = nextAttr;
- found++;
- }
- }
- AssertJUnit.assertEquals(1, found);
- return attr;
- }
-
- private static String findAttrIDUsingEnumMore(NamingEnumeration<String> \
idEnum, String attrID) throws NamingException {
- String id = null;
- int found = 0;
- while (idEnum.hasMore()) {
- String nextID = idEnum.next();
- if (nextID.equals(attrID)) {
- id = nextID;
- found++;
- }
- }
- AssertJUnit.assertEquals(1, found);
- return id;
- }
-
- private static String \
findAttrIDUsingEnumMoreElements(NamingEnumeration<String> idEnum, String \
attrID) {
- String id = null;
- int found = 0;
- while (idEnum.hasMoreElements()) {
- String nextID = idEnum.nextElement();
- if (nextID.equals(attrID)) {
- id = nextID;
- found++;
- }
- }
- AssertJUnit.assertEquals(1, found);
- return id;
- }
-
- private static final class AppendingAttrImpl extends AppendingAttributes {
-
- private static final long serialVersionUID = 1L;
-
- private final Attribute[] toAppend;
-
- public AppendingAttrImpl(Attributes delegate, Attribute... toAppend) {
- super(delegate);
- this.toAppend = toAppend;
- }
-
- @Override
- public Object clone() {
- return new AppendingAttrImpl((Attributes) delegate.clone(), toAppend);
- }
-
- @Override
- protected Attribute getAttributeToAppend(String attrID) {
- for (Attribute attr : toAppend) {
- if (attrID.equals(attr.getID())) {
- return attr;
- }
- }
- return null;
- }
-
- @Override
- protected Set<String> getAttributeIDsToAppend() {
- Set<String> result = new HashSet<String>();
- for (Attribute attr : toAppend) {
- result.add(attr.getID());
- }
- return result;
- }
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapAppendingAtt \
ributesTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapAppendingAttributesTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/AppendingAttributesTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,200 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.testng.AssertJUnit;
+import org.testng.Assert;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+
+public class AppendingAttributesTests {
+
+ private Attribute foo, existingFoo, existingCapitalFoo;
+ private Attribute bar, existingBar;
+
+ @BeforeMethod
+ public void before() {
+ foo = new BasicAttribute("foo", "Foo");
+ existingFoo = new BasicAttribute("foo", "Existing Foo");
+ existingCapitalFoo = new BasicAttribute("FOO", "EXISTING \
FOO"); + bar = new BasicAttribute("bar", "Bar");
+ existingBar = new BasicAttribute("bar", "Existing Bar");
+ }
+
+ @Test
+ public void testAppending() throws Exception {
+ BasicAttributes existingAttrs = new BasicAttributes(true);
+ AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar); + AssertJUnit.assertEquals(2, appendingAttrs.size());
+ assertHasAttribute(foo, "foo", appendingAttrs);
+ assertHasAttribute(bar, "bar", appendingAttrs);
+ AssertJUnit.assertEquals(foo, appendingAttrs.get("FOO"));
+ Assert.assertNull(existingAttrs.get("inexistent"));
+ }
+
+ @Test
+ public void testAppendAndReplaceCaseInsensitive() throws Exception {
+ BasicAttributes existingAttrs = new BasicAttributes(true);
+ existingAttrs.put(existingCapitalFoo);
+ AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar); + AssertJUnit.assertEquals(2, appendingAttrs.size());
+ assertHasAttribute(foo, "foo", appendingAttrs);
+ assertHasAttribute(bar, "bar", appendingAttrs);
+ AssertJUnit.assertEquals(foo, appendingAttrs.get("FOO"));
+ Assert.assertNull(existingAttrs.get("inexistent"));
+ }
+
+ @Test
+ public void testAppendCaseInsensitive() throws Exception {
+ BasicAttributes existingAttrs = new BasicAttributes(false);
+ existingAttrs.put(existingCapitalFoo);
+ AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar); + AssertJUnit.assertEquals(3, appendingAttrs.size());
+ assertHasAttribute(foo, "foo", appendingAttrs);
+ assertHasAttribute(existingCapitalFoo, "FOO", appendingAttrs);
+ assertHasAttribute(bar, "bar", appendingAttrs);
+ Assert.assertNull(existingAttrs.get("inexistent"));
+ }
+
+ @Test
+ public void testReplace() throws Exception {
+ BasicAttributes existingAttrs = new BasicAttributes(true);
+ existingAttrs.put(existingFoo);
+ existingAttrs.put(existingBar);
+ AppendingAttrImpl appendingAttrs = new AppendingAttrImpl(existingAttrs, foo, \
bar); + AssertJUnit.assertEquals(2, appendingAttrs.size());
+ assertHasAttribute(foo, "foo", appendingAttrs);
+ assertHasAttribute(bar, "bar", appendingAttrs);
+ Assert.assertNull(existingAttrs.get("inexistent"));
+ }
+
+ private void assertHasAttribute(Attribute expected, String attrID, Attributes \
attrs) throws NamingException { + AssertJUnit.assertEquals(expected, \
attrs.get(attrID)); +
+ AssertJUnit.assertEquals(expected, findAttrUsingEnumMore(attrs.getAll(), \
attrID)); + AssertJUnit.assertEquals(expected, \
findAttrUsingEnumMoreElements(attrs.getAll(), attrID)); + \
AssertJUnit.assertEquals(attrID, findAttrIDUsingEnumMore(attrs.getIDs(), attrID)); + \
AssertJUnit.assertEquals(attrID, findAttrIDUsingEnumMoreElements(attrs.getIDs(), \
attrID)); + }
+
+ private static Attribute findAttrUsingEnumMore(NamingEnumeration<? extends \
Attribute> attrEnum, String attrID) throws NamingException { + Attribute \
attr = null; + int found = 0;
+ while (attrEnum.hasMore()) {
+ Attribute nextAttr = attrEnum.next();
+ if (nextAttr.getID().equals(attrID)) {
+ attr = nextAttr;
+ found++;
+ }
+ }
+ AssertJUnit.assertEquals(1, found);
+ return attr;
+ }
+
+ private static Attribute findAttrUsingEnumMoreElements(NamingEnumeration<? \
extends Attribute> attrEnum, String attrID) { + Attribute attr = null;
+ int found = 0;
+ while (attrEnum.hasMoreElements()) {
+ Attribute nextAttr = attrEnum.nextElement();
+ if (nextAttr.getID().equals(attrID)) {
+ attr = nextAttr;
+ found++;
+ }
+ }
+ AssertJUnit.assertEquals(1, found);
+ return attr;
+ }
+
+ private static String findAttrIDUsingEnumMore(NamingEnumeration<String> \
idEnum, String attrID) throws NamingException { + String id = null;
+ int found = 0;
+ while (idEnum.hasMore()) {
+ String nextID = idEnum.next();
+ if (nextID.equals(attrID)) {
+ id = nextID;
+ found++;
+ }
+ }
+ AssertJUnit.assertEquals(1, found);
+ return id;
+ }
+
+ private static String \
findAttrIDUsingEnumMoreElements(NamingEnumeration<String> idEnum, String \
attrID) { + String id = null;
+ int found = 0;
+ while (idEnum.hasMoreElements()) {
+ String nextID = idEnum.nextElement();
+ if (nextID.equals(attrID)) {
+ id = nextID;
+ found++;
+ }
+ }
+ AssertJUnit.assertEquals(1, found);
+ return id;
+ }
+
+ private static final class AppendingAttrImpl extends AppendingAttributes {
+
+ private static final long serialVersionUID = 1L;
+
+ private final Attribute[] toAppend;
+
+ public AppendingAttrImpl(Attributes delegate, Attribute... toAppend) {
+ super(delegate);
+ this.toAppend = toAppend;
+ }
+
+ @Override
+ public Object clone() {
+ return new AppendingAttrImpl((Attributes) delegate.clone(), toAppend);
+ }
+
+ @Override
+ protected Attribute getAttributeToAppend(String attrID) {
+ for (Attribute attr : toAppend) {
+ if (attrID.equals(attr.getID())) {
+ return attr;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected Set<String> getAttributeIDsToAppend() {
+ Set<String> result = new HashSet<String>();
+ for (Attribute attr : toAppend) {
+ result.add(attr.getID());
+ }
+ return result;
+ }
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapAuthenticateTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,142 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.Test;
-import org.testng.Assert;
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.common.exceptions.ConnectorSecurityException;
-import org.identityconnectors.framework.common.exceptions.PasswordExpiredException;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.OperationOptions;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.Uid;
-
-public class LdapAuthenticateTests extends LdapConnectorTestBase {
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return false;
- }
-
- @Test
- public void testAuthenticateWithDefaultConfiguration() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- Uid uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, new \
GuardedString("carrot".toCharArray()), null);
- assertEquals(bugs.getUid(), uid);
- uid = facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, null);
- assertEquals(bugs.getUid(), uid);
-
- uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, new \
GuardedString("carrot".toCharArray()), null);
- assertEquals(bugs.getUid(), uid);
- uid = facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, null);
- assertEquals(bugs.getUid(), uid);
- }
-
- @Test
- public void testAuthenticateWithCustomAttributes() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setOption(LdapConstants.LDAP_UID_ATTRS_NAME, new String[] { \
"sn" });
- OperationOptions options = builder.build();
- Uid uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_SN, new \
GuardedString("carrot".toCharArray()), options);
- assertEquals(bugs.getUid(), uid);
- uid = facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_SN, options);
- assertEquals(bugs.getUid(), uid);
-
- // Should not be possible to authenticate with the attributes from the \
default configuration ("cn"...
- try {
- facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, new \
GuardedString("carrot".toCharArray()), options);
- Assert.fail();
- } catch (ConnectorSecurityException e) { }
- try {
- facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, options);
- Assert.fail();
- } catch (ConnectorSecurityException e) { }
-
- // ... and "uid").
- try {
- uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, new \
GuardedString("carrot".toCharArray()), options);
- Assert.fail();
- } catch (ConnectorSecurityException e) { }
- try {
- uid = facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, \
options);
- Assert.fail();
- } catch (ConnectorSecurityException e) { }
- }
-
- @Test
- public void testAuthenticateWithEntryDN() {
- LdapConfiguration config = newConfiguration();
- config.setAccountUserNameAttributes("entryDN");
- ConnectorFacade facade = newFacade(config);
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- Uid uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_DN, new \
GuardedString("carrot".toCharArray()), null);
- assertEquals(bugs.getUid(), uid);
- uid = facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_DN, null);
- assertEquals(bugs.getUid(), uid);
- }
-
- @Test(expectedExceptions = ConnectorSecurityException.class)
- public void testAuthenticateInvalidPassword() {
- ConnectorFacade facade = newFacade();
- facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, new \
GuardedString("rabbithole".toCharArray()), null);
- }
-
- @Test
- public void testAuthenticateUnknownAccount() {
- ConnectorFacade facade = newFacade();
- try {
- facade.authenticate(ObjectClass.ACCOUNT, \
"hopefully.inexisting.user", new \
GuardedString("none".toCharArray()), null);
- Assert.fail();
- } catch (ConnectorSecurityException e) { }
- try {
- facade.resolveUsername(ObjectClass.ACCOUNT, \
"hopefully.inexisting.user", null);
- Assert.fail();
- } catch (ConnectorSecurityException e) { }
- }
-
- @Test
- public void testAuthenticateExpiredPassword() {
- LdapConfiguration config = newConfiguration();
- config.setRespectResourcePasswordPolicyChangeAfterReset(false);
- ConnectorFacade facade = newFacade(config);
- facade.authenticate(ObjectClass.ACCOUNT, EXPIRED_UID, new \
GuardedString("password".toCharArray()), null);
-
- config = newConfiguration();
- config.setRespectResourcePasswordPolicyChangeAfterReset(true);
- facade = newFacade(config);
- try {
- facade.authenticate(ObjectClass.ACCOUNT, EXPIRED_UID, new \
GuardedString("password".toCharArray()), null);
- Assert.fail();
- } catch (PasswordExpiredException e) {
- // OK.
- }
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapAuthenti \
cateTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapLdapAuthenticateTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapAuthenticateTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,142 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.exceptions.ConnectorSecurityException;
+import org.identityconnectors.framework.common.exceptions.PasswordExpiredException;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
+import org.identityconnectors.framework.common.objects.Uid;
+
+public class LdapAuthenticateTests extends LdapConnectorTestBase {
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return false;
+ }
+
+ @Test
+ public void testAuthenticateWithDefaultConfiguration() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + Uid uid = facade.authenticate(ObjectClass.ACCOUNT, \
BUGS_BUNNY_CN, new GuardedString("carrot".toCharArray()), null); + \
assertEquals(bugs.getUid(), uid); + uid = \
facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, null); + \
assertEquals(bugs.getUid(), uid); +
+ uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, new \
GuardedString("carrot".toCharArray()), null); + \
assertEquals(bugs.getUid(), uid); + uid = \
facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, null); + \
assertEquals(bugs.getUid(), uid); + }
+
+ @Test
+ public void testAuthenticateWithCustomAttributes() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + OperationOptionsBuilder builder = new \
OperationOptionsBuilder(); + \
builder.setOption(LdapConstants.LDAP_UID_ATTRS_NAME, new String[] { "sn" \
}); + OperationOptions options = builder.build();
+ Uid uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_SN, new \
GuardedString("carrot".toCharArray()), options); + \
assertEquals(bugs.getUid(), uid); + uid = \
facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_SN, options); + \
assertEquals(bugs.getUid(), uid); +
+ // Should not be possible to authenticate with the attributes from the \
default configuration ("cn"... + try {
+ facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, new \
GuardedString("carrot".toCharArray()), options); + \
Assert.fail(); + } catch (ConnectorSecurityException e) { }
+ try {
+ facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, options);
+ Assert.fail();
+ } catch (ConnectorSecurityException e) { }
+
+ // ... and "uid").
+ try {
+ uid = facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, new \
GuardedString("carrot".toCharArray()), options); + \
Assert.fail(); + } catch (ConnectorSecurityException e) { }
+ try {
+ uid = facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_UID, \
options); + Assert.fail();
+ } catch (ConnectorSecurityException e) { }
+ }
+
+ @Test
+ public void testAuthenticateWithEntryDN() {
+ LdapConfiguration config = newConfiguration();
+ config.setAccountUserNameAttributes("entryDN");
+ ConnectorFacade facade = newFacade(config);
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + Uid uid = facade.authenticate(ObjectClass.ACCOUNT, \
BUGS_BUNNY_DN, new GuardedString("carrot".toCharArray()), null); + \
assertEquals(bugs.getUid(), uid); + uid = \
facade.resolveUsername(ObjectClass.ACCOUNT, BUGS_BUNNY_DN, null); + \
assertEquals(bugs.getUid(), uid); + }
+
+ @Test(expectedExceptions = ConnectorSecurityException.class)
+ public void testAuthenticateInvalidPassword() {
+ ConnectorFacade facade = newFacade();
+ facade.authenticate(ObjectClass.ACCOUNT, BUGS_BUNNY_CN, new \
GuardedString("rabbithole".toCharArray()), null); + }
+
+ @Test
+ public void testAuthenticateUnknownAccount() {
+ ConnectorFacade facade = newFacade();
+ try {
+ facade.authenticate(ObjectClass.ACCOUNT, \
"hopefully.inexisting.user", new \
GuardedString("none".toCharArray()), null); + Assert.fail();
+ } catch (ConnectorSecurityException e) { }
+ try {
+ facade.resolveUsername(ObjectClass.ACCOUNT, \
"hopefully.inexisting.user", null); + Assert.fail();
+ } catch (ConnectorSecurityException e) { }
+ }
+
+ @Test
+ public void testAuthenticateExpiredPassword() {
+ LdapConfiguration config = newConfiguration();
+ config.setRespectResourcePasswordPolicyChangeAfterReset(false);
+ ConnectorFacade facade = newFacade(config);
+ facade.authenticate(ObjectClass.ACCOUNT, EXPIRED_UID, new \
GuardedString("password".toCharArray()), null); +
+ config = newConfiguration();
+ config.setRespectResourcePasswordPolicyChangeAfterReset(true);
+ facade = newFacade(config);
+ try {
+ facade.authenticate(ObjectClass.ACCOUNT, EXPIRED_UID, new \
GuardedString("password".toCharArray()), null); + Assert.fail();
+ } catch (PasswordExpiredException e) {
+ // OK.
+ }
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapConfigurationTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,337 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import org.testng.annotations.BeforeMethod;
-import org.testng.Assert;
-import static org.identityconnectors.common.CollectionUtil.newList;
-import java.util.Arrays;
-
-import org.identityconnectors.common.security.GuardedByteArray;
-import org.identityconnectors.framework.common.exceptions.ConfigurationException;
-import org.identityconnectors.test.common.TestHelpers;
-
-public class LdapConfigurationTests {
-
- private static final String INVALID_DN = "dc=a,,";
-
- private LdapConfiguration config;
-
- @BeforeMethod
- public void before() throws Exception {
- config = new LdapConfiguration();
- config.setConnectorMessages(TestHelpers.createDummyMessages());
- config.setHost("localhost");
- config.setBaseContexts("dc=example,dc=com");
- assertCanValidate(config);
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBaseContextsNotEmpty() {
- config.setBaseContexts();
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBaseContextsItemNotNull() {
- config.setBaseContexts((String) null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBaseContextsItemNotBlank() {
- config.setBaseContexts(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBaseContextsValid() {
- config.setBaseContexts(LdapConnectorTestBase.ACME_DN, INVALID_DN);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordAttributeNotNull() {
- config.setPasswordAttribute(null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordAttributeNotBlank() {
- config.setPasswordAttribute(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testAccountObjectClassesNotEmpty() {
- config.setAccountObjectClasses();
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testAccountObjectClassesItemNotNull() {
- config.setAccountObjectClasses((String) null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testAccountUserNameAttributesNotEmpty() {
- config.setAccountUserNameAttributes();
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testAccountUserNameAttributesItemNotNull() {
- config.setAccountUserNameAttributes((String) null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testGroupMemberAttributeNotNull() {
- config.setGroupMemberAttribute(null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testGroupMemberAttributeNotBlank() {
- config.setGroupMemberAttribute(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBlockCountGreatherThanZero() {
- config.setBlockSize(0);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testVlvSortAttributeNotNull() {
- config.setUidAttribute(null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testVlvSortAttributeNotBlank() {
- config.setUidAttribute(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testUidAttributeNotNull() {
- config.setUidAttribute(null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testUidAttributeNotBlank() {
- config.setUidAttribute(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBaseContextsToSynchronizeItemNotNull() {
- config.setBaseContextsToSynchronize((String) null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBaseContextsToSynchronizeItemNotBlank() {
- config.setBaseContextsToSynchronize(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testBaseContextsToSyncronizeValid() {
- config.setBaseContextsToSynchronize(LdapConnectorTestBase.ACME_DN, \
INVALID_DN);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testObjectClassesToSynchronizeNotEmpty() {
- config.setObjectClassesToSynchronize();
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testObjectClassesToSynchronizeItemNotNull() {
- config.setObjectClassesToSynchronize((String) null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testObjectClassesToSynchronizeItemNotBlank() {
- config.setObjectClassesToSynchronize(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testAttributesToSynchronizeItemNotNull() {
- config.setAttributesToSynchronize((String) null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testAttributesToSynchronizeItemNotBlank() {
- config.setAttributesToSynchronize(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testModifiersNamesToFilterOutItemNotNull() {
- config.setModifiersNamesToFilterOut((String) null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testModifiersNamesToFilterOutItemNotBlank() {
- config.setModifiersNamesToFilterOut(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testModifiersNamesToFilterOutValid() {
- config.setModifiersNamesToFilterOut(LdapConnectorTestBase.ACME_DN, \
INVALID_DN);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testChangeNumberAttributeNotNull() {
- config.setChangeNumberAttribute(null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testChangeNumberAttributeNotBlank() {
- config.setChangeNumberAttribute(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testChangeLogBlockSizeGreatherThanZero() {
- config.setChangeLogBlockSize(0);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordAttributeToSynchronizeNotNull() {
- config.setSynchronizePasswords(true);
- config.setPasswordAttributeToSynchronize(null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordAttributeToSynchronizeNotBlank() {
- config.setSynchronizePasswords(true);
- config.setPasswordAttributeToSynchronize(" ");
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordDecryptionKeyNotNull() {
- config.setSynchronizePasswords(true);
- config.setPasswordAttributeToSynchronize("somepassword");
- config.setPasswordDecryptionKey(null);
- config.setPasswordDecryptionInitializationVector(new GuardedByteArray(new \
byte[1]));
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordDecryptionKeyNotBlank() {
- config.setSynchronizePasswords(true);
- config.setPasswordAttributeToSynchronize("somepassword");
- config.setPasswordDecryptionKey(new GuardedByteArray(new byte[0]));
- config.setPasswordDecryptionInitializationVector(new GuardedByteArray(new \
byte[1]));
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordDecryptionInitializationVectorNotNull() {
- config.setSynchronizePasswords(true);
- config.setPasswordAttributeToSynchronize("somepassword");
- config.setPasswordDecryptionKey(new GuardedByteArray(new byte[1]));
- config.setPasswordDecryptionInitializationVector(null);
- config.validate();
- }
-
- @Test(expectedExceptions = ConfigurationException.class)
- public void testPasswordDecryptionInitializationVectorNotBlank() {
- config.setSynchronizePasswords(true);
- config.setPasswordAttributeToSynchronize("somepassword");
- config.setPasswordDecryptionKey(new GuardedByteArray(new byte[1]));
- config.setPasswordDecryptionInitializationVector(new GuardedByteArray(new \
byte[0]));
- config.validate();
- }
-
- @Test
- public void testDefaultValues() {
- config = new LdapConfiguration();
- assertNull(config.getHost());
- assertEquals(LdapConfiguration.DEFAULT_PORT, config.getPort());
- assertFalse(config.isSsl());
- assertEquals(0, config.getFailover().length);
- assertNull(config.getPrincipal());
- assertNull(config.getCredentials());
- assertEquals(0, config.getBaseContexts().length);
- assertEquals("userPassword", config.getPasswordAttribute());
- assertEquals(newList("top", "person", \
"organizationalPerson", "inetOrgPerson"), \
Arrays.asList(config.getAccountObjectClasses()));
- assertEquals(newList("uid", "cn"), \
Arrays.asList(config.getAccountUserNameAttributes()));
- assertNull(config.getAccountSearchFilter());
- assertEquals("uniqueMember", config.getGroupMemberAttribute());
- assertFalse(config.isMaintainLdapGroupMembership());
- assertFalse(config.isMaintainPosixGroupMembership());
- assertFalse(config.isRespectResourcePasswordPolicyChangeAfterReset());
- assertNull(config.getPasswordHashAlgorithm());
- assertTrue(config.isUseBlocks());
- assertEquals(100, config.getBlockSize());
- assertFalse(config.isUsePagedResultControl());
- assertEquals("uid", config.getVlvSortAttribute());
- assertEquals("entryUUID", config.getUidAttribute());
- assertTrue(config.isReadSchema());
- assertEquals(0, config.getBaseContextsToSynchronize().length);
- assertTrue(Arrays.equals(new String[] { "inetOrgPerson" }, \
config.getObjectClassesToSynchronize()));
- assertEquals(0, config.getAttributesToSynchronize().length);
- assertEquals(0, config.getModifiersNamesToFilterOut().length);
- assertNull(config.getAccountSynchronizationFilter());
- assertEquals(100, config.getChangeLogBlockSize());
- assertEquals("changeNumber", config.getChangeNumberAttribute());
- assertFalse(config.isFilterWithOrInsteadOfAnd());
- assertTrue(config.isRemoveLogEntryObjectClassFromFilter());
- assertFalse(config.isSynchronizePasswords());
- assertNull(config.getPasswordAttributeToSynchronize());
- assertNull(config.getPasswordDecryptionKey());
- assertNull(config.getPasswordDecryptionInitializationVector());
- }
-
- private static void assertCanValidate(LdapConfiguration config) {
- try {
- config.validate();
- } catch (Exception e) {
- Assert.fail();
- }
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapConfigur \
ationTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapLdapConfigurationTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConfigurationTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,337 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeMethod;
+import org.testng.Assert;
+import static org.identityconnectors.common.CollectionUtil.newList;
+import java.util.Arrays;
+
+import org.identityconnectors.common.security.GuardedByteArray;
+import org.identityconnectors.framework.common.exceptions.ConfigurationException;
+import org.identityconnectors.test.common.TestHelpers;
+
+public class LdapConfigurationTests {
+
+ private static final String INVALID_DN = "dc=a,,";
+
+ private LdapConfiguration config;
+
+ @BeforeMethod
+ public void before() throws Exception {
+ config = new LdapConfiguration();
+ config.setConnectorMessages(TestHelpers.createDummyMessages());
+ config.setHost("localhost");
+ config.setBaseContexts("dc=example,dc=com");
+ assertCanValidate(config);
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBaseContextsNotEmpty() {
+ config.setBaseContexts();
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBaseContextsItemNotNull() {
+ config.setBaseContexts((String) null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBaseContextsItemNotBlank() {
+ config.setBaseContexts(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBaseContextsValid() {
+ config.setBaseContexts(LdapConnectorTestBase.ACME_DN, INVALID_DN);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordAttributeNotNull() {
+ config.setPasswordAttribute(null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordAttributeNotBlank() {
+ config.setPasswordAttribute(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testAccountObjectClassesNotEmpty() {
+ config.setAccountObjectClasses();
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testAccountObjectClassesItemNotNull() {
+ config.setAccountObjectClasses((String) null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testAccountUserNameAttributesNotEmpty() {
+ config.setAccountUserNameAttributes();
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testAccountUserNameAttributesItemNotNull() {
+ config.setAccountUserNameAttributes((String) null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testGroupMemberAttributeNotNull() {
+ config.setGroupMemberAttribute(null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testGroupMemberAttributeNotBlank() {
+ config.setGroupMemberAttribute(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBlockCountGreatherThanZero() {
+ config.setBlockSize(0);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testVlvSortAttributeNotNull() {
+ config.setUidAttribute(null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testVlvSortAttributeNotBlank() {
+ config.setUidAttribute(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testUidAttributeNotNull() {
+ config.setUidAttribute(null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testUidAttributeNotBlank() {
+ config.setUidAttribute(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBaseContextsToSynchronizeItemNotNull() {
+ config.setBaseContextsToSynchronize((String) null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBaseContextsToSynchronizeItemNotBlank() {
+ config.setBaseContextsToSynchronize(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testBaseContextsToSyncronizeValid() {
+ config.setBaseContextsToSynchronize(LdapConnectorTestBase.ACME_DN, \
INVALID_DN); + config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testObjectClassesToSynchronizeNotEmpty() {
+ config.setObjectClassesToSynchronize();
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testObjectClassesToSynchronizeItemNotNull() {
+ config.setObjectClassesToSynchronize((String) null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testObjectClassesToSynchronizeItemNotBlank() {
+ config.setObjectClassesToSynchronize(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testAttributesToSynchronizeItemNotNull() {
+ config.setAttributesToSynchronize((String) null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testAttributesToSynchronizeItemNotBlank() {
+ config.setAttributesToSynchronize(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testModifiersNamesToFilterOutItemNotNull() {
+ config.setModifiersNamesToFilterOut((String) null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testModifiersNamesToFilterOutItemNotBlank() {
+ config.setModifiersNamesToFilterOut(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testModifiersNamesToFilterOutValid() {
+ config.setModifiersNamesToFilterOut(LdapConnectorTestBase.ACME_DN, \
INVALID_DN); + config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testChangeNumberAttributeNotNull() {
+ config.setChangeNumberAttribute(null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testChangeNumberAttributeNotBlank() {
+ config.setChangeNumberAttribute(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testChangeLogBlockSizeGreatherThanZero() {
+ config.setChangeLogBlockSize(0);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordAttributeToSynchronizeNotNull() {
+ config.setSynchronizePasswords(true);
+ config.setPasswordAttributeToSynchronize(null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordAttributeToSynchronizeNotBlank() {
+ config.setSynchronizePasswords(true);
+ config.setPasswordAttributeToSynchronize(" ");
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordDecryptionKeyNotNull() {
+ config.setSynchronizePasswords(true);
+ config.setPasswordAttributeToSynchronize("somepassword");
+ config.setPasswordDecryptionKey(null);
+ config.setPasswordDecryptionInitializationVector(new GuardedByteArray(new \
byte[1])); + config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordDecryptionKeyNotBlank() {
+ config.setSynchronizePasswords(true);
+ config.setPasswordAttributeToSynchronize("somepassword");
+ config.setPasswordDecryptionKey(new GuardedByteArray(new byte[0]));
+ config.setPasswordDecryptionInitializationVector(new GuardedByteArray(new \
byte[1])); + config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordDecryptionInitializationVectorNotNull() {
+ config.setSynchronizePasswords(true);
+ config.setPasswordAttributeToSynchronize("somepassword");
+ config.setPasswordDecryptionKey(new GuardedByteArray(new byte[1]));
+ config.setPasswordDecryptionInitializationVector(null);
+ config.validate();
+ }
+
+ @Test(expectedExceptions = ConfigurationException.class)
+ public void testPasswordDecryptionInitializationVectorNotBlank() {
+ config.setSynchronizePasswords(true);
+ config.setPasswordAttributeToSynchronize("somepassword");
+ config.setPasswordDecryptionKey(new GuardedByteArray(new byte[1]));
+ config.setPasswordDecryptionInitializationVector(new GuardedByteArray(new \
byte[0])); + config.validate();
+ }
+
+ @Test
+ public void testDefaultValues() {
+ config = new LdapConfiguration();
+ assertNull(config.getHost());
+ assertEquals(LdapConfiguration.DEFAULT_PORT, config.getPort());
+ assertFalse(config.isSsl());
+ assertEquals(0, config.getFailover().length);
+ assertNull(config.getPrincipal());
+ assertNull(config.getCredentials());
+ assertEquals(0, config.getBaseContexts().length);
+ assertEquals("userPassword", config.getPasswordAttribute());
+ assertEquals(newList("top", "person", \
"organizationalPerson", "inetOrgPerson"), \
Arrays.asList(config.getAccountObjectClasses())); + \
assertEquals(newList("uid", "cn"), \
Arrays.asList(config.getAccountUserNameAttributes())); + \
assertNull(config.getAccountSearchFilter()); + \
assertEquals("uniqueMember", config.getGroupMemberAttribute()); + \
assertFalse(config.isMaintainLdapGroupMembership()); + \
assertFalse(config.isMaintainPosixGroupMembership()); + \
assertFalse(config.isRespectResourcePasswordPolicyChangeAfterReset()); + \
assertNull(config.getPasswordHashAlgorithm()); + \
assertTrue(config.isUseBlocks()); + assertEquals(100, config.getBlockSize());
+ assertFalse(config.isUsePagedResultControl());
+ assertEquals("uid", config.getVlvSortAttribute());
+ assertEquals("entryUUID", config.getUidAttribute());
+ assertTrue(config.isReadSchema());
+ assertEquals(0, config.getBaseContextsToSynchronize().length);
+ assertTrue(Arrays.equals(new String[] { "inetOrgPerson" }, \
config.getObjectClassesToSynchronize())); + assertEquals(0, \
config.getAttributesToSynchronize().length); + assertEquals(0, \
config.getModifiersNamesToFilterOut().length); + \
assertNull(config.getAccountSynchronizationFilter()); + assertEquals(100, \
config.getChangeLogBlockSize()); + assertEquals("changeNumber", \
config.getChangeNumberAttribute()); + \
assertFalse(config.isFilterWithOrInsteadOfAnd()); + \
assertTrue(config.isRemoveLogEntryObjectClassFromFilter()); + \
assertFalse(config.isSynchronizePasswords()); + \
assertNull(config.getPasswordAttributeToSynchronize()); + \
assertNull(config.getPasswordDecryptionKey()); + \
assertNull(config.getPasswordDecryptionInitializationVector()); + }
+
+ private static void assertCanValidate(LdapConfiguration config) {
+ try {
+ config.validate();
+ } catch (Exception e) {
+ Assert.fail();
+ }
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapConnectionTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,177 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import org.testng.Assert;
-import static org.identityconnectors.ldap.LdapUtil.getStringAttrValue;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.common.exceptions.ConnectorException;
-import org.identityconnectors.ldap.LdapConstants.ServerType;
-import javax.naming.ldap.PagedResultsControl;
-import org.forgerock.opendj.ldap.controls.VirtualListViewRequestControl;
-
-public class LdapConnectionTests extends LdapConnectorTestBase {
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return false;
- }
-
- @Test
- public void testSSL() throws NamingException {
- BlindTrustProvider.register();
- LdapConfiguration config = newConfiguration();
- config.setSsl(true);
- config.setPort(SSL_PORT);
- testConnection(config);
- }
-
- @Test
- public void testFailover() throws NamingException {
- LdapConfiguration config = newConfiguration();
- config.setHost("foobarbaz");
- config.setPort(65535);
- try {
- testConnection(config);
- } catch (ConnectorException e) {
- // OK.
- } catch (NamingException e) {
- // Should not normally occur.
- throw e;
- }
-
- config = newConfiguration();
- config.setHost("foobarbaz");
- config.setPort(65535);
- config.setFailover("ldap://localhost:" + PORT);
- testConnection(config);
- }
-
- @Test(enabled = false)
- private void testConnection(LdapConfiguration config) throws NamingException {
- LdapConnection conn = new LdapConnection(config);
- Attributes attrs = conn.getInitialContext().getAttributes(BUGS_BUNNY_DN);
- assertEquals(BUGS_BUNNY_CN, getStringAttrValue(attrs, "cn"));
- }
-
- @Test
- public void testDefaultAuthenticationMethodIsInferred() throws NamingException {
- LdapConfiguration config = newConfiguration();
- config.setPrincipal(null);
- LdapConnection conn = new LdapConnection(config);
- assertEquals("none", \
conn.getInitialContext().getEnvironment().get(Context.SECURITY_AUTHENTICATION));
-
- config = newConfiguration();
- config.setPrincipal(ADMIN_DN);
- config.setCredentials(ADMIN_PASSWORD);
- conn = new LdapConnection(config);
- assertEquals("simple", \
conn.getInitialContext().getEnvironment().get(Context.SECURITY_AUTHENTICATION));
- }
-
- @Test
- public void testTest() {
- LdapConfiguration config = newConfiguration();
- config.setPort(4242);
- LdapConnection conn = new LdapConnection(config);
- try {
- conn.test();
- Assert.fail();
- } catch (RuntimeException e) {
- // Expected.
- }
-
- config = newConfiguration();
- config.setHost("invalid");
- conn = new LdapConnection(config);
- try {
- conn.test();
- Assert.fail();
- } catch (RuntimeException e) {
- // Expected.
- }
-
- config = newConfiguration();
- config.setPrincipal("uid=nobody");
- conn = new LdapConnection(config);
- try {
- conn.test();
- Assert.fail();
- } catch (RuntimeException e) {
- // Expected.
- }
-
- config = newConfiguration();
- config.setCredentials(new GuardedString("bogus".toCharArray()));
- conn = new LdapConnection(config);
- try {
- conn.test();
- Assert.fail();
- } catch (RuntimeException e) {
- // Expected.
- }
-
- config = newConfiguration();
- conn = new LdapConnection(config);
- conn.test();
- }
-
- @Test
- public void testCheckAlive() {
- // Set readSchema to true since we are calling createNativeSchema() below, \
and we
- // want to get the server schema, not the static one.
- LdapConfiguration config = newConfiguration(true);
- LdapConnection conn = new LdapConnection(config);
- conn.checkAlive();
- // Ensure the connection is really connected to the server.
- conn.createNativeSchema();
- conn.checkAlive();
- stopServer();
- try {
- // This should throw RuntimeException.
- conn.checkAlive();
- Assert.fail();
- } catch (RuntimeException e) {
- // OK.
- }
- }
-
- @Test
- public void testSupportedControls() {
- LdapConnection conn = new LdapConnection(newConfiguration());
- assertTrue(conn.supportsControl(PagedResultsControl.OID));
- assertTrue(conn.supportsControl(VirtualListViewRequestControl.OID));
- }
-
- @Test
- public void testServerType() {
- LdapConnection conn = new LdapConnection(newConfiguration());
- assertEquals(ServerType.OPENDS, conn.getServerType());
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapConnecti \
onTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapLdapConnectionTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectionTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,177 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import org.testng.Assert;
+import static org.identityconnectors.ldap.LdapUtil.getStringAttrValue;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.framework.common.exceptions.ConnectorException;
+import org.identityconnectors.ldap.LdapConstants.ServerType;
+import javax.naming.ldap.PagedResultsControl;
+import org.forgerock.opendj.ldap.controls.VirtualListViewRequestControl;
+
+public class LdapConnectionTests extends LdapConnectorTestBase {
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return false;
+ }
+
+ @Test
+ public void testSSL() throws NamingException {
+ BlindTrustProvider.register();
+ LdapConfiguration config = newConfiguration();
+ config.setSsl(true);
+ config.setPort(SSL_PORT);
+ testConnection(config);
+ }
+
+ @Test
+ public void testFailover() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ config.setHost("foobarbaz");
+ config.setPort(65535);
+ try {
+ testConnection(config);
+ } catch (ConnectorException e) {
+ // OK.
+ } catch (NamingException e) {
+ // Should not normally occur.
+ throw e;
+ }
+
+ config = newConfiguration();
+ config.setHost("foobarbaz");
+ config.setPort(65535);
+ config.setFailover("ldap://localhost:" + PORT);
+ testConnection(config);
+ }
+
+ @Test(enabled = false)
+ private void testConnection(LdapConfiguration config) throws NamingException {
+ LdapConnection conn = new LdapConnection(config);
+ Attributes attrs = conn.getInitialContext().getAttributes(BUGS_BUNNY_DN);
+ assertEquals(BUGS_BUNNY_CN, getStringAttrValue(attrs, "cn"));
+ }
+
+ @Test
+ public void testDefaultAuthenticationMethodIsInferred() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ config.setPrincipal(null);
+ LdapConnection conn = new LdapConnection(config);
+ assertEquals("none", \
conn.getInitialContext().getEnvironment().get(Context.SECURITY_AUTHENTICATION)); +
+ config = newConfiguration();
+ config.setPrincipal(ADMIN_DN);
+ config.setCredentials(ADMIN_PASSWORD);
+ conn = new LdapConnection(config);
+ assertEquals("simple", \
conn.getInitialContext().getEnvironment().get(Context.SECURITY_AUTHENTICATION)); + \
} +
+ @Test
+ public void testTest() {
+ LdapConfiguration config = newConfiguration();
+ config.setPort(4242);
+ LdapConnection conn = new LdapConnection(config);
+ try {
+ conn.test();
+ Assert.fail();
+ } catch (RuntimeException e) {
+ // Expected.
+ }
+
+ config = newConfiguration();
+ config.setHost("invalid");
+ conn = new LdapConnection(config);
+ try {
+ conn.test();
+ Assert.fail();
+ } catch (RuntimeException e) {
+ // Expected.
+ }
+
+ config = newConfiguration();
+ config.setPrincipal("uid=nobody");
+ conn = new LdapConnection(config);
+ try {
+ conn.test();
+ Assert.fail();
+ } catch (RuntimeException e) {
+ // Expected.
+ }
+
+ config = newConfiguration();
+ config.setCredentials(new GuardedString("bogus".toCharArray()));
+ conn = new LdapConnection(config);
+ try {
+ conn.test();
+ Assert.fail();
+ } catch (RuntimeException e) {
+ // Expected.
+ }
+
+ config = newConfiguration();
+ conn = new LdapConnection(config);
+ conn.test();
+ }
+
+ @Test
+ public void testCheckAlive() {
+ // Set readSchema to true since we are calling createNativeSchema() below, \
and we + // want to get the server schema, not the static one.
+ LdapConfiguration config = newConfiguration(true);
+ LdapConnection conn = new LdapConnection(config);
+ conn.checkAlive();
+ // Ensure the connection is really connected to the server.
+ conn.createNativeSchema();
+ conn.checkAlive();
+ stopServer();
+ try {
+ // This should throw RuntimeException.
+ conn.checkAlive();
+ Assert.fail();
+ } catch (RuntimeException e) {
+ // OK.
+ }
+ }
+
+ @Test
+ public void testSupportedControls() {
+ LdapConnection conn = new LdapConnection(newConfiguration());
+ assertTrue(conn.supportsControl(PagedResultsControl.OID));
+ assertTrue(conn.supportsControl(VirtualListViewRequestControl.OID));
+ }
+
+ @Test
+ public void testServerType() {
+ LdapConnection conn = new LdapConnection(newConfiguration());
+ assertEquals(ServerType.OPENDS, conn.getServerType());
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapConnectorTestBasejava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,271 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.Assert;
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.List;
-
-import org.identityconnectors.common.IOUtil;
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.api.APIConfiguration;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.api.ConnectorFacadeFactory;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeUtil;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.OperationOptions;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
-import org.identityconnectors.test.common.TestHelpers;
-import org.opends.server.config.ConfigException;
-import org.opends.server.types.DirectoryEnvironmentConfig;
-import org.opends.server.types.InitializationException;
-import org.opends.server.util.EmbeddedUtils;
-
-public abstract class LdapConnectorTestBase {
-
- // Cf. data.ldif and bigcompany.ldif.
-
- public static final int PORT = 2389;
- public static final int SSL_PORT = 2636;
-
- public static final String EXAMPLE_COM_DN = "dc=example,dc=com";
-
- public static final String ADMIN_DN = "uid=admin,dc=example,dc=com";
- public static final GuardedString ADMIN_PASSWORD = new \
GuardedString("password".toCharArray());
-
- public static final String ACME_DN = "o=Acme,dc=example,dc=com";
- public static final String ACME_O = "Acme";
-
- public static final String CZECH_REPUBLIC_DN = "c=Czech \
Republic,o=Acme,dc=example,dc=com";
- public static final String CZECH_REPUBLIC_C = "Czech Republic";
-
- public static final String ACME_USERS_DN = \
"ou=Users,o=Acme,dc=example,dc=com";
-
- public static final String BUGS_BUNNY_DN = \
"uid=bugs.bunny,ou=Users,o=Acme,dc=example,dc=com";
- public static final String BUGS_BUNNY_UID = "bugs.bunny";
- public static final String BBUNNY_UID = "bbunny";
- public static final String BUGS_BUNNY_CN = "Bugs Bunny";
- public static final String BUGS_BUNNY_SN = "Bunny";
- public static final String ELMER_FUDD_DN = \
"uid=elmer.fudd,ou=Users,o=Acme,dc=example,dc=com";
- public static final String ELMER_FUDD_UID = "elmer.fudd";
- public static final String SYLVESTER_DN = \
"uid=sylvester,ou=Users,o=Acme,dc=example,dc=com";
- public static final String SYLVESTER_UID = "sylvester";
- public static final String EXPIRED_UID = "expired";
-
- public static final String BUGS_AND_FRIENDS_DN = "cn=Bugs and \
Friends,o=Acme,dc=example,dc=com";
- public static final String EXTERNAL_PEERS_DN = "cn=External \
Peers,o=Acme,dc=example,dc=com";
-
- public static final String UNIQUE_BUGS_AND_FRIENDS_DN = "cn=Unique Bugs and \
Friends,o=Acme,dc=example,dc=com";
- public static final String UNIQUE_BUGS_AND_FRIENDS_CN = "Unique Bugs and \
Friends";
- public static final String UNIQUE_EXTERNAL_PEERS_DN = "cn=Unique External \
Peers,o=Acme,dc=example,dc=com";
- public static final String UNIQUE_EMPTY_GROUP_DN = "cn=Unique Empty \
Group,o=Acme,dc=example,dc=com";
-
- public static final String POSIX_BUGS_AND_FRIENDS_DN = "cn=POSIX Bugs and \
Friends,o=Acme,dc=example,dc=com";
- public static final String POSIX_EXTERNAL_PEERS_DN = "cn=POSIX External \
Peers,o=Acme,dc=example,dc=com";
- public static final String POSIX_EMPTY_GROUP_DN = "cn=POSIX Empty \
Group,o=Acme,dc=example,dc=com";
- public static final String POSIX_BUGS_BUNNY_GROUP = "cn=POSIX Bugs Bunny \
Group,o=Acme,dc=example,dc=com";
-
- public static final String SMALL_COMPANY_DN = "o=Small \
Company,dc=example,dc=com";
- public static final String SMALL_COMPANY_O = "Small Company";
- public static final String SINGLE_ACCOUNT_DN = "uid=single.account,o=Small \
Company,dc=example,dc=com";
- public static final String SINGLE_ACCOUNT_UID = "single.account";
- public static final String OWNER_DN = "cn=Owner,o=Small \
Company,dc=example,dc=com";
-
- public static final String BIG_COMPANY_DN = "o=Big \
Company,dc=example,dc=com";
- public static final String BIG_COMPANY_O = "Big Company";
- public static final String USER_0_DN = "uid=user.0,ou=People,o=Big \
Company,dc=example,dc=com";
- public static final String USER_0_UID = "user.0";
- public static final String USER_0_CN = "Aaccf Amar";
- public static final String USER_0_SN = "Amar";
- public static final String USER_0_GIVEN_NAME = "Aaccf";
-
- // Cf. test/opends/config/config.ldif and setup-test-opends.xml.
-
- private static final String[] FILES = {
- "config/config.ldif",
- "config/admin-backend.ldif",
- "config/keystore",
- "config/keystore.pin",
- "config/schema/00-core.ldif",
- "config/schema/01-pwpolicy.ldif",
- "config/schema/02-config.ldif",
- "config/schema/03-changelog.ldif",
- "config/schema/03-rfc2713.ldif",
- "config/schema/03-rfc2714.ldif",
- "config/schema/03-rfc2739.ldif",
- "config/schema/03-rfc2926.ldif",
- "config/schema/03-rfc3112.ldif",
- "config/schema/03-rfc3712.ldif",
- "config/schema/03-uddiv3.ldif",
- "config/schema/04-rfc2307bis.ldif",
- "db/userRoot/00000000.jdb"
- };
-
- @AfterClass
- public static void afterClass() {
- if (EmbeddedUtils.isRunning()) {
- stopServer();
- }
- }
-
- @BeforeMethod
- public void before() throws Exception {
- if (!EmbeddedUtils.isRunning()) {
- startServer();
- }
- }
-
- @AfterMethod
- public void after() throws Exception {
- if (restartServerAfterEachTest()) {
- stopServer();
- }
- }
-
- protected abstract boolean restartServerAfterEachTest();
-
- public static LdapConfiguration newConfiguration() {
- // IdM will not read the schema, so prefer to test with that setting.
- return newConfiguration(false);
- }
-
- public static LdapConfiguration newConfiguration(boolean readSchema) {
- LdapConfiguration config = new LdapConfiguration();
- // Cf. opends/config.ldif.
- config.setHost("localhost");
- config.setPort(PORT);
- config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
- config.setPrincipal(ADMIN_DN);
- config.setCredentials(ADMIN_PASSWORD);
- config.setReadSchema(readSchema);
- return config;
- }
-
- public static ConnectorFacade newFacade() {
- return newFacade(newConfiguration());
- }
-
- public static ConnectorFacade newFacade(LdapConfiguration cfg) {
- ConnectorFacadeFactory factory = ConnectorFacadeFactory.getInstance();
- APIConfiguration impl = \
TestHelpers.createTestConfiguration(LdapConnector.class, cfg);
- return factory.newInstance(impl);
- }
-
- public static ConnectorObject searchByAttribute(ConnectorFacade facade, \
ObjectClass oclass, Attribute attr) {
- return searchByAttribute(facade, oclass, attr, (OperationOptions) null);
- }
-
- public static ConnectorObject searchByAttribute(ConnectorFacade facade, \
ObjectClass oclass, Attribute attr, String... attributesToGet) {
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet(attributesToGet);
- return searchByAttribute(facade, oclass, attr, builder.build());
- }
-
- public static ConnectorObject searchByAttribute(ConnectorFacade facade, \
ObjectClass oclass, Attribute attr, OperationOptions options) {
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
oclass, FilterBuilder.equalTo(attr), options);
- return objects.size() > 0 ? objects.get(0) : null;
- }
-
- public static ConnectorObject findByAttribute(List<ConnectorObject> \
objects, String attrName, Object value) {
- for (ConnectorObject object : objects) {
- Attribute attr = object.getAttributeByName(attrName);
- if (attr != null) {
- Object attrValue = AttributeUtil.getSingleValue(attr);
- if (value.equals(attrValue)) {
- return object;
- }
- }
- }
- return null;
- }
-
- protected void startServer() throws IOException {
- File root = new File(System.getProperty("java.io.tmpdir"), \
"opends");
- IOUtil.delete(root);
- if (!root.mkdirs()) {
- throw new IOException();
- }
- for (String path : FILES) {
- File file = new File(root, path);
- File parent = file.getParentFile();
- if (!parent.exists() && !parent.mkdirs()) {
- throw new IOException(file.getAbsolutePath());
- }
- IOUtil.extractResourceToFile(LdapConnectorTestBase.class, \
"opends/" + path, file);
- }
-
- File configDir = new File(root, "config");
- File configFile = new File(configDir, "config.ldif");
- File schemaDir = new File(configDir, "schema");
- File lockDir = new File(root, "locks");
- if (!lockDir.mkdirs()) {
- throw new IOException();
- }
-
- try {
- DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
- config.setServerRoot(root);
- config.setConfigFile(configFile);
- config.setSchemaDirectory(schemaDir);
- config.setLockDirectory(lockDir);
- EmbeddedUtils.startServer(config);
- } catch (ConfigException e) {
- throw (IOException) new IOException(e.getMessage()).initCause(e);
- } catch (InitializationException e) {
- throw (IOException) new IOException(e.getMessage()).initCause(e);
- }
- }
-
- protected static void stopServer() {
- EmbeddedUtils.stopServer("org.test.opends.EmbeddedOpenDS", null);
- // It seems that EmbeddedUtils.stopServer() returns before the server has \
stopped listening on its port,
- // causing the next test to fail when starting the server.
- final int WAIT = 200; // ms
- final int ITERATIONS = 25;
- for (int i = 1; ; i++) {
- try {
- new Socket(InetAddress.getLocalHost(), PORT).close();
- } catch (IOException e) {
- // Okay, server has stopped.
- return;
- }
- if (i < ITERATIONS) {
- try {
- Thread.sleep(WAIT);
- } catch (InterruptedException e) {}
- } else {
- break;
- }
- }
- Assert.fail("OpenDS failed to stop");
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapConnecto \
rTestBasejavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapLdapConnectorTestBasejava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapConnectorTestBase.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,271 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.Assert;
+import java.io.File;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.util.List;
+
+import org.identityconnectors.common.IOUtil;
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.framework.api.APIConfiguration;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.api.ConnectorFacadeFactory;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeUtil;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
+import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
+import org.identityconnectors.test.common.TestHelpers;
+import org.opends.server.config.ConfigException;
+import org.opends.server.types.DirectoryEnvironmentConfig;
+import org.opends.server.types.InitializationException;
+import org.opends.server.util.EmbeddedUtils;
+
+public abstract class LdapConnectorTestBase {
+
+ // Cf. data.ldif and bigcompany.ldif.
+
+ public static final int PORT = 2389;
+ public static final int SSL_PORT = 2636;
+
+ public static final String EXAMPLE_COM_DN = "dc=example,dc=com";
+
+ public static final String ADMIN_DN = "uid=admin,dc=example,dc=com";
+ public static final GuardedString ADMIN_PASSWORD = new \
GuardedString("password".toCharArray()); +
+ public static final String ACME_DN = "o=Acme,dc=example,dc=com";
+ public static final String ACME_O = "Acme";
+
+ public static final String CZECH_REPUBLIC_DN = "c=Czech \
Republic,o=Acme,dc=example,dc=com"; + public static final String \
CZECH_REPUBLIC_C = "Czech Republic"; +
+ public static final String ACME_USERS_DN = \
"ou=Users,o=Acme,dc=example,dc=com"; +
+ public static final String BUGS_BUNNY_DN = \
"uid=bugs.bunny,ou=Users,o=Acme,dc=example,dc=com"; + public static \
final String BUGS_BUNNY_UID = "bugs.bunny"; + public static final String \
BBUNNY_UID = "bbunny"; + public static final String BUGS_BUNNY_CN = \
"Bugs Bunny"; + public static final String BUGS_BUNNY_SN = \
"Bunny"; + public static final String ELMER_FUDD_DN = \
"uid=elmer.fudd,ou=Users,o=Acme,dc=example,dc=com"; + public static \
final String ELMER_FUDD_UID = "elmer.fudd"; + public static final String \
SYLVESTER_DN = "uid=sylvester,ou=Users,o=Acme,dc=example,dc=com"; + \
public static final String SYLVESTER_UID = "sylvester"; + public static \
final String EXPIRED_UID = "expired"; +
+ public static final String BUGS_AND_FRIENDS_DN = "cn=Bugs and \
Friends,o=Acme,dc=example,dc=com"; + public static final String \
EXTERNAL_PEERS_DN = "cn=External Peers,o=Acme,dc=example,dc=com"; +
+ public static final String UNIQUE_BUGS_AND_FRIENDS_DN = "cn=Unique Bugs and \
Friends,o=Acme,dc=example,dc=com"; + public static final String \
UNIQUE_BUGS_AND_FRIENDS_CN = "Unique Bugs and Friends"; + public static \
final String UNIQUE_EXTERNAL_PEERS_DN = "cn=Unique External \
Peers,o=Acme,dc=example,dc=com"; + public static final String \
UNIQUE_EMPTY_GROUP_DN = "cn=Unique Empty Group,o=Acme,dc=example,dc=com"; +
+ public static final String POSIX_BUGS_AND_FRIENDS_DN = "cn=POSIX Bugs and \
Friends,o=Acme,dc=example,dc=com"; + public static final String \
POSIX_EXTERNAL_PEERS_DN = "cn=POSIX External \
Peers,o=Acme,dc=example,dc=com"; + public static final String \
POSIX_EMPTY_GROUP_DN = "cn=POSIX Empty Group,o=Acme,dc=example,dc=com"; + \
public static final String POSIX_BUGS_BUNNY_GROUP = "cn=POSIX Bugs Bunny \
Group,o=Acme,dc=example,dc=com"; +
+ public static final String SMALL_COMPANY_DN = "o=Small \
Company,dc=example,dc=com"; + public static final String SMALL_COMPANY_O = \
"Small Company"; + public static final String SINGLE_ACCOUNT_DN = \
"uid=single.account,o=Small Company,dc=example,dc=com"; + public static \
final String SINGLE_ACCOUNT_UID = "single.account"; + public static \
final String OWNER_DN = "cn=Owner,o=Small Company,dc=example,dc=com"; +
+ public static final String BIG_COMPANY_DN = "o=Big \
Company,dc=example,dc=com"; + public static final String BIG_COMPANY_O = \
"Big Company"; + public static final String USER_0_DN = \
"uid=user.0,ou=People,o=Big Company,dc=example,dc=com"; + public static \
final String USER_0_UID = "user.0"; + public static final String \
USER_0_CN = "Aaccf Amar"; + public static final String USER_0_SN = \
"Amar"; + public static final String USER_0_GIVEN_NAME = \
"Aaccf"; +
+ // Cf. test/opends/config/config.ldif and setup-test-opends.xml.
+
+ private static final String[] FILES = {
+ "config/config.ldif",
+ "config/admin-backend.ldif",
+ "config/keystore",
+ "config/keystore.pin",
+ "config/schema/00-core.ldif",
+ "config/schema/01-pwpolicy.ldif",
+ "config/schema/02-config.ldif",
+ "config/schema/03-changelog.ldif",
+ "config/schema/03-rfc2713.ldif",
+ "config/schema/03-rfc2714.ldif",
+ "config/schema/03-rfc2739.ldif",
+ "config/schema/03-rfc2926.ldif",
+ "config/schema/03-rfc3112.ldif",
+ "config/schema/03-rfc3712.ldif",
+ "config/schema/03-uddiv3.ldif",
+ "config/schema/04-rfc2307bis.ldif",
+ "db/userRoot/00000000.jdb"
+ };
+
+ @AfterClass
+ public static void afterClass() {
+ if (EmbeddedUtils.isRunning()) {
+ stopServer();
+ }
+ }
+
+ @BeforeMethod
+ public void before() throws Exception {
+ if (!EmbeddedUtils.isRunning()) {
+ startServer();
+ }
+ }
+
+ @AfterMethod
+ public void after() throws Exception {
+ if (restartServerAfterEachTest()) {
+ stopServer();
+ }
+ }
+
+ protected abstract boolean restartServerAfterEachTest();
+
+ public static LdapConfiguration newConfiguration() {
+ // IdM will not read the schema, so prefer to test with that setting.
+ return newConfiguration(false);
+ }
+
+ public static LdapConfiguration newConfiguration(boolean readSchema) {
+ LdapConfiguration config = new LdapConfiguration();
+ // Cf. opends/config.ldif.
+ config.setHost("localhost");
+ config.setPort(PORT);
+ config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
+ config.setPrincipal(ADMIN_DN);
+ config.setCredentials(ADMIN_PASSWORD);
+ config.setReadSchema(readSchema);
+ return config;
+ }
+
+ public static ConnectorFacade newFacade() {
+ return newFacade(newConfiguration());
+ }
+
+ public static ConnectorFacade newFacade(LdapConfiguration cfg) {
+ ConnectorFacadeFactory factory = ConnectorFacadeFactory.getInstance();
+ APIConfiguration impl = \
TestHelpers.createTestConfiguration(LdapConnector.class, cfg); + return \
factory.newInstance(impl); + }
+
+ public static ConnectorObject searchByAttribute(ConnectorFacade facade, \
ObjectClass oclass, Attribute attr) { + return searchByAttribute(facade, \
oclass, attr, (OperationOptions) null); + }
+
+ public static ConnectorObject searchByAttribute(ConnectorFacade facade, \
ObjectClass oclass, Attribute attr, String... attributesToGet) { + \
OperationOptionsBuilder builder = new OperationOptionsBuilder(); + \
builder.setAttributesToGet(attributesToGet); + return \
searchByAttribute(facade, oclass, attr, builder.build()); + }
+
+ public static ConnectorObject searchByAttribute(ConnectorFacade facade, \
ObjectClass oclass, Attribute attr, OperationOptions options) { + \
List<ConnectorObject> objects = TestHelpers.searchToList(facade, oclass, \
FilterBuilder.equalTo(attr), options); + return objects.size() > 0 ? \
objects.get(0) : null; + }
+
+ public static ConnectorObject findByAttribute(List<ConnectorObject> \
objects, String attrName, Object value) { + for (ConnectorObject object : \
objects) { + Attribute attr = object.getAttributeByName(attrName);
+ if (attr != null) {
+ Object attrValue = AttributeUtil.getSingleValue(attr);
+ if (value.equals(attrValue)) {
+ return object;
+ }
+ }
+ }
+ return null;
+ }
+
+ protected void startServer() throws IOException {
+ File root = new File(System.getProperty("java.io.tmpdir"), \
"opends"); + IOUtil.delete(root);
+ if (!root.mkdirs()) {
+ throw new IOException();
+ }
+ for (String path : FILES) {
+ File file = new File(root, path);
+ File parent = file.getParentFile();
+ if (!parent.exists() && !parent.mkdirs()) {
+ throw new IOException(file.getAbsolutePath());
+ }
+ IOUtil.extractResourceToFile(LdapConnectorTestBase.class, \
"opends/" + path, file); + }
+
+ File configDir = new File(root, "config");
+ File configFile = new File(configDir, "config.ldif");
+ File schemaDir = new File(configDir, "schema");
+ File lockDir = new File(root, "locks");
+ if (!lockDir.mkdirs()) {
+ throw new IOException();
+ }
+
+ try {
+ DirectoryEnvironmentConfig config = new DirectoryEnvironmentConfig();
+ config.setServerRoot(root);
+ config.setConfigFile(configFile);
+ config.setSchemaDirectory(schemaDir);
+ config.setLockDirectory(lockDir);
+ EmbeddedUtils.startServer(config);
+ } catch (ConfigException e) {
+ throw (IOException) new IOException(e.getMessage()).initCause(e);
+ } catch (InitializationException e) {
+ throw (IOException) new IOException(e.getMessage()).initCause(e);
+ }
+ }
+
+ protected static void stopServer() {
+ EmbeddedUtils.stopServer("org.test.opends.EmbeddedOpenDS", null);
+ // It seems that EmbeddedUtils.stopServer() returns before the server has \
stopped listening on its port, + // causing the next test to fail when \
starting the server. + final int WAIT = 200; // ms
+ final int ITERATIONS = 25;
+ for (int i = 1; ; i++) {
+ try {
+ new Socket(InetAddress.getLocalHost(), PORT).close();
+ } catch (IOException e) {
+ // Okay, server has stopped.
+ return;
+ }
+ if (i < ITERATIONS) {
+ try {
+ Thread.sleep(WAIT);
+ } catch (InterruptedException e) {}
+ } else {
+ break;
+ }
+ }
+ Assert.fail("OpenDS failed to stop");
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapEntryTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,48 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.Test;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-
-public class LdapEntryTests {
-
- @Test
- public void testEntryDNAttribute() throws Exception {
- final String NAME = "uid=admin";
- final String BASE = "dc=example,dc=com";
- final String ENTRY_DN = NAME + "," + BASE;
- final String OTHER_ENTRY_DN = "uid=nothing,dc=example,dc=com";
-
- BasicAttributes attrs = new BasicAttributes(false);
- attrs.put(new BasicAttribute("entryDN", OTHER_ENTRY_DN));
- attrs.put(new BasicAttribute("cn", "Common Name"));
- LdapEntry entry = LdapEntry.create(NAME + "," + BASE, attrs);
-
- assertEquals("Common Name", \
entry.getAttributes().get("cn").get());
- assertEquals(ENTRY_DN, entry.getAttributes().get("dn").get());
- assertEquals(ENTRY_DN, \
entry.getAttributes().get("entryDN").get());
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapLdapEntryTes \
tsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapLdapEntryTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/LdapEntryTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.Test;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+
+public class LdapEntryTests {
+
+ @Test
+ public void testEntryDNAttribute() throws Exception {
+ final String NAME = "uid=admin";
+ final String BASE = "dc=example,dc=com";
+ final String ENTRY_DN = NAME + "," + BASE;
+ final String OTHER_ENTRY_DN = "uid=nothing,dc=example,dc=com";
+
+ BasicAttributes attrs = new BasicAttributes(false);
+ attrs.put(new BasicAttribute("entryDN", OTHER_ENTRY_DN));
+ attrs.put(new BasicAttribute("cn", "Common Name"));
+ LdapEntry entry = LdapEntry.create(NAME + "," + BASE, attrs);
+
+ assertEquals("Common Name", \
entry.getAttributes().get("cn").get()); + assertEquals(ENTRY_DN, \
entry.getAttributes().get("dn").get()); + assertEquals(ENTRY_DN, \
entry.getAttributes().get("entryDN").get()); + }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapSunDSTestBasejava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,89 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap;
-
-import static java.util.Collections.reverse;
-import static java.util.Collections.sort;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.naming.NamingException;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
-import javax.naming.ldap.LdapName;
-
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.api.APIConfiguration;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.api.ConnectorFacadeFactory;
-import org.identityconnectors.ldap.search.DefaultSearchStrategy;
-import org.identityconnectors.ldap.search.LdapInternalSearch;
-import org.identityconnectors.ldap.search.LdapSearchResultsHandler;
-import org.identityconnectors.test.common.PropertyBag;
-import org.identityconnectors.test.common.TestHelpers;
-
-public class SunDSTestBase {
-
- public static LdapConfiguration newConfiguration() {
- LdapConfiguration config = new LdapConfiguration();
- config.setConnectorMessages(TestHelpers.createDummyMessages());
- PropertyBag testProps = TestHelpers.getProperties(LdapConnector.class);
- config.setHost(testProps.getStringProperty("sunds.host"));
- config.setPort(testProps.getProperty("sunds.port", Integer.class, \
389));
- config.setPrincipal(testProps.getStringProperty("sunds.principal"));
- config.setCredentials(testProps.getProperty("sunds.credentials", \
GuardedString.class));
- config.setBaseContexts(testProps.getStringProperty("sunds.baseContext"));
- config.setUidAttribute("entryDN");
- config.setReadSchema(false); // To be compatible with IdM.
- config.validate();
- return config;
- }
-
- public static void cleanupBaseContext(LdapConnection conn) throws \
NamingException {
- SearchControls controls = LdapInternalSearch.createDefaultSearchControls();
- controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- LdapInternalSearch search = new LdapInternalSearch(conn, null, \
Arrays.asList(conn.getConfiguration().getBaseContexts()),
- new DefaultSearchStrategy(false), controls);
- final List<LdapName> entryDNs = new ArrayList<LdapName>();
- search.execute(new LdapSearchResultsHandler() {
- public boolean handle(String baseDN, SearchResult result) throws \
NamingException {
- entryDNs.add(LdapEntry.create(baseDN, result).getDN());
- return true;
- }
- });
- entryDNs.removeAll(conn.getConfiguration().getBaseContextsAsLdapNames());
- sort(entryDNs);
- reverse(entryDNs); // Cf. LdapName.compareTo().
- for (LdapName entryDN : entryDNs) {
- conn.getInitialContext().destroySubcontext(entryDN);
- }
- }
-
- public static ConnectorFacade newFacade(LdapConfiguration cfg) {
- ConnectorFacadeFactory factory = ConnectorFacadeFactory.getInstance();
- APIConfiguration impl = \
TestHelpers.createTestConfiguration(LdapConnector.class, cfg);
- return factory.newInstance(impl);
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapSunDSTestBas \
ejavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapSunDSTestBasejava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/SunDSTestBase.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap;
+
+import static java.util.Collections.reverse;
+import static java.util.Collections.sort;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapName;
+
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.framework.api.APIConfiguration;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.api.ConnectorFacadeFactory;
+import org.identityconnectors.ldap.search.DefaultSearchStrategy;
+import org.identityconnectors.ldap.search.LdapInternalSearch;
+import org.identityconnectors.ldap.search.LdapSearchResultsHandler;
+import org.identityconnectors.test.common.PropertyBag;
+import org.identityconnectors.test.common.TestHelpers;
+
+public class SunDSTestBase {
+
+ public static LdapConfiguration newConfiguration() {
+ LdapConfiguration config = new LdapConfiguration();
+ config.setConnectorMessages(TestHelpers.createDummyMessages());
+ PropertyBag testProps = TestHelpers.getProperties(LdapConnector.class);
+ config.setHost(testProps.getStringProperty("sunds.host"));
+ config.setPort(testProps.getProperty("sunds.port", Integer.class, \
389)); + config.setPrincipal(testProps.getStringProperty("sunds.principal"));
+ config.setCredentials(testProps.getProperty("sunds.credentials", \
GuardedString.class)); + \
config.setBaseContexts(testProps.getStringProperty("sunds.baseContext")); + \
config.setUidAttribute("entryDN"); + config.setReadSchema(false); // \
To be compatible with IdM. + config.validate();
+ return config;
+ }
+
+ public static void cleanupBaseContext(LdapConnection conn) throws \
NamingException { + SearchControls controls = \
LdapInternalSearch.createDefaultSearchControls(); + \
controls.setSearchScope(SearchControls.SUBTREE_SCOPE); + LdapInternalSearch \
search = new LdapInternalSearch(conn, null, \
Arrays.asList(conn.getConfiguration().getBaseContexts()), + new \
DefaultSearchStrategy(false), controls); + final List<LdapName> entryDNs \
= new ArrayList<LdapName>(); + search.execute(new \
LdapSearchResultsHandler() { + public boolean handle(String baseDN, \
SearchResult result) throws NamingException { + \
entryDNs.add(LdapEntry.create(baseDN, result).getDN()); + return true;
+ }
+ });
+ entryDNs.removeAll(conn.getConfiguration().getBaseContextsAsLdapNames());
+ sort(entryDNs);
+ reverse(entryDNs); // Cf. LdapName.compareTo().
+ for (LdapName entryDN : entryDNs) {
+ conn.getInitialContext().destroySubcontext(entryDN);
+ }
+ }
+
+ public static ConnectorFacade newFacade(LdapConfiguration cfg) {
+ ConnectorFacadeFactory factory = ConnectorFacadeFactory.getInstance();
+ APIConfiguration impl = \
TestHelpers.createTestConfiguration(LdapConnector.class, cfg); + return \
factory.newInstance(impl); + }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodifyLdapCreateTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,230 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.modify;
-
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.identityconnectors.common.IOUtil;
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.Uid;
-import org.identityconnectors.ldap.LdapConfiguration;
-import org.identityconnectors.ldap.LdapConnectorTestBase;
-
-public class LdapCreateTests extends LdapConnectorTestBase{
-
- // TODO test that we can create an entry of an object class not in the schema.
- // TODO test that we can't create an entry outside the configured base DNs.
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return true;
- }
-
- @Test
- public void testCreateAccount() {
- LdapConfiguration config = newConfiguration();
- config.setBaseContexts(SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- doCreateAccount(facade);
- }
-
- @Test
- public void testCreateAccountWhenReadingSchema() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.isReadSchema());
- config.setReadSchema(true);
- config.setBaseContexts(SMALL_COMPANY_DN);
- config.setAccountObjectClasses("inetOrgPerson");
- ConnectorFacade facade = newFacade(config);
-
- doCreateAccount(facade);
- }
-
- @Test
- public void testCreateAccountWhenUidNotDefault() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
- config.setUidAttribute("entryDN");
- config.setBaseContexts(SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- doCreateAccount(facade);
- }
-
- private void doCreateAccount(ConnectorFacade facade) {
- Set<Attribute> attributes = new HashSet<Attribute>();
- Name name = new Name("uid=another.worker," + SMALL_COMPANY_DN);
- attributes.add(name);
- attributes.add(AttributeBuilder.build("uid", \
"another.worker"));
- attributes.add(AttributeBuilder.build("cn", "Another \
Worker"));
- attributes.add(AttributeBuilder.build("givenName", \
"Another"));
- attributes.add(AttributeBuilder.build("sn", "Worker"));
- Uid uid = facade.create(ObjectClass.ACCOUNT, attributes, null);
-
- ConnectorObject newAccount = facade.getObject(ObjectClass.ACCOUNT, uid, \
null);
- assertEquals(name, newAccount.getName());
- }
-
- @Test
- public void testCreateGroup() {
- LdapConfiguration config = newConfiguration();
- config.setBaseContexts(SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- doCreateGroup(facade);
- }
-
- @Test
- public void testCreateGroupWhenReadingSchema() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.isReadSchema());
- config.setReadSchema(true);
- config.setBaseContexts(SMALL_COMPANY_DN);
- config.setAccountObjectClasses("inetOrgPerson");
- ConnectorFacade facade = newFacade(config);
-
- doCreateGroup(facade);
- }
-
- @Test
- public void testCreateGroupWhenUidNotDefault() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
- config.setUidAttribute("entryDN");
- config.setBaseContexts(SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- doCreateGroup(facade);
- }
-
- private void doCreateGroup(ConnectorFacade facade) {
- Set<Attribute> attributes = new HashSet<Attribute>();
- Name name = new Name("cn=Another Group," + SMALL_COMPANY_DN);
- attributes.add(name);
- attributes.add(AttributeBuilder.build("cn", "Another \
Group"));
- Uid uid = facade.create(ObjectClass.GROUP, attributes, null);
-
- ConnectorObject newGroup = facade.getObject(ObjectClass.GROUP, uid, null);
- assertEquals(name, newGroup.getName());
- }
-
- @Test
- public void testCreateArbitrary() {
- LdapConfiguration config = newConfiguration();
- config.setBaseContexts(SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- doCreateArbitrary(facade);
- }
-
- @Test
- public void testCreateArbitraryWhenReadingSchema() {
- LdapConfiguration config = newConfiguration(true);
- config.setBaseContexts(SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- doCreateArbitrary(facade);
- }
-
- @Test
- public void testCreateArbitraryWhenUidNotDefault() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
- config.setUidAttribute("entryDN");
- config.setBaseContexts(SMALL_COMPANY_DN);
- ConnectorFacade facade = newFacade(config);
-
- doCreateArbitrary(facade);
- }
-
- private void doCreateArbitrary(ConnectorFacade facade) {
- // Let the arbitrary object class be organization.
- Set<Attribute> attributes = new HashSet<Attribute>();
- Name name = new Name("o=Smallest," + SMALL_COMPANY_DN);
- attributes.add(name);
- attributes.add(AttributeBuilder.build("o", "Smallest"));
- ObjectClass oclass = new ObjectClass("organization");
- Uid uid = facade.create(oclass, attributes, null);
-
- ConnectorObject newObject = facade.getObject(oclass, uid, null);
- assertEquals(name, newObject.getName());
- }
-
- @Test
- public void testCreateBinaryAttributes() throws IOException {
- ConnectorFacade facade = newFacade();
-
- Set<Attribute> attributes = new HashSet<Attribute>();
- attributes.add(new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com"));
- attributes.add(AttributeBuilder.build("uid", \
"daffy.duck"));
- attributes.add(AttributeBuilder.build("cn", "Daffy \
Duck"));
- attributes.add(AttributeBuilder.build("givenName", \
"Daffy"));
- attributes.add(AttributeBuilder.build("sn", "Duck"));
- byte[] certificate = IOUtil.getResourceAsBytes(LdapCreateTests.class, \
"certificate.cert");
- attributes.add(AttributeBuilder.build("userCertificate", \
certificate));
- byte[] photo = IOUtil.getResourceAsBytes(LdapCreateTests.class, \
"photo.jpg");
- attributes.add(AttributeBuilder.build("jpegPhoto", photo));
- Uid uid = facade.create(ObjectClass.ACCOUNT, attributes, null);
-
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("userCertificate", \
"jpegPhoto");
-
- ConnectorObject newAccount = facade.getObject(ObjectClass.ACCOUNT, uid, \
builder.build());
- byte[] storedCertificate = (byte[]) \
newAccount.getAttributeByName("userCertificate").getValue().get(0);
- assertTrue(Arrays.equals(certificate, storedCertificate));
- byte[] storedPhoto = (byte[]) \
newAccount.getAttributeByName("jpegPhoto").getValue().get(0);
- assertTrue(Arrays.equals(photo, storedPhoto));
- }
-
- @Test
- public void testCreatePassword() {
- ConnectorFacade facade = newFacade();
-
- Set<Attribute> attributes = new HashSet<Attribute>();
- attributes.add(new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com"));
- attributes.add(AttributeBuilder.build("uid", \
"daffy.duck"));
- attributes.add(AttributeBuilder.build("cn", "Daffy \
Duck"));
- attributes.add(AttributeBuilder.build("givenName", \
"Daffy"));
- attributes.add(AttributeBuilder.build("sn", "Duck"));
- GuardedString password = new \
GuardedString("I.hate.rabbits".toCharArray());
- attributes.add(AttributeBuilder.buildPassword(password));
- facade.create(ObjectClass.ACCOUNT, attributes, null);
-
- facade.authenticate(ObjectClass.ACCOUNT, "daffy.duck", password, \
null);
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodifyLdapCr \
eateTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapmodifyLdapCreateTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapCreateTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,230 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.modify;
+
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.identityconnectors.common.IOUtil;
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.ldap.LdapConfiguration;
+import org.identityconnectors.ldap.LdapConnectorTestBase;
+
+public class LdapCreateTests extends LdapConnectorTestBase{
+
+ // TODO test that we can create an entry of an object class not in the schema.
+ // TODO test that we can't create an entry outside the configured base DNs.
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return true;
+ }
+
+ @Test
+ public void testCreateAccount() {
+ LdapConfiguration config = newConfiguration();
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateAccount(facade);
+ }
+
+ @Test
+ public void testCreateAccountWhenReadingSchema() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.isReadSchema());
+ config.setReadSchema(true);
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ config.setAccountObjectClasses("inetOrgPerson");
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateAccount(facade);
+ }
+
+ @Test
+ public void testCreateAccountWhenUidNotDefault() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
+ config.setUidAttribute("entryDN");
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateAccount(facade);
+ }
+
+ private void doCreateAccount(ConnectorFacade facade) {
+ Set<Attribute> attributes = new HashSet<Attribute>();
+ Name name = new Name("uid=another.worker," + SMALL_COMPANY_DN);
+ attributes.add(name);
+ attributes.add(AttributeBuilder.build("uid", \
"another.worker")); + \
attributes.add(AttributeBuilder.build("cn", "Another Worker")); + \
attributes.add(AttributeBuilder.build("givenName", "Another")); + \
attributes.add(AttributeBuilder.build("sn", "Worker")); + \
Uid uid = facade.create(ObjectClass.ACCOUNT, attributes, null); +
+ ConnectorObject newAccount = facade.getObject(ObjectClass.ACCOUNT, uid, \
null); + assertEquals(name, newAccount.getName());
+ }
+
+ @Test
+ public void testCreateGroup() {
+ LdapConfiguration config = newConfiguration();
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateGroup(facade);
+ }
+
+ @Test
+ public void testCreateGroupWhenReadingSchema() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.isReadSchema());
+ config.setReadSchema(true);
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ config.setAccountObjectClasses("inetOrgPerson");
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateGroup(facade);
+ }
+
+ @Test
+ public void testCreateGroupWhenUidNotDefault() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
+ config.setUidAttribute("entryDN");
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateGroup(facade);
+ }
+
+ private void doCreateGroup(ConnectorFacade facade) {
+ Set<Attribute> attributes = new HashSet<Attribute>();
+ Name name = new Name("cn=Another Group," + SMALL_COMPANY_DN);
+ attributes.add(name);
+ attributes.add(AttributeBuilder.build("cn", "Another \
Group")); + Uid uid = facade.create(ObjectClass.GROUP, attributes, null);
+
+ ConnectorObject newGroup = facade.getObject(ObjectClass.GROUP, uid, null);
+ assertEquals(name, newGroup.getName());
+ }
+
+ @Test
+ public void testCreateArbitrary() {
+ LdapConfiguration config = newConfiguration();
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateArbitrary(facade);
+ }
+
+ @Test
+ public void testCreateArbitraryWhenReadingSchema() {
+ LdapConfiguration config = newConfiguration(true);
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateArbitrary(facade);
+ }
+
+ @Test
+ public void testCreateArbitraryWhenUidNotDefault() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
+ config.setUidAttribute("entryDN");
+ config.setBaseContexts(SMALL_COMPANY_DN);
+ ConnectorFacade facade = newFacade(config);
+
+ doCreateArbitrary(facade);
+ }
+
+ private void doCreateArbitrary(ConnectorFacade facade) {
+ // Let the arbitrary object class be organization.
+ Set<Attribute> attributes = new HashSet<Attribute>();
+ Name name = new Name("o=Smallest," + SMALL_COMPANY_DN);
+ attributes.add(name);
+ attributes.add(AttributeBuilder.build("o", "Smallest"));
+ ObjectClass oclass = new ObjectClass("organization");
+ Uid uid = facade.create(oclass, attributes, null);
+
+ ConnectorObject newObject = facade.getObject(oclass, uid, null);
+ assertEquals(name, newObject.getName());
+ }
+
+ @Test
+ public void testCreateBinaryAttributes() throws IOException {
+ ConnectorFacade facade = newFacade();
+
+ Set<Attribute> attributes = new HashSet<Attribute>();
+ attributes.add(new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com")); + \
attributes.add(AttributeBuilder.build("uid", "daffy.duck")); + \
attributes.add(AttributeBuilder.build("cn", "Daffy Duck")); + \
attributes.add(AttributeBuilder.build("givenName", "Daffy")); + \
attributes.add(AttributeBuilder.build("sn", "Duck")); + \
byte[] certificate = IOUtil.getResourceAsBytes(LdapCreateTests.class, \
"certificate.cert"); + \
attributes.add(AttributeBuilder.build("userCertificate", certificate)); + \
byte[] photo = IOUtil.getResourceAsBytes(LdapCreateTests.class, \
"photo.jpg"); + \
attributes.add(AttributeBuilder.build("jpegPhoto", photo)); + Uid \
uid = facade.create(ObjectClass.ACCOUNT, attributes, null); +
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("userCertificate", \
"jpegPhoto"); +
+ ConnectorObject newAccount = facade.getObject(ObjectClass.ACCOUNT, uid, \
builder.build()); + byte[] storedCertificate = (byte[]) \
newAccount.getAttributeByName("userCertificate").getValue().get(0); + \
assertTrue(Arrays.equals(certificate, storedCertificate)); + byte[] \
storedPhoto = (byte[]) \
newAccount.getAttributeByName("jpegPhoto").getValue().get(0); + \
assertTrue(Arrays.equals(photo, storedPhoto)); + }
+
+ @Test
+ public void testCreatePassword() {
+ ConnectorFacade facade = newFacade();
+
+ Set<Attribute> attributes = new HashSet<Attribute>();
+ attributes.add(new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com")); + \
attributes.add(AttributeBuilder.build("uid", "daffy.duck")); + \
attributes.add(AttributeBuilder.build("cn", "Daffy Duck")); + \
attributes.add(AttributeBuilder.build("givenName", "Daffy")); + \
attributes.add(AttributeBuilder.build("sn", "Duck")); + \
GuardedString password = new GuardedString("I.hate.rabbits".toCharArray()); \
+ attributes.add(AttributeBuilder.buildPassword(password)); + \
facade.create(ObjectClass.ACCOUNT, attributes, null); +
+ facade.authenticate(ObjectClass.ACCOUNT, "daffy.duck", password, \
null); + }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodifyLdapDeleteTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,68 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.modify;
-
-import static org.testng.AssertJUnit.assertNull;
-import org.testng.annotations.Test;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.common.exceptions.ConnectorException;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.ldap.LdapConnectorTestBase;
-
-public class LdapDeleteTests extends LdapConnectorTestBase{
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return false;
- }
-
- @Test(expectedExceptions = ConnectorException.class)
- public void testCannotDeleteExistingUidButWrongObjectClass() {
- ConnectorFacade facade = newFacade();
- ConnectorObject organization = searchByAttribute(facade, new \
ObjectClass("organization"), new Name(BIG_COMPANY_DN));
- // Should fail because the object class passed to delete() is not \
ORGANIZATION.
- facade.delete(ObjectClass.ACCOUNT, organization.getUid(), null);
- }
-
- @Test(expectedExceptions = ConnectorException.class)
- public void testCannotDeleteNonEmptyDN() {
- // TODO: not sure this is the right behavior. Perhaps should instead
- // recursively delete everything under the deleted entry.
- ConnectorFacade facade = newFacade();
- ObjectClass oclass = new ObjectClass("organization");
- ConnectorObject organization = searchByAttribute(facade, oclass, new \
Name(ACME_DN));
- facade.delete(oclass, organization.getUid(), null);
- }
-
- @Test()
- public void testDelete() {
- ConnectorFacade facade = newFacade();
- ConnectorObject account = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- facade.delete(ObjectClass.ACCOUNT, account.getUid(), null);
-
- account = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- assertNull(account);
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodifyLdapDe \
leteTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapmodifyLdapDeleteTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapDeleteTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.modify;
+
+import static org.testng.AssertJUnit.assertNull;
+import org.testng.annotations.Test;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.exceptions.ConnectorException;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.ldap.LdapConnectorTestBase;
+
+public class LdapDeleteTests extends LdapConnectorTestBase{
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return false;
+ }
+
+ @Test(expectedExceptions = ConnectorException.class)
+ public void testCannotDeleteExistingUidButWrongObjectClass() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject organization = searchByAttribute(facade, new \
ObjectClass("organization"), new Name(BIG_COMPANY_DN)); + // Should \
fail because the object class passed to delete() is not ORGANIZATION. + \
facade.delete(ObjectClass.ACCOUNT, organization.getUid(), null); + }
+
+ @Test(expectedExceptions = ConnectorException.class)
+ public void testCannotDeleteNonEmptyDN() {
+ // TODO: not sure this is the right behavior. Perhaps should instead
+ // recursively delete everything under the deleted entry.
+ ConnectorFacade facade = newFacade();
+ ObjectClass oclass = new ObjectClass("organization");
+ ConnectorObject organization = searchByAttribute(facade, oclass, new \
Name(ACME_DN)); + facade.delete(oclass, organization.getUid(), null);
+ }
+
+ @Test()
+ public void testDelete() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject account = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + facade.delete(ObjectClass.ACCOUNT, account.getUid(), \
null); +
+ account = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + assertNull(account);
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodifyLdapUpdateTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,211 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.modify;
-
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import static java.util.Collections.singleton;
-import static org.identityconnectors.common.CollectionUtil.newSet;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.identityconnectors.common.IOUtil;
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.OperationOptions;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.Uid;
-import org.identityconnectors.ldap.LdapConfiguration;
-import org.identityconnectors.ldap.LdapConnectorTestBase;
-import org.identityconnectors.test.common.TestHelpers;
-
-public class LdapUpdateTests extends LdapConnectorTestBase {
-
- // XXX need tests for the case when the one of the modified (or removed)
- // attribute is the Name or especially Uid.
-
- private static final String NUMBER1 = "+1 800 123 4567";
- private static final String NUMBER2 = "+1 800 765 4321";
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return true;
- }
-
- @Test
- public void testSimpleAddRemoveAttrs() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
-
- Attribute number1 = AttributeBuilder.build("telephoneNumber", \
NUMBER1);
-
- Uid newUid = facade.addAttributeValues(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(number1), null);
-
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("telephoneNumber");
- OperationOptions options = builder.build();
-
- bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, options);
- List<Object> numberAttr = \
bugs.getAttributeByName("telephoneNumber").getValue();
- assertEquals(NUMBER1, numberAttr.get(0));
- assertEquals(1, numberAttr.size());
-
- Attribute number2 = AttributeBuilder.build("telephoneNumber", \
NUMBER2);
- newUid = facade.addAttributeValues(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(number2), null);
-
- bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, options);
- numberAttr = \
bugs.getAttributeByName("telephoneNumber").getValue();
- assertEquals(NUMBER1, numberAttr.get(0));
- assertEquals(NUMBER2, numberAttr.get(1));
- assertEquals(2, numberAttr.size());
-
- newUid = facade.removeAttributeValues(ObjectClass.ACCOUNT, bugs.getUid(), \
newSet(number1, number2), null);
-
- bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, options);
- assertTrue(bugs.getAttributeByName("telephoneNumber").getValue().isEmpty());
- }
-
- @Test
- public void testRename() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
-
- Name name = new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com");
- Attribute number = AttributeBuilder.build("telephoneNumber", \
NUMBER1);
- Uid newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), newSet(name, \
number), null);
-
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("telephoneNumber");
-
- ConnectorObject daffy = facade.getObject(ObjectClass.ACCOUNT, newUid, \
builder.build());
- assertEquals(name, daffy.getName());
- assertEquals(NUMBER1, \
daffy.getAttributeByName("telephoneNumber").getValue().get(0));
- }
-
- @Test
- public void testRenameWhenUidNotDefault() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
- config.setUidAttribute("entryDN");
- ConnectorFacade facade = newFacade(config);
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
-
- Name name = new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com");
- Uid newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton((Attribute) name), null);
-
- assertEquals(name.getNameValue(), newUid.getUidValue()); // Since they are \
both the entry DN.
- ConnectorObject daffy = facade.getObject(ObjectClass.ACCOUNT, newUid, null);
- assertEquals(name, daffy.getName());
- }
-
- @Test
- public void testEmptyAttributeValueRemovesAttribute() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
-
- Attribute number = AttributeBuilder.build("telephoneNumber", \
NUMBER1);
- Uid newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(number), null);
-
- Attribute noNumber = AttributeBuilder.build("telephoneNumber");
- assertNull(noNumber.getValue());
- newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(noNumber), null);
-
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("telephoneNumber");
-
- bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, builder.build());
- assertTrue(bugs.getAttributeByName("telephoneNumber").getValue().isEmpty());
- }
-
- @Test
- public void testUpdateBinaryAttributes() throws IOException {
- ConnectorFacade facade = newFacade();
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
-
- byte[] certificate = IOUtil.getResourceAsBytes(LdapUpdateTests.class, \
"certificate.cert");
- Attribute certAttr = AttributeBuilder.build("userCertificate", \
certificate);
- Uid newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(certAttr), null);
-
- byte[] photo = IOUtil.getResourceAsBytes(LdapUpdateTests.class, \
"photo.jpg");
- Attribute photoAttr = AttributeBuilder.build("jpegPhoto", photo);
- newUid = facade.addAttributeValues(ObjectClass.ACCOUNT, newUid, \
singleton(photoAttr), null);
-
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("userCertificate", \
"jpegPhoto");
-
- bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, builder.build());
- byte[] storedCertificate = (byte[]) \
bugs.getAttributeByName("userCertificate").getValue().get(0);
- assertTrue(Arrays.equals(certificate, storedCertificate));
- byte[] storedPhoto = (byte[]) \
bugs.getAttributeByName("jpegPhoto").getValue().get(0);
- assertTrue(Arrays.equals(photo, storedPhoto));
- }
-
- @Test
- public void testAdminCanChangePassword() {
- ConnectorFacade facade = newFacade();
- ConnectorObject elmer = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(ELMER_FUDD_DN));
-
- GuardedString password = new \
GuardedString("shotgun".toCharArray());
- Attribute pwdAttr = AttributeBuilder.buildPassword(password);
- facade.update(ObjectClass.ACCOUNT, elmer.getUid(), singleton(pwdAttr), \
null);
-
- // Now test that the user can login with the new password and execute an \
operation.
- LdapConfiguration config = newConfiguration();
- config.setPrincipal(ELMER_FUDD_DN);
- config.setCredentials(password);
- config.setUseBlocks(false); // Do not use block (paged, VLV) search, since \
the user doesn't have the privilege.
- facade = newFacade(config);
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, new \
ObjectClass("organization"), null);
- assertNotNull(findByAttribute(objects, Name.NAME, ACME_DN));
- }
-
- @Test
- public void testUserCanChangePassword() {
- LdapConfiguration config = newConfiguration();
- config.setPrincipal(BUGS_BUNNY_DN);
- config.setCredentials(new GuardedString("carrot".toCharArray()));
- config.setUseBlocks(false); // Do not use paged search, since the user \
doesn't have the privilege.
- ConnectorFacade facade = newFacade(config);
- ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
-
- GuardedString password = new \
GuardedString("cabbage".toCharArray());
- Attribute pwdAttr = AttributeBuilder.buildPassword(password);
- facade.update(ObjectClass.ACCOUNT, bugs.getUid(), singleton(pwdAttr), null);
-
- // Now test that the user can login with the new password and execute an \
operation.
- config.setCredentials(password);
- facade = newFacade(config);
- ConnectorObject elmer = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(ELMER_FUDD_DN));
- assertNotNull(elmer);
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapmodifyLdapUp \
dateTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapmodifyLdapUpdateTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/modify/LdapUpdateTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,211 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.modify;
+
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import static java.util.Collections.singleton;
+import static org.identityconnectors.common.CollectionUtil.newSet;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.identityconnectors.common.IOUtil;
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.ldap.LdapConfiguration;
+import org.identityconnectors.ldap.LdapConnectorTestBase;
+import org.identityconnectors.test.common.TestHelpers;
+
+public class LdapUpdateTests extends LdapConnectorTestBase {
+
+ // XXX need tests for the case when the one of the modified (or removed)
+ // attribute is the Name or especially Uid.
+
+ private static final String NUMBER1 = "+1 800 123 4567";
+ private static final String NUMBER2 = "+1 800 765 4321";
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return true;
+ }
+
+ @Test
+ public void testSimpleAddRemoveAttrs() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); +
+ Attribute number1 = AttributeBuilder.build("telephoneNumber", \
NUMBER1); +
+ Uid newUid = facade.addAttributeValues(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(number1), null); +
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("telephoneNumber");
+ OperationOptions options = builder.build();
+
+ bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, options);
+ List<Object> numberAttr = \
bugs.getAttributeByName("telephoneNumber").getValue(); + \
assertEquals(NUMBER1, numberAttr.get(0)); + assertEquals(1, \
numberAttr.size()); +
+ Attribute number2 = AttributeBuilder.build("telephoneNumber", \
NUMBER2); + newUid = facade.addAttributeValues(ObjectClass.ACCOUNT, \
bugs.getUid(), singleton(number2), null); +
+ bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, options);
+ numberAttr = \
bugs.getAttributeByName("telephoneNumber").getValue(); + \
assertEquals(NUMBER1, numberAttr.get(0)); + assertEquals(NUMBER2, \
numberAttr.get(1)); + assertEquals(2, numberAttr.size());
+
+ newUid = facade.removeAttributeValues(ObjectClass.ACCOUNT, bugs.getUid(), \
newSet(number1, number2), null); +
+ bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, options);
+ assertTrue(bugs.getAttributeByName("telephoneNumber").getValue().isEmpty());
+ }
+
+ @Test
+ public void testRename() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); +
+ Name name = new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com"); + \
Attribute number = AttributeBuilder.build("telephoneNumber", NUMBER1); + \
Uid newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), newSet(name, number), \
null); +
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("telephoneNumber");
+
+ ConnectorObject daffy = facade.getObject(ObjectClass.ACCOUNT, newUid, \
builder.build()); + assertEquals(name, daffy.getName());
+ assertEquals(NUMBER1, \
daffy.getAttributeByName("telephoneNumber").getValue().get(0)); + }
+
+ @Test
+ public void testRenameWhenUidNotDefault() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
+ config.setUidAttribute("entryDN");
+ ConnectorFacade facade = newFacade(config);
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); +
+ Name name = new \
Name("uid=daffy.duck,ou=Users,o=Acme,dc=example,dc=com"); + Uid \
newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), singleton((Attribute) \
name), null); +
+ assertEquals(name.getNameValue(), newUid.getUidValue()); // Since they are \
both the entry DN. + ConnectorObject daffy = \
facade.getObject(ObjectClass.ACCOUNT, newUid, null); + assertEquals(name, \
daffy.getName()); + }
+
+ @Test
+ public void testEmptyAttributeValueRemovesAttribute() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); +
+ Attribute number = AttributeBuilder.build("telephoneNumber", \
NUMBER1); + Uid newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(number), null); +
+ Attribute noNumber = AttributeBuilder.build("telephoneNumber");
+ assertNull(noNumber.getValue());
+ newUid = facade.update(ObjectClass.ACCOUNT, bugs.getUid(), \
singleton(noNumber), null); +
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("telephoneNumber");
+
+ bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, builder.build());
+ assertTrue(bugs.getAttributeByName("telephoneNumber").getValue().isEmpty());
+ }
+
+ @Test
+ public void testUpdateBinaryAttributes() throws IOException {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); +
+ byte[] certificate = IOUtil.getResourceAsBytes(LdapUpdateTests.class, \
"certificate.cert"); + Attribute certAttr = \
AttributeBuilder.build("userCertificate", certificate); + Uid newUid \
= facade.update(ObjectClass.ACCOUNT, bugs.getUid(), singleton(certAttr), null); +
+ byte[] photo = IOUtil.getResourceAsBytes(LdapUpdateTests.class, \
"photo.jpg"); + Attribute photoAttr = \
AttributeBuilder.build("jpegPhoto", photo); + newUid = \
facade.addAttributeValues(ObjectClass.ACCOUNT, newUid, singleton(photoAttr), null); +
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("userCertificate", \
"jpegPhoto"); +
+ bugs = facade.getObject(ObjectClass.ACCOUNT, newUid, builder.build());
+ byte[] storedCertificate = (byte[]) \
bugs.getAttributeByName("userCertificate").getValue().get(0); + \
assertTrue(Arrays.equals(certificate, storedCertificate)); + byte[] \
storedPhoto = (byte[]) \
bugs.getAttributeByName("jpegPhoto").getValue().get(0); + \
assertTrue(Arrays.equals(photo, storedPhoto)); + }
+
+ @Test
+ public void testAdminCanChangePassword() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject elmer = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(ELMER_FUDD_DN)); +
+ GuardedString password = new \
GuardedString("shotgun".toCharArray()); + Attribute pwdAttr = \
AttributeBuilder.buildPassword(password); + facade.update(ObjectClass.ACCOUNT, \
elmer.getUid(), singleton(pwdAttr), null); +
+ // Now test that the user can login with the new password and execute an \
operation. + LdapConfiguration config = newConfiguration();
+ config.setPrincipal(ELMER_FUDD_DN);
+ config.setCredentials(password);
+ config.setUseBlocks(false); // Do not use block (paged, VLV) search, since \
the user doesn't have the privilege. + facade = newFacade(config);
+ List<ConnectorObject> objects = TestHelpers.searchToList(facade, new \
ObjectClass("organization"), null); + \
assertNotNull(findByAttribute(objects, Name.NAME, ACME_DN)); + }
+
+ @Test
+ public void testUserCanChangePassword() {
+ LdapConfiguration config = newConfiguration();
+ config.setPrincipal(BUGS_BUNNY_DN);
+ config.setCredentials(new GuardedString("carrot".toCharArray()));
+ config.setUseBlocks(false); // Do not use paged search, since the user \
doesn't have the privilege. + ConnectorFacade facade = newFacade(config);
+ ConnectorObject bugs = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); +
+ GuardedString password = new \
GuardedString("cabbage".toCharArray()); + Attribute pwdAttr = \
AttributeBuilder.buildPassword(password); + facade.update(ObjectClass.ACCOUNT, \
bugs.getUid(), singleton(pwdAttr), null); +
+ // Now test that the user can login with the new password and execute an \
operation. + config.setCredentials(password);
+ facade = newFacade(config);
+ ConnectorObject elmer = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(ELMER_FUDD_DN)); + assertNotNull(elmer);
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapschemaGuardedPasswordAttributeTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,73 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.schema;
-
-import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.Test;
-import java.io.UnsupportedEncodingException;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.ldap.schema.GuardedPasswordAttribute.Accessor;
-
-public class GuardedPasswordAttributeTests {
-
- @Test
- public void testAccess() throws NamingException {
- final String PASSWORD = \
"\u011b\u0161\u010d\u0159\u017e\u00fd\u00e1\u00ed\u00e9"; // Czech \
characters ;-)
-
- GuardedPasswordAttribute pwdAttr = \
GuardedPasswordAttribute.create("userPassword", new \
GuardedString(PASSWORD.toCharArray()));
- final Attribute[] attribute = { null };
-
- pwdAttr.access(new Accessor() {
- public void access(Attribute passwordAttribute) {
- assertEquals("userPassword", passwordAttribute.getID());
- try {
- assertEquals(PASSWORD, new String((byte[]) \
passwordAttribute.get(), "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- } catch (NamingException e) {
- throw new RuntimeException(e);
- }
- attribute[0] = passwordAttribute;
- }
- });
- assertEquals(1, attribute[0].size());
- byte[] value = (byte[]) attribute[0].get();
- for (int i = 0; i < value.length; i++) {
- assertEquals((byte) 0, value[i]);
- }
- }
-
- @Test
- public void testEmpty() {
- GuardedPasswordAttribute pwdAttr = \
GuardedPasswordAttribute.create("userPassword");
- pwdAttr.access(new Accessor() {
- public void access(Attribute passwordAttribute) {
- assertEquals(0, passwordAttribute.size());
- }
- });
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapschemaGuarde \
dPasswordAttributeTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapschemaGuardedPasswordAttributeTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/GuardedPasswordAttributeTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.schema;
+
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.Test;
+import java.io.UnsupportedEncodingException;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.ldap.schema.GuardedPasswordAttribute.Accessor;
+
+public class GuardedPasswordAttributeTests {
+
+ @Test
+ public void testAccess() throws NamingException {
+ final String PASSWORD = \
"\u011b\u0161\u010d\u0159\u017e\u00fd\u00e1\u00ed\u00e9"; // Czech \
characters ;-) +
+ GuardedPasswordAttribute pwdAttr = \
GuardedPasswordAttribute.create("userPassword", new \
GuardedString(PASSWORD.toCharArray())); + final Attribute[] attribute = { null \
}; +
+ pwdAttr.access(new Accessor() {
+ public void access(Attribute passwordAttribute) {
+ assertEquals("userPassword", passwordAttribute.getID());
+ try {
+ assertEquals(PASSWORD, new String((byte[]) \
passwordAttribute.get(), "UTF-8")); + } catch \
(UnsupportedEncodingException e) { + throw new \
RuntimeException(e); + } catch (NamingException e) {
+ throw new RuntimeException(e);
+ }
+ attribute[0] = passwordAttribute;
+ }
+ });
+ assertEquals(1, attribute[0].size());
+ byte[] value = (byte[]) attribute[0].get();
+ for (int i = 0; i < value.length; i++) {
+ assertEquals((byte) 0, value[i]);
+ }
+ }
+
+ @Test
+ public void testEmpty() {
+ GuardedPasswordAttribute pwdAttr = \
GuardedPasswordAttribute.create("userPassword"); + \
pwdAttr.access(new Accessor() { + public void access(Attribute \
passwordAttribute) { + assertEquals(0, passwordAttribute.size());
+ }
+ });
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapschemaLdapSchemaMappingTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,175 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.schema;
-
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import java.util.EnumSet;
-import java.util.Set;
-
-import org.identityconnectors.framework.api.operations.AuthenticationApiOp;
-import org.identityconnectors.framework.api.operations.SyncApiOp;
-import org.identityconnectors.framework.common.objects.AttributeInfo;
-import org.identityconnectors.framework.common.objects.AttributeInfoBuilder;
-import org.identityconnectors.framework.common.objects.AttributeInfoUtil;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.ObjectClassInfo;
-import org.identityconnectors.framework.common.objects.OperationalAttributes;
-import org.identityconnectors.framework.common.objects.Schema;
-import org.identityconnectors.framework.common.objects.AttributeInfo.Flags;
-import org.identityconnectors.ldap.LdapConfiguration;
-import org.identityconnectors.ldap.LdapConnection;
-import org.identityconnectors.ldap.LdapConnectorTestBase;
-import org.identityconnectors.ldap.LdapConstants;
-import org.identityconnectors.ldap.LdapConstants.ServerType;
-
-public class LdapSchemaMappingTests extends LdapConnectorTestBase {
-
- // TODO operational attributes.
- // TODO test for operation option infos.
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return false;
- }
-
- @Test
- public void testObjectClassAttrIsReadOnly() {
- LdapConfiguration config = newConfiguration(true);
- Schema schema = newFacade(config).schema();
- for (ObjectClassInfo oci : schema.getObjectClassInfo()) {
- AttributeInfo attrInfo = AttributeInfoUtil.find("objectClass", \
oci.getAttributeInfo());
- assertFalse(attrInfo.isRequired());
- assertFalse(attrInfo.isCreateable());
- assertFalse(attrInfo.isUpdateable());
- }
- }
-
- @Test
- public void testAccountSchema() {
- LdapConfiguration config = newConfiguration(true);
- Schema schema = newFacade(config).schema();
-
- ObjectClassInfo oci = schema.findObjectClassInfo(ObjectClass.ACCOUNT_NAME);
- assertFalse(oci.isContainer());
-
- // Check some, but not all, attributes of inetOrgClass.
- Set<AttributeInfo> attrInfos = oci.getAttributeInfo();
- AttributeInfo info = AttributeInfoUtil.find("cn", attrInfos);
- assertEquals(AttributeInfoBuilder.build("cn", String.class, \
EnumSet.of(Flags.REQUIRED, Flags.MULTIVALUED)), info);
- info = AttributeInfoUtil.find("uid", attrInfos);
- assertEquals(AttributeInfoBuilder.build("uid", String.class, \
EnumSet.of(Flags.MULTIVALUED)), info);
- info = AttributeInfoUtil.find("givenName", attrInfos);
- assertEquals(AttributeInfoBuilder.build("givenName", String.class, \
EnumSet.of(Flags.MULTIVALUED)), info);
- info = AttributeInfoUtil.find("sn", attrInfos);
- assertEquals(AttributeInfoBuilder.build("sn", String.class, \
EnumSet.of(Flags.REQUIRED, Flags.MULTIVALUED)), info);
-
- // Operational attributes.
- info = AttributeInfoUtil.find(OperationalAttributes.PASSWORD_NAME, \
attrInfos);
- assertEquals(LdapConstants.PASSWORD, info);
- }
-
- @Test
- public void testGroupSchema() {
- LdapConfiguration config = newConfiguration(true);
- Schema schema = newFacade(config).schema();
-
- ObjectClassInfo oci = schema.findObjectClassInfo(ObjectClass.GROUP_NAME);
- assertFalse(oci.isContainer());
-
- Set<AttributeInfo> attrInfos = oci.getAttributeInfo();
-
- AttributeInfo info = AttributeInfoUtil.find("cn", attrInfos);
- assertEquals(AttributeInfoBuilder.build("cn", String.class, \
EnumSet.of(Flags.REQUIRED, Flags.MULTIVALUED)), info);
- }
-
- @Test
- public void testAuthenticationOnlyForAccounts() {
- LdapConfiguration config = newConfiguration(true);
- Schema schema = newFacade(config).schema();
- Set<ObjectClassInfo> ocis = \
schema.getSupportedObjectClassesByOperation().get(AuthenticationApiOp.class);
- assertEquals(1, ocis.size());
- assertTrue(ocis.iterator().next().is(ObjectClass.ACCOUNT_NAME));
- }
-
- @Test
- public void testAllObjectClassesInSchema() {
- Schema schema = newFacade(newConfiguration(true)).schema();
- // Well, at least some of the most well-known.
- assertNotNull(schema.findObjectClassInfo("organization"));
- assertNotNull(schema.findObjectClassInfo("groupOfNames"));
- assertNotNull(schema.findObjectClassInfo("dNSDomain"));
- // top is abstract, so it shouldn't be in the schema.
- assertNull(schema.findObjectClassInfo("top"));
- // extensibleObject is auxiliary, so it shouldn't be in the schema.
- assertNull(schema.findObjectClassInfo("extensibleObject"));
- }
-
- @Test
- public void testArbitraryObjectClass() {
- Schema schema = newFacade(newConfiguration(true)).schema();
-
- ObjectClassInfo dnsDomainInfo = \
schema.findObjectClassInfo("dNSDomain");
- assertTrue(dnsDomainInfo.isContainer());
-
- Set<AttributeInfo> dnsDomainAttrInfos = dnsDomainInfo \
.getAttributeInfo();
- // Inherited from domain.
- AttributeInfo info = AttributeInfoUtil.find("dc", \
dnsDomainAttrInfos );
- assertEquals(AttributeInfoBuilder.build("dc", String.class, \
EnumSet.of(Flags.REQUIRED)), info);
- info = AttributeInfoUtil.find("telephoneNumber", \
dnsDomainAttrInfos );
- assertEquals(AttributeInfoBuilder.build("telephoneNumber", \
String.class, EnumSet.of(Flags.MULTIVALUED)), info);
- // Defined in dNSDomain.
- info = AttributeInfoUtil.find("MXRecord", dnsDomainAttrInfos );
- assertEquals(AttributeInfoBuilder.build("MXRecord", String.class, \
EnumSet.of(Flags.MULTIVALUED)), info);
- }
-
- @Test
- public void testAttributeTypes() {
- LdapConfiguration config = newConfiguration(true);
- Schema schema = newFacade(config).schema();
- ObjectClassInfo accountInfo = \
schema.findObjectClassInfo(ObjectClass.ACCOUNT_NAME);
- Set<AttributeInfo> accountAttrInfos = accountInfo.getAttributeInfo();
-
- assertEquals(String.class, AttributeInfoUtil.find("cn", \
accountAttrInfos).getType());
- assertEquals(String.class, AttributeInfoUtil.find("ou", \
accountAttrInfos).getType());
- assertEquals(String.class, \
AttributeInfoUtil.find("telephoneNumber", \
accountAttrInfos).getType());
-
- assertEquals(byte[].class, AttributeInfoUtil.find("audio", \
accountAttrInfos).getType());
- assertEquals(byte[].class, AttributeInfoUtil.find("jpegPhoto", \
accountAttrInfos).getType());
- assertEquals(byte[].class, \
AttributeInfoUtil.find("userCertificate", \
accountAttrInfos).getType());
- assertEquals(byte[].class, \
AttributeInfoUtil.find("x500UniqueIdentifier", \
accountAttrInfos).getType());
- }
-
- @Test
- public void testSyncNotSupported() {
- LdapConfiguration config = newConfiguration();
- LdapConnection conn = new LdapConnection(config);
- assertEquals(ServerType.OPENDS, conn.getServerType());
- Schema schema = newFacade(config).schema();
- assertTrue(schema.getSupportedObjectClassesByOperation().get(SyncApiOp.class).isEmpty());
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapschemaLdapSc \
hemaMappingTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapschemaLdapSchemaMappingTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/schema/LdapSchemaMappingTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,175 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.schema;
+
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import java.util.EnumSet;
+import java.util.Set;
+
+import org.identityconnectors.framework.api.operations.AuthenticationApiOp;
+import org.identityconnectors.framework.api.operations.SyncApiOp;
+import org.identityconnectors.framework.common.objects.AttributeInfo;
+import org.identityconnectors.framework.common.objects.AttributeInfoBuilder;
+import org.identityconnectors.framework.common.objects.AttributeInfoUtil;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.ObjectClassInfo;
+import org.identityconnectors.framework.common.objects.OperationalAttributes;
+import org.identityconnectors.framework.common.objects.Schema;
+import org.identityconnectors.framework.common.objects.AttributeInfo.Flags;
+import org.identityconnectors.ldap.LdapConfiguration;
+import org.identityconnectors.ldap.LdapConnection;
+import org.identityconnectors.ldap.LdapConnectorTestBase;
+import org.identityconnectors.ldap.LdapConstants;
+import org.identityconnectors.ldap.LdapConstants.ServerType;
+
+public class LdapSchemaMappingTests extends LdapConnectorTestBase {
+
+ // TODO operational attributes.
+ // TODO test for operation option infos.
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return false;
+ }
+
+ @Test
+ public void testObjectClassAttrIsReadOnly() {
+ LdapConfiguration config = newConfiguration(true);
+ Schema schema = newFacade(config).schema();
+ for (ObjectClassInfo oci : schema.getObjectClassInfo()) {
+ AttributeInfo attrInfo = AttributeInfoUtil.find("objectClass", \
oci.getAttributeInfo()); + assertFalse(attrInfo.isRequired());
+ assertFalse(attrInfo.isCreateable());
+ assertFalse(attrInfo.isUpdateable());
+ }
+ }
+
+ @Test
+ public void testAccountSchema() {
+ LdapConfiguration config = newConfiguration(true);
+ Schema schema = newFacade(config).schema();
+
+ ObjectClassInfo oci = schema.findObjectClassInfo(ObjectClass.ACCOUNT_NAME);
+ assertFalse(oci.isContainer());
+
+ // Check some, but not all, attributes of inetOrgClass.
+ Set<AttributeInfo> attrInfos = oci.getAttributeInfo();
+ AttributeInfo info = AttributeInfoUtil.find("cn", attrInfos);
+ assertEquals(AttributeInfoBuilder.build("cn", String.class, \
EnumSet.of(Flags.REQUIRED, Flags.MULTIVALUED)), info); + info = \
AttributeInfoUtil.find("uid", attrInfos); + \
assertEquals(AttributeInfoBuilder.build("uid", String.class, \
EnumSet.of(Flags.MULTIVALUED)), info); + info = \
AttributeInfoUtil.find("givenName", attrInfos); + \
assertEquals(AttributeInfoBuilder.build("givenName", String.class, \
EnumSet.of(Flags.MULTIVALUED)), info); + info = \
AttributeInfoUtil.find("sn", attrInfos); + \
assertEquals(AttributeInfoBuilder.build("sn", String.class, \
EnumSet.of(Flags.REQUIRED, Flags.MULTIVALUED)), info); +
+ // Operational attributes.
+ info = AttributeInfoUtil.find(OperationalAttributes.PASSWORD_NAME, \
attrInfos); + assertEquals(LdapConstants.PASSWORD, info);
+ }
+
+ @Test
+ public void testGroupSchema() {
+ LdapConfiguration config = newConfiguration(true);
+ Schema schema = newFacade(config).schema();
+
+ ObjectClassInfo oci = schema.findObjectClassInfo(ObjectClass.GROUP_NAME);
+ assertFalse(oci.isContainer());
+
+ Set<AttributeInfo> attrInfos = oci.getAttributeInfo();
+
+ AttributeInfo info = AttributeInfoUtil.find("cn", attrInfos);
+ assertEquals(AttributeInfoBuilder.build("cn", String.class, \
EnumSet.of(Flags.REQUIRED, Flags.MULTIVALUED)), info); + }
+
+ @Test
+ public void testAuthenticationOnlyForAccounts() {
+ LdapConfiguration config = newConfiguration(true);
+ Schema schema = newFacade(config).schema();
+ Set<ObjectClassInfo> ocis = \
schema.getSupportedObjectClassesByOperation().get(AuthenticationApiOp.class); + \
assertEquals(1, ocis.size()); + \
assertTrue(ocis.iterator().next().is(ObjectClass.ACCOUNT_NAME)); + }
+
+ @Test
+ public void testAllObjectClassesInSchema() {
+ Schema schema = newFacade(newConfiguration(true)).schema();
+ // Well, at least some of the most well-known.
+ assertNotNull(schema.findObjectClassInfo("organization"));
+ assertNotNull(schema.findObjectClassInfo("groupOfNames"));
+ assertNotNull(schema.findObjectClassInfo("dNSDomain"));
+ // top is abstract, so it shouldn't be in the schema.
+ assertNull(schema.findObjectClassInfo("top"));
+ // extensibleObject is auxiliary, so it shouldn't be in the schema.
+ assertNull(schema.findObjectClassInfo("extensibleObject"));
+ }
+
+ @Test
+ public void testArbitraryObjectClass() {
+ Schema schema = newFacade(newConfiguration(true)).schema();
+
+ ObjectClassInfo dnsDomainInfo = \
schema.findObjectClassInfo("dNSDomain"); + \
assertTrue(dnsDomainInfo.isContainer()); +
+ Set<AttributeInfo> dnsDomainAttrInfos = dnsDomainInfo \
.getAttributeInfo(); + // Inherited from domain.
+ AttributeInfo info = AttributeInfoUtil.find("dc", \
dnsDomainAttrInfos ); + \
assertEquals(AttributeInfoBuilder.build("dc", String.class, \
EnumSet.of(Flags.REQUIRED)), info); + info = \
AttributeInfoUtil.find("telephoneNumber", dnsDomainAttrInfos ); + \
assertEquals(AttributeInfoBuilder.build("telephoneNumber", String.class, \
EnumSet.of(Flags.MULTIVALUED)), info); + // Defined in dNSDomain.
+ info = AttributeInfoUtil.find("MXRecord", dnsDomainAttrInfos );
+ assertEquals(AttributeInfoBuilder.build("MXRecord", String.class, \
EnumSet.of(Flags.MULTIVALUED)), info); + }
+
+ @Test
+ public void testAttributeTypes() {
+ LdapConfiguration config = newConfiguration(true);
+ Schema schema = newFacade(config).schema();
+ ObjectClassInfo accountInfo = \
schema.findObjectClassInfo(ObjectClass.ACCOUNT_NAME); + \
Set<AttributeInfo> accountAttrInfos = accountInfo.getAttributeInfo(); +
+ assertEquals(String.class, AttributeInfoUtil.find("cn", \
accountAttrInfos).getType()); + assertEquals(String.class, \
AttributeInfoUtil.find("ou", accountAttrInfos).getType()); + \
assertEquals(String.class, AttributeInfoUtil.find("telephoneNumber", \
accountAttrInfos).getType()); +
+ assertEquals(byte[].class, AttributeInfoUtil.find("audio", \
accountAttrInfos).getType()); + assertEquals(byte[].class, \
AttributeInfoUtil.find("jpegPhoto", accountAttrInfos).getType()); + \
assertEquals(byte[].class, AttributeInfoUtil.find("userCertificate", \
accountAttrInfos).getType()); + assertEquals(byte[].class, \
AttributeInfoUtil.find("x500UniqueIdentifier", \
accountAttrInfos).getType()); + }
+
+ @Test
+ public void testSyncNotSupported() {
+ LdapConfiguration config = newConfiguration();
+ LdapConnection conn = new LdapConnection(config);
+ assertEquals(ServerType.OPENDS, conn.getServerType());
+ Schema schema = newFacade(config).schema();
+ assertTrue(schema.getSupportedObjectClassesByOperation().get(SyncApiOp.class).isEmpty());
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsearchLdapFilterTranslatorTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,174 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.search;
-
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.Test;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter;
-import org.identityconnectors.framework.common.objects.filter.ContainsFilter;
-import org.identityconnectors.framework.common.objects.filter.EndsWithFilter;
-import org.identityconnectors.framework.common.objects.filter.EqualsFilter;
-import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
-import org.identityconnectors.framework.common.objects.filter.GreaterThanFilter;
-import org.identityconnectors.framework.common.objects.filter.GreaterThanOrEqualFilter;
-import org.identityconnectors.framework.common.objects.filter.LessThanFilter;
-import org.identityconnectors.framework.common.objects.filter.LessThanOrEqualFilter;
-import org.identityconnectors.framework.common.objects.filter.StartsWithFilter;
-import org.identityconnectors.ldap.LdapConfiguration;
-import org.identityconnectors.ldap.LdapConnection;
-import org.identityconnectors.ldap.LdapConnectorTestBase;
-import org.identityconnectors.ldap.schema.LdapSchemaMapping;
-
-public class LdapFilterTranslatorTests {
-
- @Test
- public void testAnd() {
- assertEquals(LdapFilter.forNativeFilter("(&(foo=1)(bar=2))"), \
newTranslator().createAndExpression(
- LdapFilter.forNativeFilter("(foo=1)"),
- LdapFilter.forNativeFilter("(bar=2)")));
- assertEquals(LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(foo=1)"), \
newTranslator().createAndExpression(
- LdapFilter.forEntryDN("dc=example,dc=com"),
- LdapFilter.forNativeFilter("(foo=1)")));
- assertEquals(LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(&(foo=1)(bar=2))"), \
newTranslator().createAndExpression(
- LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(foo=1)"),
- LdapFilter.forNativeFilter("(bar=2)")));
- assertNull(newTranslator().createAndExpression(
- LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(foo=1)"),
- LdapFilter.forEntryDN("dc=example,dc=org").withNativeFilter("(bar=2)")));
- }
-
- @Test
- public void testOr() {
- assertEquals(LdapFilter.forNativeFilter("(|(foo=1)(bar=2))"),
- newTranslator().createOrExpression(LdapFilter.forNativeFilter("(foo=1)"), \
LdapFilter.forNativeFilter("(bar=2)")));
- assertNull(newTranslator().createOrExpression(
- LdapFilter.forEntryDN("dc=example,dc=com"), \
LdapFilter.forNativeFilter("(foo=1)")));
- }
-
- @Test
- public void testContains() {
- ContainsFilter filter = (ContainsFilter) \
FilterBuilder.contains(AttributeBuilder.build("foo", \
""));
- assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createContainsExpression(filter, false));
-
- filter = (ContainsFilter) \
FilterBuilder.contains(AttributeBuilder.build("foo", \
"bar"));
- assertEquals(LdapFilter.forNativeFilter("(foo=*bar*)"), \
newTranslator().createContainsExpression(filter, false));
- }
-
- @Test
- public void testStartsWith() {
- StartsWithFilter filter = (StartsWithFilter) \
FilterBuilder.startsWith(AttributeBuilder.build("foo", \
""));
- assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createStartsWithExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo=*))"), \
newTranslator().createStartsWithExpression(filter, true));
-
- filter = (StartsWithFilter) \
FilterBuilder.startsWith(AttributeBuilder.build("foo", \
"bar"));
- assertEquals(LdapFilter.forNativeFilter("(foo=bar*)"), \
newTranslator().createStartsWithExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo=bar*))"), \
newTranslator().createStartsWithExpression(filter, true));
- }
-
- @Test
- public void testEndsWith() {
- EndsWithFilter filter = (EndsWithFilter) \
FilterBuilder.endsWith(AttributeBuilder.build("foo", \
""));
- assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createEndsWithExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo=*))"), \
newTranslator().createEndsWithExpression(filter, true));
-
- filter = (EndsWithFilter) \
FilterBuilder.endsWith(AttributeBuilder.build("foo", \
"bar"));
- assertEquals(LdapFilter.forNativeFilter("(foo=*bar)"), \
newTranslator().createEndsWithExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo=*bar))"), \
newTranslator().createEndsWithExpression(filter, true));
- }
-
- @Test
- public void testEquals() {
- EqualsFilter filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo"));
- assertNull(newTranslator().createEqualsExpression(filter, false));
-
- filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo", \
""));
- assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createEqualsExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo=*))"), \
newTranslator().createEqualsExpression(filter, true));
-
- filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo", \
"bar"));
- assertEquals(LdapFilter.forNativeFilter("(foo=bar)"), \
newTranslator().createEqualsExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo=bar))"), \
newTranslator().createEqualsExpression(filter, true));
-
- filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo", "bar", \
"baz"));
- assertEquals(LdapFilter.forNativeFilter("(&(foo=bar)(foo=baz))"), \
newTranslator().createEqualsExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(&(foo=bar)(foo=baz)))"), \
newTranslator().createEqualsExpression(filter, true));
- }
-
- @Test
- public void testGreaterThan() {
- GreaterThanFilter filter = (GreaterThanFilter) \
FilterBuilder.greaterThan(AttributeBuilder.build("foo", \
42));
- assertEquals(LdapFilter.forNativeFilter("(!(foo<=42))"), \
newTranslator().createGreaterThanExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(foo<=42)"), \
newTranslator().createGreaterThanExpression(filter, true));
- }
-
- @Test
- public void testGreaterThanOrEqual() {
- GreaterThanOrEqualFilter filter = (GreaterThanOrEqualFilter) \
FilterBuilder.greaterThanOrEqualTo(AttributeBuilder.build("foo", \
42));
- assertEquals(LdapFilter.forNativeFilter("(foo>=42)"), \
newTranslator().createGreaterThanOrEqualExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo>=42))"), \
newTranslator().createGreaterThanOrEqualExpression(filter, true));
- }
-
- @Test
- public void testLessThan() {
- LessThanFilter filter = (LessThanFilter) \
FilterBuilder.lessThan(AttributeBuilder.build("foo", 42));
- assertEquals(LdapFilter.forNativeFilter("(!(foo>=42))"), \
newTranslator().createLessThanExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(foo>=42)"), \
newTranslator().createLessThanExpression(filter, true));
- }
-
- @Test
- public void testLessThanOrEqual() {
- LessThanOrEqualFilter filter = (LessThanOrEqualFilter) \
FilterBuilder.lessThanOrEqualTo(AttributeBuilder.build("foo", \
42));
- assertEquals(LdapFilter.forNativeFilter("(foo<=42)"), \
newTranslator().createLessThanOrEqualExpression(filter, false));
- assertEquals(LdapFilter.forNativeFilter("(!(foo<=42))"), \
newTranslator().createLessThanOrEqualExpression(filter, true));
- }
-
- @Test
- public void testEntryDN() {
- ContainsFilter contains = (ContainsFilter) \
FilterBuilder.contains(AttributeBuilder.build("entryDN", \
"dc=example,dc=com"));
- assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createContainsExpression(contains, false));
-
- StartsWithFilter startsWith = (StartsWithFilter) \
FilterBuilder.startsWith(AttributeBuilder.build("entryDN", \
"dc=example,dc=com"));
- assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createStartsWithExpression(startsWith, false));
-
- EndsWithFilter endsWith = (EndsWithFilter) \
FilterBuilder.endsWith(AttributeBuilder.build("entryDN", \
"dc=example,dc=com"));
- assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createEndsWithExpression(endsWith, false));
-
- EqualsFilter equals = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("entryDN", \
"dc=example,dc=com"));
- assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createEqualsExpression(equals, false));
-
- ContainsAllValuesFilter containsAllValues = (ContainsAllValuesFilter) \
FilterBuilder.containsAllValues(AttributeBuilder.build("entryDN", \
"dc=example,dc=com"));
- assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createContainsAllValuesExpression(containsAllValues, \
false));
-
- containsAllValues = (ContainsAllValuesFilter) \
FilterBuilder.containsAllValues(AttributeBuilder.build("entryDN", \
"dc=example,dc=com", \
"o=Acme,dc=example,dc=com"));
- assertNull(newTranslator().createContainsAllValuesExpression(containsAllValues, \
false));
- }
-
- private static LdapFilterTranslator newTranslator() {
- LdapConfiguration config = LdapConnectorTestBase.newConfiguration();
- LdapConnection conn = new LdapConnection(config);
- return new LdapFilterTranslator(new LdapSchemaMapping(conn), \
ObjectClass.ACCOUNT);
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsearchLdapFi \
lterTranslatorTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapsearchLdapFilterTranslatorTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapFilterTranslatorTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,174 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.search;
+
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.Test;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter;
+import org.identityconnectors.framework.common.objects.filter.ContainsFilter;
+import org.identityconnectors.framework.common.objects.filter.EndsWithFilter;
+import org.identityconnectors.framework.common.objects.filter.EqualsFilter;
+import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
+import org.identityconnectors.framework.common.objects.filter.GreaterThanFilter;
+import org.identityconnectors.framework.common.objects.filter.GreaterThanOrEqualFilter;
+import org.identityconnectors.framework.common.objects.filter.LessThanFilter;
+import org.identityconnectors.framework.common.objects.filter.LessThanOrEqualFilter;
+import org.identityconnectors.framework.common.objects.filter.StartsWithFilter;
+import org.identityconnectors.ldap.LdapConfiguration;
+import org.identityconnectors.ldap.LdapConnection;
+import org.identityconnectors.ldap.LdapConnectorTestBase;
+import org.identityconnectors.ldap.schema.LdapSchemaMapping;
+
+public class LdapFilterTranslatorTests {
+
+ @Test
+ public void testAnd() {
+ assertEquals(LdapFilter.forNativeFilter("(&(foo=1)(bar=2))"), \
newTranslator().createAndExpression( + \
LdapFilter.forNativeFilter("(foo=1)"), + \
LdapFilter.forNativeFilter("(bar=2)"))); + \
assertEquals(LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(foo=1)"), \
newTranslator().createAndExpression( + \
LdapFilter.forEntryDN("dc=example,dc=com"), + \
LdapFilter.forNativeFilter("(foo=1)"))); + \
assertEquals(LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(&(foo=1)(bar=2))"), \
newTranslator().createAndExpression( + \
LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(foo=1)"),
+ LdapFilter.forNativeFilter("(bar=2)")));
+ assertNull(newTranslator().createAndExpression(
+ LdapFilter.forEntryDN("dc=example,dc=com").withNativeFilter("(foo=1)"),
+ LdapFilter.forEntryDN("dc=example,dc=org").withNativeFilter("(bar=2)")));
+ }
+
+ @Test
+ public void testOr() {
+ assertEquals(LdapFilter.forNativeFilter("(|(foo=1)(bar=2))"),
+ newTranslator().createOrExpression(LdapFilter.forNativeFilter("(foo=1)"), \
LdapFilter.forNativeFilter("(bar=2)"))); + \
assertNull(newTranslator().createOrExpression( + \
LdapFilter.forEntryDN("dc=example,dc=com"), \
LdapFilter.forNativeFilter("(foo=1)"))); + }
+
+ @Test
+ public void testContains() {
+ ContainsFilter filter = (ContainsFilter) \
FilterBuilder.contains(AttributeBuilder.build("foo", "")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createContainsExpression(filter, false)); +
+ filter = (ContainsFilter) \
FilterBuilder.contains(AttributeBuilder.build("foo", "bar")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=*bar*)"), \
newTranslator().createContainsExpression(filter, false)); + }
+
+ @Test
+ public void testStartsWith() {
+ StartsWithFilter filter = (StartsWithFilter) \
FilterBuilder.startsWith(AttributeBuilder.build("foo", "")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createStartsWithExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo=*))"), \
newTranslator().createStartsWithExpression(filter, true)); +
+ filter = (StartsWithFilter) \
FilterBuilder.startsWith(AttributeBuilder.build("foo", "bar")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=bar*)"), \
newTranslator().createStartsWithExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo=bar*))"), \
newTranslator().createStartsWithExpression(filter, true)); + }
+
+ @Test
+ public void testEndsWith() {
+ EndsWithFilter filter = (EndsWithFilter) \
FilterBuilder.endsWith(AttributeBuilder.build("foo", "")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createEndsWithExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo=*))"), \
newTranslator().createEndsWithExpression(filter, true)); +
+ filter = (EndsWithFilter) \
FilterBuilder.endsWith(AttributeBuilder.build("foo", "bar")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=*bar)"), \
newTranslator().createEndsWithExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo=*bar))"), \
newTranslator().createEndsWithExpression(filter, true)); + }
+
+ @Test
+ public void testEquals() {
+ EqualsFilter filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo")); + \
assertNull(newTranslator().createEqualsExpression(filter, false)); +
+ filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo", "")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=*)"), \
newTranslator().createEqualsExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo=*))"), \
newTranslator().createEqualsExpression(filter, true)); +
+ filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo", "bar")); + \
assertEquals(LdapFilter.forNativeFilter("(foo=bar)"), \
newTranslator().createEqualsExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo=bar))"), \
newTranslator().createEqualsExpression(filter, true)); +
+ filter = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("foo", "bar", \
"baz")); + \
assertEquals(LdapFilter.forNativeFilter("(&(foo=bar)(foo=baz))"), \
newTranslator().createEqualsExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(&(foo=bar)(foo=baz)))"), \
newTranslator().createEqualsExpression(filter, true)); + }
+
+ @Test
+ public void testGreaterThan() {
+ GreaterThanFilter filter = (GreaterThanFilter) \
FilterBuilder.greaterThan(AttributeBuilder.build("foo", 42)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo<=42))"), \
newTranslator().createGreaterThanExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(foo<=42)"), \
newTranslator().createGreaterThanExpression(filter, true)); + }
+
+ @Test
+ public void testGreaterThanOrEqual() {
+ GreaterThanOrEqualFilter filter = (GreaterThanOrEqualFilter) \
FilterBuilder.greaterThanOrEqualTo(AttributeBuilder.build("foo", 42)); + \
assertEquals(LdapFilter.forNativeFilter("(foo>=42)"), \
newTranslator().createGreaterThanOrEqualExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo>=42))"), \
newTranslator().createGreaterThanOrEqualExpression(filter, true)); + }
+
+ @Test
+ public void testLessThan() {
+ LessThanFilter filter = (LessThanFilter) \
FilterBuilder.lessThan(AttributeBuilder.build("foo", 42)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo>=42))"), \
newTranslator().createLessThanExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(foo>=42)"), \
newTranslator().createLessThanExpression(filter, true)); + }
+
+ @Test
+ public void testLessThanOrEqual() {
+ LessThanOrEqualFilter filter = (LessThanOrEqualFilter) \
FilterBuilder.lessThanOrEqualTo(AttributeBuilder.build("foo", 42)); + \
assertEquals(LdapFilter.forNativeFilter("(foo<=42)"), \
newTranslator().createLessThanOrEqualExpression(filter, false)); + \
assertEquals(LdapFilter.forNativeFilter("(!(foo<=42))"), \
newTranslator().createLessThanOrEqualExpression(filter, true)); + }
+
+ @Test
+ public void testEntryDN() {
+ ContainsFilter contains = (ContainsFilter) \
FilterBuilder.contains(AttributeBuilder.build("entryDN", \
"dc=example,dc=com")); + \
assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createContainsExpression(contains, false)); +
+ StartsWithFilter startsWith = (StartsWithFilter) \
FilterBuilder.startsWith(AttributeBuilder.build("entryDN", \
"dc=example,dc=com")); + \
assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createStartsWithExpression(startsWith, false)); +
+ EndsWithFilter endsWith = (EndsWithFilter) \
FilterBuilder.endsWith(AttributeBuilder.build("entryDN", \
"dc=example,dc=com")); + \
assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createEndsWithExpression(endsWith, false)); +
+ EqualsFilter equals = (EqualsFilter) \
FilterBuilder.equalTo(AttributeBuilder.build("entryDN", \
"dc=example,dc=com")); + \
assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createEqualsExpression(equals, false)); +
+ ContainsAllValuesFilter containsAllValues = (ContainsAllValuesFilter) \
FilterBuilder.containsAllValues(AttributeBuilder.build("entryDN", \
"dc=example,dc=com")); + \
assertEquals(LdapFilter.forEntryDN("dc=example,dc=com"), \
newTranslator().createContainsAllValuesExpression(containsAllValues, false)); +
+ containsAllValues = (ContainsAllValuesFilter) \
FilterBuilder.containsAllValues(AttributeBuilder.build("entryDN", \
"dc=example,dc=com", "o=Acme,dc=example,dc=com")); + \
assertNull(newTranslator().createContainsAllValuesExpression(containsAllValues, \
false)); + }
+
+ private static LdapFilterTranslator newTranslator() {
+ LdapConfiguration config = LdapConnectorTestBase.newConfiguration();
+ LdapConnection conn = new LdapConnection(config);
+ return new LdapFilterTranslator(new LdapSchemaMapping(conn), \
ObjectClass.ACCOUNT); + }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsearchLdapSearchTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,422 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- * "Portions Copyrighted 2014 ForgeRock AS"
- */
-package org.identityconnectors.ldap.search;
-
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import static java.util.Collections.singleton;
-import static org.identityconnectors.common.CollectionUtil.newSet;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.identityconnectors.common.security.GuardedString;
-import org.identityconnectors.common.security.GuardedString.Accessor;
-import org.identityconnectors.framework.api.ConnectorFacade;
-import org.identityconnectors.framework.common.exceptions.ConnectorException;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.identityconnectors.framework.common.objects.AttributeInfo;
-import org.identityconnectors.framework.common.objects.AttributeInfoUtil;
-import org.identityconnectors.framework.common.objects.AttributeUtil;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.OperationOptions;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.OperationalAttributes;
-import org.identityconnectors.framework.common.objects.QualifiedUid;
-import org.identityconnectors.framework.common.objects.ResultsHandler;
-import org.identityconnectors.framework.common.objects.Uid;
-import org.identityconnectors.framework.common.objects.filter.Filter;
-import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
-import org.identityconnectors.ldap.LdapConfiguration;
-import org.identityconnectors.ldap.LdapConnection;
-import org.identityconnectors.ldap.LdapConnectorTestBase;
-import org.identityconnectors.test.common.TestHelpers;
-import org.identityconnectors.test.common.ToListResultsHandler;
-
-public class LdapSearchTests extends LdapConnectorTestBase {
-
- // TODO operational attributes.
- // TODO LDAP directory attributes (entryDN, etc.).
-
- @Override
- protected boolean restartServerAfterEachTest() {
- return false;
- }
-
- @Test
- public void testLdapFilter() {
- LdapConnection conn = new LdapConnection(newConfiguration());
-
- LdapFilter filter = LdapFilter.forEntryDN(BUGS_BUNNY_DN);
- ToListResultsHandler handler = new ToListResultsHandler();
- new LdapSearch(conn, ObjectClass.ACCOUNT, filter, handler, new \
OperationOptionsBuilder().build()).execute();
- assertEquals(1, handler.getObjects().size());
-
- filter = filter.withNativeFilter("(foo=bar)");
- handler = new ToListResultsHandler();
- new LdapSearch(conn, ObjectClass.ACCOUNT, filter, handler, new \
OperationOptionsBuilder().build()).execute();
- assertTrue(handler.getObjects().isEmpty());
- }
-
- @Test
- public void testLdapFilterWithNonExistingEntryDN() {
- LdapFilter filter = LdapFilter.forEntryDN("dc=foo,dc=bar");
-
- // VLV index.
- LdapConfiguration config = newConfiguration();
- config.setUseBlocks(true);
- config.setUsePagedResultControl(false);
- searchExpectingNoResult(config, filter);
-
- // Simple paged results.
- config = newConfiguration();
- config.setUseBlocks(true);
- config.setUsePagedResultControl(true);
- searchExpectingNoResult(config, filter);
-
- // No paging.
- config = newConfiguration();
- config.setUseBlocks(false);
- searchExpectingNoResult(config, filter);
- }
-
-
- @Test
- public void testLdapFilterWithInvalidEntryDN() {
- LdapFilter filter = LdapFilter.forEntryDN("dc=foo,,");
-
- // VLV index.
- LdapConfiguration config = newConfiguration();
- config.setUseBlocks(true);
- config.setUsePagedResultControl(false);
- searchExpectingNoResult(config, filter);
-
- // Simple paged results.
- config = newConfiguration();
- config.setUseBlocks(true);
- config.setUsePagedResultControl(true);
- searchExpectingNoResult(config, filter);
-
- // No paging.
- config = newConfiguration();
- config.setUseBlocks(false);
- searchExpectingNoResult(config, filter);
- }
-
- private void searchExpectingNoResult(LdapConfiguration config, LdapFilter \
filter) {
- LdapConnection conn = new LdapConnection(config);
- ToListResultsHandler handler = new ToListResultsHandler();
- // Should not fail with NameNotFoundException or InvalidNameException.
- new LdapSearch(conn, ObjectClass.ACCOUNT, filter, handler, new \
OperationOptionsBuilder().build()).execute();
- assertTrue(handler.getObjects().isEmpty());
- }
-
- @Test
- public void testCanCancelSearch() {
- // VLV Index.
- LdapConfiguration config = newConfiguration();
- config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
- config.setUseBlocks(true);
- config.setUsePagedResultControl(false);
- searchExpectingSingleResult(config);
-
- // Simple paged results.
- config = newConfiguration();
- config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
- config.setUseBlocks(true);
- config.setUsePagedResultControl(true);
- searchExpectingSingleResult(config);
-
- // No paging.
- config = newConfiguration();
- config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
- config.setUseBlocks(false);
- searchExpectingSingleResult(config);
- }
-
- private void searchExpectingSingleResult(LdapConfiguration config) {
- LdapConnection conn = new LdapConnection(config);
- FirstOnlyResultsHandler handler = new FirstOnlyResultsHandler();
- new LdapSearch(conn, ObjectClass.ACCOUNT, null, handler, new \
OperationOptionsBuilder().build()).execute();
- handler.assertSingleResult();
- }
-
- @Test
- public void testSimplePagedSearch() {
- LdapConfiguration config = newConfiguration();
- config.setUseBlocks(true);
- config.setUsePagedResultControl(true);
- ConnectorFacade facade = newFacade(config);
-
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null);
- assertNotNull(getObjectByName(objects, BUGS_BUNNY_DN));
- assertNotNull(getObjectByName(objects, USER_0_DN));
- // 1000 is the default search size limit for OpenDS.
- assertTrue(objects.size() > 1000);
- }
-
- @Test
- public void testVlvIndexSearch() {
- LdapConfiguration config = newConfiguration();
- config.setBaseContexts(EXAMPLE_COM_DN);
- config.setUseBlocks(true);
- config.setUsePagedResultControl(false);
- config.setUidAttribute("entryDN");
- ConnectorFacade facade = newFacade(config);
-
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null);
- assertNotNull(getObjectByName(objects, USER_0_DN));
- // 1000 is the default search size limit for OpenDS.
- assertTrue(objects.size() > 1000);
-
- // OpenDS-specific.
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("debugsearchindex");
- FirstOnlyResultsHandler handler = new FirstOnlyResultsHandler();
- facade.search(ObjectClass.ACCOUNT, null, handler, builder.build());
- String debugsearch = \
handler.getSingleResult().getAttributeByName("debugsearchindex").getValue().get(0).toString();
- assertTrue(debugsearch.contains("vlv"));
- }
-
- @Test(expectedExceptions = ConnectorException.class)
- public void testNoUseBlocks() {
- LdapConfiguration config = newConfiguration();
- config.setUseBlocks(false);
- ConnectorFacade facade = newFacade(config);
- // This should fail, since the search will exceed the maximum number of
- // entries to return.
- TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null);
- }
-
- @Test
- public void testWithFilter() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- assertEquals(BUGS_BUNNY_DN, bunny.getName().getNameValue());
- }
-
- @Test
- public void testWithFilterByBinaryAttribute() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
-
- byte[] photo = { -4, -3, -2, -1, 0, 1, 2, 3, 63, 127 };
- Attribute photoAttr = AttributeBuilder.build("jpegPhoto", photo);
- Uid newUid = facade.addAttributeValues(ObjectClass.ACCOUNT, bunny.getUid(), \
singleton(photoAttr), null);
-
- ConnectorObject bunnyWithPhoto = searchByAttribute(facade, \
ObjectClass.ACCOUNT, photoAttr, "jpegPhoto");
- assertEquals(newUid, bunnyWithPhoto.getUid());
- }
-
- @Test
- public void testAttributesToGet() {
- ConnectorFacade facade = newFacade();
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(USER_0_DN), "employeeNumber", \
"telephoneNumber");
-
- Set<Attribute> attrs = newSet(object.getAttributes());
- assertTrue(attrs.remove(AttributeUtil.find(Uid.NAME, attrs)));
- assertTrue(attrs.remove(AttributeUtil.find(Name.NAME, attrs)));
- assertTrue(attrs.remove(AttributeUtil.find("employeeNumber", \
attrs)));
- assertTrue(attrs.remove(AttributeUtil.find("telephoneNumber", \
attrs)));
-
- assertTrue(attrs.isEmpty());
- }
-
- @Test
- public void testAttributesReturnedByDefaultWithNoValueAreNotReturned() {
- LdapConfiguration config = newConfiguration(true);
- ConnectorFacade facade = newFacade(config);
- AttributeInfo attr = AttributeInfoUtil.find("givenName", \
facade.schema().findObjectClassInfo(ObjectClass.ACCOUNT_NAME).getAttributeInfo());
- assertTrue(attr.isReturnedByDefault());
-
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN));
- assertNull(object.getAttributeByName("givenName"));
- }
-
- @Test
- public void testAttributesToGetNotPresentInEntryAreEmpty() {
- ConnectorFacade facade = newFacade();
- ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN), "employeeNumber");
-
- assertTrue(object.getAttributeByName("employeeNumber").getValue().isEmpty());
- }
-
- @Test
- public void testScope() {
- ConnectorFacade facade = newFacade();
- // Find an organization to pass in OP_CONTAINER.
- ObjectClass oclass = new ObjectClass("organization");
- ConnectorObject organization = searchByAttribute(facade, oclass, new \
Name(BIG_COMPANY_DN));
-
- // There are no accounts directly under the organization...
- OperationOptionsBuilder optionsBuilder = new OperationOptionsBuilder();
- optionsBuilder.setScope(OperationOptions.SCOPE_ONE_LEVEL);
- optionsBuilder.setContainer(new QualifiedUid(oclass, \
organization.getUid()));
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null, optionsBuilder.build());
- assertTrue(objects.isEmpty());
-
- // ... but there are some in the organization subtree.
- optionsBuilder.setScope(OperationOptions.SCOPE_SUBTREE);
- objects = TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null, \
optionsBuilder.build());
- assertFalse(objects.isEmpty());
- }
-
- @Test
- public void testAccountSearchFilter() {
- ConnectorFacade facade = newFacade();
- // Find an organization to pass in OP_CONTAINER.
- ObjectClass oclass = new ObjectClass("organization");
- ConnectorObject organization = searchByAttribute(facade, oclass, new \
Name(ACME_DN));
-
- // First just check that there really are some users.
- OperationOptionsBuilder optionsBuilder = new OperationOptionsBuilder();
- optionsBuilder.setScope(OperationOptions.SCOPE_SUBTREE);
- optionsBuilder.setContainer(new QualifiedUid(oclass, \
organization.getUid()));
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null, optionsBuilder.build());
- assertNotNull(getObjectByName(objects, BUGS_BUNNY_DN));
- assertNotNull(getObjectByName(objects, ELMER_FUDD_DN));
-
- LdapConfiguration config = newConfiguration();
- config.setAccountSearchFilter("(uid=" + BUGS_BUNNY_UID + \
")");
- facade = newFacade(config);
- objects = TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null, \
optionsBuilder.build());
- assertEquals(1, objects.size());
- assertNotNull(getObjectByName(objects, BUGS_BUNNY_DN));
- }
-
- @Test
- public void testAccountSearchFilterOnlyAppliesToAccounts() {
- LdapConfiguration config = newConfiguration();
- config.setAccountSearchFilter("(cn=foobarbaz)");
- ConnectorFacade facade = newFacade(config);
-
- // If the (cn=foobarbaz) filter above applied, the search would return \
nothing.
- assertNotNull(searchByAttribute(facade, new \
ObjectClass("organization"), new Name(ACME_DN)));
- }
-
- @Test
- public void testMissingParenthesesAddedToAccountSearchFilter() {
- LdapConfiguration config = newConfiguration();
- config.setAccountSearchFilter("uid=" + BUGS_BUNNY_UID); // No \
parentheses enclosing the filter.
- ConnectorFacade facade = newFacade(config);
-
- // If parentheses were not added, the search would fail.
- assertNotNull(searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)));
- }
-
- @Test
- public void testMultipleBaseDNs() {
- ConnectorFacade facade = newFacade();
-
- // This should find accounts from both base DNs.
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null);
- assertNotNull(getObjectByName(objects, BUGS_BUNNY_DN));
- assertNotNull(getObjectByName(objects, USER_0_DN));
- }
-
- @Test
- public void testUidAttributeCn() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.getUidAttribute().equalsIgnoreCase("cn"));
- config.setUidAttribute("cn");
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Uid(BUGS_BUNNY_CN));
- assertEquals(BUGS_BUNNY_DN, bunny.getName().getNameValue());
- }
-
- @Test
- public void testUidAttributeEntryDN() {
- LdapConfiguration config = newConfiguration();
- assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
- config.setUidAttribute("entryDN");
- ConnectorFacade facade = newFacade(config);
-
- ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Uid(BUGS_BUNNY_DN));
- assertEquals(BUGS_BUNNY_DN, bunny.getName().getNameValue());
- }
-
- @Test
- public void testSearchArbitraryObjectClass() {
- ConnectorFacade facade = newFacade();
-
- // Simplest: try w/o filter.
- List<ConnectorObject> objects = TestHelpers.searchToList(facade, new \
ObjectClass("country"), null, null);
- ConnectorObject czechRep = getObjectByName(objects, CZECH_REPUBLIC_DN);
-
- // Try with a name filter and options.
- Filter filter = FilterBuilder.equalTo(AttributeBuilder.build(Name.NAME, \
CZECH_REPUBLIC_DN));
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("c");
- objects = TestHelpers.searchToList(facade, new \
ObjectClass("country"), filter, builder.build());
- czechRep = getObjectByName(objects, CZECH_REPUBLIC_DN);
- assertEquals(CZECH_REPUBLIC_C, \
AttributeUtil.getAsStringValue(czechRep.getAttributeByName("c")));
- }
-
- @Test
- public void testCannotReturnPasswordFromSearch() {
- ConnectorFacade facade = newFacade();
- ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN), OperationalAttributes.PASSWORD_NAME);
- GuardedString password = (GuardedString) \
bunny.getAttributeByName(OperationalAttributes.PASSWORD_NAME).getValue().get(0);
- password.access(new Accessor() {
- public void access(char[] clearChars) {
- assertEquals(0, clearChars.length);
- }
- });
- }
-
- private static ConnectorObject getObjectByName(List<ConnectorObject> \
objects, String name) {
- for (ConnectorObject object : objects) {
- if (name.equals(object.getName().getNameValue())) {
- return object;
- }
- }
- return null;
- }
-
- private static final class FirstOnlyResultsHandler implements ResultsHandler {
-
- private final List<ConnectorObject> objects = new \
ArrayList<ConnectorObject>();
-
- public boolean handle(ConnectorObject obj) {
- objects.add(obj);
- return false; // We only want the first one.
- }
-
- public void assertSingleResult() {
- assertEquals(1, objects.size());
- }
-
- public ConnectorObject getSingleResult() {
- return objects.get(0);
- }
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsearchLdapSe \
archTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapsearchLdapSearchTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/search/LdapSearchTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,422 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ * "Portions Copyrighted 2014 ForgeRock AS"
+ */
+package org.identityconnectors.ldap.search;
+
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertFalse;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import static java.util.Collections.singleton;
+import static org.identityconnectors.common.CollectionUtil.newSet;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.identityconnectors.common.security.GuardedString;
+import org.identityconnectors.common.security.GuardedString.Accessor;
+import org.identityconnectors.framework.api.ConnectorFacade;
+import org.identityconnectors.framework.common.exceptions.ConnectorException;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.AttributeInfo;
+import org.identityconnectors.framework.common.objects.AttributeInfoUtil;
+import org.identityconnectors.framework.common.objects.AttributeUtil;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
+import org.identityconnectors.framework.common.objects.OperationalAttributes;
+import org.identityconnectors.framework.common.objects.QualifiedUid;
+import org.identityconnectors.framework.common.objects.ResultsHandler;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.framework.common.objects.filter.Filter;
+import org.identityconnectors.framework.common.objects.filter.FilterBuilder;
+import org.identityconnectors.ldap.LdapConfiguration;
+import org.identityconnectors.ldap.LdapConnection;
+import org.identityconnectors.ldap.LdapConnectorTestBase;
+import org.identityconnectors.test.common.TestHelpers;
+import org.identityconnectors.test.common.ToListResultsHandler;
+
+public class LdapSearchTests extends LdapConnectorTestBase {
+
+ // TODO operational attributes.
+ // TODO LDAP directory attributes (entryDN, etc.).
+
+ @Override
+ protected boolean restartServerAfterEachTest() {
+ return false;
+ }
+
+ @Test
+ public void testLdapFilter() {
+ LdapConnection conn = new LdapConnection(newConfiguration());
+
+ LdapFilter filter = LdapFilter.forEntryDN(BUGS_BUNNY_DN);
+ ToListResultsHandler handler = new ToListResultsHandler();
+ new LdapSearch(conn, ObjectClass.ACCOUNT, filter, handler, new \
OperationOptionsBuilder().build()).execute(); + assertEquals(1, \
handler.getObjects().size()); +
+ filter = filter.withNativeFilter("(foo=bar)");
+ handler = new ToListResultsHandler();
+ new LdapSearch(conn, ObjectClass.ACCOUNT, filter, handler, new \
OperationOptionsBuilder().build()).execute(); + \
assertTrue(handler.getObjects().isEmpty()); + }
+
+ @Test
+ public void testLdapFilterWithNonExistingEntryDN() {
+ LdapFilter filter = LdapFilter.forEntryDN("dc=foo,dc=bar");
+
+ // VLV index.
+ LdapConfiguration config = newConfiguration();
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(false);
+ searchExpectingNoResult(config, filter);
+
+ // Simple paged results.
+ config = newConfiguration();
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(true);
+ searchExpectingNoResult(config, filter);
+
+ // No paging.
+ config = newConfiguration();
+ config.setUseBlocks(false);
+ searchExpectingNoResult(config, filter);
+ }
+
+
+ @Test
+ public void testLdapFilterWithInvalidEntryDN() {
+ LdapFilter filter = LdapFilter.forEntryDN("dc=foo,,");
+
+ // VLV index.
+ LdapConfiguration config = newConfiguration();
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(false);
+ searchExpectingNoResult(config, filter);
+
+ // Simple paged results.
+ config = newConfiguration();
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(true);
+ searchExpectingNoResult(config, filter);
+
+ // No paging.
+ config = newConfiguration();
+ config.setUseBlocks(false);
+ searchExpectingNoResult(config, filter);
+ }
+
+ private void searchExpectingNoResult(LdapConfiguration config, LdapFilter \
filter) { + LdapConnection conn = new LdapConnection(config);
+ ToListResultsHandler handler = new ToListResultsHandler();
+ // Should not fail with NameNotFoundException or InvalidNameException.
+ new LdapSearch(conn, ObjectClass.ACCOUNT, filter, handler, new \
OperationOptionsBuilder().build()).execute(); + \
assertTrue(handler.getObjects().isEmpty()); + }
+
+ @Test
+ public void testCanCancelSearch() {
+ // VLV Index.
+ LdapConfiguration config = newConfiguration();
+ config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(false);
+ searchExpectingSingleResult(config);
+
+ // Simple paged results.
+ config = newConfiguration();
+ config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(true);
+ searchExpectingSingleResult(config);
+
+ // No paging.
+ config = newConfiguration();
+ config.setBaseContexts(ACME_DN, BIG_COMPANY_DN);
+ config.setUseBlocks(false);
+ searchExpectingSingleResult(config);
+ }
+
+ private void searchExpectingSingleResult(LdapConfiguration config) {
+ LdapConnection conn = new LdapConnection(config);
+ FirstOnlyResultsHandler handler = new FirstOnlyResultsHandler();
+ new LdapSearch(conn, ObjectClass.ACCOUNT, null, handler, new \
OperationOptionsBuilder().build()).execute(); + handler.assertSingleResult();
+ }
+
+ @Test
+ public void testSimplePagedSearch() {
+ LdapConfiguration config = newConfiguration();
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(true);
+ ConnectorFacade facade = newFacade(config);
+
+ List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null); + assertNotNull(getObjectByName(objects, \
BUGS_BUNNY_DN)); + assertNotNull(getObjectByName(objects, USER_0_DN));
+ // 1000 is the default search size limit for OpenDS.
+ assertTrue(objects.size() > 1000);
+ }
+
+ @Test
+ public void testVlvIndexSearch() {
+ LdapConfiguration config = newConfiguration();
+ config.setBaseContexts(EXAMPLE_COM_DN);
+ config.setUseBlocks(true);
+ config.setUsePagedResultControl(false);
+ config.setUidAttribute("entryDN");
+ ConnectorFacade facade = newFacade(config);
+
+ List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null); + assertNotNull(getObjectByName(objects, \
USER_0_DN)); + // 1000 is the default search size limit for OpenDS.
+ assertTrue(objects.size() > 1000);
+
+ // OpenDS-specific.
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("debugsearchindex");
+ FirstOnlyResultsHandler handler = new FirstOnlyResultsHandler();
+ facade.search(ObjectClass.ACCOUNT, null, handler, builder.build());
+ String debugsearch = \
handler.getSingleResult().getAttributeByName("debugsearchindex").getValue().get(0).toString();
+ assertTrue(debugsearch.contains("vlv"));
+ }
+
+ @Test(expectedExceptions = ConnectorException.class)
+ public void testNoUseBlocks() {
+ LdapConfiguration config = newConfiguration();
+ config.setUseBlocks(false);
+ ConnectorFacade facade = newFacade(config);
+ // This should fail, since the search will exceed the maximum number of
+ // entries to return.
+ TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null);
+ }
+
+ @Test
+ public void testWithFilter() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + assertEquals(BUGS_BUNNY_DN, \
bunny.getName().getNameValue()); + }
+
+ @Test
+ public void testWithFilterByBinaryAttribute() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); +
+ byte[] photo = { -4, -3, -2, -1, 0, 1, 2, 3, 63, 127 };
+ Attribute photoAttr = AttributeBuilder.build("jpegPhoto", photo);
+ Uid newUid = facade.addAttributeValues(ObjectClass.ACCOUNT, bunny.getUid(), \
singleton(photoAttr), null); +
+ ConnectorObject bunnyWithPhoto = searchByAttribute(facade, \
ObjectClass.ACCOUNT, photoAttr, "jpegPhoto"); + assertEquals(newUid, \
bunnyWithPhoto.getUid()); + }
+
+ @Test
+ public void testAttributesToGet() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(USER_0_DN), "employeeNumber", "telephoneNumber"); +
+ Set<Attribute> attrs = newSet(object.getAttributes());
+ assertTrue(attrs.remove(AttributeUtil.find(Uid.NAME, attrs)));
+ assertTrue(attrs.remove(AttributeUtil.find(Name.NAME, attrs)));
+ assertTrue(attrs.remove(AttributeUtil.find("employeeNumber", \
attrs))); + assertTrue(attrs.remove(AttributeUtil.find("telephoneNumber", \
attrs))); +
+ assertTrue(attrs.isEmpty());
+ }
+
+ @Test
+ public void testAttributesReturnedByDefaultWithNoValueAreNotReturned() {
+ LdapConfiguration config = newConfiguration(true);
+ ConnectorFacade facade = newFacade(config);
+ AttributeInfo attr = AttributeInfoUtil.find("givenName", \
facade.schema().findObjectClassInfo(ObjectClass.ACCOUNT_NAME).getAttributeInfo()); + \
assertTrue(attr.isReturnedByDefault()); +
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN)); + \
assertNull(object.getAttributeByName("givenName")); + }
+
+ @Test
+ public void testAttributesToGetNotPresentInEntryAreEmpty() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject object = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN), "employeeNumber"); +
+ assertTrue(object.getAttributeByName("employeeNumber").getValue().isEmpty());
+ }
+
+ @Test
+ public void testScope() {
+ ConnectorFacade facade = newFacade();
+ // Find an organization to pass in OP_CONTAINER.
+ ObjectClass oclass = new ObjectClass("organization");
+ ConnectorObject organization = searchByAttribute(facade, oclass, new \
Name(BIG_COMPANY_DN)); +
+ // There are no accounts directly under the organization...
+ OperationOptionsBuilder optionsBuilder = new OperationOptionsBuilder();
+ optionsBuilder.setScope(OperationOptions.SCOPE_ONE_LEVEL);
+ optionsBuilder.setContainer(new QualifiedUid(oclass, \
organization.getUid())); + List<ConnectorObject> objects = \
TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null, optionsBuilder.build()); \
+ assertTrue(objects.isEmpty()); +
+ // ... but there are some in the organization subtree.
+ optionsBuilder.setScope(OperationOptions.SCOPE_SUBTREE);
+ objects = TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null, \
optionsBuilder.build()); + assertFalse(objects.isEmpty());
+ }
+
+ @Test
+ public void testAccountSearchFilter() {
+ ConnectorFacade facade = newFacade();
+ // Find an organization to pass in OP_CONTAINER.
+ ObjectClass oclass = new ObjectClass("organization");
+ ConnectorObject organization = searchByAttribute(facade, oclass, new \
Name(ACME_DN)); +
+ // First just check that there really are some users.
+ OperationOptionsBuilder optionsBuilder = new OperationOptionsBuilder();
+ optionsBuilder.setScope(OperationOptions.SCOPE_SUBTREE);
+ optionsBuilder.setContainer(new QualifiedUid(oclass, \
organization.getUid())); + List<ConnectorObject> objects = \
TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null, optionsBuilder.build()); \
+ assertNotNull(getObjectByName(objects, BUGS_BUNNY_DN)); + \
assertNotNull(getObjectByName(objects, ELMER_FUDD_DN)); +
+ LdapConfiguration config = newConfiguration();
+ config.setAccountSearchFilter("(uid=" + BUGS_BUNNY_UID + \
")"); + facade = newFacade(config);
+ objects = TestHelpers.searchToList(facade, ObjectClass.ACCOUNT, null, \
optionsBuilder.build()); + assertEquals(1, objects.size());
+ assertNotNull(getObjectByName(objects, BUGS_BUNNY_DN));
+ }
+
+ @Test
+ public void testAccountSearchFilterOnlyAppliesToAccounts() {
+ LdapConfiguration config = newConfiguration();
+ config.setAccountSearchFilter("(cn=foobarbaz)");
+ ConnectorFacade facade = newFacade(config);
+
+ // If the (cn=foobarbaz) filter above applied, the search would return \
nothing. + assertNotNull(searchByAttribute(facade, new \
ObjectClass("organization"), new Name(ACME_DN))); + }
+
+ @Test
+ public void testMissingParenthesesAddedToAccountSearchFilter() {
+ LdapConfiguration config = newConfiguration();
+ config.setAccountSearchFilter("uid=" + BUGS_BUNNY_UID); // No \
parentheses enclosing the filter. + ConnectorFacade facade = \
newFacade(config); +
+ // If parentheses were not added, the search would fail.
+ assertNotNull(searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN))); + }
+
+ @Test
+ public void testMultipleBaseDNs() {
+ ConnectorFacade facade = newFacade();
+
+ // This should find accounts from both base DNs.
+ List<ConnectorObject> objects = TestHelpers.searchToList(facade, \
ObjectClass.ACCOUNT, null); + assertNotNull(getObjectByName(objects, \
BUGS_BUNNY_DN)); + assertNotNull(getObjectByName(objects, USER_0_DN));
+ }
+
+ @Test
+ public void testUidAttributeCn() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.getUidAttribute().equalsIgnoreCase("cn"));
+ config.setUidAttribute("cn");
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Uid(BUGS_BUNNY_CN)); + assertEquals(BUGS_BUNNY_DN, \
bunny.getName().getNameValue()); + }
+
+ @Test
+ public void testUidAttributeEntryDN() {
+ LdapConfiguration config = newConfiguration();
+ assertFalse(config.getUidAttribute().equalsIgnoreCase("entryDN"));
+ config.setUidAttribute("entryDN");
+ ConnectorFacade facade = newFacade(config);
+
+ ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Uid(BUGS_BUNNY_DN)); + assertEquals(BUGS_BUNNY_DN, \
bunny.getName().getNameValue()); + }
+
+ @Test
+ public void testSearchArbitraryObjectClass() {
+ ConnectorFacade facade = newFacade();
+
+ // Simplest: try w/o filter.
+ List<ConnectorObject> objects = TestHelpers.searchToList(facade, new \
ObjectClass("country"), null, null); + ConnectorObject czechRep = \
getObjectByName(objects, CZECH_REPUBLIC_DN); +
+ // Try with a name filter and options.
+ Filter filter = FilterBuilder.equalTo(AttributeBuilder.build(Name.NAME, \
CZECH_REPUBLIC_DN)); + OperationOptionsBuilder builder = new \
OperationOptionsBuilder(); + builder.setAttributesToGet("c");
+ objects = TestHelpers.searchToList(facade, new \
ObjectClass("country"), filter, builder.build()); + czechRep = \
getObjectByName(objects, CZECH_REPUBLIC_DN); + assertEquals(CZECH_REPUBLIC_C, \
AttributeUtil.getAsStringValue(czechRep.getAttributeByName("c"))); + }
+
+ @Test
+ public void testCannotReturnPasswordFromSearch() {
+ ConnectorFacade facade = newFacade();
+ ConnectorObject bunny = searchByAttribute(facade, ObjectClass.ACCOUNT, new \
Name(BUGS_BUNNY_DN), OperationalAttributes.PASSWORD_NAME); + GuardedString \
password = (GuardedString) \
bunny.getAttributeByName(OperationalAttributes.PASSWORD_NAME).getValue().get(0); + \
password.access(new Accessor() { + public void access(char[] clearChars) {
+ assertEquals(0, clearChars.length);
+ }
+ });
+ }
+
+ private static ConnectorObject getObjectByName(List<ConnectorObject> \
objects, String name) { + for (ConnectorObject object : objects) {
+ if (name.equals(object.getName().getNameValue())) {
+ return object;
+ }
+ }
+ return null;
+ }
+
+ private static final class FirstOnlyResultsHandler implements ResultsHandler {
+
+ private final List<ConnectorObject> objects = new \
ArrayList<ConnectorObject>(); +
+ public boolean handle(ConnectorObject obj) {
+ objects.add(obj);
+ return false; // We only want the first one.
+ }
+
+ public void assertSingleResult() {
+ assertEquals(1, objects.size());
+ }
+
+ public ConnectorObject getSingleResult() {
+ return objects.get(0);
+ }
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsyncsundsLdapModifyForTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,206 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.sync.sunds;
-
-import org.testng.annotations.Test;
-import static org.identityconnectors.ldap.LdapUtil.quietCreateLdapName;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.ModificationItem;
-import javax.naming.ldap.LdapContext;
-import javax.naming.ldap.LdapName;
-import javax.naming.ldap.Rdn;
-
-import org.identityconnectors.common.logging.Log;
-import org.identityconnectors.ldap.LdapConnection;
-import org.identityconnectors.ldap.sync.sunds.LdifParser.ChangeSeparator;
-import org.identityconnectors.ldap.sync.sunds.LdifParser.Line;
-import org.identityconnectors.ldap.sync.sunds.LdifParser.NameValue;
-import org.identityconnectors.ldap.sync.sunds.LdifParser.Separator;
-
-/**
- * A simple, and in no way complete, way to modify an LDAP server
- * based on an LDIF file.
- */
-public class LdapModifyForTests {
-
- private static final Log log = Log.getLog(LdapModifyForTests.class);
-
- public static void modify(LdapConnection conn, String ldif) throws \
NamingException {
- LdifParser parser = new LdifParser(ldif);
- Iterator<Line> lines = parser.iterator();
-
- String dn = null;
- String changeType = null;
-
- Map<String, List<String>> added = new HashMap<String, \
List<String>>();
- Map<String, List<String>> deleted = new HashMap<String, \
List<String>>();
- Map<String, List<String>> modifyMap = null;
-
- String newRdn = null;
- String deleteOldRdn = "true";
-
- while (lines.hasNext()) {
- Line line = lines.next();
- if (line instanceof ChangeSeparator && dn != null) {
- performChange(conn, dn, changeType, added, deleted, newRdn, \
deleteOldRdn);
- dn = null;
- changeType = null;
- added.clear();
- deleted.clear();
- modifyMap = null;
- newRdn = null;
- deleteOldRdn = "true";
- continue;
- }
- if (dn == null) {
- NameValue nameValue = (NameValue) line;
- if (!"dn".equalsIgnoreCase(nameValue.getName())) {
- throw new IllegalArgumentException();
- }
- dn = nameValue.getValue();
- continue;
- }
- if (changeType == null) {
- NameValue nameValue = (NameValue) line;
- if (!"changeType".equalsIgnoreCase(nameValue.getName())) {
- throw new IllegalArgumentException();
- }
- changeType = nameValue.getValue();
- continue;
- }
- if ("add".equalsIgnoreCase(changeType)) {
- NameValue nameValue = (NameValue) line;
- List<String> values = added.get(nameValue.getName());
- if (values == null) {
- values = new ArrayList<String>();
- added.put(nameValue.getName(), values);
- }
- values.add(nameValue.getValue());
- } else if ("modify".equalsIgnoreCase(changeType)) {
- if (line instanceof Separator) {
- modifyMap = null;
- continue;
- }
- if (modifyMap == null) {
- NameValue nameValue = (NameValue) line;
- String op = nameValue.getName();
- if ("add".equalsIgnoreCase(op)) {
- modifyMap = added;
- } else if ("delete".equalsIgnoreCase(op)) {
- modifyMap = deleted;
- } else {
- throw new IllegalArgumentException();
- }
- continue;
- }
- if (modifyMap != null) {
- NameValue nameValue = (NameValue) line;
- List<String> values = modifyMap.get(nameValue.getName());
- if (values == null) {
- values = new ArrayList<String>();
- modifyMap.put(nameValue.getName(), values);
- }
- values.add(nameValue.getValue());
- }
- } else if ("modrdn".equalsIgnoreCase(changeType)) {
- NameValue nameValue = (NameValue) line;
- if ("newRdn".equalsIgnoreCase(nameValue.getName())) {
- newRdn = nameValue.getValue();
- } else if \
("deleteOldRdn".equalsIgnoreCase(nameValue.getName())) {
- deleteOldRdn = nameValue.getValue().toLowerCase(Locale.US);
- }
- }
- }
- }
-
- private static void performChange(LdapConnection conn, String dn, String \
changeType,
- Map<String, List<String>> added, Map<String, \
List<String>> deleted, String newRdn, String deleteOldRdn)
- throws NamingException {
- if ("add".equalsIgnoreCase(changeType)) {
- BasicAttributes attrs = new BasicAttributes();
- for (Entry<String, List<String>> entry : added.entrySet()) {
- Attribute attr = new BasicAttribute(entry.getKey());
- for (String each : entry.getValue()) {
- attr.add(each);
- }
- attrs.put(attr);
- }
- LdapName newName = quietCreateLdapName(dn);
- log.ok("Creating context {0} with attributes {1}", newName, \
attrs);
- String container = newName.getPrefix(newName.size() - 1).toString();
- Rdn rdn = newName.getRdn(newName.size() - 1);
- LdapContext containerCtx = (LdapContext) \
conn.getInitialContext().lookup(container);
- containerCtx.createSubcontext(rdn.toString(), attrs);
- } else if ("modify".equalsIgnoreCase(changeType)) {
- List<ModificationItem> modItems = new \
ArrayList<ModificationItem>();
- addModificationItems(DirContext.ADD_ATTRIBUTE, added, modItems);
- addModificationItems(DirContext.REMOVE_ATTRIBUTE, deleted, modItems);
- log.ok("Modifying context {0} with attributes {1}", dn, \
modItems);
- conn.getInitialContext().modifyAttributes(dn, modItems.toArray(new \
ModificationItem[modItems.size()]));
- } else if ("delete".equalsIgnoreCase(changeType)) {
- log.ok("Deleting context {0}");
- conn.getInitialContext().destroySubcontext(dn);
- } else if ("modrdn".equalsIgnoreCase(changeType)) {
- LdapName oldName = quietCreateLdapName(dn);
- LdapName newName = (LdapName) oldName.getPrefix(oldName.size() - 1);
- newName.add(newRdn);
- log.ok("Renaming context {0} to {1}", oldName, newName);
- LdapContext ctx = conn.getInitialContext().newInstance(null);
- try {
- ctx.addToEnvironment("java.naming.ldap.deleteRDN", \
deleteOldRdn);
- ctx.rename(oldName, newName);
- } finally {
- ctx.close();
- }
- }
- }
-
- private static void addModificationItems(int operation, Map<String, \
List<String>> map, List<ModificationItem> toList) {
- for (Entry<String, List<String>> entry : map.entrySet()) {
- Attribute attr = new BasicAttribute(entry.getKey());
- for (String each : entry.getValue()) {
- attr.add(each);
- }
- toList.add(new ModificationItem(operation, attr));
- }
- }
-
- @Test
- public void dummy() {
- // This is here because the class needs to end in "Tests" for it \
not to be
- // included in the jar, but then JUnit complains about no runnable methods.
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsyncsundsLda \
pModifyForTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapsyncsundsLdapModifyForTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdapModifyForTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,206 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.sync.sunds;
+
+import org.testng.annotations.Test;
+import static org.identityconnectors.ldap.LdapUtil.quietCreateLdapName;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.BasicAttribute;
+import javax.naming.directory.BasicAttributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.LdapName;
+import javax.naming.ldap.Rdn;
+
+import org.identityconnectors.common.logging.Log;
+import org.identityconnectors.ldap.LdapConnection;
+import org.identityconnectors.ldap.sync.sunds.LdifParser.ChangeSeparator;
+import org.identityconnectors.ldap.sync.sunds.LdifParser.Line;
+import org.identityconnectors.ldap.sync.sunds.LdifParser.NameValue;
+import org.identityconnectors.ldap.sync.sunds.LdifParser.Separator;
+
+/**
+ * A simple, and in no way complete, way to modify an LDAP server
+ * based on an LDIF file.
+ */
+public class LdapModifyForTests {
+
+ private static final Log log = Log.getLog(LdapModifyForTests.class);
+
+ public static void modify(LdapConnection conn, String ldif) throws \
NamingException { + LdifParser parser = new LdifParser(ldif);
+ Iterator<Line> lines = parser.iterator();
+
+ String dn = null;
+ String changeType = null;
+
+ Map<String, List<String>> added = new HashMap<String, \
List<String>>(); + Map<String, List<String>> deleted = \
new HashMap<String, List<String>>(); + Map<String, \
List<String>> modifyMap = null; +
+ String newRdn = null;
+ String deleteOldRdn = "true";
+
+ while (lines.hasNext()) {
+ Line line = lines.next();
+ if (line instanceof ChangeSeparator && dn != null) {
+ performChange(conn, dn, changeType, added, deleted, newRdn, \
deleteOldRdn); + dn = null;
+ changeType = null;
+ added.clear();
+ deleted.clear();
+ modifyMap = null;
+ newRdn = null;
+ deleteOldRdn = "true";
+ continue;
+ }
+ if (dn == null) {
+ NameValue nameValue = (NameValue) line;
+ if (!"dn".equalsIgnoreCase(nameValue.getName())) {
+ throw new IllegalArgumentException();
+ }
+ dn = nameValue.getValue();
+ continue;
+ }
+ if (changeType == null) {
+ NameValue nameValue = (NameValue) line;
+ if (!"changeType".equalsIgnoreCase(nameValue.getName())) {
+ throw new IllegalArgumentException();
+ }
+ changeType = nameValue.getValue();
+ continue;
+ }
+ if ("add".equalsIgnoreCase(changeType)) {
+ NameValue nameValue = (NameValue) line;
+ List<String> values = added.get(nameValue.getName());
+ if (values == null) {
+ values = new ArrayList<String>();
+ added.put(nameValue.getName(), values);
+ }
+ values.add(nameValue.getValue());
+ } else if ("modify".equalsIgnoreCase(changeType)) {
+ if (line instanceof Separator) {
+ modifyMap = null;
+ continue;
+ }
+ if (modifyMap == null) {
+ NameValue nameValue = (NameValue) line;
+ String op = nameValue.getName();
+ if ("add".equalsIgnoreCase(op)) {
+ modifyMap = added;
+ } else if ("delete".equalsIgnoreCase(op)) {
+ modifyMap = deleted;
+ } else {
+ throw new IllegalArgumentException();
+ }
+ continue;
+ }
+ if (modifyMap != null) {
+ NameValue nameValue = (NameValue) line;
+ List<String> values = modifyMap.get(nameValue.getName());
+ if (values == null) {
+ values = new ArrayList<String>();
+ modifyMap.put(nameValue.getName(), values);
+ }
+ values.add(nameValue.getValue());
+ }
+ } else if ("modrdn".equalsIgnoreCase(changeType)) {
+ NameValue nameValue = (NameValue) line;
+ if ("newRdn".equalsIgnoreCase(nameValue.getName())) {
+ newRdn = nameValue.getValue();
+ } else if \
("deleteOldRdn".equalsIgnoreCase(nameValue.getName())) { + \
deleteOldRdn = nameValue.getValue().toLowerCase(Locale.US); + }
+ }
+ }
+ }
+
+ private static void performChange(LdapConnection conn, String dn, String \
changeType, + Map<String, List<String>> added, Map<String, \
List<String>> deleted, String newRdn, String deleteOldRdn) + \
throws NamingException { + if ("add".equalsIgnoreCase(changeType)) {
+ BasicAttributes attrs = new BasicAttributes();
+ for (Entry<String, List<String>> entry : added.entrySet()) {
+ Attribute attr = new BasicAttribute(entry.getKey());
+ for (String each : entry.getValue()) {
+ attr.add(each);
+ }
+ attrs.put(attr);
+ }
+ LdapName newName = quietCreateLdapName(dn);
+ log.ok("Creating context {0} with attributes {1}", newName, \
attrs); + String container = newName.getPrefix(newName.size() - \
1).toString(); + Rdn rdn = newName.getRdn(newName.size() - 1);
+ LdapContext containerCtx = (LdapContext) \
conn.getInitialContext().lookup(container); + \
containerCtx.createSubcontext(rdn.toString(), attrs); + } else if \
("modify".equalsIgnoreCase(changeType)) { + \
List<ModificationItem> modItems = new ArrayList<ModificationItem>(); + \
addModificationItems(DirContext.ADD_ATTRIBUTE, added, modItems); + \
addModificationItems(DirContext.REMOVE_ATTRIBUTE, deleted, modItems); + \
log.ok("Modifying context {0} with attributes {1}", dn, modItems); + \
conn.getInitialContext().modifyAttributes(dn, modItems.toArray(new \
ModificationItem[modItems.size()])); + } else if \
("delete".equalsIgnoreCase(changeType)) { + \
log.ok("Deleting context {0}"); + \
conn.getInitialContext().destroySubcontext(dn); + } else if \
("modrdn".equalsIgnoreCase(changeType)) { + LdapName oldName = \
quietCreateLdapName(dn); + LdapName newName = (LdapName) \
oldName.getPrefix(oldName.size() - 1); + newName.add(newRdn);
+ log.ok("Renaming context {0} to {1}", oldName, newName);
+ LdapContext ctx = conn.getInitialContext().newInstance(null);
+ try {
+ ctx.addToEnvironment("java.naming.ldap.deleteRDN", \
deleteOldRdn); + ctx.rename(oldName, newName);
+ } finally {
+ ctx.close();
+ }
+ }
+ }
+
+ private static void addModificationItems(int operation, Map<String, \
List<String>> map, List<ModificationItem> toList) { + for \
(Entry<String, List<String>> entry : map.entrySet()) { + \
Attribute attr = new BasicAttribute(entry.getKey()); + for (String each : \
entry.getValue()) { + attr.add(each);
+ }
+ toList.add(new ModificationItem(operation, attr));
+ }
+ }
+
+ @Test
+ public void dummy() {
+ // This is here because the class needs to end in "Tests" for it \
not to be + // included in the jar, but then JUnit complains about no runnable \
methods. + }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsyncsundsLdifParserTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,94 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.sync.sunds;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import java.util.Iterator;
-
-import org.identityconnectors.ldap.sync.sunds.LdifParser.ChangeSeparator;
-import org.identityconnectors.ldap.sync.sunds.LdifParser.Line;
-import org.identityconnectors.ldap.sync.sunds.LdifParser.NameValue;
-import org.identityconnectors.ldap.sync.sunds.LdifParser.Separator;
-
-public class LdifParserTests {
-
- @Test
- public void testSimple() {
- String ldif =
- "changeType: mo\n" +
- " dify\n" +
- "rep\n" +
- " lace: cn\n" +
- "cn: Na\n" +
- " me 1\n" +
- "cn: Name 2\n" +
- "-\n" +
- "\n" +
- "\n" +
- "c\n" +
- " hang\n" +
- " eType: add\n" +
- "add: \n" +
- " uid\n" +
- "uid: \n" +
- " 1\n" +
- "\n" +
- "changeType: delete\n";
-
- LdifParser parser = new LdifParser(ldif);
- Iterator<Line> lines = parser.iterator();
- assertLineEquals(lines.next(), new NameValue("changeType", \
"modify"));
- assertLineEquals(lines.next(), new NameValue("replace", \
"cn"));
- assertLineEquals(lines.next(), new NameValue("cn", "Name \
1"));
- assertLineEquals(lines.next(), new NameValue("cn", "Name \
2"));
- assertTrue(lines.next() instanceof Separator);
- // LdifParser merges multiple change separators into one.
- assertTrue(lines.next() instanceof ChangeSeparator);
- assertLineEquals(lines.next(), new NameValue("changeType", \
"add"));
- assertLineEquals(lines.next(), new NameValue("add", \
"uid"));
- assertLineEquals(lines.next(), new NameValue("uid", \
"1"));
- assertTrue(lines.next() instanceof ChangeSeparator);
- assertLineEquals(lines.next(), new NameValue("changeType", \
"delete"));
- assertTrue(lines.next() instanceof ChangeSeparator);
- }
-
- @Test
- public void testChangeSeparatorAsLastLine() {
- String ldif =
- "changeType: modify";
-
- LdifParser parser = new LdifParser(ldif);
- Iterator<Line> lines = parser.iterator();
- assertLineEquals(lines.next(), new NameValue("changeType", \
"modify"));
- assertTrue(lines.next() instanceof ChangeSeparator);
- }
-
- private static void assertLineEquals(Line expected, NameValue value) {
- assertTrue(expected instanceof NameValue);
- NameValue expectedValue = (NameValue) expected;
- assertEquals(expectedValue.getName(), value.getName());
- assertEquals(expectedValue.getValue(), value.getValue());
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsyncsundsLdi \
fParserTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapsyncsundsLdifParserTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/LdifParserTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.sync.sunds;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import java.util.Iterator;
+
+import org.identityconnectors.ldap.sync.sunds.LdifParser.ChangeSeparator;
+import org.identityconnectors.ldap.sync.sunds.LdifParser.Line;
+import org.identityconnectors.ldap.sync.sunds.LdifParser.NameValue;
+import org.identityconnectors.ldap.sync.sunds.LdifParser.Separator;
+
+public class LdifParserTests {
+
+ @Test
+ public void testSimple() {
+ String ldif =
+ "changeType: mo\n" +
+ " dify\n" +
+ "rep\n" +
+ " lace: cn\n" +
+ "cn: Na\n" +
+ " me 1\n" +
+ "cn: Name 2\n" +
+ "-\n" +
+ "\n" +
+ "\n" +
+ "c\n" +
+ " hang\n" +
+ " eType: add\n" +
+ "add: \n" +
+ " uid\n" +
+ "uid: \n" +
+ " 1\n" +
+ "\n" +
+ "changeType: delete\n";
+
+ LdifParser parser = new LdifParser(ldif);
+ Iterator<Line> lines = parser.iterator();
+ assertLineEquals(lines.next(), new NameValue("changeType", \
"modify")); + assertLineEquals(lines.next(), new \
NameValue("replace", "cn")); + \
assertLineEquals(lines.next(), new NameValue("cn", "Name 1")); + \
assertLineEquals(lines.next(), new NameValue("cn", "Name 2")); + \
assertTrue(lines.next() instanceof Separator); + // LdifParser merges multiple \
change separators into one. + assertTrue(lines.next() instanceof \
ChangeSeparator); + assertLineEquals(lines.next(), new \
NameValue("changeType", "add")); + \
assertLineEquals(lines.next(), new NameValue("add", "uid")); + \
assertLineEquals(lines.next(), new NameValue("uid", "1")); + \
assertTrue(lines.next() instanceof ChangeSeparator); + \
assertLineEquals(lines.next(), new NameValue("changeType", \
"delete")); + assertTrue(lines.next() instanceof ChangeSeparator);
+ }
+
+ @Test
+ public void testChangeSeparatorAsLastLine() {
+ String ldif =
+ "changeType: modify";
+
+ LdifParser parser = new LdifParser(ldif);
+ Iterator<Line> lines = parser.iterator();
+ assertLineEquals(lines.next(), new NameValue("changeType", \
"modify")); + assertTrue(lines.next() instanceof ChangeSeparator);
+ }
+
+ private static void assertLineEquals(Line expected, NameValue value) {
+ assertTrue(expected instanceof NameValue);
+ NameValue expectedValue = (NameValue) expected;
+ assertEquals(expectedValue.getName(), value.getName());
+ assertEquals(expectedValue.getValue(), value.getValue());
+ }
+}
</ins></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsyncsundsSunDSChangeLogSyncStrategyTestsjava"></a>
<div class="delfile"><h4>Deleted: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java \
(6871 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java 2015-09-11 \
09:21:57 UTC (rev 6871)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -1,304 +0,0 @@
</span><del>-/*
- * ====================
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
- *
- * The contents of this file are subject to the terms of the Common Development
- * and Distribution License("CDDL") (the "License"). You may \
not use this file
- * except in compliance with the License.
- *
- * You can obtain a copy of the License at
- * http://IdentityConnectors.dev.java.net/legal/license.txt
- * See the License for the specific language governing permissions and limitations
- * under the License.
- *
- * When distributing the Covered Code, include this CDDL Header Notice in each file
- * and include the License file at identityconnectors/legal/license.txt.
- * If applicable, add the following below this CDDL Header, with the fields
- * enclosed by brackets [] replaced by your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * ====================
- */
-package org.identityconnectors.ldap.sync.sunds;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.Test;
-import static java.util.Collections.emptyList;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.naming.NamingException;
-
-import org.identityconnectors.common.logging.Log;
-import org.identityconnectors.framework.api.operations.SyncApiOp;
-import org.identityconnectors.framework.common.objects.AttributeBuilder;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
-import org.identityconnectors.framework.common.objects.Name;
-import org.identityconnectors.framework.common.objects.ObjectClass;
-import org.identityconnectors.framework.common.objects.ObjectClassInfo;
-import org.identityconnectors.framework.common.objects.OperationOptions;
-import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
-import org.identityconnectors.framework.common.objects.Schema;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-import org.identityconnectors.framework.common.objects.SyncDeltaType;
-import org.identityconnectors.framework.common.objects.SyncResultsHandler;
-import org.identityconnectors.framework.common.objects.SyncToken;
-import org.identityconnectors.framework.common.objects.Uid;
-import org.identityconnectors.ldap.LdapConfiguration;
-import org.identityconnectors.ldap.LdapConnection;
-import org.identityconnectors.ldap.SunDSTestBase;
-import org.identityconnectors.ldap.LdapConstants.ServerType;
-
-public class SunDSChangeLogSyncStrategyTests extends SunDSTestBase {
-
- private static final Log log = \
Log.getLog(SunDSChangeLogSyncStrategyTests.class);
-
- private static final int STABLE_CHANGELOG_INTERVAL = 2000; /* milliseconds */
-
- private static LdapConnection newConnection(LdapConfiguration config) throws \
NamingException {
- LdapConnection conn = new LdapConnection(config);
- cleanupBaseContext(conn);
- waitForChangeLogToStabilize(conn);
- return conn;
- }
-
- private static void waitForChangeLogToStabilize(LdapConnection conn) {
- int lastChangeNumber = -1;
- int previousLastChangeNumber;
- do {
- if (lastChangeNumber > 0) {
- log.ok("Waiting for change log to stabilize (last change \
number: {0})", lastChangeNumber);
- try {
- Thread.sleep(STABLE_CHANGELOG_INTERVAL);
- } catch (InterruptedException e) {
- // Ignore.
- }
- }
- previousLastChangeNumber = lastChangeNumber;
- lastChangeNumber = new SunDSChangeLogSyncStrategy(conn, \
ObjectClass.ACCOUNT).getChangeLogAttributes().getLastChangeNumber();
- } while (lastChangeNumber != previousLastChangeNumber);
- }
-
- private List<SyncDelta> doTest(LdapConnection conn, String ldif, int \
expected) throws NamingException {
- SunDSChangeLogSyncStrategy sync = new SunDSChangeLogSyncStrategy(conn, \
ObjectClass.ACCOUNT);
- SyncToken token = sync.getLatestSyncToken();
-
- LdapModifyForTests.modify(conn, ldif);
- waitForChangeLogToStabilize(conn);
-
- OperationOptionsBuilder builder = new OperationOptionsBuilder();
- builder.setAttributesToGet("cn", "sn", \
"givenName", "uid");
- OperationOptions options = builder.build();
-
- final List<SyncDelta> result = new ArrayList<SyncDelta>();
- sync.sync(token, new SyncResultsHandler() {
- public boolean handle(SyncDelta delta) {
- result.add(delta);
- return true;
- }
- }, options);
- return result;
- }
-
- @Test
- public void testSimple() throws Exception {
- LdapConnection conn = newConnection(newConfiguration());
- String baseContext = conn.getConfiguration().getBaseContexts()[0];
-
- String entryDN = "uid=foobar," + baseContext;
- List<SyncDelta> result = doTest(conn,
- "dn: " +entryDN + "\n" +
- "changetype: add\n" +
- "objectClass: inetOrgPerson\n" +
- "objectClass: organizationalPerson\n" +
- "objectClass: person\n" +
- "objectClass: top\n" +
- "uid: foobar\n" +
- "cn: Foo Bar\n" +
- "sn: Bar\n", 1);
-
- assertEquals(1, result.size());
- SyncDelta delta = result.get(0);
- assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
- ConnectorObject object = delta.getObject();
- assertEquals(new Uid(entryDN), object.getUid());
- assertEquals(new Name(entryDN), object.getName());
- assertEquals(AttributeBuilder.build("uid", "foobar"), \
object.getAttributeByName("uid"));
- assertEquals(AttributeBuilder.build("cn", "Foo Bar"), \
object.getAttributeByName("cn"));
- assertEquals(AttributeBuilder.build("sn", "Bar"), \
object.getAttributeByName("sn"));
-
- result = doTest(conn,
- "dn: " + entryDN + "\n" +
- "changeType: modrdn\n" +
- "newRdn: cn=Foo Bar", 1);
- entryDN = "cn=Foo Bar," + baseContext;
-
- assertEquals(1, result.size());
- delta = result.get(0);
- assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
- object = delta.getObject();
- assertEquals(new Uid(entryDN), object.getUid());
- assertEquals(new Name(entryDN), object.getName());
- assertEquals(AttributeBuilder.build("uid", emptyList()), \
object.getAttributeByName("uid"));
- assertEquals(AttributeBuilder.build("cn", "Foo Bar"), \
object.getAttributeByName("cn"));
- assertEquals(AttributeBuilder.build("sn", "Bar"), \
object.getAttributeByName("sn"));
-
- result = doTest(conn,
- "dn: " + entryDN + "\n" +
- "changeType: modify\n" +
- "add: cn\n" +
- "cn: Dummy User", 1);
-
- assertEquals(1, result.size());
- delta = result.get(0);
- assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
- object = delta.getObject();
- assertEquals(AttributeBuilder.build("cn", "Foo Bar", \
"Dummy User"), object.getAttributeByName("cn"));
-
- result = doTest(conn,
- "dn: " + entryDN + "\n" +
- "changeType: modrdn\n" +
- "newRdn: cn=Dummy User\n" +
- "deleteOldRdn: FALSE", 1);
- entryDN = "cn=Dummy User," + baseContext;
-
- assertEquals(1, result.size());
- delta = result.get(0);
- assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
- object = delta.getObject();
- assertEquals(new Uid(entryDN), object.getUid());
- assertEquals(new Name(entryDN), object.getName());
- assertEquals(AttributeBuilder.build("cn", "Foo Bar", \
"Dummy User"), object.getAttributeByName("cn"));
-
- result = doTest(conn,
- "dn: " + entryDN + "\n" +
- "changeType: modify\n" +
- "delete: cn\n" +
- "cn: Foo Bar", 1);
-
- assertEquals(1, result.size());
- delta = result.get(0);
- assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
- object = delta.getObject();
- assertEquals(AttributeBuilder.build("cn", "Dummy User"), \
object.getAttributeByName("cn"));
-
- result = doTest(conn,
- "dn: " + entryDN + "\n" +
- "changeType: delete", 1);
-
- assertEquals(1, result.size());
- delta = result.get(0);
- assertEquals(SyncDeltaType.DELETE, delta.getDeltaType());
- assertEquals(new Uid(entryDN), delta.getUid());
- }
-
- @Test
- public void testAllBlocksReturnedFromSingleSyncCall() throws NamingException {
- LdapConfiguration config = newConfiguration();
- // Set a small block size so connector would have to do
- // a couple of searches to return all deltas.
- config.setChangeLogBlockSize(2);
- LdapConnection conn = newConnection(config);
- String baseContext = conn.getConfiguration().getBaseContexts()[0];
-
- int COUNT = 10;
- StringBuilder ldif = new StringBuilder();
- for (int i = 0; i < COUNT; i++) {
- String name = "user." + i;
- String entryDN = "uid=" + name + "," + baseContext;
- ldif.append(MessageFormat.format(
- "dn: {0}\n" +
- "changetype: add\n" +
- "objectClass: inetOrgPerson\n" +
- "objectClass: organizationalPerson\n" +
- "objectClass: person\n" +
- "objectClass: top\n" +
- "uid: {1}\n" +
- "cn: {1}\n" +
- "sn: {1}\n" +
- "\n",
- entryDN, name));
- }
-
- List<SyncDelta> result = doTest(conn, ldif.toString(), COUNT);
- assertEquals(10, result.size());
- for (int i = 0; i < COUNT; i++) {
- String name = "user." + i;
- String entryDN = "uid=" + name + "," + baseContext;
- ConnectorObject object = result.get(i).getObject();
- assertEquals(new Uid(entryDN), object.getUid());
- assertEquals(new Name(entryDN), object.getName());
- }
- }
-
- @Test
- public void testFilterOutByBaseContexts() throws NamingException {
- LdapConfiguration config = newConfiguration();
- String baseContext = config.getBaseContexts()[0];
- config.setBaseContextsToSynchronize("ou=Subcontext," + \
baseContext);
- LdapConnection conn = newConnection(config);
- testExpectingNoDelta(conn);
- }
-
- @Test
- public void testFilterOutByModifiersNames() throws NamingException {
- LdapConfiguration config = newConfiguration();
- config.setModifiersNamesToFilterOut("cn=Directory Manager");
- LdapConnection conn = newConnection(config);
- testExpectingNoDelta(conn);
- }
-
- @Test
- public void testFilterOutByAttributes() throws NamingException {
- LdapConfiguration config = newConfiguration();
- config.setAttributesToSynchronize("telephoneNumber");
- LdapConnection conn = newConnection(config);
- testExpectingNoDelta(conn);
- }
-
- @Test
- public void testFilterOutByObjectClasses() throws NamingException {
- LdapConfiguration config = newConfiguration();
- config.setObjectClassesToSynchronize("groupOfUniqueNames");
- LdapConnection conn = newConnection(config);
- testExpectingNoDelta(conn);
- }
-
- @Test
- public void testAccountSynchronizationFilter() throws NamingException {
- LdapConfiguration config = newConfiguration();
- config.setAccountSynchronizationFilter("cn=value");
- LdapConnection conn = newConnection(config);
- testExpectingNoDelta(conn);
- }
-
- @Test(enabled = false)
- private void testExpectingNoDelta(LdapConnection conn) throws NamingException {
- String baseContext = conn.getConfiguration().getBaseContexts()[0];
- String entryDN = "uid=foobar," + baseContext;
- List<SyncDelta> result = doTest(conn,
- "dn: " +entryDN + "\n" +
- "changetype: add\n" +
- "objectClass: inetOrgPerson\n" +
- "objectClass: organizationalPerson\n" +
- "objectClass: person\n" +
- "objectClass: top\n" +
- "uid: foobar\n" +
- "cn: Foo Bar\n" +
- "sn: Bar\n", 0);
- assertTrue(result.isEmpty());
- }
-
- @Test
- public void testSyncSupported() throws NamingException {
- LdapConfiguration config = newConfiguration();
- LdapConnection conn = newConnection(config);
- assertEquals(ServerType.SUN_DSEE, conn.getServerType());
- Schema schema = newFacade(config).schema();
- ObjectClassInfo accountInfo = \
schema.findObjectClassInfo(ObjectClass.ACCOUNT_NAME);
- assertTrue(schema.getSupportedObjectClassesByOperation().get(SyncApiOp.class).contains(accountInfo));
- }
-}
</del></span></pre></div>
<a id="tagsopenicfldapconnector1410RC3srctestjavaorgidentityconnectorsldapsyncsundsSun \
DSChangeLogSyncStrategyTestsjavafromrev6872branchesopenicfldapconnector141xsrctestjavaorgidentityconnectorsldapsyncsundsSunDSChangeLogSyncStrategyTestsjava"></a>
<div class="copfile"><h4>Copied: \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java \
(from rev 6872, branches/openicf-ldap-connector-1.4.1.x/src/test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java) \
(0 => 6874)</h4> <pre class="diff"><span>
<span class="info">--- \
tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java \
(rev 0)
+++ tags/openicf-ldap-connector-1.4.1.0-RC3/src/test/java/org/identityconnectors/ldap/sync/sunds/SunDSChangeLogSyncStrategyTests.java 2015-09-11 \
13:00:13 UTC (rev 6874) </span><span class="lines">@@ -0,0 +1,304 @@
</span><ins>+/*
+ * ====================
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License("CDDL") (the "License"). You may \
not use this file + * except in compliance with the License.
+ *
+ * You can obtain a copy of the License at
+ * http://IdentityConnectors.dev.java.net/legal/license.txt
+ * See the License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * When distributing the Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at identityconnectors/legal/license.txt.
+ * If applicable, add the following below this CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ * ====================
+ */
+package org.identityconnectors.ldap.sync.sunds;
+
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.Test;
+import static java.util.Collections.emptyList;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingException;
+
+import org.identityconnectors.common.logging.Log;
+import org.identityconnectors.framework.api.operations.SyncApiOp;
+import org.identityconnectors.framework.common.objects.AttributeBuilder;
+import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.Name;
+import org.identityconnectors.framework.common.objects.ObjectClass;
+import org.identityconnectors.framework.common.objects.ObjectClassInfo;
+import org.identityconnectors.framework.common.objects.OperationOptions;
+import org.identityconnectors.framework.common.objects.OperationOptionsBuilder;
+import org.identityconnectors.framework.common.objects.Schema;
+import org.identityconnectors.framework.common.objects.SyncDelta;
+import org.identityconnectors.framework.common.objects.SyncDeltaType;
+import org.identityconnectors.framework.common.objects.SyncResultsHandler;
+import org.identityconnectors.framework.common.objects.SyncToken;
+import org.identityconnectors.framework.common.objects.Uid;
+import org.identityconnectors.ldap.LdapConfiguration;
+import org.identityconnectors.ldap.LdapConnection;
+import org.identityconnectors.ldap.SunDSTestBase;
+import org.identityconnectors.ldap.LdapConstants.ServerType;
+
+public class SunDSChangeLogSyncStrategyTests extends SunDSTestBase {
+
+ private static final Log log = \
Log.getLog(SunDSChangeLogSyncStrategyTests.class); +
+ private static final int STABLE_CHANGELOG_INTERVAL = 2000; /* milliseconds */
+
+ private static LdapConnection newConnection(LdapConfiguration config) throws \
NamingException { + LdapConnection conn = new LdapConnection(config);
+ cleanupBaseContext(conn);
+ waitForChangeLogToStabilize(conn);
+ return conn;
+ }
+
+ private static void waitForChangeLogToStabilize(LdapConnection conn) {
+ int lastChangeNumber = -1;
+ int previousLastChangeNumber;
+ do {
+ if (lastChangeNumber > 0) {
+ log.ok("Waiting for change log to stabilize (last change \
number: {0})", lastChangeNumber); + try {
+ Thread.sleep(STABLE_CHANGELOG_INTERVAL);
+ } catch (InterruptedException e) {
+ // Ignore.
+ }
+ }
+ previousLastChangeNumber = lastChangeNumber;
+ lastChangeNumber = new SunDSChangeLogSyncStrategy(conn, \
ObjectClass.ACCOUNT).getChangeLogAttributes().getLastChangeNumber(); + } while \
(lastChangeNumber != previousLastChangeNumber); + }
+
+ private List<SyncDelta> doTest(LdapConnection conn, String ldif, int \
expected) throws NamingException { + SunDSChangeLogSyncStrategy sync = new \
SunDSChangeLogSyncStrategy(conn, ObjectClass.ACCOUNT); + SyncToken token = \
sync.getLatestSyncToken(); +
+ LdapModifyForTests.modify(conn, ldif);
+ waitForChangeLogToStabilize(conn);
+
+ OperationOptionsBuilder builder = new OperationOptionsBuilder();
+ builder.setAttributesToGet("cn", "sn", \
"givenName", "uid"); + OperationOptions options = \
builder.build(); +
+ final List<SyncDelta> result = new ArrayList<SyncDelta>();
+ sync.sync(token, new SyncResultsHandler() {
+ public boolean handle(SyncDelta delta) {
+ result.add(delta);
+ return true;
+ }
+ }, options);
+ return result;
+ }
+
+ @Test
+ public void testSimple() throws Exception {
+ LdapConnection conn = newConnection(newConfiguration());
+ String baseContext = conn.getConfiguration().getBaseContexts()[0];
+
+ String entryDN = "uid=foobar," + baseContext;
+ List<SyncDelta> result = doTest(conn,
+ "dn: " +entryDN + "\n" +
+ "changetype: add\n" +
+ "objectClass: inetOrgPerson\n" +
+ "objectClass: organizationalPerson\n" +
+ "objectClass: person\n" +
+ "objectClass: top\n" +
+ "uid: foobar\n" +
+ "cn: Foo Bar\n" +
+ "sn: Bar\n", 1);
+
+ assertEquals(1, result.size());
+ SyncDelta delta = result.get(0);
+ assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
+ ConnectorObject object = delta.getObject();
+ assertEquals(new Uid(entryDN), object.getUid());
+ assertEquals(new Name(entryDN), object.getName());
+ assertEquals(AttributeBuilder.build("uid", "foobar"), \
object.getAttributeByName("uid")); + \
assertEquals(AttributeBuilder.build("cn", "Foo Bar"), \
object.getAttributeByName("cn")); + \
assertEquals(AttributeBuilder.build("sn", "Bar"), \
object.getAttributeByName("sn")); +
+ result = doTest(conn,
+ "dn: " + entryDN + "\n" +
+ "changeType: modrdn\n" +
+ "newRdn: cn=Foo Bar", 1);
+ entryDN = "cn=Foo Bar," + baseContext;
+
+ assertEquals(1, result.size());
+ delta = result.get(0);
+ assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
+ object = delta.getObject();
+ assertEquals(new Uid(entryDN), object.getUid());
+ assertEquals(new Name(entryDN), object.getName());
+ assertEquals(AttributeBuilder.build("uid", emptyList()), \
object.getAttributeByName("uid")); + \
assertEquals(AttributeBuilder.build("cn", "Foo Bar"), \
object.getAttributeByName("cn")); + \
assertEquals(AttributeBuilder.build("sn", "Bar"), \
object.getAttributeByName("sn")); +
+ result = doTest(conn,
+ "dn: " + entryDN + "\n" +
+ "changeType: modify\n" +
+ "add: cn\n" +
+ "cn: Dummy User", 1);
+
+ assertEquals(1, result.size());
+ delta = result.get(0);
+ assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
+ object = delta.getObject();
+ assertEquals(AttributeBuilder.build("cn", "Foo Bar", \
"Dummy User"), object.getAttributeByName("cn")); +
+ result = doTest(conn,
+ "dn: " + entryDN + "\n" +
+ "changeType: modrdn\n" +
+ "newRdn: cn=Dummy User\n" +
+ "deleteOldRdn: FALSE", 1);
+ entryDN = "cn=Dummy User," + baseContext;
+
+ assertEquals(1, result.size());
+ delta = result.get(0);
+ assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
+ object = delta.getObject();
+ assertEquals(new Uid(entryDN), object.getUid());
+ assertEquals(new Name(entryDN), object.getName());
+ assertEquals(AttributeBuilder.build("cn", "Foo Bar", \
"Dummy User"), object.getAttributeByName("cn")); +
+ result = doTest(conn,
+ "dn: " + entryDN + "\n" +
+ "changeType: modify\n" +
+ "delete: cn\n" +
+ "cn: Foo Bar", 1);
+
+ assertEquals(1, result.size());
+ delta = result.get(0);
+ assertEquals(SyncDeltaType.CREATE_OR_UPDATE, delta.getDeltaType());
+ object = delta.getObject();
+ assertEquals(AttributeBuilder.build("cn", "Dummy User"), \
object.getAttributeByName("cn")); +
+ result = doTest(conn,
+ "dn: " + entryDN + "\n" +
+ "changeType: delete", 1);
+
+ assertEquals(1, result.size());
+ delta = result.get(0);
+ assertEquals(SyncDeltaType.DELETE, delta.getDeltaType());
+ assertEquals(new Uid(entryDN), delta.getUid());
+ }
+
+ @Test
+ public void testAllBlocksReturnedFromSingleSyncCall() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ // Set a small block size so connector would have to do
+ // a couple of searches to return all deltas.
+ config.setChangeLogBlockSize(2);
+ LdapConnection conn = newConnection(config);
+ String baseContext = conn.getConfiguration().getBaseContexts()[0];
+
+ int COUNT = 10;
+ StringBuilder ldif = new StringBuilder();
+ for (int i = 0; i < COUNT; i++) {
+ String name = "user." + i;
+ String entryDN = "uid=" + name + "," + baseContext;
+ ldif.append(MessageFormat.format(
+ "dn: {0}\n" +
+ "changetype: add\n" +
+ "objectClass: inetOrgPerson\n" +
+ "objectClass: organizationalPerson\n" +
+ "objectClass: person\n" +
+ "objectClass: top\n" +
+ "uid: {1}\n" +
+ "cn: {1}\n" +
+ "sn: {1}\n" +
+ "\n",
+ entryDN, name));
+ }
+
+ List<SyncDelta> result = doTest(conn, ldif.toString(), COUNT);
+ assertEquals(10, result.size());
+ for (int i = 0; i < COUNT; i++) {
+ String name = "user." + i;
+ String entryDN = "uid=" + name + "," + baseContext;
+ ConnectorObject object = result.get(i).getObject();
+ assertEquals(new Uid(entryDN), object.getUid());
+ assertEquals(new Name(entryDN), object.getName());
+ }
+ }
+
+ @Test
+ public void testFilterOutByBaseContexts() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ String baseContext = config.getBaseContexts()[0];
+ config.setBaseContextsToSynchronize("ou=Subcontext," + \
baseContext); + LdapConnection conn = newConnection(config);
+ testExpectingNoDelta(conn);
+ }
+
+ @Test
+ public void testFilterOutByModifiersNames() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ config.setModifiersNamesToFilterOut("cn=Directory Manager");
+ LdapConnection conn = newConnection(config);
+ testExpectingNoDelta(conn);
+ }
+
+ @Test
+ public void testFilterOutByAttributes() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ config.setAttributesToSynchronize("telephoneNumber");
+ LdapConnection conn = newConnection(config);
+ testExpectingNoDelta(conn);
+ }
+
+ @Test
+ public void testFilterOutByObjectClasses() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ config.setObjectClassesToSynchronize("groupOfUniqueNames");
+ LdapConnection conn = newConnection(config);
+ testExpectingNoDelta(conn);
+ }
+
+ @Test
+ public void testAccountSynchronizationFilter() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ config.setAccountSynchronizationFilter("cn=value");
+ LdapConnection conn = newConnection(config);
+ testExpectingNoDelta(conn);
+ }
+
+ @Test(enabled = false)
+ private void testExpectingNoDelta(LdapConnection conn) throws NamingException {
+ String baseContext = conn.getConfiguration().getBaseContexts()[0];
+ String entryDN = "uid=foobar," + baseContext;
+ List<SyncDelta> result = doTest(conn,
+ "dn: " +entryDN + "\n" +
+ "changetype: add\n" +
+ "objectClass: inetOrgPerson\n" +
+ "objectClass: organizationalPerson\n" +
+ "objectClass: person\n" +
+ "objectClass: top\n" +
+ "uid: foobar\n" +
+ "cn: Foo Bar\n" +
+ "sn: Bar\n", 0);
+ assertTrue(result.isEmpty());
+ }
+
+ @Test
+ public void testSyncSupported() throws NamingException {
+ LdapConfiguration config = newConfiguration();
+ LdapConnection conn = newConnection(config);
+ assertEquals(ServerType.SUN_DSEE, conn.getServerType());
+ Schema schema = newFacade(config).schema();
+ ObjectClassInfo accountInfo = \
schema.findObjectClassInfo(ObjectClass.ACCOUNT_NAME); + \
assertTrue(schema.getSupportedObjectClassesByOperation().get(SyncApiOp.class).contains(accountInfo));
+ }
+}
</ins></span></pre>
</div>
</div>
<div id="footer">Copyright (c) by ForgeRock. All rights reserved.</div>
</body>
</html>
_______________________________________________
Commitopenicf mailing list
Commitopenicf@forgerock.org
https://lists.forgerock.org/mailman/listinfo/commitopenicf
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic