Author: brane
Date: Sun Feb 25 13:22:55 2018
New Revision: 1825302

URL: http://svn.apache.org/viewvc?rev=1825302&view=rev
Log:
Return a better error message when connecting to an URL on a server
that does not implement the DAV protocol.

* subversion/libsvn_ra_serf/options.c
  (options_context_t): New member received_dav_header.
  (capabilities_headers_iterator_callback):
   Set it if the HTTP response contains the DAV: header.
  (options_response_handler):
   Bail out early with a specific message if the server doesn't support DAV.

* subversion/tests/cmdline/dav_tests.py: New test fixture.
* subversion/tests/cmdline/svntest/main.py
  (other_dav_root_dir, non_dav_root_dir): New global variable.
  (execute_tests): Initialize other_dav_root_dir and non_dav_root_dir.
* subversion/tests/cmdline/svntest/actions.py
  (setup_pristine_greek_repository):
   Create the directories for other_dav_root_dir and non_dav_root_dir.

* subversion/tests/cmdline/davautocheck.sh:
   Load mod_dav_fs and configure httpd for dav_tests.py.

Added:
    subversion/trunk/subversion/tests/cmdline/dav_tests.py   (with props)
Modified:
    subversion/trunk/subversion/libsvn_ra_serf/options.c
    subversion/trunk/subversion/tests/cmdline/davautocheck.sh
    subversion/trunk/subversion/tests/cmdline/svntest/actions.py
    subversion/trunk/subversion/tests/cmdline/svntest/main.py

