def copy_delete_unreadable_child(sbox): "copy, then rm at-src-unreadable child" # Prepare the source: Greek tree (r1), cp+rm (r2). sbox.build("copy-delete-unreadable-child") svntest.actions.run_and_verify_svnmucc(None, None, [], '-m', 'r2', '-U', sbox.repo_url, 'cp', 'HEAD', '/', 'branch', 'rm', 'branch/A') # Create the destination. dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) # Lock down the source. authz = sbox.authz_name() write_restrictive_svnserve_conf(sbox.repo_dir, anon_access='read') svntest.main.file_write(sbox.authz_file, "[%s:/]\n" "* = r\n" "[%s:/A]\n" "* = \n" % (authz, authz)) dest_url = svntest.main.file_scheme_prefix \ + urllib.pathname2url(os.path.abspath(dest_sbox.repo_dir)) run_init(dest_url, sbox.repo_url) run_sync(dest_url) # sanity check svntest.actions.run_and_verify_svn(None, ["iota\n"], [], 'ls', dest_url+'/branch@2')
def copy_delete_unreadable_child(sbox): "copy, then rm at-src-unreadable child" # Prepare the source: Greek tree (r1), cp+rm (r2). sbox.build(create_wc = False) svntest.actions.run_and_verify_svnmucc(None, None, [], '-m', 'r2', '-U', sbox.repo_url, 'cp', 'HEAD', '/', 'branch', 'rm', 'branch/A') # Create the destination. dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) # Lock down the source. authz = sbox.authz_name() write_restrictive_svnserve_conf(sbox.repo_dir, anon_access='read') svntest.main.file_write(sbox.authz_file, "[%s:/]\n" "* = r\n" "[%s:/A]\n" "* = \n" % (authz, authz)) dest_url = svntest.main.file_scheme_prefix \ + urllib.pathname2url(os.path.abspath(dest_sbox.repo_dir)) run_init(dest_url, sbox.repo_url) run_sync(dest_url) # sanity check svntest.actions.run_and_verify_svn(None, ["iota\n"], [], 'ls', dest_url+'/branch@2')
def specific_deny_authz(sbox): "verify if specifically denied paths dont sync" sbox.build() dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) run_init(dest_sbox.repo_url, sbox.repo_url) svntest.main.run_svn(None, "cp", os.path.join(sbox.wc_dir, "A"), os.path.join(sbox.wc_dir, "A_COPY") ) svntest.main.run_svn(None, "ci", "-mm", sbox.wc_dir) write_restrictive_svnserve_conf(sbox.repo_dir) # For mod_dav_svn's parent path setup we need per-repos permissions in # the authz file... if sbox.repo_url.startswith('http'): args = tuple(s.authz_name() for s in [sbox, sbox, sbox, dest_sbox]) svntest.main.file_write(sbox.authz_file, "[%s:/]\n" "* = r\n" "\n" "[%s:/A]\n" "* = \n" "\n" "[%s:/A_COPY/B/lambda]\n" "* = \n" "\n" "[%s:/]\n" "* = rw\n" % args) # Otherwise we can just go with the permissions needed for the source # repository. else: svntest.main.file_write(sbox.authz_file, "[/]\n" "* = r\n" "\n" "[/A]\n" "* = \n" "\n" "[/A_COPY/B/lambda]\n" "* = \n") run_sync(dest_sbox.repo_url) lambda_url = dest_sbox.repo_url + '/A_COPY/B/lambda' # this file should have been blocked by authz svntest.actions.run_and_verify_svn(None, [], svntest.verify.AnyOutput, 'cat', lambda_url)
def specific_deny_authz(sbox): "verify if specifically denied paths dont sync" sbox.build("specific-deny-authz") dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) run_init(dest_sbox.repo_url, sbox.repo_url) svntest.main.run_svn(None, "cp", os.path.join(sbox.wc_dir, "A"), os.path.join(sbox.wc_dir, "A_COPY") ) svntest.main.run_svn(None, "ci", "-mm", sbox.wc_dir) write_restrictive_svnserve_conf(sbox.repo_dir) # For mod_dav_svn's parent path setup we need per-repos permissions in # the authz file... if sbox.repo_url.startswith('http'): svntest.main.file_write(sbox.authz_file, "[specific-deny-authz:/]\n" "* = r\n" "\n" "[specific-deny-authz:/A]\n" "* = \n" "\n" "[specific-deny-authz:/A_COPY/B/lambda]\n" "* = \n" "\n" "[specific-deny-authz-1:/]\n" "* = rw\n") # Otherwise we can just go with the permissions needed for the source # repository. else: svntest.main.file_write(sbox.authz_file, "[/]\n" "* = r\n" "\n" "[/A]\n" "* = \n" "\n" "[/A_COPY/B/lambda]\n" "* = \n") run_sync(dest_sbox.repo_url) lambda_url = dest_sbox.repo_url + '/A_COPY/B/lambda' # this file should have been blocked by authz svntest.actions.run_and_verify_svn(None, [], svntest.verify.AnyOutput, 'cat', lambda_url)
def basic_authz(sbox): "verify that unreadable content is not synced" sbox.build("svnsync-basic-authz") write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) run_init(dest_sbox.repo_url, sbox.repo_url) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) svntest.main.file_write(sbox.authz_file, "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw\n" % args) run_sync(dest_sbox.repo_url) lambda_url = dest_sbox.repo_url + '/A/B/lambda' iota_url = dest_sbox.repo_url + '/iota' # this file should have been blocked by authz svntest.actions.run_and_verify_svn(None, [], svntest.verify.AnyOutput, 'cat', lambda_url) # this file should have been synced svntest.actions.run_and_verify_svn(None, svntest.verify.AnyOutput, [], 'cat', iota_url)
def basic_authz(sbox): "verify that unreadable content is not synced" sbox.build(create_wc = False) write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) run_init(dest_sbox.repo_url, sbox.repo_url) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) svntest.main.file_write(sbox.authz_file, "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw\n" % args) run_sync(dest_sbox.repo_url) lambda_url = dest_sbox.repo_url + '/A/B/lambda' iota_url = dest_sbox.repo_url + '/iota' # this file should have been blocked by authz svntest.actions.run_and_verify_svn(None, [], svntest.verify.AnyOutput, 'cat', lambda_url) # this file should have been synced svntest.actions.run_and_verify_svn(None, svntest.verify.AnyOutput, [], 'cat', iota_url)
def copy_from_unreadable_dir(sbox): "verify that copies from unreadable dirs work" sbox.build("svnsync-copy-from-unreadable-dir") B_url = sbox.repo_url + '/A/B' P_url = sbox.repo_url + '/A/P' # Set a property on the directory we're going to copy, and a file in it, to # confirm that they're transmitted when we later sync the copied directory svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar', sbox.wc_dir + '/A/B/lambda') svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'baz', 'zot', sbox.wc_dir + '/A/B') svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir + '/A/B', '-m', 'log_msg') # Now copy that directory so we'll see it in our synced copy svntest.actions.run_and_verify_svn(None, None, [], 'cp', B_url, P_url, '-m', 'Copy B to P') write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) open(sbox.authz_file, 'w').write( "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw" % args) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) expected_out = [ 'Changed paths:\n', ' A /A/P\n', ' A /A/P/E\n', ' A /A/P/E/alpha\n', ' A /A/P/E/beta\n', ' A /A/P/F\n', ' A /A/P/lambda\n', '\n', '\n', # log message is stripped ] exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '3', '-v', dest_sbox.repo_url) if err: raise SVNUnexpectedStderr(err) svntest.verify.compare_and_display_lines(None, 'LOG', expected_out, out[2:11]) svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo', dest_sbox.repo_url + '/A/P/lambda') svntest.actions.run_and_verify_svn(None, ['zot\n'], [], 'pget', 'baz', dest_sbox.repo_url + '/A/P')
def copy_with_mod_from_unreadable_dir_and_copy(sbox): "verify copies with mods from unreadable dirs +copy" sbox.build("svnsync-copy-with-mod-from-unreadable-dir-and-copy") # Make a copy of the B directory. svntest.actions.run_and_verify_svn(None, None, [], 'cp', sbox.wc_dir + '/A/B', sbox.wc_dir + '/A/P') # Copy a (readable) file into the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'cp', sbox.wc_dir + '/A/D/gamma', sbox.wc_dir + '/A/P/E') # Commit the copy-with-modification. svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m', 'log_msg') # Lock down the source repository. write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) open(sbox.authz_file, 'w').write( "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw" % args) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) expected_out = [ 'Changed paths:\n', ' A /A/P\n', ' A /A/P/E\n', ' A /A/P/E/alpha\n', ' A /A/P/E/beta\n', ' A /A/P/E/gamma (from /A/D/gamma:1)\n', ' A /A/P/F\n', ' A /A/P/lambda\n', '\n', '\n', # log message is stripped ] exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v', dest_sbox.repo_url) if err: raise SVNUnexpectedStderr(err) svntest.verify.compare_and_display_lines(None, 'LOG', expected_out, out[2:12])
def copy_with_mod_from_unreadable_dir(sbox): "verify copies with mods from unreadable dirs" sbox.build("svnsync-copy-with-mod-from-unreadable-dir") # Make a copy of the B directory. svntest.actions.run_and_verify_svn(None, None, [], 'cp', sbox.wc_dir + '/A/B', sbox.wc_dir + '/A/P') # Set a property inside the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar', sbox.wc_dir + '/A/P/lambda') # Add a new directory and file inside the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', sbox.wc_dir + '/A/P/NEW-DIR') svntest.main.file_append(sbox.wc_dir + '/A/P/E/new-file', "bla bla") svntest.main.run_svn(None, 'add', sbox.wc_dir + '/A/P/E/new-file') # Delete a file inside the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'rm', sbox.wc_dir + '/A/P/E/beta') # Commit the copy-with-modification. svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m', 'log_msg') # Lock down the source repository. write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) open(sbox.authz_file, 'w').write( "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw" % args) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) expected_out = [ 'Changed paths:\n', ' A /A/P\n', ' A /A/P/E\n', ' A /A/P/E/alpha\n', ' A /A/P/E/new-file\n', ' A /A/P/F\n', ' A /A/P/NEW-DIR\n', ' A /A/P/lambda\n', '\n', '\n', # log message is stripped ] exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v', dest_sbox.repo_url) if err: raise SVNUnexpectedStderr(err) svntest.verify.compare_and_display_lines(None, 'LOG', expected_out, out[2:12]) svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo', dest_sbox.repo_url + '/A/P/lambda')
def copy_from_unreadable_dir(sbox): "verify that copies from unreadable dirs work" sbox.build() B_url = sbox.repo_url + '/A/B' P_url = sbox.repo_url + '/A/P' # Set a property on the directory we're going to copy, and a file in it, to # confirm that they're transmitted when we later sync the copied directory svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar', sbox.wc_dir + '/A/B/lambda') svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'baz', 'zot', sbox.wc_dir + '/A/B') svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir + '/A/B', '-m', 'log_msg') # Now copy that directory so we'll see it in our synced copy svntest.actions.run_and_verify_svn(None, None, [], 'cp', B_url, P_url, '-m', 'Copy B to P') write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) open(sbox.authz_file, 'w').write( "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw" % args) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) expected_out = [ 'Changed paths:\n', ' A /A/P\n', ' A /A/P/E\n', ' A /A/P/E/alpha\n', ' A /A/P/E/beta\n', ' A /A/P/F\n', ' A /A/P/lambda\n', '\n', '\n', # log message is stripped ] exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '3', '-v', dest_sbox.repo_url) if err: raise SVNUnexpectedStderr(err) svntest.verify.compare_and_display_lines(None, 'LOG', expected_out, out[2:11]) svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo', dest_sbox.repo_url + '/A/P/lambda') svntest.actions.run_and_verify_svn(None, ['zot\n'], [], 'pget', 'baz', dest_sbox.repo_url + '/A/P')
def copy_with_mod_from_unreadable_dir_and_copy(sbox): "verify copies with mods from unreadable dirs +copy" sbox.build() # Make a copy of the B directory. svntest.actions.run_and_verify_svn(None, None, [], 'cp', sbox.wc_dir + '/A/B', sbox.wc_dir + '/A/P') # Copy a (readable) file into the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'cp', sbox.wc_dir + '/A/D/gamma', sbox.wc_dir + '/A/P/E') # Commit the copy-with-modification. svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m', 'log_msg') # Lock down the source repository. write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) open(sbox.authz_file, 'w').write( "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw" % args) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) expected_out = [ 'Changed paths:\n', ' A /A/P\n', ' A /A/P/E\n', ' A /A/P/E/alpha\n', ' A /A/P/E/beta\n', ' A /A/P/E/gamma (from /A/D/gamma:1)\n', ' A /A/P/F\n', ' A /A/P/lambda\n', '\n', '\n', # log message is stripped ] exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v', dest_sbox.repo_url) if err: raise SVNUnexpectedStderr(err) svntest.verify.compare_and_display_lines(None, 'LOG', expected_out, out[2:12])
def copy_with_mod_from_unreadable_dir(sbox): "verify copies with mods from unreadable dirs" sbox.build() # Make a copy of the B directory. svntest.actions.run_and_verify_svn(None, None, [], 'cp', sbox.wc_dir + '/A/B', sbox.wc_dir + '/A/P') # Set a property inside the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'pset', 'foo', 'bar', sbox.wc_dir + '/A/P/lambda') # Add a new directory and file inside the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'mkdir', sbox.wc_dir + '/A/P/NEW-DIR') svntest.main.file_append(sbox.wc_dir + '/A/P/E/new-file', "bla bla") svntest.main.run_svn(None, 'add', sbox.wc_dir + '/A/P/E/new-file') # Delete a file inside the copied directory. svntest.actions.run_and_verify_svn(None, None, [], 'rm', sbox.wc_dir + '/A/P/E/beta') # Commit the copy-with-modification. svntest.actions.run_and_verify_svn(None, None, [], 'ci', sbox.wc_dir, '-m', 'log_msg') # Lock down the source repository. write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() build_repos(dest_sbox) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) args = tuple(s.authz_name() for s in [sbox, sbox, dest_sbox]) open(sbox.authz_file, 'w').write( "[%s:/]\n" "* = r\n" "\n" "[%s:/A/B]\n" "* = \n" "\n" "[%s:/]\n" "* = rw" % args) run_init(dest_sbox.repo_url, sbox.repo_url) run_sync(dest_sbox.repo_url) expected_out = [ 'Changed paths:\n', ' A /A/P\n', ' A /A/P/E\n', ' A /A/P/E/alpha\n', ' A /A/P/E/new-file\n', ' A /A/P/F\n', ' A /A/P/NEW-DIR\n', ' A /A/P/lambda\n', '\n', '\n', # log message is stripped ] exit_code, out, err = svntest.main.run_svn(None, 'log', '-r', '2', '-v', dest_sbox.repo_url) if err: raise SVNUnexpectedStderr(err) svntest.verify.compare_and_display_lines(None, 'LOG', expected_out, out[2:12]) svntest.actions.run_and_verify_svn(None, ['bar\n'], [], 'pget', 'foo', dest_sbox.repo_url + '/A/P/lambda')