Blame SOURCES/openldap-cbinding-ITS-8573-TLS-option-test-suite.patch

ef2d9b
From eb087e0861f207858a4e08c72836a86f26d9701c Mon Sep 17 00:00:00 2001
ef2d9b
From: Quanah Gibson-Mount <quanah@openldap.org>
ef2d9b
Date: Thu, 14 Jun 2018 16:12:59 +0100
ef2d9b
Subject: [PATCH] ITS#8573 TLS option test suite
ef2d9b
ef2d9b
---
ef2d9b
 configure                                     |   4 +
ef2d9b
 configure.in                                  |   4 +
ef2d9b
 tests/data/slapd-tls-sasl.conf                |  65 ++
ef2d9b
 tests/data/slapd-tls.conf                     |  61 ++
ef2d9b
 tests/data/tls/ca/certs/testsuiteCA.crt       |  16 +
ef2d9b
 tests/data/tls/ca/private/testsuiteCA.key     |  16 +
ef2d9b
 .../tls/certs/bjensen@mailgw.example.com.crt  |  16 +
ef2d9b
 tests/data/tls/certs/localhost.crt            |  16 +
ef2d9b
 tests/data/tls/conf/openssl.cnf               | 129 ++++
ef2d9b
 tests/data/tls/create-crt.sh                  |  78 +++
ef2d9b
 .../private/bjensen@mailgw.example.com.key    |  16 +
ef2d9b
 tests/data/tls/private/localhost.key          |  16 +
ef2d9b
 tests/run.in                                  |   3 +-
ef2d9b
 tests/scripts/defines.sh                      |  21 +-
ef2d9b
 tests/scripts/test067-tls                     | 140 +++++
ef2d9b
 tests/scripts/test068-sasl-tls-external       | 102 ++++
ef2d9b
 .../test069-delta-multimaster-starttls        | 574 ++++++++++++++++++
ef2d9b
 tests/scripts/test070-delta-multimaster-ldaps | 571 +++++++++++++++++
ef2d9b
 18 files changed, 1846 insertions(+), 2 deletions(-)
ef2d9b
 create mode 100644 tests/data/slapd-tls-sasl.conf
ef2d9b
 create mode 100644 tests/data/slapd-tls.conf
ef2d9b
 create mode 100644 tests/data/tls/ca/certs/testsuiteCA.crt
ef2d9b
 create mode 100644 tests/data/tls/ca/private/testsuiteCA.key
ef2d9b
 create mode 100644 tests/data/tls/certs/bjensen@mailgw.example.com.crt
ef2d9b
 create mode 100644 tests/data/tls/certs/localhost.crt
ef2d9b
 create mode 100644 tests/data/tls/conf/openssl.cnf
ef2d9b
 create mode 100755 tests/data/tls/create-crt.sh
ef2d9b
 create mode 100644 tests/data/tls/private/bjensen@mailgw.example.com.key
ef2d9b
 create mode 100644 tests/data/tls/private/localhost.key
ef2d9b
 create mode 100755 tests/scripts/test067-tls
ef2d9b
 create mode 100755 tests/scripts/test068-sasl-tls-external
ef2d9b
 create mode 100755 tests/scripts/test069-delta-multimaster-starttls
ef2d9b
 create mode 100755 tests/scripts/test070-delta-multimaster-ldaps
ef2d9b
ef2d9b
diff --git a/configure b/configure
ef2d9b
index 16d4ab884..29b7ad91d 100755
ef2d9b
--- a/configure
ef2d9b
+++ b/configure
ef2d9b
@@ -761,6 +761,7 @@ AUTH_LIBS
ef2d9b
 LIBSLAPI
ef2d9b
 SLAPI_LIBS
ef2d9b
 MODULES_LIBS
ef2d9b
+WITH_TLS_TYPE
ef2d9b
 TLS_LIBS
ef2d9b
 SASL_LIBS
ef2d9b
 KRB5_LIBS
ef2d9b
@@ -5223,6 +5224,7 @@ KRB4_LIBS=
ef2d9b
 KRB5_LIBS=
ef2d9b
 SASL_LIBS=
ef2d9b
 TLS_LIBS=
ef2d9b
+WITH_TLS_TYPE=
ef2d9b
 MODULES_LIBS=
ef2d9b
 SLAPI_LIBS=
ef2d9b
 LIBSLAPI=
ef2d9b
@@ -15701,6 +15703,7 @@ fi
ef2d9b
 		if test $have_openssl = yes ; then
ef2d9b
 			ol_with_tls=openssl
ef2d9b
 			ol_link_tls=yes
ef2d9b
+			WITH_TLS_TYPE=openssl
ef2d9b
 
ef2d9b
 
ef2d9b
 $as_echo "#define HAVE_OPENSSL 1" >>confdefs.h
ef2d9b
@@ -15835,6 +15838,7 @@ fi
ef2d9b
 			if test $have_gnutls = yes ; then
ef2d9b
 				ol_with_tls=gnutls
ef2d9b
 				ol_link_tls=yes
ef2d9b
+				WITH_TLS_TYPE=gnutls
ef2d9b
 
ef2d9b
 				TLS_LIBS="-lgnutls"
ef2d9b
 
ef2d9b
diff --git a/configure.in b/configure.in
ef2d9b
index ee25a4a90..60c446096 100644
ef2d9b
--- a/configure.in
ef2d9b
+++ b/configure.in
ef2d9b
@@ -610,6 +610,7 @@ KRB4_LIBS=
ef2d9b
 KRB5_LIBS=
ef2d9b
 SASL_LIBS=
ef2d9b
 TLS_LIBS=
ef2d9b
+WITH_TLS_TYPE=
ef2d9b
 MODULES_LIBS=
ef2d9b
 SLAPI_LIBS=
ef2d9b
 LIBSLAPI=
ef2d9b
@@ -1210,6 +1211,7 @@ if test $ol_with_tls = openssl || test $ol_with_tls = auto ; then
ef2d9b
 		if test $have_openssl = yes ; then
ef2d9b
 			ol_with_tls=openssl
ef2d9b
 			ol_link_tls=yes
ef2d9b
+			WITH_TLS_TYPE=openssl
ef2d9b
 
ef2d9b
 			AC_DEFINE(HAVE_OPENSSL, 1, 
ef2d9b
 				[define if you have OpenSSL])
ef2d9b
@@ -1250,6 +1252,7 @@ if test $ol_link_tls = no ; then
ef2d9b
 			if test $have_gnutls = yes ; then
ef2d9b
 				ol_with_tls=gnutls
ef2d9b
 				ol_link_tls=yes
ef2d9b
+				WITH_TLS_TYPE=gnutls
ef2d9b
 
ef2d9b
 				TLS_LIBS="-lgnutls"
ef2d9b
 
ef2d9b
@@ -3261,6 +3264,7 @@ AC_SUBST(KRB4_LIBS)
ef2d9b
 AC_SUBST(KRB5_LIBS)
ef2d9b
 AC_SUBST(SASL_LIBS)
ef2d9b
 AC_SUBST(TLS_LIBS)
ef2d9b
+AC_SUBST(WITH_TLS_TYPE)
ef2d9b
 AC_SUBST(MODULES_LIBS)
ef2d9b
 AC_SUBST(SLAPI_LIBS)
ef2d9b
 AC_SUBST(LIBSLAPI)