Modified: subversion/trunk/subversion/libsvn_ra_serf/options.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/options.c?rev=1825302&r1=1825301&r2=1825302&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/options.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/options.c Sun Feb 25 13:22:55 
2018
@@ -71,6 +71,9 @@ typedef struct options_context_t {
   svn_ra_serf__response_handler_t inner_handler;
   void *inner_baton;
 
+  /* Have we received any DAV headers at all? */
+  svn_boolean_t received_dav_header;
+
   const char *activity_collection;
   svn_revnum_t youngest_rev;
 
@@ -165,6 +168,8 @@ capabilities_headers_iterator_callback(v
       apr_array_header_t *vals = svn_cstring_split(val, ",", TRUE,
                                                    opt_ctx->pool);
 
+      opt_ctx->received_dav_header = TRUE;
+
       /* Right now we only have a few capabilities to detect, so just
          seek for them directly.  This could be written slightly more
          efficiently, but that wouldn't be worth it until we have many
@@ -396,6 +401,19 @@ options_response_handler(serf_request_t
       serf_bucket_headers_do(hdrs, capabilities_headers_iterator_callback,
                              opt_ctx);
 
+      /* Bail out early if we're not talking to a DAV server.
+         Note that this check is only valid if we've received a success
+         response; redirects and errors don't count. */
+      if (opt_ctx->handler->sline.code >= 200
+          && opt_ctx->handler->sline.code < 300
+          && !opt_ctx->received_dav_header)
+        {
+          return svn_error_createf
+            (SVN_ERR_RA_DAV_OPTIONS_REQ_FAILED, NULL,
+             _("The server at '%s' does not support the HTTP/DAV protocol"),
+             session->session_url_str);
+        }
+
       /* Assume mergeinfo capability unsupported, if didn't receive information
          about server or repository mergeinfo capability. */
       if (!svn_hash_gets(session->capabilities, SVN_RA_CAPABILITY_MERGEINFO))

Added: subversion/trunk/subversion/tests/cmdline/dav_tests.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/dav_tests.py?rev=1825302&view=auto
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/dav_tests.py (added)
+++ subversion/trunk/subversion/tests/cmdline/dav_tests.py Sun Feb 25 13:22:55 
2018
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+#
+#  dav_tests.py:  testing connections to HTTP and DAV servers.
+#
+#  Subversion is a tool for revision control.
+#  See http://subversion.apache.org for more information.
+#
+# ====================================================================
+#    Licensed to the Apache Software Foundation (ASF) under one
+#    or more contributor license agreements.  See the NOTICE file
+#    distributed with this work for additional information
+#    regarding copyright ownership.  The ASF licenses this file
+#    to you under the Apache License, Version 2.0 (the
+#    "License"); you may not use this file except in compliance
+#    with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing,
+#    software distributed under the License is distributed on an
+#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#    KIND, either express or implied.  See the License for the
+#    specific language governing permissions and limitations
+#    under the License.
+######################################################################
+
+# General modules
+import os, re
+
+# Our testing module
+import svntest
+
+# (abbreviation)
+Skip = svntest.testcase.Skip_deco
+SkipUnless = svntest.testcase.SkipUnless_deco
+XFail = svntest.testcase.XFail_deco
+Issues = svntest.testcase.Issues_deco
+Issue = svntest.testcase.Issue_deco
+Wimp = svntest.testcase.Wimp_deco
+Item = svntest.wc.StateItem
+
+
+######################################################################
+# Tests
+#
+#   Each test must return on success or raise on failure.
+
+
+#----------------------------------------------------------------------
+
+@SkipUnless(svntest.main.is_ra_type_dav)
+def connect_plain_http_server(sbox):
+  "connect to a non-DAV HTTP server"
+  expected_errors = svntest.verify.RegexListOutput([
+    "^svn: E170013: Unable to connect to a repository at URL '[^']+'",
+    "^svn: E175003: The server at '[^']+' does not support the HTTP/DAV 
protocol"
+  ], False)
+  svntest.actions.run_and_verify_svn([], expected_errors,
+                                     'info', svntest.main.non_dav_root_url)
+
+@SkipUnless(svntest.main.is_ra_type_dav)
+def connect_other_dav_server(sbox):
+  "connect to a DAV server which is not an SVN server"
+  svntest.actions.run_and_verify_svn([], svntest.verify.AnyOutput,
+                                     'info', svntest.main.other_dav_root_url)
+
+########################################################################
+# Run the tests
+
+
+# list all tests here, starting with None:
+test_list = [ None,
+              connect_plain_http_server,
+              connect_other_dav_server,
+             ]
+
+if __name__ == '__main__':
+  svntest.main.run_tests(test_list)
+  # NOTREACHED
+
+
+### End of file.

Propchange: subversion/trunk/subversion/tests/cmdline/dav_tests.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: subversion/trunk/subversion/tests/cmdline/dav_tests.py
------------------------------------------------------------------------------
    svn:executable = *

Modified: subversion/trunk/subversion/tests/cmdline/davautocheck.sh
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/davautocheck.sh?rev=1825302&r1=1825301&r2=1825302&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/davautocheck.sh (original)
+++ subversion/trunk/subversion/tests/cmdline/davautocheck.sh Sun Feb 25 
13:22:55 2018
@@ -274,6 +274,9 @@ say "Using '$HTPASSWD'..."
 LOAD_MOD_DAV=$(get_loadmodule_config mod_dav) \
   || fail "DAV module not found"
 
+LOAD_MOD_DAV_FS=$(get_loadmodule_config mod_dav_fs) \
+  || fail "Filesystem DAV module not found"
+
 LOAD_MOD_LOG_CONFIG=$(get_loadmodule_config mod_log_config) \
   || fail "log_config module not found"
 
@@ -440,6 +443,7 @@ $LOAD_MOD_MIME
 $LOAD_MOD_ALIAS
 $LOAD_MOD_UNIXD
 $LOAD_MOD_DAV
+$LOAD_MOD_DAV_FS
 LoadModule          dav_svn_module "$MOD_DAV_SVN"
 $LOAD_MOD_AUTH
 $LOAD_MOD_AUTHN_CORE
@@ -475,6 +479,13 @@ mkdir "$HTTPD_LOCK" \
 __EOF__
 fi
 
+HTTPD_DAV="$HTTPD_ROOT/dav"
+mkdir "$HTTPD_DAV" \
+    || fail "couldn't create DAV lock directory '$HTTPD_DAV'"
+cat >> "$HTTPD_CFG" <<__EOF__
+DavLockDB "$HTTPD_DAV/lock.db"
+__EOF__
+
 if [ ${USE_SSL:+set} ]; then
 cat >> "$HTTPD_CFG" <<__EOF__
 SSLEngine on
@@ -518,6 +529,15 @@ CustomLog           "$HTTPD_ROOT/ops" "%
   #Require           all granted
 </Directory>
 
+Alias /nodavroot $ABS_BUILDDIR/subversion/tests/cmdline/svn-test-work/nodavroot
+<Directory $ABS_BUILDDIR/subversion/tests/cmdline/svn-test-work/nodavroot>
+</Directory>
+
+Alias /fsdavroot $ABS_BUILDDIR/subversion/tests/cmdline/svn-test-work/fsdavroot
+<Directory $ABS_BUILDDIR/subversion/tests/cmdline/svn-test-work/fsdavroot>
+  DAV filesystem
+</Directory>
+
 <Location /svn-test-work/repositories>
   DAV               svn
   SVNParentPath     
"$ABS_BUILDDIR/subversion/tests/cmdline/svn-test-work/repositories"

Modified: subversion/trunk/subversion/tests/cmdline/svntest/actions.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/actions.py?rev=1825302&r1=1825301&r2=1825302&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/actions.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/actions.py Sun Feb 25 
13:22:55 2018
@@ -74,6 +74,11 @@ def setup_pristine_greek_repository():
   if not os.path.exists(main.general_repo_dir):
     os.makedirs(main.general_repo_dir) # this also creates all the 
intermediate dirs
 
+  if not os.path.exists(main.other_dav_root_dir):
+    os.makedirs(main.other_dav_root_dir)
+  if not os.path.exists(main.non_dav_root_dir):
+    os.makedirs(main.non_dav_root_dir)
+
   # If there's no pristine repos, create one.
   if not os.path.exists(main.pristine_greek_repos_dir):
     if main.options.fsfs_version is not None:

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1825302&r1=1825301&r2=1825302&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Sun Feb 25 
13:22:55 2018
@@ -224,6 +224,10 @@ SVN_PROP_INHERITABLE_IGNORES = "svn:glob
 general_repo_dir = os.path.join(work_dir, "repositories")
 general_wc_dir = os.path.join(work_dir, "working_copies")
 
+# Directories used for DAV tests
+other_dav_root_dir = os.path.join(work_dir, "fsdavroot")
+non_dav_root_dir = os.path.join(work_dir, "nodavroot")
+
 # temp directory in which we will create our 'pristine' local
 # repository and other scratch data.  This should be removed when we
 # quit and when we startup.
@@ -2336,6 +2340,8 @@ def execute_tests(test_list, serial_only
 
   global pristine_url
   global pristine_greek_repos_url
+  global other_dav_root_url
+  global non_dav_root_url
   global svn_binary
   global svnadmin_binary
   global svnlook_binary
@@ -2415,6 +2421,10 @@ def execute_tests(test_list, serial_only
                                   pristine_greek_repos_dir.replace(
                                       os.path.sep, '/'))
 
+  other_dav_root_url = options.test_area_url + '/fsdavroot'
+  non_dav_root_url = options.test_area_url + '/nodavroot'
+
+
   if options.use_jsvn:
     if options.svn_bin is None:
       options.svn_bin = ''


Reply via email to