[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH]move some utils functions from authz_tests to svntest.main

From: Kamesh Jayachandran <kamesh_at_collab.net>
Date: 2007-05-12 03:13:51 CEST

Hi All,
I am writing merge test which needs some strict authz setting.
In this regard I would like the utility functions available in
authz_tests.py to be under svntest.main for easy consumption.

This patch addresses the same.

With regards
Kamesh Jayachandran

[[[
Move authz_tests utils funcs to svntest.main for the consumption by
other tests.

* subversion/tests/cmdline/authz_tests.py
* subversion/tests/cmdline/svntest/main.py
  (global): move skip_test_when_no_authz_available,
            write_restrictive_svnserve_conf, write_authz_file to svntest.main

Patch by: kameshj
]]]

Index: subversion/tests/cmdline/svntest/main.py
===================================================================
--- subversion/tests/cmdline/svntest/main.py (revision 24999)
+++ subversion/tests/cmdline/svntest/main.py (working copy)
@@ -582,6 +582,42 @@
     except ValueError:
       raise Failure("Expected output does not match actual output")
 
+def skip_test_when_no_authz_available():
+ "skip this test when authz is not available"
+ if test_area_url.startswith('file://'):
+ raise svntest.Skip
+
+def write_restrictive_svnserve_conf(repo_dir):
+ "Create a restrictive authz file ( no anynomous access )."
+
+ fp = open(get_svnserve_conf_file_path(repo_dir), 'w')
+ fp.write("[general]\nanon-access = none\nauth-access = write\n"
+ "authz-db = authz\n")
+ if enable_sasl == 1:
+ fp.write("realm = svntest\n[sasl]\nuse-sasl = true\n");
+ else:
+ fp.write("password-db = passwd\n")
+ fp.close()
+
+def write_authz_file(sbox, rules, sections=None):
+ """Write an authz file to SBOX, appropriate for the RA method used,
+with authorizations rules RULES mapping paths to strings containing
+the rules. You can add sections SECTIONS (ex. groups, aliases...) with
+an appropriate list of mappings.
+"""
+ fp = open(sbox.authz_file, 'w')
+ if sbox.repo_url.startswith("http"):
+ prefix = sbox.name + ":"
+ else:
+ prefix = ""
+ if sections:
+ for p, r in sections.items():
+ fp.write("[%s]\n%s\n" % (p, r))
+
+ for p, r in rules.items():
+ fp.write("[%s%s]\n%s\n" % (prefix, p, r))
+ fp.close()
+
 def use_editor(func):
   os.environ['SVN_EDITOR'] = svneditor_script
   os.environ['SVNTEST_EDITOR_FUNC'] = func
Index: subversion/tests/cmdline/authz_tests.py
===================================================================
--- subversion/tests/cmdline/authz_tests.py (revision 24999)
+++ subversion/tests/cmdline/authz_tests.py (working copy)
@@ -22,52 +22,15 @@
 # Our testing module
 import svntest
 
+from svntest.main import skip_test_when_no_authz_available
+from svntest.main import write_restrictive_svnserve_conf
+from svntest.main import write_authz_file
 
 # (abbreviation)
 Item = svntest.wc.StateItem
 XFail = svntest.testcase.XFail
 
 ######################################################################
-# Utilities
-#
-
-def write_restrictive_svnserve_conf(repo_dir):
- "Create a restrictive authz file ( no anynomous access )."
-
- fp = open(svntest.main.get_svnserve_conf_file_path(repo_dir), 'w')
- fp.write("[general]\nanon-access = none\nauth-access = write\n"
- "authz-db = authz\n")
- if svntest.main.enable_sasl == 1:
- fp.write("realm = svntest\n[sasl]\nuse-sasl = true\n");
- else:
- fp.write("password-db = passwd\n")
- fp.close()
-
-def write_authz_file(sbox, rules, sections=None):
- """Write an authz file to SBOX, appropriate for the RA method used,
-with authorizations rules RULES mapping paths to strings containing
-the rules. You can add sections SECTIONS (ex. groups, aliases...) with
-an appropriate list of mappings.
-"""
- fp = open(sbox.authz_file, 'w')
- if sbox.repo_url.startswith("http"):
- prefix = sbox.name + ":"
- else:
- prefix = ""
- if sections:
- for p, r in sections.items():
- fp.write("[%s]\n%s\n" % (p, r))
-
- for p, r in rules.items():
- fp.write("[%s%s]\n%s\n" % (prefix, p, r))
- fp.close()
-
-def skip_test_when_no_authz_available():
- "skip this test when authz is not available"
- if svntest.main.test_area_url.startswith('file://'):
- raise svntest.Skip
-
-######################################################################
 # Tests
 #
 # Each test must return on success or raise on failure.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat May 12 03:13:55 2007

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.