]> git.eshelyaron.com Git - emacs.git/commitdiff
EUDC: Add LDAP tests
authorThomas Fitzsimmons <fitzsim@fitzsim.org>
Sat, 19 Nov 2022 07:05:36 +0000 (02:05 -0500)
committerThomas Fitzsimmons <fitzsim@fitzsim.org>
Sat, 19 Nov 2022 07:05:36 +0000 (02:05 -0500)
* test/lisp/net/eudc-resources/slapd.conf: New file.
* test/lisp/net/eudc-resources/dc=gnu,dc=org.ldif: Likewise.
* test/lisp/net/eudc-resources/dc=gnu,dc=org: New files.
* test/lisp/net/eudc-tests.el (eudcb-ldap): New test.

test/lisp/net/eudc-resources/dc=gnu,dc=org.ldif [new file with mode: 0644]
test/lisp/net/eudc-resources/dc=gnu,dc=org/cn=emacs-ert-test-1.ldif [new file with mode: 0644]
test/lisp/net/eudc-resources/dc=gnu,dc=org/cn=emacs-ert-test-2.ldif [new file with mode: 0644]
test/lisp/net/eudc-resources/slapd.conf [new file with mode: 0644]
test/lisp/net/eudc-tests.el

diff --git a/test/lisp/net/eudc-resources/dc=gnu,dc=org.ldif b/test/lisp/net/eudc-resources/dc=gnu,dc=org.ldif
new file mode 100644 (file)
index 0000000..9db4be2
--- /dev/null
@@ -0,0 +1,15 @@
+# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
+# CRC32 12f0e8c3
+dn: dc=gnu
+objectClass: dcObject
+objectClass: organization
+dc: gnu
+o: The ldap.gnu.org organization
+description: An organization for the following person
+structuralObjectClass: organization
+entryUUID: 43dd74ec-fc0d-103c-8d5c-7dbac5615d14
+creatorsName:
+createTimestamp: 20221119042038Z
+entryCSN: 20221119042038.100000Z#000000#000#000000
+modifiersName:
+modifyTimestamp: 20221119042038Z
diff --git a/test/lisp/net/eudc-resources/dc=gnu,dc=org/cn=emacs-ert-test-1.ldif b/test/lisp/net/eudc-resources/dc=gnu,dc=org/cn=emacs-ert-test-1.ldif
new file mode 100644 (file)
index 0000000..7828f17
--- /dev/null
@@ -0,0 +1,17 @@
+# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
+# CRC32 a33c0168
+dn: cn=emacs-ert-test-1
+objectClass: OpenLDAPperson
+cn: emacs-ert-test-1
+description:: RW1hY3Mg
+uid: 1
+sn: ERT1
+givenName: Emacs
+mail: emacs-ert-test-1@ldap.gnu.org
+structuralObjectClass: OpenLDAPperson
+entryUUID: 43dd805e-fc0d-103c-8d5d-7dbac5615d14
+creatorsName:
+createTimestamp: 20221119042038Z
+entryCSN: 20221119042038.100350Z#000000#000#000000
+modifiersName:
+modifyTimestamp: 20221119042038Z
diff --git a/test/lisp/net/eudc-resources/dc=gnu,dc=org/cn=emacs-ert-test-2.ldif b/test/lisp/net/eudc-resources/dc=gnu,dc=org/cn=emacs-ert-test-2.ldif
new file mode 100644 (file)
index 0000000..d3de3d8
--- /dev/null
@@ -0,0 +1,17 @@
+# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
+# CRC32 56119237
+dn: cn=emacs-ert-test-2
+objectClass: OpenLDAPperson
+cn: emacs-ert-test-2
+description:: RW1hY3Mg
+uid: 2
+sn: ERT2
+givenName: Emacs
+mail: emacs-ert-test-2@ldap.gnu.org
+structuralObjectClass: OpenLDAPperson
+entryUUID: 43dd92b0-fc0d-103c-8d5e-7dbac5615d14
+creatorsName:
+createTimestamp: 20221119042038Z
+entryCSN: 20221119042038.100819Z#000000#000#000000
+modifiersName:
+modifyTimestamp: 20221119042038Z
diff --git a/test/lisp/net/eudc-resources/slapd.conf b/test/lisp/net/eudc-resources/slapd.conf
new file mode 100644 (file)
index 0000000..9afafe7
--- /dev/null
@@ -0,0 +1,7 @@
+include /etc/ldap/schema/core.schema
+include /etc/ldap/schema/cosine.schema
+include /etc/ldap/schema/inetorgperson.schema
+include /etc/ldap/schema/openldap.schema
+database ldif
+directory eudc-resources
+suffix "dc=gnu,dc=org"
index c326dcc793f5fbd9c89961559acb2943d96acaac..59dce55b820c66d2ff22c5cfa1afb70c78401933 100644 (file)
                      '(((email . "Lars Ingebrigtsen <larsi@mail-abbrev.com>, \
 Karl Fogel <kfogel@mail-abbrev.com")))))))))
 
+(require 'ldap)
+(ert-deftest eudcb-ldap ()
+  "Test the LDAP back-end."
+  (when (and (file-exists-p "/usr/sbin/slapd")
+             (file-exists-p "/usr/bin/ldapsearch"))
+    (cd (concat (ert-resource-directory) ".."))
+    (let ((ldap-process
+           (start-process "slapd" "*slapd*" "/usr/sbin/slapd"
+                          "-h" "ldap://127.0.0.1:3899" "-d" "0" "-4"
+                          "-f" (ert-resource-file "slapd.conf")))
+          (ldap-host-parameters-alist '(("ldap://localhost:3899"
+                                         base "dc=gnu,dc=org" auth simple)))
+          (eudc-server-hotlist '(("ldap://localhost:3899" . ldap)))
+          (eudc-ignore-options-file t))
+      (sleep-for 1) ; Wait for slapd to start.
+      (should (equal (with-temp-buffer
+                       (insert "emacs-ert-test-1")
+                       (eudc-expand-try-all)
+                       (buffer-string))
+                     "Emacs ERT1 <emacs-ert-test-1@ldap.gnu.org>"))
+      (kill-process ldap-process))))
+
 (provide 'eudc-tests)
 ;;; eudc-tests.el ends here