You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ch...@apache.org on 2018/05/16 20:14:08 UTC
[10/12] qpid-dispatch git commit: DISPATCH-990: Add hostname pattern
self test
DISPATCH-990: Add hostname pattern self test
Remove stray variables from log message.
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/415b4568
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/415b4568
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/415b4568
Branch: refs/heads/master
Commit: 415b4568ecac113f3ea4212507407dba03f7cdd1
Parents: 82cef3a
Author: Chuck Rolke <cr...@redhat.com>
Authored: Mon May 14 15:56:58 2018 -0400
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Mon May 14 15:56:58 2018 -0400
----------------------------------------------------------------------
.../policy/policy_local.py | 4 +-
tests/system_tests_policy.py | 75 ++++++++++++++++++++
2 files changed, 77 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/415b4568/python/qpid_dispatch_internal/policy/policy_local.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/policy/policy_local.py b/python/qpid_dispatch_internal/policy/policy_local.py
index 4f33fc6..f651dcc 100644
--- a/python/qpid_dispatch_internal/policy/policy_local.py
+++ b/python/qpid_dispatch_internal/policy/policy_local.py
@@ -711,8 +711,8 @@ class PolicyLocal(object):
vhost = self._default_vhost
if vhost != vhost_in:
self._manager.log_debug(
- "AMQP Open lookup settings for user '%s', rhost '%s', vhost '%s': "
- "proceeds using vhost '%s' ruleset" % (user, rhost, vhost_in, vhost))
+ "AMQP Open lookup settings for vhost '%s': "
+ "proceeds using vhost '%s' ruleset" % (vhost_in, vhost))
if vhost not in self.rulesetdb:
self._manager.log_info(
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/415b4568/tests/system_tests_policy.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_policy.py b/tests/system_tests_policy.py
index 93c7d6a..e2f2797 100644
--- a/tests/system_tests_policy.py
+++ b/tests/system_tests_policy.py
@@ -745,5 +745,80 @@ class PolicyLinkNamePatternTest(TestCase):
self.assertTrue(exception)
+class PolicyHostamePatternTest(TestCase):
+ """
+ Verify hostname pattern matching
+ """
+ @classmethod
+ def setUpClass(cls):
+ """Start the router"""
+ super(PolicyHostamePatternTest, cls).setUpClass()
+ listen_port = cls.tester.get_port()
+ policy_config_path = os.path.join(DIR, 'policy-8')
+ config = Qdrouterd.Config([
+ ('router', {'mode': 'standalone', 'id': 'QDR.Policy8'}),
+ ('listener', {'port': listen_port}),
+ ('policy', {'maxConnections': 2, 'policyDir': policy_config_path, 'enableVhostPolicy': 'true', 'useVhostNamePatterns': 'true'})
+ ])
+
+ cls.router = cls.tester.qdrouterd('PolicyVhostNamePatternTest', config, wait=True)
+ try:
+ cls.router.wait_ready(timeout = 5)
+ except Exception, e:
+ pass
+
+ def address(self):
+ return self.router.addresses[0]
+
+ def run_qdmanage(self, cmd, input=None, expect=Process.EXIT_OK):
+ p = self.popen(
+ ['qdmanage'] + cmd.split(' ') + ['--bus', 'u1:password@' + self.address(), '--indent=-1', '--timeout', str(TIMEOUT)],
+ stdin=PIPE, stdout=PIPE, stderr=STDOUT, expect=expect)
+ out = p.communicate(input)[0]
+ try:
+ p.teardown()
+ except Exception, e:
+ raise Exception("%s\n%s" % (e, out))
+ return out
+
+ def disallowed_hostname(self):
+ return """
+{
+ "hostname": "#.#.0.0",
+ "maxConnections": 3,
+ "maxConnectionsPerHost": 3,
+ "maxConnectionsPerUser": 3,
+ "allowUnknownUser": true,
+ "groups": {
+ "$default": {
+ "allowAnonymousSender": true,
+ "maxReceivers": 99,
+ "users": "*",
+ "maxSessionWindow": 1000000,
+ "maxFrameSize": 222222,
+ "sources": "public, private, $management",
+ "maxMessageSize": 222222,
+ "allowDynamicSource": true,
+ "remoteHosts": "*",
+ "maxSessions": 2,
+ "maxSenders": 22
+ }
+ }
+}
+"""
+
+ def test_hostname_pattern_00_hello(self):
+ rulesets = json.loads(self.run_qdmanage('query --type=vhost'))
+ self.assertEqual(len(rulesets), 1)
+
+ def test_hostname_pattern_01_denied_add(self):
+ qdm_out = "<not written>"
+ try:
+ qdm_out = self.run_qdmanage('create --type=vhost --name=#.#.0.0 --stdin', input=self.disallowed_hostname())
+ except Exception, e:
+ self.assertTrue("pattern conflicts" in e.message, msg=('Error running qdmanage %s' % e.message))
+ self.assertFalse("222222" in qdm_out)
+
+
if __name__ == '__main__':
unittest.main(main_module())
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org