diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-11 13:41:25 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-07-11 13:41:25 -0400 |
| commit | e6d1f6e4af4d6a192d1c859d6cb0db0d407c42e5 (patch) | |
| tree | 5ccb5e2b4795b7d98a59f47587d85d62b2f51136 /tests | |
| parent | 746dfbae96cde12541446743ca24e61d48291850 (diff) | |
- check that when we reference a non-existent attribute, it doesn't show up
- check that when we add a previously-not-present attribute, it shows up
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/clients/Makefile.am | 2 | ||||
| -rw-r--r-- | tests/clients/ldifsort.c | 101 | ||||
| -rw-r--r-- | tests/clients/yp.c | 22 | ||||
| -rw-r--r-- | tests/slapd.sh.in | 2 | ||||
| -rw-r--r-- | tests/test10-schema-modrdn-entry/description.txt | 2 | ||||
| -rwxr-xr-x | tests/test11-schema-modify-entry/after.sh | 2 | ||||
| -rw-r--r-- | tests/test11-schema-modify-entry/after.txt | 11 | ||||
| -rwxr-xr-x | tests/test11-schema-modify-entry/before.sh | 2 | ||||
| -rw-r--r-- | tests/test11-schema-modify-entry/before.txt | 10 | ||||
| -rwxr-xr-x | tests/test11-schema-modify-entry/change.sh | 9 | ||||
| -rw-r--r-- | tests/test11-schema-modify-entry/change.txt | 2 | ||||
| -rw-r--r-- | tests/test11-schema-modify-entry/description.txt | 1 | ||||
| -rw-r--r-- | tests/test11-schema-modify-entry/dse.ldif | 12 |
13 files changed, 176 insertions, 2 deletions
diff --git a/tests/clients/Makefile.am b/tests/clients/Makefile.am index 966ed52..69830d2 100644 --- a/tests/clients/Makefile.am +++ b/tests/clients/Makefile.am @@ -1,6 +1,6 @@ RPCGEN=@RPCGEN@ if CAN_TEST -noinst_PROGRAMS = yp +noinst_PROGRAMS = yp ldifsort yp_SOURCES = yp.c yp_clnt.c yp_LDADD = -lnsl yp_clnt.c: $(includedir)/rpcsvc/yp.x diff --git a/tests/clients/ldifsort.c b/tests/clients/ldifsort.c new file mode 100644 index 0000000..dd7f223 --- /dev/null +++ b/tests/clients/ldifsort.c @@ -0,0 +1,101 @@ +/* + * Copyright 2008 Red Hat, Inc. + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This Program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this Program; if not, write to the + * + * Free Software Foundation, Inc. + * 59 Temple Place, Suite 330 + * Boston, MA 02111-1307 USA + * + */ + +#include "../../config.h" +#include <sys/types.h> +#include <limits.h> +#include <search.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define MAX_ENTRIES 4096 + +struct ldif_entry { + char *dn; + char *entry; +}; + +static int +compare_entries(const void *a, const void *b) +{ + return strcoll(((const struct ldif_entry *) a)->dn, + ((const struct ldif_entry *) b)->dn); +} + +int +main(int argv, char **argc) +{ + char buf[LINE_MAX], *p; + struct ldif_entry entry, entries[MAX_ENTRIES]; + size_t n_entries, l; + memset(&entry, 0, sizeof(entry)); + memset(&entries, 0, sizeof(entries)); + n_entries = 0; + while (fgets(buf, sizeof(buf), stdin) != NULL) { + if (buf[0] == '#') { + continue; + } + p = strchr(buf, '\n'); + if (p != NULL) { + if ((p == buf) && (entry.dn != NULL)) { + if (n_entries < + sizeof(entries) / sizeof(entries[0])) { + lsearch(&entry, + (void *) &entries, + &n_entries, + sizeof(entry), + &compare_entries); + } + memset(&entry, 0, sizeof(entry)); + } + if (strncasecmp(buf, "dn:", 3) == 0) { + *p = '\0'; + entry.dn = strdup(buf); + entry.entry = NULL; + } else { + l = (entry.entry ? strlen(entry.entry) : 0) + + strlen(buf) + 1; + p = malloc(l); + if (p != NULL) { + if (entry.entry) { + strcpy(p, entry.entry); + strcat(p, buf); + } else { + strcpy(p, buf); + } + free(entry.entry); + entry.entry = p; + } + } + } + } + qsort((void *) &entries, n_entries, sizeof(entry), &compare_entries); + for (l = 0; l < n_entries; l++) { + puts(entries[l].dn); + if (entries[l].entry != NULL) { + puts(entries[l].entry); + } else { + puts(""); + } + } + return 0; +} diff --git a/tests/clients/yp.c b/tests/clients/yp.c index f08cb53..6620f27 100644 --- a/tests/clients/yp.c +++ b/tests/clients/yp.c @@ -1,3 +1,25 @@ +/* + * Copyright 2008 Red Hat, Inc. + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This Program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this Program; if not, write to the + * + * Free Software Foundation, Inc. + * 59 Temple Place, Suite 330 + * Boston, MA 02111-1307 USA + * + */ + +#include "../../config.h" #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> diff --git a/tests/slapd.sh.in b/tests/slapd.sh.in index c641c33..c6a59fd 100644 --- a/tests/slapd.sh.in +++ b/tests/slapd.sh.in @@ -5,6 +5,8 @@ STATEDIR=@abs_builddir@/state YP="@abs_builddir@/clients/yp -p @test_nisport@" export YP +LDIFSORT="@abs_builddir@/clients/ldifsort" +export LDIFSORT PORT=@test_ldapport@ export PORT diff --git a/tests/test10-schema-modrdn-entry/description.txt b/tests/test10-schema-modrdn-entry/description.txt index fd9ff6d..35783fa 100644 --- a/tests/test10-schema-modrdn-entry/description.txt +++ b/tests/test10-schema-modrdn-entry/description.txt @@ -1 +1 @@ -ignore after modrdn while keeping old RDN +modrdn replacing the RDN diff --git a/tests/test11-schema-modify-entry/after.sh b/tests/test11-schema-modify-entry/after.sh new file mode 100755 index 0000000..9c78326 --- /dev/null +++ b/tests/test11-schema-modify-entry/after.sh @@ -0,0 +1,2 @@ +#!/bin/sh +search -b cn=compat,cn=accounts,dc=example,dc=com dn inetUserHttpURL | $LDIFSORT diff --git a/tests/test11-schema-modify-entry/after.txt b/tests/test11-schema-modify-entry/after.txt new file mode 100644 index 0000000..d61c919 --- /dev/null +++ b/tests/test11-schema-modify-entry/after.txt @@ -0,0 +1,11 @@ +dn: cn=compat, cn=Accounts, dc=example, dc=com + +dn: ou=passwd,cn=compat, cn=Accounts, dc=example, dc=com + +dn: uid=user1a,ou=passwd,cn=compat,cn=accounts,dc=example,dc=com + +dn: uid=user1b,ou=passwd,cn=compat,cn=accounts,dc=example,dc=com +inetUserHttpURL: http://localhost/ + +dn: uid=user1c,ou=passwd,cn=compat,cn=accounts,dc=example,dc=com + diff --git a/tests/test11-schema-modify-entry/before.sh b/tests/test11-schema-modify-entry/before.sh new file mode 100755 index 0000000..9c78326 --- /dev/null +++ b/tests/test11-schema-modify-entry/before.sh @@ -0,0 +1,2 @@ +#!/bin/sh +search -b cn=compat,cn=accounts,dc=example,dc=com dn inetUserHttpURL | $LDIFSORT diff --git a/tests/test11-schema-modify-entry/before.txt b/tests/test11-schema-modify-entry/before.txt new file mode 100644 index 0000000..5685722 --- /dev/null +++ b/tests/test11-schema-modify-entry/before.txt @@ -0,0 +1,10 @@ +dn: cn=compat, cn=Accounts, dc=example, dc=com + +dn: ou=passwd,cn=compat, cn=Accounts, dc=example, dc=com + +dn: uid=user1a,ou=passwd,cn=compat,cn=accounts,dc=example,dc=com + +dn: uid=user1b,ou=passwd,cn=compat,cn=accounts,dc=example,dc=com + +dn: uid=user1c,ou=passwd,cn=compat,cn=accounts,dc=example,dc=com + diff --git a/tests/test11-schema-modify-entry/change.sh b/tests/test11-schema-modify-entry/change.sh new file mode 100755 index 0000000..219c0c4 --- /dev/null +++ b/tests/test11-schema-modify-entry/change.sh @@ -0,0 +1,9 @@ +#!/bin/sh +modify << EOF +dn: uid=user1b, cn=Users1, cn=Accounts, dc=example, dc=com +changetype: modify +add: inetUserHttpURL +inetUserHttpURL: http://localhost/ +- + +EOF diff --git a/tests/test11-schema-modify-entry/change.txt b/tests/test11-schema-modify-entry/change.txt new file mode 100644 index 0000000..8c1f597 --- /dev/null +++ b/tests/test11-schema-modify-entry/change.txt @@ -0,0 +1,2 @@ +modifying entry "uid=user1b, cn=Users1, cn=Accounts, dc=example, dc=com" + diff --git a/tests/test11-schema-modify-entry/description.txt b/tests/test11-schema-modify-entry/description.txt new file mode 100644 index 0000000..ee2bba0 --- /dev/null +++ b/tests/test11-schema-modify-entry/description.txt @@ -0,0 +1 @@ +modify to add previously-not-present attribute diff --git a/tests/test11-schema-modify-entry/dse.ldif b/tests/test11-schema-modify-entry/dse.ldif new file mode 100644 index 0000000..58afb27 --- /dev/null +++ b/tests/test11-schema-modify-entry/dse.ldif @@ -0,0 +1,12 @@ +dn: cn=compat-passwd,cn=Schema Compatibility,cn=plugins,cn=config +objectClass: top +objectClass: extensibleObject +cn: compat-passwd +schema-compat-container-group: cn=compat, cn=Accounts, dc=example, dc=com +schema-compat-container-rdn: ou=passwd +schema-compat-check-access: yes +schema-compat-search-base: cn=Users1, cn=Accounts, dc=example, dc=com +schema-compat-search-filter: (objectClass=posixAccount) +schema-compat-entry-rdn: uid=%{uid} +schema-compat-entry-attribute: inetUserHttpURL=%{inetUserHttpURL} + |
