Add tests for apache, output tests/httpd.conf
authorDan Winship <danw@src.gnome.org>
Fri, 9 Jun 2006 16:28:13 +0000 (16:28 +0000)
committerDan Winship <danw@src.gnome.org>
Fri, 9 Jun 2006 16:28:13 +0000 (16:28 +0000)
* configure.in: Add tests for apache, output tests/httpd.conf

* tests/htdigest:
* tests/htpasswd:
* tests/httpd.conf.in: Apache 2.2 config files for auth-test

* tests/apache-wrapper.c (apache_init, apache_cleanup): functions
to start/stop apache

* tests/auth-test.c: Use apache-wrapper functions to start a local
apache process to test authentication against, since the auth-test
tree at developer.ximian.com went missing a long time ago. #311825

* tests/Makefile.am (auth_test_SOURCES): use apache-wrapper.c
(TESTS): include auth-test if HAVE_APACHE.

* libsoup/soup-session.c (lookup_auth): Fix this in the case of a
URI pointing to a directory rather than a file.

ChangeLog
configure.in
libsoup/soup-session.c
tests/.cvsignore
tests/Makefile.am
tests/apache-wrapper.c [new file with mode: 0644]
tests/apache-wrapper.h [new file with mode: 0644]
tests/auth-test.c
tests/htdigest [new file with mode: 0644]
tests/htpasswd [new file with mode: 0644]
tests/httpd.conf.in [new file with mode: 0644]

index 4a63620..ca43f54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2006-06-09  Dan Winship  <danw@novell.com>
+
+       * configure.in: Add tests for apache, output tests/httpd.conf
+
+       * tests/htdigest: 
+       * tests/htpasswd: 
+       * tests/httpd.conf.in: Apache 2.2 config files for auth-test
+
+       * tests/apache-wrapper.c (apache_init, apache_cleanup): functions
+       to start/stop apache
+
+       * tests/auth-test.c: Use apache-wrapper functions to start a local
+       apache process to test authentication against, since the auth-test
+       tree at developer.ximian.com went missing a long time ago. #311825
+
+       * tests/Makefile.am (auth_test_SOURCES): use apache-wrapper.c
+       (TESTS): include auth-test if HAVE_APACHE.
+
+       * libsoup/soup-session.c (lookup_auth): Fix this in the case of a
+       URI pointing to a directory rather than a file.
+
 2006-06-08  Dan Winship  <danw@novell.com>
 
        * libsoup/soup-xmlrpc-response.c (soup_xmlrpc_value_get_int,
 2006-06-07  Dan Winship  <danw@novell.com>
 
        * libsoup/soup-xmlrpc-response.c
-        (soup_xmlrpc_response_from_string): record whether or not the
-        response was a fault.
-        (soup_xmlrpc_response_is_fault): test that. #343973, patch from
-        Brent Smith.
+       (soup_xmlrpc_response_from_string): record whether or not the
+       response was a fault.
+       (soup_xmlrpc_response_is_fault): test that. #343973, patch from
+       Brent Smith.
 
 2006-05-29  Dan Winship  <danw@novell.com>
 
index 3ad6bf8..fce1148 100644 (file)
@@ -207,6 +207,55 @@ if test "$os_win32" != yes; then
        CFLAGS="$CFLAGS -D_REENTRANT"
 fi
 
+dnl *************************************
+dnl *** Apache (for regression tests) ***
+dnl *************************************
+
+AC_ARG_WITH(apache-httpd,
+           [  --with-apache-httpd      Path to apache httpd (for tests)],
+           APACHE_HTTPD="$withval",
+           [AC_PATH_PROGS(APACHE_HTTPD, httpd2 httpd, no, ${PATH}:/usr/sbin)])
+if test "$APACHE_HTTPD" != "no"; then
+    AC_MSG_CHECKING([Apache version])
+    apache_version=`$APACHE_HTTPD -v 2>/dev/null | sed -ne 's/Server version: Apache\///p'`
+    case $apache_version in
+    2.2.*)
+       AC_MSG_RESULT([$apache_version (ok)])
+       ;;
+    *)
+       AC_MSG_RESULT([$apache_version (ignoring)])
+       APACHE_HTTPD="no"
+       ;;
+    esac
+fi
+AC_SUBST(APACHE_HTTPD)
+AC_DEFINE_UNQUOTED(APACHE_HTTPD, "$APACHE_HTTPD", [Apache httpd])
+
+if test "$APACHE_HTTPD" != "no"; then
+    AC_MSG_CHECKING([for Apache module directory])
+    AC_ARG_WITH(apache-module-dir,
+               [  --with-apache-module-dir Apache modules dir (for tests)],
+               APACHE_MODULE_DIR="$withval",
+               [apache_prefix=`dirname \`dirname $APACHE_HTTPD\``
+               # This only works with bash, but should fail harmlessly in sh
+               for dir in $apache_prefix/lib{64,}/{apache,http}{2,}{/modules,}; do
+                   if test -f $dir/mod_auth_digest.so; then
+                       APACHE_MODULE_DIR="$dir"
+                       break
+                   fi
+               done])
+    AC_MSG_RESULT($APACHE_MODULE_DIR)
+    AC_SUBST(APACHE_MODULE_DIR)
+fi
+
+if test "$APACHE_HTTPD" != "no" -a -n "$APACHE_MODULE_DIR"; then
+    AC_DEFINE(HAVE_APACHE, 1, [Whether or not apache can be used for tests])
+    have_apache=1
+else
+    have_apache=0
+fi
+AM_CONDITIONAL(HAVE_APACHE, test $have_apache = 1)
+
 dnl *************************
 dnl *** Output Everything ***
 dnl *************************