ef2d9b
diff --git a/tests/data/slapd-tls-sasl.conf b/tests/data/slapd-tls-sasl.conf
ef2d9b
new file mode 100644
ef2d9b
index 000000000..f4bb0773e
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/slapd-tls-sasl.conf
ef2d9b
@@ -0,0 +1,65 @@
ef2d9b
+# stand-alone slapd config -- for testing (with indexing)
ef2d9b
+# $OpenLDAP$
ef2d9b
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
ef2d9b
+##
ef2d9b
+## Copyright 1998-2017 The OpenLDAP Foundation.
ef2d9b
+## All rights reserved.
ef2d9b
+##
ef2d9b
+## Redistribution and use in source and binary forms, with or without
ef2d9b
+## modification, are permitted only as authorized by the OpenLDAP
ef2d9b
+## Public License.
ef2d9b
+##
ef2d9b
+## A copy of this license is available in the file LICENSE in the
ef2d9b
+## top-level directory of the distribution or, alternatively, at
ef2d9b
+## <http://www.OpenLDAP.org/license.html>.
ef2d9b
+
ef2d9b
+#
ef2d9b
+include		@SCHEMADIR@/core.schema
ef2d9b
+include		@SCHEMADIR@/cosine.schema
ef2d9b
+#
ef2d9b
+include		@SCHEMADIR@/corba.schema
ef2d9b
+include		@SCHEMADIR@/java.schema
ef2d9b
+include		@SCHEMADIR@/inetorgperson.schema
ef2d9b
+include		@SCHEMADIR@/misc.schema
ef2d9b
+include		@SCHEMADIR@/nis.schema
ef2d9b
+include		@SCHEMADIR@/openldap.schema
ef2d9b
+#
ef2d9b
+include		@SCHEMADIR@/duaconf.schema
ef2d9b
+include		@SCHEMADIR@/dyngroup.schema
ef2d9b
+include		@SCHEMADIR@/ppolicy.schema
ef2d9b
+
ef2d9b
+#
ef2d9b
+pidfile		@TESTDIR@/slapd.1.pid
ef2d9b
+argsfile	@TESTDIR@/slapd.1.args
ef2d9b
+
ef2d9b
+# SSL configuration
ef2d9b
+TLSCACertificateFile @TESTDIR@/tls/ca/certs/testsuiteCA.crt
ef2d9b
+TLSCertificateKeyFile @TESTDIR@/tls/private/localhost.key
ef2d9b
+TLSCertificateFile @TESTDIR@/tls/certs/localhost.crt
ef2d9b
+TLSVerifyClient hard
ef2d9b
+
ef2d9b
+#
ef2d9b
+rootdse 	@DATADIR@/rootdse.ldif
ef2d9b
+
ef2d9b
+#mod#modulepath	../servers/slapd/back-@BACKEND@/
ef2d9b
+#mod#moduleload	back_@BACKEND@.la
ef2d9b
+#monitormod#modulepath ../servers/slapd/back-monitor/
ef2d9b
+#monitormod#moduleload back_monitor.la
ef2d9b
+
ef2d9b
+authz-regexp "email=([^,]*),cn=[^,]*,ou=OpenLDAP,o=OpenLDAP Foundation,st=CA,c=US" ldap:///ou=People,dc=example,dc=com??sub?(mail=$1)
ef2d9b
+
ef2d9b
+#######################################################################
ef2d9b
+# database definitions
ef2d9b
+#######################################################################
ef2d9b
+
ef2d9b
+database	@BACKEND@
ef2d9b
+suffix          "dc=example,dc=com"
ef2d9b
+rootdn          "cn=Manager,dc=example,dc=com"
ef2d9b
+rootpw          secret
ef2d9b
+#~null~#directory	@TESTDIR@/db.1.a
ef2d9b
+#indexdb#index		objectClass eq
ef2d9b
+#indexdb#index		mail eq
ef2d9b
+#ndb#dbname db_1_a
ef2d9b
+#ndb#include @DATADIR@/ndb.conf
ef2d9b
+
ef2d9b
+#monitor#database	monitor
ef2d9b
diff --git a/tests/data/slapd-tls.conf b/tests/data/slapd-tls.conf
ef2d9b
new file mode 100644
ef2d9b
index 000000000..6a7785557
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/slapd-tls.conf
ef2d9b
@@ -0,0 +1,61 @@
ef2d9b
+# stand-alone slapd config -- for testing (with indexing)
ef2d9b
+# $OpenLDAP$
ef2d9b
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
ef2d9b
+##
ef2d9b
+## Copyright 1998-2017 The OpenLDAP Foundation.
ef2d9b
+## All rights reserved.
ef2d9b
+##
ef2d9b
+## Redistribution and use in source and binary forms, with or without
ef2d9b
+## modification, are permitted only as authorized by the OpenLDAP
ef2d9b
+## Public License.
ef2d9b
+##
ef2d9b
+## A copy of this license is available in the file LICENSE in the
ef2d9b
+## top-level directory of the distribution or, alternatively, at
ef2d9b
+## <http://www.OpenLDAP.org/license.html>.
ef2d9b
+
ef2d9b
+#
ef2d9b
+include		@SCHEMADIR@/core.schema
ef2d9b
+include		@SCHEMADIR@/cosine.schema
ef2d9b
+#
ef2d9b
+include		@SCHEMADIR@/corba.schema
ef2d9b
+include		@SCHEMADIR@/java.schema
ef2d9b
+include		@SCHEMADIR@/inetorgperson.schema
ef2d9b
+include		@SCHEMADIR@/misc.schema
ef2d9b
+include		@SCHEMADIR@/nis.schema
ef2d9b
+include		@SCHEMADIR@/openldap.schema
ef2d9b
+#
ef2d9b
+include		@SCHEMADIR@/duaconf.schema
ef2d9b
+include		@SCHEMADIR@/dyngroup.schema
ef2d9b
+include		@SCHEMADIR@/ppolicy.schema
ef2d9b
+
ef2d9b
+#
ef2d9b
+pidfile		@TESTDIR@/slapd.1.pid
ef2d9b
+argsfile	@TESTDIR@/slapd.1.args
ef2d9b
+
ef2d9b
+# SSL configuration
ef2d9b
+TLSCertificateKeyFile @TESTDIR@/tls/private/localhost.key
ef2d9b
+TLSCertificateFile @TESTDIR@/tls/certs/localhost.crt
ef2d9b
+
ef2d9b
+#
ef2d9b
+rootdse 	@DATADIR@/rootdse.ldif
ef2d9b
+
ef2d9b
+#mod#modulepath	../servers/slapd/back-@BACKEND@/
ef2d9b
+#mod#moduleload	back_@BACKEND@.la
ef2d9b
+#monitormod#modulepath ../servers/slapd/back-monitor/
ef2d9b
+#monitormod#moduleload back_monitor.la
ef2d9b
+
ef2d9b
+#######################################################################
ef2d9b
+# database definitions
ef2d9b
+#######################################################################
ef2d9b
+
ef2d9b
+database	@BACKEND@
ef2d9b
+suffix          "dc=example,dc=com"
ef2d9b
+rootdn          "cn=Manager,dc=example,dc=com"
ef2d9b
+rootpw          secret
ef2d9b
+#~null~#directory	@TESTDIR@/db.1.a
ef2d9b
+#indexdb#index		objectClass eq
ef2d9b
+#indexdb#index		mail eq
ef2d9b
+#ndb#dbname db_1_a
ef2d9b
+#ndb#include @DATADIR@/ndb.conf
ef2d9b
+
ef2d9b
+#monitor#database	monitor
ef2d9b
diff --git a/tests/data/tls/ca/certs/testsuiteCA.crt b/tests/data/tls/ca/certs/testsuiteCA.crt
ef2d9b
new file mode 100644
ef2d9b
index 000000000..7458e7461
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/ca/certs/testsuiteCA.crt
ef2d9b
@@ -0,0 +1,16 @@
ef2d9b
+-----BEGIN CERTIFICATE-----
ef2d9b
+MIICgjCCAeugAwIBAgIJAJGJtO9oGgLiMA0GCSqGSIb3DQEBCwUAMFkxCzAJBgNV
ef2d9b
+BAYTAlVTMQswCQYDVQQIDAJDQTEcMBoGA1UECgwTT3BlbkxEQVAgRm91bmRhdGlv
ef2d9b
+bjEfMB0GA1UECwwWT3BlbkxEQVAgVGVzdCBTdWl0ZSBDQTAgFw0xNzAxMTkyMDI0
ef2d9b
+NTFaGA8yNTE4MDIwMjIwMjQ1MVowWTELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNB
ef2d9b
+MRwwGgYDVQQKDBNPcGVuTERBUCBGb3VuZGF0aW9uMR8wHQYDVQQLDBZPcGVuTERB
ef2d9b
+UCBUZXN0IFN1aXRlIENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC3xcMd
ef2d9b
+rvEPxIzZ0FnGVfk6sLXW//4UbBZmmsHSNT7UDNpL301QrsOaATyiOMSPHxmQoLPb
ef2d9b
+lYOtTCPaHN9/KIHoCnEQ6tJRe30okA0DFnZvSH5jAm9E2QvsXMVXU5XIi9dZTNdL
ef2d9b
+6jwRajPQP3YfK+PyrtIqc0IvhB4Ori39vrFLpQIDAQABo1AwTjAdBgNVHQ4EFgQU
ef2d9b
+7fEPwfVJESrieK5MzzjBSK8xEfIwHwYDVR0jBBgwFoAU7fEPwfVJESrieK5MzzjB
ef2d9b
+SK8xEfIwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQBtXLZWW6ZKZux/
ef2d9b
+wk7uLNZl01kPJUBiI+yMU5uY5PgOph1CpaUXp3QftCb0yRQ2g5d0CNYI5DyXuHws
ef2d9b
+ZSZRFF8SRwm3AogkMzYKenPF5m2OXSpvOMdnlbbFmIJnvwUfKhtinw+r0zvW8I8Q
ef2d9b
+aL52EFPS0o3tiAJXS82U2wrQdJ0YEw==
ef2d9b
+-----END CERTIFICATE-----
ef2d9b
diff --git a/tests/data/tls/ca/private/testsuiteCA.key b/tests/data/tls/ca/private/testsuiteCA.key
ef2d9b
new file mode 100644
ef2d9b
index 000000000..2e14d7033
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/ca/private/testsuiteCA.key
ef2d9b
@@ -0,0 +1,16 @@
ef2d9b
+-----BEGIN PRIVATE KEY-----
ef2d9b
+MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALfFwx2u8Q/EjNnQ
ef2d9b
+WcZV+Tqwtdb//hRsFmaawdI1PtQM2kvfTVCuw5oBPKI4xI8fGZCgs9uVg61MI9oc
ef2d9b
+338ogegKcRDq0lF7fSiQDQMWdm9IfmMCb0TZC+xcxVdTlciL11lM10vqPBFqM9A/
ef2d9b
+dh8r4/Ku0ipzQi+EHg6uLf2+sUulAgMBAAECgYBDOb7kjuh0Iix8SXFt0ml3hMkg
ef2d9b
+O0kQ43FWW2pnoT64h3MbqjY4O5YmMimiFi4hRPkvJPpma01eCapb0ZAYjhLm1bpf
ef2d9b
+7Ey+724CEN3/DnorbQ3b/Fe2AVl4msJKEQFoercnaS9tFDPoijzH/quC2agH41tn
ef2d9b
+rGWTpahq6JUIP6xkwQJBAPHJZVHGQ8P/5bGxqOkPLtjIfDLtAgInMxZgDjHhHw2f
ef2d9b
+wGoeRrZ3J1yW0tnWtTXBN+5fKjCd6QpEvBmwhiZ+S+0CQQDCk1JBq64UotqeSWnk
ef2d9b
+AmhRMyVs87P0DPW2Gg8y96Q3d5Rwmy65ITr4pf/xufcSkrTSObDLhfhRyJKz7W4l
ef2d9b
+vjeZAkBq99CtZuugENxLyu+RfDgbjEb2OMjErxb49TISeyhD3MNBr3dVTk3Jtqg9
ef2d9b
+27F7wKm/+bYuoA3zjwkwzFntOb7ZAkAY0Hz/DwwGabaD1U0B3SS8pk8xk+rxRu3X
ef2d9b
+KX+iul5hDIkLy16sEYbZyyHXDCZsYfVZki3v5sgCdhfvhmozugyRAkBQgCeI8K1N
ef2d9b
+I9rHrcMZUjVT/3AdjSu6xIM87Vv/oIzGUNaadnQONRaXZ+Kp5pv9j4B/18rPcQwL
ef2d9b
++b2qljWeZbGH
ef2d9b
+-----END PRIVATE KEY-----
ef2d9b
diff --git a/tests/data/tls/certs/bjensen@mailgw.example.com.crt b/tests/data/tls/certs/bjensen@mailgw.example.com.crt
ef2d9b
new file mode 100644
ef2d9b
index 000000000..93e3a0d39
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/certs/bjensen@mailgw.example.com.crt
ef2d9b
@@ -0,0 +1,16 @@
ef2d9b
+-----BEGIN CERTIFICATE-----
ef2d9b
+MIICejCCAeOgAwIBAgIBADANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJVUzEL
ef2d9b
+MAkGA1UECAwCQ0ExHDAaBgNVBAoME09wZW5MREFQIEZvdW5kYXRpb24xHzAdBgNV
ef2d9b
+BAsMFk9wZW5MREFQIFRlc3QgU3VpdGUgQ0EwIBcNMTcwNTEwMjMxNjExWhgPMjUx
ef2d9b
+ODA1MjQyMzE2MTFaMIGbMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExHDAaBgNV
ef2d9b
+BAoME09wZW5MREFQIEZvdW5kYXRpb24xETAPBgNVBAsMCE9wZW5MREFQMSMwIQYD
ef2d9b
+VQQDDBpiamVuc2VuQG1haWxndy5leGFtcGxlLmNvbTEpMCcGCSqGSIb3DQEJARYa
ef2d9b
+YmplbnNlbkBtYWlsZ3cuZXhhbXBsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0A
ef2d9b
+MIGJAoGBAMjb2C5VL+f/B/f2xJyhsdXeaGhWdABWqJlCiupk7QVPotpZphqJ2fKg
ef2d9b
+QbX2w0sPazujt8hG96F2mBv49pHqzhSrKN70EA/E7b8d6ynjJpBU2P9ZgVlttnmU
ef2d9b
+U++22BSuhthP5VQK7IqNyI7ZyQ4hFzuqb/XrHD1VCDo/Z/JAkw7jAgMBAAGjDTAL
ef2d9b
+MAkGA1UdEwQCMAAwDQYJKoZIhvcNAQELBQADgYEAmAQhIIKqjC13rtAGEQHV/pKn
ef2d9b
+wOnLbNOumODqM+0MkEfqXXtR6eNGres2RNAtCJ5fqqDBTQCTqRzIt67cqdlJle2f
ef2d9b
+7vXYm8Y6NgxHwG+N1y7S0Xf+oo7/BJ+YJTLF7CLJuPNRqILWvXGlcNDcM1nekeKo
ef2d9b
+4DnnYQBDnq48VORVX94=
ef2d9b
+-----END CERTIFICATE-----
ef2d9b
diff --git a/tests/data/tls/certs/localhost.crt b/tests/data/tls/certs/localhost.crt
ef2d9b
new file mode 100644
ef2d9b
index 000000000..194cb119d
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/certs/localhost.crt
ef2d9b
@@ -0,0 +1,16 @@
ef2d9b
+-----BEGIN CERTIFICATE-----
ef2d9b
+MIICgzCCAeygAwIBAgIBADANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJVUzEL
ef2d9b
+MAkGA1UECAwCQ0ExHDAaBgNVBAoME09wZW5MREFQIEZvdW5kYXRpb24xHzAdBgNV
ef2d9b
+BAsMFk9wZW5MREFQIFRlc3QgU3VpdGUgQ0EwIBcNMTcwNTEwMjMxNjExWhgPMjUx
ef2d9b
+ODA1MjQyMzE2MTFaMGoxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEcMBoGA1UE
ef2d9b
+CgwTT3BlbkxEQVAgRm91bmRhdGlvbjEcMBoGA1UECwwTT3BlbkxEQVAgVGVzdCBT
ef2d9b
+dWl0ZTESMBAGA1UEAwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB
ef2d9b
+iQKBgQDutp3GaZXGSm7joDm1TYI+dhBAuL1+O+oJlmZL10GX/oHqc8WNobvuZGH4
ef2d9b
+7H8mQf7zWwJQWxL805oBDMPi2ncgha5ydaVsf4rBZATpweji04vd+672qtR/dGgv
ef2d9b
+8Re5G3ZFYWxUv8nb/DJojG601V2Ye/K3rf+Xwa9u4Q9EJqIivwIDAQABo0gwRjAJ
ef2d9b
+BgNVHRMEAjAAMAsGA1UdDwQEAwIF4DAsBgNVHREEJTAjgglsb2NhbGhvc3SHBH8A
ef2d9b
+AAGHEAAAAAAAAAAAAAAAAAAAAAEwDQYJKoZIhvcNAQELBQADgYEAYItH9TDh/lqG
ef2d9b
+8XcBPi0bzGaUPkGlDY615xvsVCflnsfRqLKP/dCfi1GjaDajEmE874pvnmmZfwxl
ef2d9b
+0MRTqnhEmFdqjPzVSVKCeNQYWGr3wzKwI7qrhTLMg3Tz98Sz0+HUY8G9fwsNekAR
ef2d9b
+GjeZB1FxqDGHjxBq2O828iejw28bSz4=
ef2d9b
+-----END CERTIFICATE-----
ef2d9b
diff --git a/tests/data/tls/conf/openssl.cnf b/tests/data/tls/conf/openssl.cnf
ef2d9b
new file mode 100644
ef2d9b
index 000000000..a3c8ad9f6
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/conf/openssl.cnf
ef2d9b
@@ -0,0 +1,129 @@
ef2d9b
+HOME                    = .
ef2d9b
+RANDFILE                = $ENV::HOME/.rnd
ef2d9b
+
ef2d9b
+oid_section             = new_oids
ef2d9b
+
ef2d9b
+[ new_oids ]
ef2d9b
+tsa_policy1 = 1.2.3.4.1
ef2d9b
+tsa_policy2 = 1.2.3.4.5.6
ef2d9b
+tsa_policy3 = 1.2.3.4.5.7
ef2d9b
+
ef2d9b
+[ ca ]
ef2d9b
+default_ca      = CA_default            # The default ca section
ef2d9b
+
ef2d9b
+[ CA_default ]
ef2d9b
+
ef2d9b
+dir             = ./cruft		# Where everything is kept
ef2d9b
+certs           = $dir/certs            # Where the issued certs are kept
ef2d9b
+crl_dir         = $dir/crl              # Where the issued crl are kept
ef2d9b
+database        = $dir/index.txt        # database index file.
ef2d9b
+new_certs_dir   = $dir/certs         # default place for new certs.
ef2d9b
+certificate     = $dir/cacert.pem       # The CA certificate
ef2d9b
+serial          = $dir/serial           # The current serial number
ef2d9b
+crlnumber       = $dir/crlnumber        # the current crl number
ef2d9b
+crl             = $dir/crl.pem          # The current CRL
ef2d9b
+private_key     = $dir/private/cakey.pem# The private key
ef2d9b
+RANDFILE        = $dir/private/.rand    # private random number file
ef2d9b
+x509_extensions = usr_cert              # The extentions to add to the cert
ef2d9b
+name_opt        = ca_default            # Subject Name options
ef2d9b
+cert_opt        = ca_default            # Certificate field options
ef2d9b
+default_days    = 365                   # how long to certify for
ef2d9b
+default_crl_days= 30                    # how long before next CRL
ef2d9b
+default_md      = default               # use public key default MD
ef2d9b
+preserve        = no                    # keep passed DN ordering
ef2d9b
+policy          = policy_match
ef2d9b
+
ef2d9b
+[ policy_match ]
ef2d9b
+countryName             = match
ef2d9b
+stateOrProvinceName     = match
ef2d9b
+organizationName        = match
ef2d9b
+organizationalUnitName  = optional
ef2d9b
+commonName              = supplied
ef2d9b
+emailAddress            = optional
ef2d9b
+
ef2d9b
+[ policy_anything ]
ef2d9b
+countryName             = optional
ef2d9b
+stateOrProvinceName     = optional
ef2d9b
+localityName            = optional
ef2d9b
+organizationName        = optional
ef2d9b
+organizationalUnitName  = optional
ef2d9b
+commonName              = supplied
ef2d9b
+emailAddress            = optional
ef2d9b
+
ef2d9b
+[ req ]
ef2d9b
+default_bits            = 2048
ef2d9b
+default_keyfile         = privkey.pem
ef2d9b
+distinguished_name      = req_distinguished_name
ef2d9b
+attributes              = req_attributes
ef2d9b
+x509_extensions = v3_ca # The extentions to add to the self signed cert
ef2d9b
+
ef2d9b
+string_mask = utf8only
ef2d9b
+
ef2d9b
+[ req_distinguished_name ]
ef2d9b
+basicConstraints=CA:FALSE
ef2d9b
+
ef2d9b
+[ req_attributes ]
ef2d9b
+challengePassword               = A challenge password
ef2d9b
+challengePassword_min           = 4
ef2d9b
+challengePassword_max           = 20
ef2d9b
+
ef2d9b
+unstructuredName                = An optional company name
ef2d9b
+
ef2d9b
+[ usr_cert ]
ef2d9b
+
ef2d9b
+basicConstraints=CA:FALSE
ef2d9b
+nsComment                       = "OpenSSL Generated Certificate"
ef2d9b
+
ef2d9b
+subjectKeyIdentifier=hash
ef2d9b
+authorityKeyIdentifier=keyid,issuer
ef2d9b
+
ef2d9b
+[ v3_req ]
ef2d9b
+
ef2d9b
+basicConstraints = CA:FALSE
ef2d9b
+keyUsage = nonRepudiation, digitalSignature, keyEncipherment
ef2d9b
+subjectAltName = DNS:localhost,IP:127.0.0.1,IP:::1
ef2d9b
+
ef2d9b
+[ v3_ca ]
ef2d9b
+subjectKeyIdentifier=hash
ef2d9b
+authorityKeyIdentifier=keyid:always,issuer
ef2d9b
+basicConstraints = CA:true
ef2d9b
+
ef2d9b
+[ crl_ext ]
ef2d9b
+
ef2d9b
+authorityKeyIdentifier=keyid:always
ef2d9b
+
ef2d9b
+[ proxy_cert_ext ]
ef2d9b
+basicConstraints=CA:FALSE
ef2d9b
+nsComment                       = "OpenSSL Generated Certificate"
ef2d9b
+
ef2d9b
+subjectKeyIdentifier=hash
ef2d9b
+authorityKeyIdentifier=keyid,issuer
ef2d9b
+proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
ef2d9b
+
ef2d9b
+[ tsa ]
ef2d9b
+
ef2d9b
+default_tsa = tsa_config1       # the default TSA section
ef2d9b
+
ef2d9b
+[ tsa_config1 ]
ef2d9b
+
ef2d9b
+dir             = ./demoCA              # TSA root directory
ef2d9b
+serial          = $dir/tsaserial        # The current serial number (mandatory)
ef2d9b
+crypto_device   = builtin               # OpenSSL engine to use for signing
ef2d9b
+signer_cert     = $dir/tsacert.pem      # The TSA signing certificate
ef2d9b
+                                        # (optional)
ef2d9b
+certs           = $dir/cacert.pem       # Certificate chain to include in reply
ef2d9b
+                                        # (optional)
ef2d9b
+signer_key      = $dir/private/tsakey.pem # The TSA private key (optional)
ef2d9b
+
ef2d9b
+default_policy  = tsa_policy1           # Policy if request did not specify it
ef2d9b
+                                        # (optional)
ef2d9b
+other_policies  = tsa_policy2, tsa_policy3      # acceptable policies (optional)
ef2d9b
+digests         = md5, sha1             # Acceptable message digests (mandatory)
ef2d9b
+accuracy        = secs:1, millisecs:500, microsecs:100  # (optional)
ef2d9b
+clock_precision_digits  = 0     # number of digits after dot. (optional)
ef2d9b
+ordering                = yes   # Is ordering defined for timestamps?
ef2d9b
+                                # (optional, default: no)
ef2d9b
+tsa_name                = yes   # Must the TSA name be included in the reply?
ef2d9b
+                                # (optional, default: no)
ef2d9b
+ess_cert_id_chain       = no    # Must the ESS cert id chain be included?
ef2d9b
+                                # (optional, default: no)
ef2d9b
diff --git a/tests/data/tls/create-crt.sh b/tests/data/tls/create-crt.sh
ef2d9b
new file mode 100755
ef2d9b
index 000000000..8c33a24fe
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/create-crt.sh
ef2d9b
@@ -0,0 +1,78 @@
ef2d9b
+#!/bin/sh
ef2d9b
+openssl=$(which openssl)
ef2d9b
+
ef2d9b
+if [ x"$openssl" = "x" ]; then
ef2d9b
+echo "OpenSSL command line binary not found, skipping..."
ef2d9b
+fi
ef2d9b
+
ef2d9b
+USAGE="$0 [-s] [-u <user@domain.com>]"
ef2d9b
+SERVER=0
ef2d9b
+USER=0
ef2d9b
+EMAIL=
ef2d9b
+
ef2d9b
+while test $# -gt 0 ; do
ef2d9b
+	case "$1" in
ef2d9b
+		-s | -server)
ef2d9b
+			SERVER=1;
ef2d9b
+			shift;;
ef2d9b
+		-u | -user)
ef2d9b
+			if [ x"$2" = "x" ]; then
ef2d9b
+				echo "User cert requires an email address as an argument"
ef2d9b
+				exit;
ef2d9b
+			fi
ef2d9b
+			USER=1;
ef2d9b
+			EMAIL="$2";
ef2d9b
+			shift; shift;;
ef2d9b
+		-)
ef2d9b
+			shift;;
ef2d9b
+		-*)
ef2d9b
+			echo "$USAGE"; exit 1
ef2d9b
+			;;
ef2d9b
+		*)
ef2d9b
+			break;;
ef2d9b
+	esac
ef2d9b
+done
ef2d9b
+
ef2d9b
+if [ $SERVER = 0 -a $USER = 0 ]; then
ef2d9b
+	echo "$USAGE";
ef2d9b
+	exit 1;
ef2d9b
+fi
ef2d9b
+
ef2d9b
+rm -rf ./openssl.cnf cruft
ef2d9b
+mkdir -p private certs cruft/private cruft/certs
ef2d9b
+
ef2d9b
+echo "00" > cruft/serial
ef2d9b
+touch cruft/index.txt
ef2d9b
+touch cruft/index.txt.attr
ef2d9b
+hn=$(hostname -f)
ef2d9b
+sed -e "s;@HOSTNAME@;$hn;" conf/openssl.cnf >  ./openssl.cnf
ef2d9b
+
ef2d9b
+if [ $SERVER = 1 ]; then
ef2d9b
+	rm -rf private/localhost.key certs/localhost.crt
ef2d9b
+
ef2d9b
+	$openssl req -new -nodes -out localhost.csr -keyout private/localhost.key \
ef2d9b
+		-newkey rsa:1024 -config ./openssl.cnf \
ef2d9b
+		-subj "/CN=localhost/OU=OpenLDAP Test Suite/O=OpenLDAP Foundation/ST=CA/C=US" \
ef2d9b
+		-batch > /dev/null 2>&1
ef2d9b
+
ef2d9b
+	$openssl ca -out certs/localhost.crt -notext -config ./openssl.cnf -days 183000 -in localhost.csr \
ef2d9b
+		-keyfile ca/private/testsuiteCA.key -extensions v3_req -cert ca/certs/testsuiteCA.crt \
ef2d9b
+		-batch >/dev/null 2>&1
ef2d9b
+
ef2d9b
+	rm -rf ./openssl.cnf ./localhost.csr cruft
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if [ $USER = 1 ]; then
ef2d9b
+	rm -f certs/$EMAIL.crt private/$EMAIL.key $EMAIL.csr
ef2d9b
+
ef2d9b
+	$openssl req -new -nodes -out $EMAIL.csr -keyout private/$EMAIL.key \
ef2d9b
+		-newkey rsa:1024 -config ./openssl.cnf \
ef2d9b
+		-subj "/emailAddress=$EMAIL/CN=$EMAIL/OU=OpenLDAP/O=OpenLDAP Foundation/ST=CA/C=US" \
ef2d9b
+		-batch >/dev/null 2>&1
ef2d9b
+
ef2d9b
+	$openssl ca -out certs/$EMAIL.crt -notext -config ./openssl.cnf -days 183000 -in $EMAIL.csr \
ef2d9b
+		-keyfile ca/private/testsuiteCA.key -extensions req_distinguished_name \
ef2d9b
+		-cert ca/certs/testsuiteCA.crt -batch >/dev/null 2>&1
ef2d9b
+
ef2d9b
+	rm -rf ./openssl.cnf ./$EMAIL.csr cruft
ef2d9b
+fi
ef2d9b
diff --git a/tests/data/tls/private/bjensen@mailgw.example.com.key b/tests/data/tls/private/bjensen@mailgw.example.com.key
ef2d9b
new file mode 100644
ef2d9b
index 000000000..5f4625fd7
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/private/bjensen@mailgw.example.com.key
ef2d9b
@@ -0,0 +1,16 @@
ef2d9b
+-----BEGIN PRIVATE KEY-----
ef2d9b
+MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMjb2C5VL+f/B/f2
ef2d9b
+xJyhsdXeaGhWdABWqJlCiupk7QVPotpZphqJ2fKgQbX2w0sPazujt8hG96F2mBv4
ef2d9b
+9pHqzhSrKN70EA/E7b8d6ynjJpBU2P9ZgVlttnmUU++22BSuhthP5VQK7IqNyI7Z
ef2d9b
+yQ4hFzuqb/XrHD1VCDo/Z/JAkw7jAgMBAAECgYEApDgKQadoaZd7nmJlUWJqEV+r
ef2d9b
+oVK9uOEhK1zaUtV9bBA2J6uQQLZgORyJXQqJlT7f/3zVb6uGHr7lkkk03wxIu+3e
ef2d9b
+nIi7or/Cw6KmxhgslsQamf/ujjeqRlij/4pJIpEYByme9SstfzMBFNWU4t+fguPg
ef2d9b
+xXz6lvVZuNiYRWWuXxECQQDwakp31mNczqLPg8fuhdgixz7HCK5g6p4XDw+Cu9Ra
ef2d9b
+EenuOJVlnwXdW+g5jooiV5RWhxbTO6ImtgbcBGoeLSbVAkEA1eEcifIzgSi8XODd
ef2d9b
+9i6dCSMHKk4FgDRk2DJxRePLK2J1kt2bhOz/N1130fTargDWo8QiQAnd7RBOMJO/
ef2d9b
+pGaq1wJAZ2afzrjzlWf+WFgqdmk0k4i0dHBEZ8Sg5/P/TNAyPeb0gRPvFXz2zcUI
ef2d9b
+tTCcMrcOQsTpSUKdtB6YBqsTZRUwXQI/FbjHLTtr/7Ijb0tnP5l8WXE1SRajeGHZ
ef2d9b
+3BtDZdW8zKszRbc8FEP9p6HWiXxUuVdcdUV2NQrLf0goqMZYsFm9AkBtV3URLS4D
ef2d9b
+tw0VPr/TtzDx0UTJU5POdRcNrrpm233A0EyGNmLuM7y0iLxrvCIN9z0RVu7AeMBg
ef2d9b
+36Ixj3L+5H18
ef2d9b
+-----END PRIVATE KEY-----
ef2d9b
diff --git a/tests/data/tls/private/localhost.key b/tests/data/tls/private/localhost.key
ef2d9b
new file mode 100644
ef2d9b
index 000000000..8a24f69f8
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/data/tls/private/localhost.key
ef2d9b
@@ -0,0 +1,16 @@
ef2d9b
+-----BEGIN PRIVATE KEY-----
ef2d9b
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAO62ncZplcZKbuOg
ef2d9b
+ObVNgj52EEC4vX476gmWZkvXQZf+gepzxY2hu+5kYfjsfyZB/vNbAlBbEvzTmgEM
ef2d9b
+w+LadyCFrnJ1pWx/isFkBOnB6OLTi937rvaq1H90aC/xF7kbdkVhbFS/ydv8MmiM
ef2d9b
+brTVXZh78ret/5fBr27hD0QmoiK/AgMBAAECgYEA0gs5tNY/BaWFASGA5bj3u4Ij
ef2d9b
+Nu/XPPX3Lsx54o3bl6RIKEYKNF91f4QweNmP39f+P596373jbTe7sOTMkBXu7qnf
ef2d9b
+2B51VBJ72Uq92gO2VXImK+uuC6JdZfYTlX1QJkaR6mxhBl3KAgUeGUgbL0Xp9XeJ
ef2d9b
+bVcPqDOpRyIlW/80EHECQQD6PWRkk+0H4EMRA3GAnMQv/+Cy+sqF0T0OBNsQ846q
ef2d9b
+1hQhJfVvjgj2flmJZpH9zBTaqDn4grJDfQ9cViZwf4k7AkEA9DVNHPNVpkeToWrf
ef2d9b
+3yH55Ya5WEAl/6oNsHlaSZ88SHCZGqY7hQrpjSycsEezmsnDeqfdVuO97G2nHC7U
ef2d9b
+VdPUTQJAAq8r54RKs53tOj5+NjH4TMeC4oicKYlQDVlx/CGQszZuqthcZKDyaap7
ef2d9b
+TWUDReStiJbrYEYOoXiy9HucF/LWRwJAQKeH9f06lN5oaJkKEmJFbg5ALew14z1b
ef2d9b
+iHhofgtpg2hEMLkIEw4zjUvdZBJnq7h1R5j/0cxT8S+KybxgPSTrFQJBAPTrj7bP
ef2d9b
+5M7tPyQtyFxhFhas6g4ZHz/D2yB7BL+hL3IiJf3fdWNcHTzBDFEgDOVjR/7CZ6L3
ef2d9b
+b61hkjQZfbEg5cg=
ef2d9b
+-----END PRIVATE KEY-----
ef2d9b
diff --git a/tests/run.in b/tests/run.in
ef2d9b
index 6c33d4d20..793e388c1 100644
ef2d9b
--- a/tests/run.in
ef2d9b
+++ b/tests/run.in
ef2d9b
@@ -57,6 +57,7 @@ AC_valsort=valsort@BUILD_VALSORT@
ef2d9b
 # misc
