diff options
author | Rajith Muditha Attapattu <rajith@apache.org> | 2010-05-12 01:48:38 +0000 |
---|---|---|
committer | Rajith Muditha Attapattu <rajith@apache.org> | 2010-05-12 01:48:38 +0000 |
commit | e4311a90427c8023487214d83956019afac06560 (patch) | |
tree | 519b29ba21bc6a3f0d40cb08da46455876db7ec3 /cpp/src/tests/acl.py | |
parent | ae4dc20acd3b4b3da1c3649ad83001ca7275680b (diff) | |
download | qpid-python-e4311a90427c8023487214d83956019afac06560.tar.gz |
This commit contains a fix for QPID-2600
Added a test case to check if all allowed chars are accepted and the rest is rejected.
Added a check for empty continuation lines.
Improved error reporting by adding a line number.
Removed test_allowed_chars_for_username method from acl.py as the check for group name will flag the "@" char, making this test case redundent.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@943351 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/acl.py')
-rwxr-xr-x | cpp/src/tests/acl.py | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/cpp/src/tests/acl.py b/cpp/src/tests/acl.py index 96dd7934c7..a7725b36a6 100755 --- a/cpp/src/tests/acl.py +++ b/cpp/src/tests/acl.py @@ -117,36 +117,6 @@ class ACLTests(TestBase010): except qpid.session.SessionException, e: self.assertEqual(403,e.args[0].error_code) - - def test_group_and_user_with_same_name(self): - """ - Test a group and user with same name - Ex. group admin admin - """ - aclf = ACLFile() - aclf.write('group bob@QPID bob@QPID\n') - aclf.write('acl deny bob@QPID bind exchange\n') - aclf.write('acl allow all all') - aclf.close() - - result = self.reload_acl() - if (result.text.find("format error",0,len(result.text)) != -1): - self.fail(result) - - session = self.get_session('bob','bob') - try: - session.queue_declare(queue="allow_queue") - except qpid.session.SessionException, e: - if (403 == e.args[0].error_code): - self.fail("ACL should allow queue create request"); - self.fail("Error during queue create request"); - - try: - session.exchange_bind(exchange="amq.direct", queue="allow_queue", binding_key="routing_key") - self.fail("ACL should deny queue bind request"); - except qpid.session.SessionException, e: - self.assertEqual(403,e.args[0].error_code) - #===================================== # ACL file format tests @@ -185,23 +155,26 @@ class ACLTests(TestBase010): """ aclf = ACLFile() - aclf.write('group admins bob@QPID \ ') + aclf.write('group admins bob@QPID \n') aclf.write(' \ \n') aclf.write('joe@QPID \n') aclf.write('acl allow all all') aclf.close() result = self.reload_acl() - if (result.text.find("contains illegal characters",0,len(result.text)) == -1): + if (result.text.find("contains an illegal extension",0,len(result.text)) == -1): + self.fail(result) + + if (result.text.find("Non-continuation line must start with \"group\" or \"acl\"",0,len(result.text)) == -1): self.fail(result) + def test_user_domain(self): """ Test a user defined without a realm Ex. group admin rajith """ - aclf = ACLFile() - aclf.write('group test joe@EXAMPLE.com\n') # should be allowed + aclf = ACLFile() aclf.write('group admin bob\n') # shouldn't be allowed aclf.write('acl deny admin bind exchange\n') aclf.write('acl allow all all') @@ -211,6 +184,23 @@ class ACLTests(TestBase010): if (result.text.find("Username 'bob' must contain a realm",0,len(result.text)) == -1): self.fail(result) + def test_allowed_chars_for_username(self): + """ + Test a user defined without a realm + Ex. group admin rajith + """ + aclf = ACLFile() + aclf.write('group test1 joe@EXAMPLE.com\n') # should be allowed + aclf.write('group test2 jack-jill@EXAMPLE.com\n') # should be allowed + aclf.write('group test3 jack_jill@EXAMPLE.com\n') # should be allowed + aclf.write('group test4 host/somemachine.example.com@EXAMPLE.COM\n') # should be allowed + aclf.write('acl allow all all') + aclf.close() + + result = self.reload_acl() + if (result.text.find("ACL format error",0,len(result.text)) != -1): + self.fail(result) + #===================================== # ACL validation tests #===================================== |