@@ -217,6 +266,7 @@ AC_OUTPUT([
        libsoup-zip
        libsoup/Makefile
        tests/Makefile
+       tests/httpd.conf
        docs/Makefile
        docs/reference/Makefile
        ])
index 480e618..6900701 100644 (file)
@@ -670,8 +670,12 @@ lookup_auth (SoupSession *session, SoupMessage *msg, gboolean proxy)
                        break;
 
                 dir = strrchr (path, '/');
-                if (dir)
-                       *dir = '\0';
+                if (dir) {
+                       if (dir[1])
+                               dir[1] = '\0';
+                       else
+                               *dir = '\0';
+               }
         } while (dir);
 
        g_free (path);
index 4aa8516..35b83c6 100644 (file)
@@ -6,6 +6,8 @@ dict
 dns
 get
 getbug
+httpd.conf
+httpd.pid
 revserver
 simple-httpd
 simple-proxy
index 331ff4f..f09015a 100644 (file)
@@ -17,7 +17,7 @@ noinst_PROGRAMS =     \
        simple-proxy    \
        uri-parsing
 
-auth_test_SOURCES = auth-test.c
+auth_test_SOURCES = auth-test.c apache-wrapper.c
 date_SOURCES = date.c
 dict_SOURCES = dict.c
 dns_SOURCES = dns.c
@@ -28,4 +28,16 @@ simple_httpd_SOURCES = simple-httpd.c
 simple_proxy_SOURCES = simple-proxy.c
 uri_parsing_SOURCES = uri-parsing.c
 
