diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-08-05 16:22:51 +0000 |
commit | cf46733632c7279a9fd0fe6ce26f9185a4ae82a9 (patch) | |
tree | da27775a2161723ef342e91af41a8b51fedef405 /subversion/tests/cmdline/svnsync_authz_tests.py | |
parent | bb0ef45f7c46b0ae221b26265ef98a768c33f820 (diff) | |
download | subversion-tarball-master.tar.gz |
subversion-1.9.7HEADsubversion-1.9.7master
Diffstat (limited to 'subversion/tests/cmdline/svnsync_authz_tests.py')
-rwxr-xr-x | subversion/tests/cmdline/svnsync_authz_tests.py | 196 |
1 files changed, 81 insertions, 115 deletions
diff --git a/subversion/tests/cmdline/svnsync_authz_tests.py b/subversion/tests/cmdline/svnsync_authz_tests.py index 62e79c6..54dc099 100755 --- a/subversion/tests/cmdline/svnsync_authz_tests.py +++ b/subversion/tests/cmdline/svnsync_authz_tests.py @@ -30,17 +30,18 @@ import sys, os # Test suite-specific modules -import locale, re, urllib +import locale, re # Our testing module import svntest from svntest.verify import SVNUnexpectedStdout, SVNUnexpectedStderr from svntest.verify import SVNExpectedStderr from svntest.main import write_restrictive_svnserve_conf +from svntest.main import write_authz_file from svntest.main import server_has_partial_replay # Shared helpers -from svnsync_tests import build_repos, run_init, run_sync, run_test +from svnsync_tests import run_init, run_sync, run_test # (abbreviation) Skip = svntest.testcase.Skip_deco @@ -56,27 +57,25 @@ Item = svntest.wc.StateItem def basic_authz(sbox): "verify that unreadable content is not synced" - sbox.build("svnsync-basic-authz") + sbox.build(create_wc = False) write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() - build_repos(dest_sbox) + dest_sbox.build(create_wc=False, empty=True) 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) + src_authz = sbox.authz_name() + dst_authz = dest_sbox.authz_name() + write_authz_file(sbox, None, + prefixed_rules = { + src_authz + ':/': '* = r', + src_authz + ':/A/B': '* =', + dst_authz + ':/': '* = rw', + }) run_sync(dest_sbox.repo_url) @@ -84,13 +83,11 @@ def basic_authz(sbox): 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, + svntest.actions.run_and_verify_svn([], svntest.verify.AnyOutput, 'cat', lambda_url) # this file should have been synced - svntest.actions.run_and_verify_svn(None, - svntest.verify.AnyOutput, [], + svntest.actions.run_and_verify_svn(svntest.verify.AnyOutput, [], 'cat', iota_url) @@ -99,7 +96,7 @@ def basic_authz(sbox): def copy_from_unreadable_dir(sbox): "verify that copies from unreadable dirs work" - sbox.build("svnsync-copy-from-unreadable-dir") + sbox.build() B_url = sbox.repo_url + '/A/B' P_url = sbox.repo_url + '/A/P' @@ -107,7 +104,6 @@ def copy_from_unreadable_dir(sbox): # 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', @@ -115,7 +111,6 @@ def copy_from_unreadable_dir(sbox): sbox.wc_dir + '/A/B/lambda') svntest.actions.run_and_verify_svn(None, - None, [], 'pset', 'baz', @@ -123,7 +118,6 @@ def copy_from_unreadable_dir(sbox): sbox.wc_dir + '/A/B') svntest.actions.run_and_verify_svn(None, - None, [], 'ci', sbox.wc_dir + '/A/B', @@ -131,7 +125,6 @@ def copy_from_unreadable_dir(sbox): # Now copy that directory so we'll see it in our synced copy svntest.actions.run_and_verify_svn(None, - None, [], 'cp', B_url, @@ -141,21 +134,18 @@ def copy_from_unreadable_dir(sbox): write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() - build_repos(dest_sbox) + dest_sbox.build(create_wc=False, empty=True) 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) + src_authz = sbox.authz_name() + dst_authz = dest_sbox.authz_name() + write_authz_file(sbox, None, + prefixed_rules = { + src_authz + ':/': '* = r', + src_authz + ':/A/B': '* =', + dst_authz + ':/': '* = rw', + }) run_init(dest_sbox.repo_url, sbox.repo_url) @@ -187,15 +177,13 @@ def copy_from_unreadable_dir(sbox): expected_out, out[2:11]) - svntest.actions.run_and_verify_svn(None, - ['bar\n'], + svntest.actions.run_and_verify_svn(['bar\n'], [], 'pget', 'foo', dest_sbox.repo_url + '/A/P/lambda') - svntest.actions.run_and_verify_svn(None, - ['zot\n'], + svntest.actions.run_and_verify_svn(['zot\n'], [], 'pget', 'baz', @@ -207,11 +195,10 @@ def copy_from_unreadable_dir(sbox): def copy_with_mod_from_unreadable_dir(sbox): "verify copies with mods from unreadable dirs" - sbox.build("svnsync-copy-with-mod-from-unreadable-dir") + sbox.build() # Make a copy of the B directory. svntest.actions.run_and_verify_svn(None, - None, [], 'cp', sbox.wc_dir + '/A/B', @@ -219,7 +206,6 @@ def copy_with_mod_from_unreadable_dir(sbox): # Set a property inside the copied directory. svntest.actions.run_and_verify_svn(None, - None, [], 'pset', 'foo', @@ -228,7 +214,6 @@ def copy_with_mod_from_unreadable_dir(sbox): # 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') @@ -238,14 +223,12 @@ def copy_with_mod_from_unreadable_dir(sbox): # 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, @@ -255,21 +238,18 @@ def copy_with_mod_from_unreadable_dir(sbox): write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() - build_repos(dest_sbox) + dest_sbox.build(create_wc=False, empty=True) 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) + src_authz = sbox.authz_name() + dst_authz = dest_sbox.authz_name() + write_authz_file(sbox, None, + prefixed_rules = { + src_authz + ':/': '* = r', + src_authz + ':/A/B': '* =', + dst_authz + ':/': '* = rw', + }) run_init(dest_sbox.repo_url, sbox.repo_url) @@ -302,8 +282,7 @@ def copy_with_mod_from_unreadable_dir(sbox): expected_out, out[2:12]) - svntest.actions.run_and_verify_svn(None, - ['bar\n'], + svntest.actions.run_and_verify_svn(['bar\n'], [], 'pget', 'foo', @@ -315,11 +294,10 @@ def copy_with_mod_from_unreadable_dir(sbox): 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") + sbox.build() # Make a copy of the B directory. svntest.actions.run_and_verify_svn(None, - None, [], 'cp', sbox.wc_dir + '/A/B', @@ -328,7 +306,6 @@ def copy_with_mod_from_unreadable_dir_and_copy(sbox): # Copy a (readable) file into the copied directory. svntest.actions.run_and_verify_svn(None, - None, [], 'cp', sbox.wc_dir + '/A/D/gamma', @@ -337,7 +314,6 @@ def copy_with_mod_from_unreadable_dir_and_copy(sbox): # Commit the copy-with-modification. svntest.actions.run_and_verify_svn(None, - None, [], 'ci', sbox.wc_dir, @@ -347,21 +323,18 @@ def copy_with_mod_from_unreadable_dir_and_copy(sbox): write_restrictive_svnserve_conf(sbox.repo_dir) dest_sbox = sbox.clone_dependent() - build_repos(dest_sbox) + dest_sbox.build(create_wc=False, empty=True) 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) + src_authz = sbox.authz_name() + dst_authz = dest_sbox.authz_name() + write_authz_file(sbox, None, + prefixed_rules = { + src_authz + ':/': '* = r', + src_authz + ':/A/B': '* =', + dst_authz + ':/': '* = rw', + }) run_init(dest_sbox.repo_url, sbox.repo_url) @@ -396,6 +369,9 @@ def copy_with_mod_from_unreadable_dir_and_copy(sbox): def identity_copy(sbox): "copy UTF-8 svn:* props identically" + + sbox.build(create_wc = False) + orig_lc_all = locale.setlocale(locale.LC_ALL) other_locales = [ "English.1252", "German.1252", "French.1252", "en_US.ISO-8859-1", "en_GB.ISO-8859-1", "de_DE.ISO-8859-1", @@ -420,10 +396,10 @@ def identity_copy(sbox): def specific_deny_authz(sbox): "verify if specifically denied paths dont sync" - sbox.build("specific-deny-authz") + sbox.build() dest_sbox = sbox.clone_dependent() - build_repos(dest_sbox) + dest_sbox.build(create_wc=False, empty=True) svntest.actions.enable_revprop_changes(dest_sbox.repo_dir) @@ -440,38 +416,31 @@ def specific_deny_authz(sbox): # 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") + src_authz = sbox.authz_name() + dst_authz = dest_sbox.authz_name() + write_authz_file(sbox, None, + prefixed_rules = { + src_authz + ':/': '* = r', + src_authz + ':/A': '* =', + src_authz + ':/A_COPY/B/lambda': '* =', + dst_authz + ':/': '* = rw', + }) # 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") + write_authz_file(sbox, None, + prefixed_rules = { + '/': '* = r', + '/A': '* =', + '/A_COPY/B/lambda': '* =', + }) 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, + svntest.actions.run_and_verify_svn([], svntest.verify.AnyOutput, 'cat', lambda_url) @@ -481,8 +450,8 @@ 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, [], + sbox.build(create_wc = False) + svntest.actions.run_and_verify_svnmucc(None, [], '-m', 'r2', '-U', sbox.repo_url, 'cp', 'HEAD', '/', 'branch', @@ -490,27 +459,24 @@ def copy_delete_unreadable_child(sbox): # Create the destination. dest_sbox = sbox.clone_dependent() - build_repos(dest_sbox) + dest_sbox.build(create_wc=False, empty=True) 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)) + src_authz = sbox.authz_name() + write_authz_file(sbox, None, + prefixed_rules = { + src_authz + ':/': '* = r', + src_authz + ':/A': '* =', + }) + + dest_url = dest_sbox.file_protocol_url() run_init(dest_url, sbox.repo_url) run_sync(dest_url) # sanity check - svntest.actions.run_and_verify_svn(None, - ["iota\n"], [], + svntest.actions.run_and_verify_svn(["iota\n"], [], 'ls', dest_url+'/branch@2') |