forked from lsc-project/lsc-executable-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lsc-project#12 Do not delete entry if get script returns an error
- Loading branch information
Showing
4 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,12 @@ | |
<factory>com.sun.jndi.ldap.LdapCtxFactory</factory> | ||
<tlsActivated>false</tlsActivated> | ||
</ldapConnection> | ||
<pluginConnection> | ||
<name>executable</name> | ||
<url>fake</url> | ||
<username>fake</username> | ||
<password>fake</password> | ||
</pluginConnection> | ||
</connections> | ||
<tasks> | ||
<task> | ||
|
@@ -159,5 +165,130 @@ | |
</dataset> | ||
</propertiesBasedSyncOptions> | ||
</task> | ||
<task> | ||
<name>failOnErrorTestTask</name> | ||
<bean>org.lsc.beans.SimpleBean</bean> | ||
<pluginSourceService implementationClass="org.lsc.plugins.connectors.executable.ExecutableLdifSourceService"> | ||
<name>failOnErrorTestTask-src-service</name> | ||
<connection reference="executable" /> | ||
<exec:executableLdifSourceServiceSettings> | ||
<name>failOnErrorTestTask-src-service-exec</name> | ||
<connection reference="executable" /> | ||
<exec:listScript>src/test/resources/org/lsc/plugins/connectors/executable/list.sh</exec:listScript> | ||
<exec:getScript>src/test/resources/org/lsc/plugins/connectors/executable/get-bad-return-code.sh</exec:getScript> | ||
<exec:variables> | ||
<entry><key>LDAP_BIND_DN</key><value>cn=Directory Manager</value></entry> | ||
<entry><key>LDAP_BIND_PW</key><value>secret</value></entry> | ||
<entry><key>LDAP_URL</key><value>ldap://localhost:33389</value></entry> | ||
<entry><key>LDAP_BASE</key><value>ou=ldap2ldap2TestTaskSrc,ou=Test Data,dc=lsc-project,dc=org</value></entry> | ||
<entry><key>LDAP_SCOPE</key><value>sub</value></entry> | ||
</exec:variables> | ||
</exec:executableLdifSourceServiceSettings> | ||
</pluginSourceService> | ||
<pluginDestinationService | ||
implementationClass="org.lsc.plugins.connectors.executable.ExecutableLdapDestinationService"> | ||
<name>failOnErrorTestTask-dst-service</name> | ||
<connection reference="ldap-dst-conn" /> | ||
<exec:executableLdapDestinationServiceSettings> | ||
<name>failOnErrorTestTask-dst-service-exec</name> | ||
<connection reference="ldap-dst-conn" /> | ||
<baseDn>ou=ldap2ldap2TestTaskDst,ou=Test Data,dc=lsc-project,dc=org</baseDn> | ||
<pivotAttributes> | ||
<string>sn</string> | ||
</pivotAttributes> | ||
<fetchedAttributes> | ||
<string>description</string> | ||
<string>cn</string> | ||
<string>sn</string> | ||
<string>userPassword</string> | ||
<string>objectClass</string> | ||
<string>uid</string> | ||
<string>mail</string> | ||
<string>telephoneNumber</string> | ||
<string>seeAlso</string> | ||
</fetchedAttributes> | ||
<getAllFilter>(objectClass=person)</getAllFilter> | ||
<getOneFilter>(&(objectClass=person)(sn={sn}))</getOneFilter> | ||
<!-- <exec:interpretor>CYGWIN</exec:interpretor> | ||
<exec:interpretorBinary>c:/cygwin/bin/bash.exe</exec:interpretorBinary> | ||
--> <exec:addScript>src/test/resources/org/lsc/plugins/connectors/executable/add.sh</exec:addScript> | ||
<exec:updateScript>src/test/resources/org/lsc/plugins/connectors/executable/update.sh</exec:updateScript> | ||
<exec:removeScript>src/test/resources/org/lsc/plugins/connectors/executable/delete.sh</exec:removeScript> | ||
<exec:renameScript>src/test/resources/org/lsc/plugins/connectors/executable/rename.sh</exec:renameScript> | ||
<exec:variables> | ||
<entry><key>LDAP_BIND_DN</key><value>cn=Directory Manager</value></entry> | ||
<entry><key>LDAP_BIND_PW</key><value>secret</value></entry> | ||
<entry><key>LDAP_URL</key><value>ldap://localhost:33389</value></entry> | ||
</exec:variables> | ||
</exec:executableLdapDestinationServiceSettings> | ||
</pluginDestinationService> | ||
<propertiesBasedSyncOptions> | ||
<mainIdentifier>js:"cn=" + srcBean.getDatasetFirstValueById("cn") + ",ou=ldap2ldap2TestTaskDst,ou=Test Data,dc=lsc-project,dc=org"</mainIdentifier> | ||
<defaultDelimiter>,</defaultDelimiter> | ||
<defaultPolicy>KEEP</defaultPolicy> | ||
<dataset> | ||
<name>telephoneNumber</name> | ||
<policy>MERGE</policy> | ||
<defaultValues> | ||
<string>"123456"</string> | ||
<string>"789987"</string> | ||
</defaultValues> | ||
<createValues> | ||
<string>"000000"</string> | ||
<string>"11111"</string> | ||
</createValues> | ||
</dataset> | ||
<dataset> | ||
<name>objectClass</name> | ||
<policy>KEEP</policy> | ||
<createValues> | ||
<string>"inetOrgPerson"</string> | ||
<string>"organizationalPerson"</string> | ||
<string>"person"</string> | ||
<string>"top"</string> | ||
</createValues> | ||
</dataset> | ||
<dataset> | ||
<name>initials</name> | ||
<policy>FORCE</policy> | ||
<createValues> | ||
<string>"cn=oops"</string> | ||
</createValues> | ||
</dataset> | ||
<dataset> | ||
<name>default</name> | ||
<policy>FORCE</policy> | ||
</dataset> | ||
<dataset> | ||
<name>description</name> | ||
<policy>MERGE</policy> | ||
<defaultValues> | ||
<string>srcBean.getDatasetFirstValueById("userPassword")</string> | ||
</defaultValues> | ||
</dataset> | ||
<dataset> | ||
<name>seeAlso</name> | ||
<policy>FORCE</policy> | ||
</dataset> | ||
<dataset> | ||
<name>userPassword</name> | ||
<policy>FORCE</policy> | ||
<defaultValues></defaultValues> | ||
<forceValues> | ||
<string>"secret" + srcBean.getDatasetFirstValueById("cn")</string> | ||
</forceValues> | ||
<createValues></createValues> | ||
</dataset> | ||
<dataset> | ||
<name>mail</name> | ||
<policy>FORCE</policy> | ||
<defaultValues></defaultValues> | ||
<forceValues></forceValues> | ||
<createValues> | ||
<string>"[email protected]"</string> | ||
</createValues> | ||
</dataset> | ||
</propertiesBasedSyncOptions> | ||
</task> | ||
</tasks> | ||
</lsc> |
24 changes: 24 additions & 0 deletions
24
src/test/resources/org/lsc/plugins/connectors/executable/get-bad-return-code.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
line="" | ||
read line | ||
text="$line" | ||
filter="(&(`echo "$line" | sed -e "s/^\([a-zA-Z0-9]\+\): \(.*\)$/\1=\2/g"`)" | ||
|
||
while test "$line" != "" | ||
do | ||
read line | ||
text="$text | ||
$line" | ||
if test "$line" != ""; then | ||
filter="$filter(`echo "$line" | sed -e "s/^\([a-zA-Z0-9]\+\): \(.*\)$/\1=\2/g"`)" | ||
fi | ||
done | ||
|
||
filter="$filter)" | ||
|
||
echo "Getting user information for id=$1" 1>&2 | ||
ldapsearch -x -LLL -H "$LDAP_URL" -D "$LDAP_BIND_DN" -w "$LDAP_BIND_PW" -b "$LDAP_BASE" -s "$LDAP_SCOPE" "$filter" \ | ||
| sed -e "s/^\(dn: .*\),dc=lsc-project, *dc=org$/\1/g" | ||
|
||
exit 1 |