-EXTRA_DIST = libsoup.supp test-cert.pem test-key.pem
+if HAVE_APACHE
+APACHE_TESTS = auth-test
+endif
+
+TESTS = date uri-parsing $(APACHE_TESTS)
+
+EXTRA_DIST =           \
+       libsoup.supp    \
+       test-cert.pem   \
+       test-key.pem    \
+       htdigest        \
+       htpasswd        \
+       httpd.conf.in
diff --git a/tests/apache-wrapper.c b/tests/apache-wrapper.c
new file mode 100644 (file)
index 0000000..2f5cd8c
--- /dev/null
@@ -0,0 +1,52 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_APACHE
+
+#include "apache-wrapper.h"
+
+static gboolean
+apache_cmd (char *cmd)
+{
+       char *argv[8];
+       char *cwd, *conf;
+       int status;
+       gboolean ok;
+
+       cwd = g_get_current_dir ();
+       conf = g_build_filename (cwd, "httpd.conf", NULL);
+
+       argv[0] = APACHE_HTTPD;
+       argv[1] = "-d";
+       argv[2] = cwd;
+       argv[3] = "-f";
+       argv[4] = conf;
+       argv[5] = "-k";
+       argv[6] = cmd;
+       argv[7] = NULL;
+
+       ok = g_spawn_sync (cwd, argv, NULL, 0, NULL, NULL,
+                          NULL, NULL, &status, NULL);
+       if (ok)
+               ok = (status == 0);
+
+       g_free (cwd);
+       g_free (conf);
+
+       return ok;
+}
+
+gboolean
+apache_init (void)
+{
+       return apache_cmd ("start");
+}
+
+void
+apache_cleanup (void)
+{
+       apache_cmd ("stop");
+}
+
+#endif /* HAVE_APACHE */
diff --git a/tests/apache-wrapper.h b/tests/apache-wrapper.h
new file mode 100644 (file)
index 0000000..58302a9
--- /dev/null
@@ -0,0 +1,4 @@
+#include <glib.h>
+
+gboolean apache_init    (void);
+void     apache_cleanup (void);
index 65d7cb4..b586408 100644 (file)
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -6,6 +10,10 @@
 #include "libsoup/soup-auth.h"
 #include "libsoup/soup-session.h"
 
+#ifdef HAVE_APACHE
+#include "apache-wrapper.h"
+#endif
+
 int errors = 0;
 
 typedef struct {
@@ -37,151 +45,112 @@ typedef struct {
 
 SoupAuthTest tests[] = {
        { "No auth available, should fail",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/index.txt",
-         "", "0", SOUP_STATUS_UNAUTHORIZED },
+         "Basic/realm1/", "", "0", SOUP_STATUS_UNAUTHORIZED },
 
        { "Should fail with no auth, fail again with bad password, and give up",
-         "http://developer.ximian.com/test/soup-test/Basic/realm2/index.txt",
-         "4", "04", SOUP_STATUS_UNAUTHORIZED },
+         "Basic/realm2/", "4", "04", SOUP_STATUS_UNAUTHORIZED },
 
        { "Known realm, auth provided, so should succeed immediately",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/index.txt",
-         "1", "1", SOUP_STATUS_OK },
+         "Basic/realm1/", "1", "1", SOUP_STATUS_OK },
 
        { "Now should automatically reuse previous auth",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Basic/realm1/", "", "1", SOUP_STATUS_OK },
 
        { "Subdir should also automatically reuse auth",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/subdir/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Basic/realm1/subdir/", "", "1", SOUP_STATUS_OK },
 
        { "Subdir should retry last auth, but will fail this time",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/realm2/index.txt",
-         "", "1", SOUP_STATUS_UNAUTHORIZED },
+         "Basic/realm1/realm2/", "", "1", SOUP_STATUS_UNAUTHORIZED },
 
        { "Now should use provided auth on first try",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/realm2/index.txt",
-         "2", "2", SOUP_STATUS_OK },
+         "Basic/realm1/realm2/", "2", "2", SOUP_STATUS_OK },
 
        { "Reusing last auth. Should succeed on first try",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Basic/realm1/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Reuse will fail, but 2nd try will succeed because it's a known realm",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/realm2/realm1/index.txt",
-         "", "21", SOUP_STATUS_OK },
+         "Basic/realm1/realm2/realm1/", "", "21", SOUP_STATUS_OK },
 
        { "Should succeed on first try. (Known realm with cached password)",
-         "http://developer.ximian.com/test/soup-test/Basic/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Basic/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Fail once, then use typoed password, then use right password",
-         "http://developer.ximian.com/test/soup-test/Basic/realm3/index.txt",
-         "43", "043", SOUP_STATUS_OK },
+         "Basic/realm3/", "43", "043", SOUP_STATUS_OK },
 
 
        { "No auth available, should fail",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/index.txt",
-         "", "0", SOUP_STATUS_UNAUTHORIZED },
+         "Digest/realm1/", "", "0", SOUP_STATUS_UNAUTHORIZED },
 
        { "Should fail with no auth, fail again with bad password, and give up",
-         "http://developer.ximian.com/test/soup-test/Digest/realm2/index.txt",
-         "4", "04", SOUP_STATUS_UNAUTHORIZED },
+         "Digest/realm2/", "4", "04", SOUP_STATUS_UNAUTHORIZED },
 
        { "Known realm, auth provided, so should succeed immediately",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/index.txt",
-         "1", "1", SOUP_STATUS_OK },
+         "Digest/realm1/", "1", "1", SOUP_STATUS_OK },
 
        { "Now should automatically reuse previous auth",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Digest/realm1/", "", "1", SOUP_STATUS_OK },
 
        { "Subdir should also automatically reuse auth",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/subdir/index.txt",
-         "", "1", SOUP_STATUS_OK },
-
-       { "Subdir should retry last auth, but will fail this time",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/realm2/index.txt",
-         "", "1", SOUP_STATUS_UNAUTHORIZED },
+         "Digest/realm1/subdir/", "", "1", SOUP_STATUS_OK },
 