ef2d9b
 AC_WITH_SASL=@WITH_SASL@
ef2d9b
 AC_WITH_TLS=@WITH_TLS@
ef2d9b
+AC_TLS_TYPE=@WITH_TLS_TYPE@
ef2d9b
 AC_WITH_MODULES_ENABLED=@WITH_MODULES_ENABLED@
ef2d9b
 AC_ACI_ENABLED=aci@WITH_ACI_ENABLED@
ef2d9b
 AC_THREADS=threads@BUILD_THREAD@
ef2d9b
@@ -75,7 +76,7 @@ export AC_bdb AC_hdb AC_ldap AC_mdb AC_meta AC_monitor AC_null AC_relay AC_sql \
ef2d9b
 	AC_refint AC_retcode AC_rwm AC_unique AC_syncprov AC_translucent \
ef2d9b
 	AC_valsort \
ef2d9b
 	AC_WITH_SASL AC_WITH_TLS AC_WITH_MODULES_ENABLED AC_ACI_ENABLED \
ef2d9b
-	AC_THREADS AC_LIBS_DYNAMIC
ef2d9b
+	AC_THREADS AC_LIBS_DYNAMIC AC_WITH_TLS AC_TLS_TYPE
ef2d9b
 
ef2d9b
 if test ! -x ../servers/slapd/slapd ; then