-       { "Now should use provided auth on first try",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/realm2/index.txt",
-         "2", "2", SOUP_STATUS_OK },
+       { "Should already know correct domain and use provided auth on first try",
+         "Digest/realm1/realm2/", "2", "2", SOUP_STATUS_OK },
 
        { "Reusing last auth. Should succeed on first try",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Digest/realm1/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Should succeed on first try because of earlier domain directive",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/realm2/realm1/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Digest/realm1/realm2/realm1/", "", "1", SOUP_STATUS_OK },
 
        { "Should succeed on first try. (Known realm with cached password)",
-         "http://developer.ximian.com/test/soup-test/Digest/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Digest/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Fail once, then use typoed password, then use right password",
-         "http://developer.ximian.com/test/soup-test/Digest/realm3/index.txt",
-         "43", "043", SOUP_STATUS_OK },
+         "Digest/realm3/", "43", "043", SOUP_STATUS_OK },
 
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Basic/realm1/", "", "1", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Basic/realm1/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/realm2/realm1/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Basic/realm1/realm2/realm1/", "", "1", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Basic/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Basic/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Basic/realm3/index.txt",
-         "", "3", SOUP_STATUS_OK },
+         "Basic/realm3/", "", "3", SOUP_STATUS_OK },
 
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Digest/realm1/", "", "1", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Digest/realm1/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/realm2/realm1/index.txt",
-         "", "1", SOUP_STATUS_OK },
+         "Digest/realm1/realm2/realm1/", "", "1", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Digest/realm2/index.txt",
-         "", "2", SOUP_STATUS_OK },
+         "Digest/realm2/", "", "2", SOUP_STATUS_OK },
 
        { "Make sure we haven't forgotten anything",
-         "http://developer.ximian.com/test/soup-test/Digest/realm3/index.txt",
-         "", "3", SOUP_STATUS_OK },
+         "Digest/realm3/", "", "3", SOUP_STATUS_OK },
 
        { "Now the server will reject the formerly-good password",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/not/index.txt",
-         "1" /* should not be used */, "1", SOUP_STATUS_UNAUTHORIZED },
+         "Basic/realm1/not/", "1" /* should not be used */, "1", SOUP_STATUS_UNAUTHORIZED },
 
        { "Make sure we've forgotten it",
-         "http://developer.ximian.com/test/soup-test/Basic/realm1/index.txt",
-         "", "0", SOUP_STATUS_UNAUTHORIZED },
+         "Basic/realm1/", "", "0", SOUP_STATUS_UNAUTHORIZED },
 
        { "Likewise, reject the formerly-good Digest password",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/not/index.txt",
-         "1" /* should not be used */, "1", SOUP_STATUS_UNAUTHORIZED },
+         "Digest/realm1/not/", "1" /* should not be used */, "1", SOUP_STATUS_UNAUTHORIZED },
 
        { "Make sure we've forgotten it",
-         "http://developer.ximian.com/test/soup-test/Digest/realm1/index.txt",
-         "", "0", SOUP_STATUS_UNAUTHORIZED }
+         "Digest/realm1/", "", "0", SOUP_STATUS_UNAUTHORIZED }
 };
 int ntests = sizeof (tests) / sizeof (tests[0]);
 
@@ -279,12 +248,36 @@ main (int argc, char **argv)
 {
        SoupSession *session;
        SoupMessage *msg;
-       char *expected;
+       char *base_uri, *uri, *expected;
+#ifdef HAVE_APACHE
+       gboolean using_apache = FALSE;
+#endif
        int i;
 
        g_type_init ();
        g_thread_init (NULL);
 
+       if (argc != 1) {
+               char *p;
+
+               base_uri = argv[0];
+               p = strrchr (base_uri, '/');
+               if (!p || p[1])
+                       base_uri = g_strdup_printf ("%s/", base_uri);
+       } else {
+#ifdef HAVE_APACHE
+               if (!apache_init ()) {
+                       fprintf (stderr, "Could not start apache\n");
+                       return 1;
+               }
+               base_uri = "http://localhost:47524/";
+               using_apache = TRUE;
+#else
+               fprintf (stderr, "Must specify base_uri for tests if configured --without-apache\n");
+               return 1;
+#endif
+       }
+
        session = soup_session_async_new ();
        g_signal_connect (session, "authenticate",
                          G_CALLBACK (authenticate), &i);
@@ -294,9 +287,11 @@ main (int argc, char **argv)
        for (i = 0; i < ntests; i++) {
                printf ("Test %d: %s\n", i + 1, tests[i].explanation);
 
-               printf ("  GET %s\n", tests[i].url);
+               uri = g_strconcat (base_uri, tests[i].url, NULL);
+               printf ("  GET %s\n", uri);
 
-               msg = soup_message_new (SOUP_METHOD_GET, tests[i].url);
+               msg = soup_message_new (SOUP_METHOD_GET, uri);
+               g_free (uri);
                if (!msg) {
                        fprintf (stderr, "auth-test: Could not parse URI\n");
                        exit (1);
@@ -318,7 +313,7 @@ main (int argc, char **argv)
                }
                if (*expected) {
                        printf ("  expected %d more round(s)\n",
-                               strlen (expected));
+                               (int)strlen (expected));
                        errors++;
                }
                g_free (expected);
@@ -333,6 +328,11 @@ main (int argc, char **argv)
 
        g_object_unref (session);
 
+#ifdef HAVE_APACHE
+       if (using_apache)
+               apache_cleanup ();
+#endif
+
        printf ("\nauth-test: %d errors\n", errors);
        return errors;
 }