ef2d9b
 	echo "Could not locate slapd(8)"
ef2d9b
diff --git a/tests/scripts/defines.sh b/tests/scripts/defines.sh
ef2d9b
index a7dacebdd..2c9e8f76a 100755
ef2d9b
--- a/tests/scripts/defines.sh
ef2d9b
+++ b/tests/scripts/defines.sh
ef2d9b
@@ -46,6 +46,9 @@ VALSORT=${AC_valsort-valsortno}
ef2d9b
 # misc
ef2d9b
 WITH_SASL=${AC_WITH_SASL-no}
ef2d9b
 USE_SASL=${SLAPD_USE_SASL-no}
ef2d9b
+WITH_TLS=${AC_WITH_TLS-no}
ef2d9b
+WITH_TLS_TYPE=${AC_TLS_TYPE-no}
ef2d9b
+
ef2d9b
 ACI=${AC_ACI_ENABLED-acino}
ef2d9b
 THREADS=${AC_THREADS-threadsno}
ef2d9b
 SLEEP0=${SLEEP0-1}
ef2d9b
@@ -104,6 +107,8 @@ P2SRSLAVECONF=$DATADIR/slapd-syncrepl-slave-persist2.conf
ef2d9b
 P3SRSLAVECONF=$DATADIR/slapd-syncrepl-slave-persist3.conf
ef2d9b
 REFSLAVECONF=$DATADIR/slapd-ref-slave.conf
ef2d9b
 SCHEMACONF=$DATADIR/slapd-schema.conf
ef2d9b
+TLSCONF=$DATADIR/slapd-tls.conf
ef2d9b
+TLSSASLCONF=$DATADIR/slapd-tls-sasl.conf
ef2d9b
 GLUECONF=$DATADIR/slapd-glue.conf
ef2d9b
 REFINTCONF=$DATADIR/slapd-refint.conf
ef2d9b
 RETCODECONF=$DATADIR/slapd-retcode.conf
ef2d9b
@@ -164,6 +169,7 @@ SLURPLOG=$TESTDIR/slurp.log
ef2d9b
 CONFIGPWF=$TESTDIR/configpw
ef2d9b
 
ef2d9b
 # args
ef2d9b
+SASLARGS="-Q"
ef2d9b
 TOOLARGS="-x $LDAP_TOOLARGS"
ef2d9b
 TOOLPROTO="-P 3"
ef2d9b
 
ef2d9b
@@ -186,7 +192,8 @@ BCMP="diff -iB"
ef2d9b
 CMPOUT=/dev/null
ef2d9b
 SLAPD="$TESTWD/../servers/slapd/slapd -s0"
ef2d9b
 LDAPPASSWD="$CLIENTDIR/ldappasswd $TOOLARGS"
ef2d9b
-LDAPSASLSEARCH="$CLIENTDIR/ldapsearch $TOOLPROTO $LDAP_TOOLARGS -LLL"
ef2d9b
+LDAPSASLSEARCH="$CLIENTDIR/ldapsearch $SASLARGS $TOOLPROTO $LDAP_TOOLARGS -LLL"
ef2d9b
+LDAPSASLWHOAMI="$CLIENTDIR/ldapwhoami $SASLARGS $LDAP_TOOLARGS"
ef2d9b
 LDAPSEARCH="$CLIENTDIR/ldapsearch $TOOLPROTO $TOOLARGS -LLL"
ef2d9b
 LDAPRSEARCH="$CLIENTDIR/ldapsearch $TOOLPROTO $TOOLARGS"
ef2d9b
 LDAPDELETE="$CLIENTDIR/ldapdelete $TOOLPROTO $TOOLARGS"
ef2d9b
@@ -201,6 +208,7 @@ LDIFFILTER=$PROGDIR/ldif-filter
ef2d9b
 SLAPDMTREAD=$PROGDIR/slapd-mtread
ef2d9b
 LVL=${SLAPD_DEBUG-0x4105}
ef2d9b
 LOCALHOST=localhost
ef2d9b
+LOCALIP=127.0.0.1
ef2d9b
 BASEPORT=${SLAPD_BASEPORT-9010}
ef2d9b
 PORT1=`expr $BASEPORT + 1`
ef2d9b
 PORT2=`expr $BASEPORT + 2`
ef2d9b
@@ -209,11 +217,22 @@ PORT4=`expr $BASEPORT + 4`
ef2d9b
 PORT5=`expr $BASEPORT + 5`