diff --git a/tests/htdigest b/tests/htdigest
new file mode 100644 (file)
index 0000000..352520f
--- /dev/null
@@ -0,0 +1,3 @@
+user1:realm1:69cb1fa0285304a71f8975aecd027008
+user2:realm2:b67d8ee3c2e271abba78f71d12fe472e
+user3:realm3:601c319693279abbc07d332bd7637239
diff --git a/tests/htpasswd b/tests/htpasswd
new file mode 100644 (file)
index 0000000..04e9ce2
--- /dev/null
@@ -0,0 +1,3 @@
+user1:sTFk2g6n8RsWY
+user2:N.Dlbd.xU4K1w
+user3:c2vSU/3eQHy.w
diff --git a/tests/httpd.conf.in b/tests/httpd.conf.in
new file mode 100644 (file)
index 0000000..8290f4f
--- /dev/null
@@ -0,0 +1,124 @@
+# http.conf used for testing auth-test
+
+ServerName 127.0.0.1
+Listen 127.0.0.1:47524
+
+PidFile @builddir@/httpd.pid
+ErrorLog /dev/null
+
+LoadModule alias_module       @APACHE_MODULE_DIR@/mod_alias.so
+LoadModule auth_basic_module  @APACHE_MODULE_DIR@/mod_auth_basic.so
+LoadModule auth_digest_module @APACHE_MODULE_DIR@/mod_auth_digest.so
+LoadModule authn_file_module  @APACHE_MODULE_DIR@/mod_authn_file.so
+LoadModule authz_user_module  @APACHE_MODULE_DIR@/mod_authz_user.so
+LoadModule dir_module         @APACHE_MODULE_DIR@/mod_dir.so
+
+DirectoryIndex httpd.pid
+
+Alias /Basic/realm1/realm2/realm1 @srcdir@
+Alias /Basic/realm1/realm2 @srcdir@
+Alias /Basic/realm1/subdir @srcdir@
+Alias /Basic/realm1/not @srcdir@
+Alias /Basic/realm1 @srcdir@
+Alias /Basic/realm2 @srcdir@
+Alias /Basic/realm3 @srcdir@
+
+<Location /Basic/realm1>
+  AuthType Basic
+  AuthName realm1
+  AuthUserFile @srcdir@/htpasswd
+  Require user user1
+</Location>
+
+<Location /Basic/realm1/not>
+  AuthType Basic
+  AuthName realm1
+  AuthUserFile @srcdir@/htpasswd
+  Require user user2
+</Location>
+
+<Location /Basic/realm1/realm2>
+  AuthType Basic
+  AuthName realm2
+  AuthUserFile @srcdir@/htpasswd
+  Require user user2
+</Location>
+
+<Location /Basic/realm1/realm2/realm1>
+  AuthType Basic
+  AuthName realm1
+  AuthUserFile @srcdir@/htpasswd
+  Require user user1
+</Location>
+
+<Location /Basic/realm2>
+  AuthType Basic
+  AuthName realm2
+  AuthUserFile @srcdir@/htpasswd
+  Require user user2
+</Location>
+
+<Location /Basic/realm3>
+  AuthType Basic
+  AuthName realm3
+  AuthUserFile @srcdir@/htpasswd
+  Require user user3
+</Location>
+
+
+Alias /Digest/realm1/realm2/realm1 @srcdir@
+Alias /Digest/realm1/realm2 @srcdir@
+Alias /Digest/realm1/subdir @srcdir@
+Alias /Digest/realm1/not @srcdir@
+Alias /Digest/realm1 @srcdir@
+Alias /Digest/realm2 @srcdir@
+Alias /Digest/realm3 @srcdir@
+
+<Location /Digest/realm1>
+  AuthType Digest
+  AuthName realm1
+  AuthUserFile @srcdir@/htdigest
+  AuthDigestDomain /Digest/realm1 /Digest/realm1/realm2/realm1
+  Require valid-user
+</Location>
+
+<Location /Digest/realm1/not>
+  AuthType Digest
+  AuthName realm1
+  AuthUserFile @srcdir@/htdigest
+  AuthDigestDomain /Digest/realm1 /Digest/realm1/realm2/realm1
+  Require user user2
+</Location>
+
+<Location /Digest/realm1/realm2>
+  AuthType Digest
+  AuthName realm2
+  AuthUserFile @srcdir@/htdigest
+  AuthDigestDomain /Digest/realm2 /Digest/realm1/realm2
+  Require valid-user
+</Location>
+
+<Location /Digest/realm1/realm2/realm1>
+  AuthType Digest
+  AuthName realm1
+  AuthUserFile @srcdir@/htdigest
+  AuthDigestDomain /Digest/realm1 /Digest/realm1/realm2/realm1
+  Require valid-user
+</Location>
+
+<Location /Digest/realm2>
+  AuthType Digest
+  AuthName realm2
+  AuthUserFile @srcdir@/htdigest
+  AuthDigestDomain /Digest/realm2 /Digest/realm1/realm2
+  Require valid-user
+</Location>
+
+<Location /Digest/realm3>
+  AuthType Digest
+  AuthName realm3
+  AuthUserFile @srcdir@/htdigest
+  AuthDigestDomain /Digest/realm3
+  Require valid-user
+</Location>
+