ef2d9b
 PORT6=`expr $BASEPORT + 6`
ef2d9b
 URI1="ldap://${LOCALHOST}:$PORT1/"
ef2d9b
+URIP1="ldap://${LOCALIP}:$PORT1/"
ef2d9b
 URI2="ldap://${LOCALHOST}:$PORT2/"
ef2d9b
+URIP2="ldap://${LOCALIP}:$PORT2/"
ef2d9b
 URI3="ldap://${LOCALHOST}:$PORT3/"
ef2d9b
+URIP3="ldap://${LOCALIP}:$PORT3/"
ef2d9b
 URI4="ldap://${LOCALHOST}:$PORT4/"
ef2d9b
 URI5="ldap://${LOCALHOST}:$PORT5/"
ef2d9b
 URI6="ldap://${LOCALHOST}:$PORT6/"
ef2d9b
+SURI1="ldaps://${LOCALHOST}:$PORT1/"
ef2d9b
+SURIP1="ldaps://${LOCALIP}:$PORT1/"
ef2d9b
+SURI2="ldaps://${LOCALHOST}:$PORT2/"
ef2d9b
+SURIP2="ldaps://${LOCALIP}:$PORT2/"
ef2d9b
+SURI3="ldaps://${LOCALHOST}:$PORT3/"
ef2d9b
+SURI4="ldaps://${LOCALHOST}:$PORT4/"
ef2d9b
+SURI5="ldaps://${LOCALHOST}:$PORT5/"
ef2d9b
+SURI6="ldaps://${LOCALHOST}:$PORT6/"
ef2d9b
 
ef2d9b
 # LDIF
ef2d9b
 LDIF=$DATADIR/test.ldif
ef2d9b
diff --git a/tests/scripts/test067-tls b/tests/scripts/test067-tls
ef2d9b
new file mode 100755
ef2d9b
index 000000000..2b245f5f5
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/scripts/test067-tls
ef2d9b
@@ -0,0 +1,140 @@
ef2d9b
+#! /bin/sh
ef2d9b
+# $OpenLDAP$
ef2d9b
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
ef2d9b
+##
ef2d9b
+## Copyright 1998-2017 The OpenLDAP Foundation.
ef2d9b
+## All rights reserved.
ef2d9b
+##
ef2d9b
+## Redistribution and use in source and binary forms, with or without
ef2d9b
+## modification, are permitted only as authorized by the OpenLDAP
ef2d9b
+## Public License.
ef2d9b
+##
ef2d9b
+## A copy of this license is available in the file LICENSE in the
ef2d9b
+## top-level directory of the distribution or, alternatively, at
ef2d9b
+## <http://www.OpenLDAP.org/license.html>.
ef2d9b
+
ef2d9b
+echo "running defines.sh"
ef2d9b
+. $SRCDIR/scripts/defines.sh
ef2d9b
+
ef2d9b
+if test $WITH_TLS = no ; then
ef2d9b
+        echo "TLS support not available, test skipped"
ef2d9b
+        exit 0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+mkdir -p $TESTDIR $DBDIR1
ef2d9b
+cp -r $DATADIR/tls $TESTDIR
ef2d9b
+
ef2d9b
+cd $TESTWD
ef2d9b
+
ef2d9b
+echo "Starting ldap:/// slapd on TCP/IP port $PORT1 and ldaps:/// slapd on $PORT2..."
ef2d9b
+. $CONFFILTER $BACKEND $MONITORDB < $TLSCONF > $CONF1
ef2d9b
+$SLAPD -f $CONF1 -h "$URI1 $SURI2" -d $LVL $TIMING > $LOG1 2>&1 &
ef2d9b
+PID=$!
ef2d9b
+if test $WAIT != 0 ; then
ef2d9b
+    echo PID $PID
ef2d9b
+    read foo
ef2d9b
+fi
ef2d9b
+KILLPIDS="$PID"
ef2d9b
+
ef2d9b
+sleep 1
ef2d9b
+
ef2d9b
+for i in 0 1 2 3 4 5; do
ef2d9b
+	$LDAPSEARCH -s base -b "" -H $URI1 \
ef2d9b
+		'objectclass=*' > /dev/null 2>&1
ef2d9b
+        RC=$?
ef2d9b
+        if test $RC = 0 ; then
ef2d9b
+                break
ef2d9b
+        fi
ef2d9b
+        echo "Waiting 5 seconds for slapd to start..."
ef2d9b
+        sleep 5
ef2d9b
+done
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo -n "Using ldapsearch with startTLS with no server cert validation...."
ef2d9b
+$LDAPSEARCH -o tls_reqcert=never -ZZ -b "" -s base -H $URIP1 \
ef2d9b
+	'@extensibleObject' > $SEARCHOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch (startTLS) failed ($RC)!"
ef2d9b
+	exit $RC
ef2d9b
+else
ef2d9b
+	echo "success"
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo -n "Using ldapsearch with startTLS with hard require cert...."
ef2d9b
+$LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -o tls_reqcert=hard -ZZ -b "" -s base -H $URIP1 \
ef2d9b
+	'@extensibleObject' > $SEARCHOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch (startTLS) failed ($RC)!"
ef2d9b
+	exit $RC
ef2d9b
+else
ef2d9b
+	echo "success"
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if test $WITH_TLS_TYPE = openssl ; then
ef2d9b
+	echo -n "Using ldapsearch with startTLS and specific protocol version...."
ef2d9b
+	$LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -o tls_reqcert=hard -o tls_protocol_min=3.3 -ZZ -b "" -s base -H $URIP1 \
ef2d9b
+		'@extensibleObject' > $SEARCHOUT 2>&1
ef2d9b
+	RC=$?
ef2d9b
+	if test $RC != 0 ; then
ef2d9b
+		echo "ldapsearch (protocol-min) failed ($RC)!"
ef2d9b
+		exit $RC
ef2d9b
+	else
ef2d9b
+		echo "success"
ef2d9b
+	fi
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo -n "Using ldapsearch on $SURI2 with no server cert validation..."
ef2d9b
+$LDAPSEARCH -o tls_reqcert=never -b "cn=Subschema" -s base -H $SURIP2 \
ef2d9b
+	'(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
ef2d9b
+	>> $SEARCHOUT  2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch (ldaps) failed($RC)!"
ef2d9b
+	exit $RC
ef2d9b
+else
ef2d9b
+	echo "success"
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo -n "Using ldapsearch on $SURI2 with reqcert HARD and no CA cert.  Should fail..."
ef2d9b
+$LDAPSEARCH -o tls_reqcert=hard -b "cn=Subschema" -s base -H $SURIP2 \
ef2d9b
+	'(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
ef2d9b
+	>> $SEARCHOUT  2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC = 0 ; then
ef2d9b
+	echo "ldapsearch (ldaps) succeeded when it should have failed($RC)!"
ef2d9b
+	exit 1
ef2d9b
+else
ef2d9b
+	echo "failed correctly with error code ($RC)"
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo -n "Using ldapsearch on $SURI2 with CA cert and reqcert HARD..."
ef2d9b
+$LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -o tls_reqcert=hard -b "cn=Subschema" -s base -H $SURIP2 \
ef2d9b
+	'(&(objectClasses=top)(objectClasses=2.5.6.0))' cn objectClass \
ef2d9b
+	>> $SEARCHOUT  2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch (ldaps) failed ($RC)!"
ef2d9b
+	exit $RC
ef2d9b
+else
ef2d9b
+	echo "success"
ef2d9b
+fi
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo ">>>>> Test failed"
ef2d9b
+else
ef2d9b
+	echo ">>>>> Test succeeded"
ef2d9b
+	RC=0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && wait
ef2d9b
+
ef2d9b
+exit $RC
ef2d9b
diff --git a/tests/scripts/test068-sasl-tls-external b/tests/scripts/test068-sasl-tls-external
ef2d9b
new file mode 100755
ef2d9b
index 000000000..dcbc50fd4
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/scripts/test068-sasl-tls-external
ef2d9b
@@ -0,0 +1,102 @@
ef2d9b
+#! /bin/sh
ef2d9b
+# $OpenLDAP$
ef2d9b
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
ef2d9b
+##
ef2d9b
+## Copyright 1998-2017 The OpenLDAP Foundation.
ef2d9b
+## All rights reserved.
ef2d9b
+##
ef2d9b
+## Redistribution and use in source and binary forms, with or without
ef2d9b
+## modification, are permitted only as authorized by the OpenLDAP
ef2d9b
+## Public License.
ef2d9b
+##
ef2d9b
+## A copy of this license is available in the file LICENSE in the
ef2d9b
+## top-level directory of the distribution or, alternatively, at
ef2d9b
+## <http://www.OpenLDAP.org/license.html>.
ef2d9b
+
ef2d9b
+echo "running defines.sh"
ef2d9b
+. $SRCDIR/scripts/defines.sh
ef2d9b
+
ef2d9b
+if test $WITH_TLS = no ; then
ef2d9b
+        echo "TLS support not available, test skipped"
ef2d9b
+        exit 0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+mkdir -p $TESTDIR $DBDIR1
ef2d9b
+cp -r $DATADIR/tls $TESTDIR
ef2d9b
+
ef2d9b
+cd $TESTWD
ef2d9b
+
ef2d9b
+echo "Running slapadd to build slapd database..."
ef2d9b
+. $CONFFILTER $BACKEND $MONITORDB < $TLSSASLCONF > $CONF1
ef2d9b
+$SLAPADD -f $CONF1 -l $LDIFORDERED
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+        echo "slapadd failed ($RC)!"
ef2d9b
+        exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo "Starting ldap:/// slapd on TCP/IP port $PORT1 and ldaps:/// slapd on $PORT2..."
ef2d9b
+$SLAPD -f $CONF1 -h "$URI1 $SURI2" -d $LVL $TIMING > $LOG1 2>&1 &
ef2d9b
+PID=$!
ef2d9b
+if test $WAIT != 0 ; then
ef2d9b
+    echo PID $PID
ef2d9b
+    read foo
ef2d9b
+fi
ef2d9b
+KILLPIDS="$PID"
ef2d9b
+
ef2d9b
+sleep 1
ef2d9b
+
ef2d9b
+for i in 0 1 2 3 4 5; do
ef2d9b
+	$LDAPSEARCH -s base -b "" -H $URI1 \
ef2d9b
+		'objectclass=*' > /dev/null 2>&1
ef2d9b
+        RC=$?
ef2d9b
+        if test $RC = 0 ; then
ef2d9b
+                break
ef2d9b
+        fi
ef2d9b
+        echo "Waiting 5 seconds for slapd to start..."
ef2d9b
+        sleep 5
ef2d9b
+done
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo -n "Using ldapwhoami with SASL/EXTERNAL...."
ef2d9b
+$LDAPSASLWHOAMI -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -o tls_reqcert=hard \
ef2d9b
+	-o tls_cert=$TESTDIR/tls/certs/bjensen@mailgw.example.com.crt -o tls_key=$TESTDIR/tls/private/bjensen@mailgw.example.com.key -ZZ -Y EXTERNAL -H $URIP1 \
ef2d9b
+	> $TESTOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapwhoami (startTLS) failed ($RC)!"
ef2d9b
+	exit $RC
ef2d9b
+else
ef2d9b
+	echo "success"
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo -n "Validating mapped SASL ID..."
ef2d9b
+echo 'dn:cn=barbara jensen,ou=information technology division,ou=people,dc=example,dc=com' > $TESTDIR/dn.out
ef2d9b
+$CMP $TESTDIR/dn.out $TESTOUT > $CMPOUT
ef2d9b
+
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "Comparison failed"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $PID
ef2d9b
+	exit $RC
ef2d9b
+else
ef2d9b
+	echo "success"
ef2d9b
+fi
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo ">>>>> Test failed"
ef2d9b
+else
ef2d9b
+	echo ">>>>> Test succeeded"
ef2d9b
+	RC=0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && wait
ef2d9b
+
ef2d9b
+exit $RC
ef2d9b
diff --git a/tests/scripts/test069-delta-multimaster-starttls b/tests/scripts/test069-delta-multimaster-starttls
ef2d9b
new file mode 100755
ef2d9b
index 000000000..2dfbb30a1
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/scripts/test069-delta-multimaster-starttls
ef2d9b
@@ -0,0 +1,574 @@
ef2d9b
+#! /bin/sh
ef2d9b
+# $OpenLDAP$
ef2d9b
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
ef2d9b
+##
ef2d9b
+## Copyright 1998-2017 The OpenLDAP Foundation.
ef2d9b
+## All rights reserved.
ef2d9b
+##
ef2d9b
+## Redistribution and use in source and binary forms, with or without
ef2d9b
+## modification, are permitted only as authorized by the OpenLDAP
ef2d9b
+## Public License.
ef2d9b
+##
ef2d9b
+## A copy of this license is available in the file LICENSE in the
ef2d9b
+## top-level directory of the distribution or, alternatively, at
ef2d9b
+## <http://www.OpenLDAP.org/license.html>.
ef2d9b
+
ef2d9b
+echo "running defines.sh"
ef2d9b
+. $SRCDIR/scripts/defines.sh
ef2d9b
+
ef2d9b
+if test $WITH_TLS = no ; then
ef2d9b
+        echo "TLS support not available, test skipped"
ef2d9b
+        exit 0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if test $SYNCPROV = syncprovno; then
ef2d9b
+	echo "Syncrepl provider overlay not available, test skipped"
ef2d9b
+	exit 0
ef2d9b
+fi
ef2d9b
+if test $ACCESSLOG = accesslogno; then
ef2d9b
+	echo "Accesslog overlay not available, test skipped"
ef2d9b
+	exit 0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+MMR=2
ef2d9b
+
ef2d9b
+XDIR=$TESTDIR/srv
ef2d9b
+TMP=$TESTDIR/tmp
ef2d9b
+
ef2d9b
+mkdir -p $TESTDIR
ef2d9b
+cp -r $DATADIR/tls $TESTDIR
ef2d9b
+
ef2d9b
+$SLAPPASSWD -g -n >$CONFIGPWF
ef2d9b
+
ef2d9b
+if test x"$SYNCMODE" = x ; then
ef2d9b
+	SYNCMODE=rp
ef2d9b
+fi
ef2d9b
+case "$SYNCMODE" in
ef2d9b
+	ro)
ef2d9b
+		SYNCTYPE="type=refreshOnly interval=00:00:00:03"
ef2d9b
+		;;
ef2d9b
+	rp)
ef2d9b
+		SYNCTYPE="type=refreshAndPersist interval=00:00:00:03"
ef2d9b
+		;;
ef2d9b
+	*)
ef2d9b
+		echo "unknown sync mode $SYNCMODE"
ef2d9b
+		exit 1;
ef2d9b
+		;;
ef2d9b
+esac
ef2d9b
+
ef2d9b
+#
ef2d9b
+# Test delta-sync mmr
ef2d9b
+# - start servers
ef2d9b
+# - configure over ldap
ef2d9b
+# - populate over ldap
ef2d9b
+# - configure syncrepl over ldap
ef2d9b
+# - break replication
ef2d9b
+# - modify each server separately
ef2d9b
+# - restore replication
ef2d9b
+# - compare results
ef2d9b
+#
ef2d9b
+
ef2d9b
+nullExclude=""
ef2d9b
+test $BACKEND = null && nullExclude="# "
ef2d9b
+
ef2d9b
+KILLPIDS=
ef2d9b
+
ef2d9b
+echo "Initializing server configurations..."
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+
ef2d9b
+DBDIR=${XDIR}$n/db
ef2d9b
+CFDIR=${XDIR}$n/slapd.d
ef2d9b
+
ef2d9b
+mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
ef2d9b
+
ef2d9b
+o=`expr 3 - $n`
ef2d9b
+cat > $TMP <
ef2d9b
+dn: cn=config
ef2d9b
+objectClass: olcGlobal
ef2d9b
+cn: config
ef2d9b
+olcServerID: $n
ef2d9b
+olcTLSCertificateFile: $TESTDIR/tls/certs/localhost.crt
ef2d9b
+olcTLSCertificateKeyFile: $TESTDIR/tls/private/localhost.key
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+
ef2d9b
+if [ "$SYNCPROV" = syncprovmod -o "$ACCESSLOG" = accesslogmod ]; then
ef2d9b
+  cat <<EOF >> $TMP
ef2d9b
+dn: cn=module,cn=config
ef2d9b
+objectClass: olcModuleList
ef2d9b
+cn: module
ef2d9b
+olcModulePath: $TESTWD/../servers/slapd/overlays
ef2d9b
+EOF
ef2d9b
+  if [ "$SYNCPROV" = syncprovmod ]; then
ef2d9b
+  echo "olcModuleLoad: syncprov.la" >> $TMP
ef2d9b
+  fi
ef2d9b
+  if [ "$ACCESSLOG" = accesslogmod ]; then
ef2d9b
+  echo "olcModuleLoad: accesslog.la" >> $TMP
ef2d9b
+  fi
ef2d9b
+  echo "" >> $TMP
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if [ "$BACKENDTYPE" = mod ]; then
ef2d9b
+cat <<EOF >> $TMP
ef2d9b
+dn: cn=module,cn=config
ef2d9b
+objectClass: olcModuleList
ef2d9b
+cn: module
ef2d9b
+olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
ef2d9b
+olcModuleLoad: back_$BACKEND.la
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+fi
ef2d9b
+MYURI=`eval echo '$URI'$n`
ef2d9b
+PROVIDERURI=`eval echo '$URIP'$o`
ef2d9b
+if test $INDEXDB = indexdb ; then
ef2d9b
+INDEX1="olcDbIndex: objectClass,entryCSN,reqStart,reqDN,reqResult eq"
ef2d9b
+INDEX2="olcDbIndex: objectClass,entryCSN,entryUUID eq"
ef2d9b
+else
ef2d9b
+INDEX1=
ef2d9b
+INDEX2=
ef2d9b
+fi
ef2d9b
+cat >> $TMP <
ef2d9b
+dn: cn=schema,cn=config
ef2d9b
+objectclass: olcSchemaconfig
ef2d9b
+cn: schema
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/core.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/cosine.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/inetorgperson.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/openldap.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/nis.ldif
ef2d9b
+
ef2d9b
+dn: olcDatabase={0}config,cn=config
ef2d9b
+objectClass: olcDatabaseConfig
ef2d9b
+olcDatabase: {0}config
ef2d9b
+olcRootPW:< file://$CONFIGPWF
ef2d9b
+
ef2d9b
+dn: olcDatabase={1}$BACKEND,cn=config
ef2d9b
+objectClass: olcDatabaseConfig
ef2d9b
+${nullExclude}objectClass: olc${BACKEND}Config
ef2d9b
+olcDatabase: {1}$BACKEND
ef2d9b
+olcSuffix: cn=log
ef2d9b
+${nullExclude}olcDbDirectory: ${DBDIR}.1
ef2d9b
+olcRootDN: $MANAGERDN
ef2d9b
+$INDEX1
ef2d9b
+
ef2d9b
+dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config
ef2d9b
+objectClass: olcOverlayConfig
ef2d9b
+objectClass: olcSyncProvConfig
ef2d9b
+olcOverlay: syncprov
ef2d9b
+olcSpNoPresent: TRUE
ef2d9b
+olcSpReloadHint: TRUE
ef2d9b
+
ef2d9b
+dn: olcDatabase={2}$BACKEND,cn=config
ef2d9b
+objectClass: olcDatabaseConfig
ef2d9b
+${nullExclude}objectClass: olc${BACKEND}Config
ef2d9b
+olcDatabase: {2}$BACKEND
ef2d9b
+olcSuffix: $BASEDN
ef2d9b
+${nullExclude}olcDbDirectory: ${DBDIR}.2
ef2d9b
+olcRootDN: $MANAGERDN
ef2d9b
+olcRootPW: $PASSWD
ef2d9b
+olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
ef2d9b
+  credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
ef2d9b
+  retry="3 +" timeout=3 logbase="cn=log"
ef2d9b
+  logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
ef2d9b
+  syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
ef2d9b
+  starttls=critical
ef2d9b
+olcMirrorMode: TRUE
ef2d9b
+$INDEX2
ef2d9b
+
ef2d9b
+dn: olcOverlay=syncprov,olcDatabase={2}$BACKEND,cn=config
ef2d9b
+objectClass: olcOverlayConfig
ef2d9b
+objectClass: olcSyncProvConfig
ef2d9b
+olcOverlay: syncprov
ef2d9b
+
ef2d9b
+dn: olcOverlay=accesslog,olcDatabase={2}$BACKEND,cn=config
ef2d9b
+objectClass: olcOverlayConfig
ef2d9b
+objectClass: olcAccessLogConfig
ef2d9b
+olcOverlay: accesslog
ef2d9b
+olcAccessLogDB: cn=log
ef2d9b
+olcAccessLogOps: writes
ef2d9b
+olcAccessLogSuccess: TRUE
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+$SLAPADD -F $CFDIR -n 0  -d-1< $TMP > $TESTOUT 2>&1
ef2d9b
+PORT=`eval echo '$PORT'$n`
ef2d9b
+echo "Starting server $n on TCP/IP port $PORT..."
ef2d9b
+cd ${XDIR}${n}
ef2d9b
+LOG=`eval echo '$LOG'$n`
ef2d9b
+$SLAPD -F slapd.d -h $MYURI -d $LVL $TIMING > $LOG 2>&1 &
ef2d9b
+PID=$!
ef2d9b
+if test $WAIT != 0 ; then
ef2d9b
+    echo PID $PID
ef2d9b
+    read foo
ef2d9b
+fi
ef2d9b
+KILLPIDS="$PID $KILLPIDS"
ef2d9b
+cd $TESTWD
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to check that server $n is running..."
ef2d9b
+for i in 0 1 2 3 4 5; do
ef2d9b
+	$LDAPSEARCH -s base -b "" -H $MYURI \
ef2d9b
+		'objectclass=*' > /dev/null 2>&1
ef2d9b
+	RC=$?
ef2d9b
+	if test $RC = 0 ; then
ef2d9b
+		break
ef2d9b
+	fi
ef2d9b
+	echo "Waiting 5 seconds for slapd to start..."
ef2d9b
+	sleep 5
ef2d9b
+done
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if [ $n = 1 ]; then
ef2d9b
+echo "Using ldapadd for context on server 1..."
ef2d9b
+$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDCP \
ef2d9b
+	>> $TESTOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapadd failed for server $n database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+fi
ef2d9b
+
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Using ldapadd to populate server 1..."
ef2d9b
+$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFORDEREDNOCP \
ef2d9b
+	>> $TESTOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapadd failed for server $n database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
ef2d9b
+sleep $SLEEP1
ef2d9b
+
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+PORT=`expr $BASEPORT + $n`
ef2d9b
+URI="ldap://${LOCALHOST}:$PORT/"
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to read all the entries from server $n..."
ef2d9b
+$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
ef2d9b
+	'objectclass=*' > $TESTDIR/server$n.out 2>&1
ef2d9b
+RC=$?
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed at server $n ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=2
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+echo "Comparing retrieved entries from server 1 and server $n..."
ef2d9b
+$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
ef2d9b
+
ef2d9b
+if test $? != 0 ; then
ef2d9b
+	echo "test failed - server 1 and server $n databases differ"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit 1
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Using ldapadd to populate server 2..."
ef2d9b
+$LDAPADD -D "$MANAGERDN" -H $URI2 -w $PASSWD -f $LDIFADD1 \
ef2d9b
+	>> $TESTOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapadd failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+THEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com"
ef2d9b
+sleep 1
ef2d9b
+for i in 1 2 3; do
ef2d9b
+	$LDAPSEARCH -S "" -b "$THEDN" -H $URI1 \
ef2d9b
+		-s base '(objectClass=*)' entryCSN > "${MASTEROUT}.$i" 2>&1
ef2d9b
+	RC=$?
ef2d9b
+
ef2d9b
+	if test $RC = 0 ; then
ef2d9b
+		break
ef2d9b
+	fi
ef2d9b
+
ef2d9b
+	if test $RC != 32 ; then
ef2d9b
+		echo "ldapsearch failed at slave ($RC)!"
ef2d9b
+		test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+		exit $RC
ef2d9b
+	fi
ef2d9b
+
ef2d9b
+	echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
ef2d9b
+	sleep $SLEEP1
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+PORT=`expr $BASEPORT + $n`
ef2d9b
+URI="ldap://${LOCALHOST}:$PORT/"
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to read all the entries from server $n..."
ef2d9b
+$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
ef2d9b
+	'objectclass=*' > $TESTDIR/server$n.out 2>&1
ef2d9b
+RC=$?
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed at server $n ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=2
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+echo "Comparing retrieved entries from server 1 and server $n..."
ef2d9b
+$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
ef2d9b
+
ef2d9b
+if test $? != 0 ; then
ef2d9b
+	echo "test failed - server 1 and server $n databases differ"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit 1
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Breaking replication between server 1 and 2..."
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+o=`expr 3 - $n`
ef2d9b
+MYURI=`eval echo '$URI'$n`
ef2d9b
+PROVIDERURI=`eval echo '$URIP'$o`
ef2d9b
+$LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <
ef2d9b
+dn: olcDatabase={2}$BACKEND,cn=config
ef2d9b
+changetype: modify
ef2d9b
+replace: olcSyncRepl
ef2d9b
+olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
ef2d9b
+  credentials=InvalidPw searchbase="$BASEDN" $SYNCTYPE
ef2d9b
+  retry="3 +" timeout=3 logbase="cn=log"
ef2d9b
+  logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
ef2d9b
+  syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
ef2d9b
+  starttls=critical
ef2d9b
+-
ef2d9b
+replace: olcMirrorMode
ef2d9b
+olcMirrorMode: TRUE
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server $n config ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Using ldapmodify to force conflicts between server 1 and 2..."
ef2d9b
+$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: description
ef2d9b
+description: Amazing
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: description
ef2d9b
+description: Stupendous
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+delete: description
ef2d9b
+description: Outstanding
ef2d9b
+-
ef2d9b
+add: description
ef2d9b
+description: Mindboggling
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+delete: description
ef2d9b
+description: OutStanding
ef2d9b
+-
ef2d9b
+add: description
ef2d9b
+description: Bizarre
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: carLicense
ef2d9b
+carLicense: 123-XYZ
ef2d9b
+-
ef2d9b
+add: employeeNumber
ef2d9b
+employeeNumber: 32
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -D "$MANAGERDN" -H $URI2 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: employeeType
ef2d9b
+employeeType: deadwood
ef2d9b
+-
ef2d9b
+add: employeeNumber
ef2d9b
+employeeNumber: 64
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+replace: sn
ef2d9b
+sn: Replaced later
ef2d9b
+-
ef2d9b
+replace: sn
ef2d9b
+sn: Surname
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo "Restoring replication between server 1 and 2..."
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+o=`expr 3 - $n`
ef2d9b
+MYURI=`eval echo '$URI'$n`
ef2d9b
+PROVIDERURI=`eval echo '$URIP'$o`
ef2d9b
+$LDAPMODIFY -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <
ef2d9b
+dn: olcDatabase={2}$BACKEND,cn=config
ef2d9b
+changetype: modify
ef2d9b
+replace: olcSyncRepl
ef2d9b
+olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
ef2d9b
+  credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
ef2d9b
+  retry="3 +" timeout=3 logbase="cn=log"
ef2d9b
+  logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
ef2d9b
+  syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
ef2d9b
+  starttls=critical
ef2d9b
+-
ef2d9b
+replace: olcMirrorMode
ef2d9b
+olcMirrorMode: TRUE
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server $n config ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
ef2d9b
+sleep $SLEEP1
ef2d9b
+
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+PORT=`expr $BASEPORT + $n`
ef2d9b
+URI="ldap://${LOCALHOST}:$PORT/"
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to read all the entries from server $n..."
ef2d9b
+$LDAPSEARCH -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
ef2d9b
+	'objectclass=*' > $TESTDIR/server$n.out 2>&1
ef2d9b
+RC=$?
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed at server $n ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+$LDIFFILTER -s a < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=2
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+echo "Comparing retrieved entries from server 1 and server $n..."
ef2d9b
+$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
ef2d9b
+
ef2d9b
+if test $? != 0 ; then
ef2d9b
+	echo "test failed - server 1 and server $n databases differ"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit 1
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+
ef2d9b
+echo ">>>>> Test succeeded"
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && wait
ef2d9b
+
ef2d9b
+exit 0
ef2d9b
diff --git a/tests/scripts/test070-delta-multimaster-ldaps b/tests/scripts/test070-delta-multimaster-ldaps
ef2d9b
new file mode 100755
ef2d9b
index 000000000..1024640ef
ef2d9b
--- /dev/null
ef2d9b
+++ b/tests/scripts/test070-delta-multimaster-ldaps
ef2d9b
@@ -0,0 +1,571 @@
ef2d9b
+#! /bin/sh
ef2d9b
+# $OpenLDAP$
ef2d9b
+## This work is part of OpenLDAP Software <http://www.openldap.org/>.
ef2d9b
+##
ef2d9b
+## Copyright 1998-2017 The OpenLDAP Foundation.
ef2d9b
+## All rights reserved.
ef2d9b
+##
ef2d9b
+## Redistribution and use in source and binary forms, with or without
ef2d9b
+## modification, are permitted only as authorized by the OpenLDAP
ef2d9b
+## Public License.
ef2d9b
+##
ef2d9b
+## A copy of this license is available in the file LICENSE in the
ef2d9b
+## top-level directory of the distribution or, alternatively, at
ef2d9b
+## <http://www.OpenLDAP.org/license.html>.
ef2d9b
+
ef2d9b
+echo "running defines.sh"
ef2d9b
+. $SRCDIR/scripts/defines.sh
ef2d9b
+
ef2d9b
+if test $WITH_TLS = no ; then
ef2d9b
+        echo "TLS support not available, test skipped"
ef2d9b
+        exit 0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if test $SYNCPROV = syncprovno; then
ef2d9b
+	echo "Syncrepl provider overlay not available, test skipped"
ef2d9b
+	exit 0
ef2d9b
+fi
ef2d9b
+if test $ACCESSLOG = accesslogno; then
ef2d9b
+	echo "Accesslog overlay not available, test skipped"
ef2d9b
+	exit 0
ef2d9b
+fi
ef2d9b
+
ef2d9b
+MMR=2
ef2d9b
+
ef2d9b
+XDIR=$TESTDIR/srv
ef2d9b
+TMP=$TESTDIR/tmp
ef2d9b
+
ef2d9b
+mkdir -p $TESTDIR
ef2d9b
+cp -r $DATADIR/tls $TESTDIR
ef2d9b
+
ef2d9b
+$SLAPPASSWD -g -n >$CONFIGPWF
ef2d9b
+
ef2d9b
+if test x"$SYNCMODE" = x ; then
ef2d9b
+	SYNCMODE=rp
ef2d9b
+fi
ef2d9b
+case "$SYNCMODE" in
ef2d9b
+	ro)
ef2d9b
+		SYNCTYPE="type=refreshOnly interval=00:00:00:03"
ef2d9b
+		;;
ef2d9b
+	rp)
ef2d9b
+		SYNCTYPE="type=refreshAndPersist interval=00:00:00:03"
ef2d9b
+		;;
ef2d9b
+	*)
ef2d9b
+		echo "unknown sync mode $SYNCMODE"
ef2d9b
+		exit 1;
ef2d9b
+		;;
ef2d9b
+esac
ef2d9b
+
ef2d9b
+#
ef2d9b
+# Test delta-sync mmr
ef2d9b
+# - start servers
ef2d9b
+# - configure over ldap
ef2d9b
+# - populate over ldap
ef2d9b
+# - configure syncrepl over ldap
ef2d9b
+# - break replication
ef2d9b
+# - modify each server separately
ef2d9b
+# - restore replication
ef2d9b
+# - compare results
ef2d9b
+#
ef2d9b
+
ef2d9b
+nullExclude=""
ef2d9b
+test $BACKEND = null && nullExclude="# "
ef2d9b
+
ef2d9b
+KILLPIDS=
ef2d9b
+
ef2d9b
+echo "Initializing server configurations..."
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+
ef2d9b
+DBDIR=${XDIR}$n/db
ef2d9b
+CFDIR=${XDIR}$n/slapd.d
ef2d9b
+
ef2d9b
+mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
ef2d9b
+
ef2d9b
+o=`expr 3 - $n`
ef2d9b
+cat > $TMP <
ef2d9b
+dn: cn=config
ef2d9b
+objectClass: olcGlobal
ef2d9b
+cn: config
ef2d9b
+olcServerID: $n
ef2d9b
+olcTLSCertificateFile: $TESTDIR/tls/certs/localhost.crt
ef2d9b
+olcTLSCertificateKeyFile: $TESTDIR/tls/private/localhost.key
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+
ef2d9b
+if [ "$SYNCPROV" = syncprovmod -o "$ACCESSLOG" = accesslogmod ]; then
ef2d9b
+  cat <<EOF >> $TMP
ef2d9b
+dn: cn=module,cn=config
ef2d9b
+objectClass: olcModuleList
ef2d9b
+cn: module
ef2d9b
+olcModulePath: $TESTWD/../servers/slapd/overlays
ef2d9b
+EOF
ef2d9b
+  if [ "$SYNCPROV" = syncprovmod ]; then
ef2d9b
+  echo "olcModuleLoad: syncprov.la" >> $TMP
ef2d9b
+  fi
ef2d9b
+  if [ "$ACCESSLOG" = accesslogmod ]; then
ef2d9b
+  echo "olcModuleLoad: accesslog.la" >> $TMP
ef2d9b
+  fi
ef2d9b
+  echo "" >> $TMP
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if [ "$BACKENDTYPE" = mod ]; then
ef2d9b
+cat <<EOF >> $TMP
ef2d9b
+dn: cn=module,cn=config
ef2d9b
+objectClass: olcModuleList
ef2d9b
+cn: module
ef2d9b
+olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND
ef2d9b
+olcModuleLoad: back_$BACKEND.la
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+fi
ef2d9b
+MYURI=`eval echo '$SURIP'$n`
ef2d9b
+PROVIDERURI=`eval echo '$SURIP'$o`
ef2d9b
+if test $INDEXDB = indexdb ; then
ef2d9b
+INDEX1="olcDbIndex: objectClass,entryCSN,reqStart,reqDN,reqResult eq"
ef2d9b
+INDEX2="olcDbIndex: objectClass,entryCSN,entryUUID eq"
ef2d9b
+else
ef2d9b
+INDEX1=
ef2d9b
+INDEX2=
ef2d9b
+fi
ef2d9b
+cat >> $TMP <
ef2d9b
+dn: cn=schema,cn=config
ef2d9b
+objectclass: olcSchemaconfig
ef2d9b
+cn: schema
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/core.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/cosine.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/inetorgperson.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/openldap.ldif
ef2d9b
+
ef2d9b
+include: file://$ABS_SCHEMADIR/nis.ldif
ef2d9b
+
ef2d9b
+dn: olcDatabase={0}config,cn=config
ef2d9b
+objectClass: olcDatabaseConfig
ef2d9b
+olcDatabase: {0}config
ef2d9b
+olcRootPW:< file://$CONFIGPWF
ef2d9b
+
ef2d9b
+dn: olcDatabase={1}$BACKEND,cn=config
ef2d9b
+objectClass: olcDatabaseConfig
ef2d9b
+${nullExclude}objectClass: olc${BACKEND}Config
ef2d9b
+olcDatabase: {1}$BACKEND
ef2d9b
+olcSuffix: cn=log
ef2d9b
+${nullExclude}olcDbDirectory: ${DBDIR}.1
ef2d9b
+olcRootDN: $MANAGERDN
ef2d9b
+$INDEX1
ef2d9b
+
ef2d9b
+dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config
ef2d9b
+objectClass: olcOverlayConfig
ef2d9b
+objectClass: olcSyncProvConfig
ef2d9b
+olcOverlay: syncprov
ef2d9b
+olcSpNoPresent: TRUE
ef2d9b
+olcSpReloadHint: TRUE
ef2d9b
+
ef2d9b
+dn: olcDatabase={2}$BACKEND,cn=config
ef2d9b
+objectClass: olcDatabaseConfig
ef2d9b
+${nullExclude}objectClass: olc${BACKEND}Config
ef2d9b
+olcDatabase: {2}$BACKEND
ef2d9b
+olcSuffix: $BASEDN
ef2d9b
+${nullExclude}olcDbDirectory: ${DBDIR}.2
ef2d9b
+olcRootDN: $MANAGERDN
ef2d9b
+olcRootPW: $PASSWD
ef2d9b
+olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
ef2d9b
+  credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
ef2d9b
+  retry="3 +" timeout=3 logbase="cn=log"
ef2d9b
+  logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
ef2d9b
+  syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
ef2d9b
+olcMirrorMode: TRUE
ef2d9b
+$INDEX2
ef2d9b
+
ef2d9b
+dn: olcOverlay=syncprov,olcDatabase={2}$BACKEND,cn=config
ef2d9b
+objectClass: olcOverlayConfig
ef2d9b
+objectClass: olcSyncProvConfig
ef2d9b
+olcOverlay: syncprov
ef2d9b
+
ef2d9b
+dn: olcOverlay=accesslog,olcDatabase={2}$BACKEND,cn=config
ef2d9b
+objectClass: olcOverlayConfig
ef2d9b
+objectClass: olcAccessLogConfig
ef2d9b
+olcOverlay: accesslog
ef2d9b
+olcAccessLogDB: cn=log
ef2d9b
+olcAccessLogOps: writes
ef2d9b
+olcAccessLogSuccess: TRUE
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+$SLAPADD -F $CFDIR -n 0  -d-1< $TMP > $TESTOUT 2>&1
ef2d9b
+PORT=`eval echo '$PORT'$n`
ef2d9b
+echo "Starting server $n on TCP/IP port $PORT..."
ef2d9b
+cd ${XDIR}${n}
ef2d9b
+LOG=`eval echo '$LOG'$n`
ef2d9b
+$SLAPD -F slapd.d -h $MYURI -d $LVL $TIMING > $LOG 2>&1 &
ef2d9b
+PID=$!
ef2d9b
+if test $WAIT != 0 ; then
ef2d9b
+    echo PID $PID
ef2d9b
+    read foo
ef2d9b
+fi
ef2d9b
+KILLPIDS="$PID $KILLPIDS"
ef2d9b
+cd $TESTWD
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to check that server $n is running..."
ef2d9b
+for i in 0 1 2 3 4 5; do
ef2d9b
+	$LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -s base -b "" -H $MYURI \
ef2d9b
+		'objectclass=*' > /dev/null 2>&1
ef2d9b
+	RC=$?
ef2d9b
+	if test $RC = 0 ; then
ef2d9b
+		break
ef2d9b
+	fi
ef2d9b
+	echo "Waiting 5 seconds for slapd to start..."
ef2d9b
+	sleep 5
ef2d9b
+done
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+if [ $n = 1 ]; then
ef2d9b
+echo "Using ldapadd for context on server 1..."
ef2d9b
+$LDAPADD -D "$MANAGERDN" -H $SURIP1 -w $PASSWD -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -f $LDIFORDEREDCP \
ef2d9b
+	>> $TESTOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapadd failed for server $n database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+fi
ef2d9b
+
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Using ldapadd to populate server 1..."
ef2d9b
+$LDAPADD -D "$MANAGERDN" -H $SURIP1 -w $PASSWD -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -f $LDIFORDEREDNOCP \
ef2d9b
+	>> $TESTOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapadd failed for server $n database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
ef2d9b
+sleep $SLEEP1
ef2d9b
+
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+PORT=`expr $BASEPORT + $n`
ef2d9b
+URI="ldaps://${LOCALIP}:$PORT/"
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to read all the entries from server $n..."
ef2d9b
+$LDAPSEARCH -S "" -b "$BASEDN" -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $URI -w $PASSWD  \
ef2d9b
+	'objectclass=*' > $TESTDIR/server$n.out 2>&1
ef2d9b
+RC=$?
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed at server $n ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=2
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+echo "Comparing retrieved entries from server 1 and server $n..."
ef2d9b
+$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
ef2d9b
+
ef2d9b
+if test $? != 0 ; then
ef2d9b
+	echo "test failed - server 1 and server $n databases differ"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit 1
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Using ldapadd to populate server 2..."
ef2d9b
+$LDAPADD -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP2 -w $PASSWD -f $LDIFADD1 \
ef2d9b
+	>> $TESTOUT 2>&1
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapadd failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+THEDN="cn=James A Jones 2,ou=Alumni Association,ou=People,dc=example,dc=com"
ef2d9b
+sleep 1
ef2d9b
+for i in 1 2 3; do
ef2d9b
+	$LDAPSEARCH -S "" -b "$THEDN" -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -H $SURIP1 \
ef2d9b
+		-s base '(objectClass=*)' entryCSN > "${MASTEROUT}.$i" 2>&1
ef2d9b
+	RC=$?
ef2d9b
+
ef2d9b
+	if test $RC = 0 ; then
ef2d9b
+		break
ef2d9b
+	fi
ef2d9b
+
ef2d9b
+	if test $RC != 32 ; then
ef2d9b
+		echo "ldapsearch failed at slave ($RC)!"
ef2d9b
+		test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+		exit $RC
ef2d9b
+	fi
ef2d9b
+
ef2d9b
+	echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
ef2d9b
+	sleep $SLEEP1
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+PORT=`expr $BASEPORT + $n`
ef2d9b
+URI="ldaps://${LOCALIP}:$PORT/"
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to read all the entries from server $n..."
ef2d9b
+$LDAPSEARCH -S "" -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
ef2d9b
+	'objectclass=*' > $TESTDIR/server$n.out 2>&1
ef2d9b
+RC=$?
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed at server $n ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+$LDIFFILTER < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=2
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+echo "Comparing retrieved entries from server 1 and server $n..."
ef2d9b
+$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
ef2d9b
+
ef2d9b
+if test $? != 0 ; then
ef2d9b
+	echo "test failed - server 1 and server $n databases differ"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit 1
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Breaking replication between server 1 and 2..."
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+o=`expr 3 - $n`
ef2d9b
+MYURI=`eval echo '$SURIP'$n`
ef2d9b
+PROVIDERURI=`eval echo '$SURIP'$o`
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D cn=config -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <
ef2d9b
+dn: olcDatabase={2}$BACKEND,cn=config
ef2d9b
+changetype: modify
ef2d9b
+replace: olcSyncRepl
ef2d9b
+olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
ef2d9b
+  credentials=InvalidPw searchbase="$BASEDN" $SYNCTYPE
ef2d9b
+  retry="3 +" timeout=3 logbase="cn=log"
ef2d9b
+  logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
ef2d9b
+  syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
ef2d9b
+-
ef2d9b
+replace: olcMirrorMode
ef2d9b
+olcMirrorMode: TRUE
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server $n config ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Using ldapmodify to force conflicts between server 1 and 2..."
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: description
ef2d9b
+description: Amazing
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP2 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: description
ef2d9b
+description: Stupendous
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+delete: description
ef2d9b
+description: Outstanding
ef2d9b
+-
ef2d9b
+add: description
ef2d9b
+description: Mindboggling
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP2 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+delete: description
ef2d9b
+description: OutStanding
ef2d9b
+-
ef2d9b
+add: description
ef2d9b
+description: Bizarre
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: carLicense
ef2d9b
+carLicense: 123-XYZ
ef2d9b
+-
ef2d9b
+add: employeeNumber
ef2d9b
+employeeNumber: 32
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP2 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+add: employeeType
ef2d9b
+employeeType: deadwood
ef2d9b
+-
ef2d9b
+add: employeeNumber
ef2d9b
+employeeNumber: 64
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 2 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+$LDAPMODIFY -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -D "$MANAGERDN" -H $SURIP1 -w $PASSWD \
ef2d9b
+	>> $TESTOUT 2>&1 << EOF
ef2d9b
+dn: $THEDN
ef2d9b
+changetype: modify
ef2d9b
+replace: sn
ef2d9b
+sn: Replaced later
ef2d9b
+-
ef2d9b
+replace: sn
ef2d9b
+sn: Surname
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server 1 database ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+
ef2d9b
+echo "Restoring replication between server 1 and 2..."
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+o=`expr 3 - $n`
ef2d9b
+MYURI=`eval echo '$SURIP'$n`
ef2d9b
+PROVIDERURI=`eval echo '$SURIP'$o`
ef2d9b
+$LDAPMODIFY -D cn=config -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -H $MYURI -y $CONFIGPWF > $TESTOUT 2>&1 <
ef2d9b
+dn: olcDatabase={2}$BACKEND,cn=config
ef2d9b
+changetype: modify
ef2d9b
+replace: olcSyncRepl
ef2d9b
+olcSyncRepl: rid=001 provider=$PROVIDERURI binddn="$MANAGERDN" bindmethod=simple
ef2d9b
+  credentials=$PASSWD searchbase="$BASEDN" $SYNCTYPE
ef2d9b
+  retry="3 +" timeout=3 logbase="cn=log"
ef2d9b
+  logfilter="(&(objectclass=auditWriteObject)(reqresult=0))"
ef2d9b
+  syncdata=accesslog tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt
ef2d9b
+-
ef2d9b
+replace: olcMirrorMode
ef2d9b
+olcMirrorMode: TRUE
ef2d9b
+
ef2d9b
+EOF
ef2d9b
+RC=$?
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapmodify failed for server $n config ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+echo "Waiting $SLEEP1 seconds for syncrepl to receive changes..."
ef2d9b
+sleep $SLEEP1
ef2d9b
+
ef2d9b
+n=1
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+PORT=`expr $BASEPORT + $n`
ef2d9b
+URI="ldaps://${LOCALIP}:$PORT/"
ef2d9b
+
ef2d9b
+echo "Using ldapsearch to read all the entries from server $n..."
ef2d9b
+$LDAPSEARCH -o tls_cacert=$TESTDIR/tls/ca/certs/testsuiteCA.crt -S "" -b "$BASEDN" -D "$MANAGERDN" -H $URI -w $PASSWD  \
ef2d9b
+	'objectclass=*' > $TESTDIR/server$n.out 2>&1
ef2d9b
+RC=$?
ef2d9b
+
ef2d9b
+if test $RC != 0 ; then
ef2d9b
+	echo "ldapsearch failed at server $n ($RC)!"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit $RC
ef2d9b
+fi
ef2d9b
+$LDIFFILTER -s a < $TESTDIR/server$n.out > $TESTDIR/server$n.flt
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+n=2
ef2d9b
+while [ $n -le $MMR ]; do
ef2d9b
+echo "Comparing retrieved entries from server 1 and server $n..."
ef2d9b
+$CMP $MASTERFLT $TESTDIR/server$n.flt > $CMPOUT
ef2d9b
+
ef2d9b
+if test $? != 0 ; then
ef2d9b
+	echo "test failed - server 1 and server $n databases differ"
ef2d9b
+	test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+	exit 1
ef2d9b
+fi
ef2d9b
+n=`expr $n + 1`
ef2d9b
+done
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && kill -HUP $KILLPIDS
ef2d9b
+
ef2d9b
+echo ">>>>> Test succeeded"
ef2d9b
+
ef2d9b
+test $KILLSERVERS != no && wait
ef2d9b
+
ef2d9b
+exit 0
ef2d9b
-- 
ef2d9b
2.26.2
ef2d9b