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/03/01 20:02:40 UTC

qpid-dispatch git commit: DISPATCH-918: Deprecate vhost:id in favor of vhost:hostname

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 5691122fc -> 75d8b7663


DISPATCH-918: Deprecate vhost:id in favor of vhost:hostname


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/75d8b766
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/75d8b766
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/75d8b766

Branch: refs/heads/master
Commit: 75d8b76631b96272f967cb613a05e109b883488f
Parents: 5691122
Author: Chuck Rolke <cr...@redhat.com>
Authored: Thu Mar 1 14:56:07 2018 -0500
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Thu Mar 1 14:56:07 2018 -0500

----------------------------------------------------------------------
 python/qpid_dispatch/management/qdrouter.json   |   9 +-
 .../qpid_dispatch_internal/management/agent.py  |   6 +-
 .../policy/policy_local.py                      |   6 +-
 tests/policy-1/management-access.json           |   6 +-
 tests/policy-1/policy-boardwalk.json            |   2 +-
 tests/policy-1/policy-boardwalk.json.in         |   2 +-
 tests/policy-1/policy-safari.json               |   2 +-
 tests/policy-1/policy-safari.json.in            |   2 +-
 tests/policy-2/test-router-with-policy.json.in  |   8 +-
 tests/policy-3/test-sender-receiver-limits.json |   6 +-
 tests/policy-4/management-access.json           |   6 +-
 tests/policy-5/permissive-default.json          |   2 +-
 tests/system_tests_policy.py                    | 228 ++++++++++++++++++-
 13 files changed, 253 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/python/qpid_dispatch/management/qdrouter.json
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json
index ac9dda8..a661795 100644
--- a/python/qpid_dispatch/management/qdrouter.json
+++ b/python/qpid_dispatch/management/qdrouter.json
@@ -1561,9 +1561,10 @@
             "extends": "configurationEntity",
             "operations": ["CREATE", "UPDATE", "DELETE"],
             "attributes": {
-                "id": {
+                "hostname": {
                     "type": "string",
-                    "description": "The vhost name.",
+                    "description": "The hostname of the vhost. This vhost policy will be applied to any client connection that is directed to this hostname.",
+                    "deprecationName": "id",
                     "required": true,
                     "create": true
                 },
@@ -1700,6 +1701,10 @@
             "attributes": {
                 "id": {
                     "type": "string",
+                    "description": "The vhost name. DEPRECATED - use 'hostname' instead."
+                },
+                "hostname": {
+                    "type": "string",
                     "description": "The vhost name."
                 },
                 "connectionsApproved": {"type": "integer", "graph": true},

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/python/qpid_dispatch_internal/management/agent.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/agent.py b/python/qpid_dispatch_internal/management/agent.py
index 1a8e14d..177d803 100644
--- a/python/qpid_dispatch_internal/management/agent.py
+++ b/python/qpid_dispatch_internal/management/agent.py
@@ -300,13 +300,13 @@ class VhostEntity(EntityAdapter):
         self._policy.create_ruleset(self.attributes)
 
     def _identifier(self):
-        return self.attributes.get('id')
+        return self.attributes.get('hostname')
 
     def __str__(self):
         return super(VhostEntity, self).__str__().replace("Entity(", "VhostEntity(")
 
     def _delete(self):
-        self._policy.delete_ruleset(self.id)
+        self._policy.delete_ruleset(self.hostname)
 
     def _update(self):
         self._policy.update_ruleset(self.attributes)
@@ -314,7 +314,7 @@ class VhostEntity(EntityAdapter):
 
 class VhostStatsEntity(EntityAdapter):
     def _identifier(self):
-        return self.attributes.get('id')
+        return self.attributes.get('hostname')
 
     def __str__(self):
         return super(VhostStatsEntity, self).__str__().replace("Entity(", "VhostStatsEntity(")

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/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 4f176e0..228d65d 100644
--- a/python/qpid_dispatch_internal/policy/policy_local.py
+++ b/python/qpid_dispatch_internal/policy/policy_local.py
@@ -39,7 +39,8 @@ class PolicyKeys(object):
     KW_IGNORED_NAME             = "name"
     KW_IGNORED_IDENTITY         = "identity"
     KW_IGNORED_TYPE             = "type"
-    KW_VHOST_NAME               = "id"
+    KW_VHOST_NAME               = "hostname"
+    KW_VHOST_DEPRECATED_ID      = "id"
 
     # Policy ruleset key words
     KW_MAXCONN                     = "maxConnections"
@@ -395,6 +396,7 @@ class AppStats(object):
         """Refresh management attributes"""
         entitymap = {}
         entitymap[PolicyKeys.KW_VHOST_NAME] =     self.my_id
+        entitymap[PolicyKeys.KW_VHOST_DEPRECATED_ID]  = self.my_id
         entitymap[PolicyKeys.KW_CONNECTIONS_APPROVED] = self.conn_mgr.connections_approved
         entitymap[PolicyKeys.KW_CONNECTIONS_DENIED] =   self.conn_mgr.connections_denied
         entitymap[PolicyKeys.KW_CONNECTIONS_CURRENT] =  self.conn_mgr.connections_active
@@ -696,7 +698,7 @@ class PolicyLocal(object):
         Test function to load a policy.
         @return:
         """
-        ruleset_str = '["vhost", {"id": "photoserver", "maxConnections": 50, "maxConnectionsPerUser": 5, "maxConnectionsPerHost": 20, "allowUnknownUser": true,'
+        ruleset_str = '["vhost", {"hostname": "photoserver", "maxConnections": 50, "maxConnectionsPerUser": 5, "maxConnectionsPerHost": 20, "allowUnknownUser": true,'
         ruleset_str += '"groups": {'
         ruleset_str += '"anonymous":       { "users": "anonymous", "remoteHosts": "*", "maxFrameSize": 111111, "maxMessageSize": 111111, "maxSessionWindow": 111111, "maxSessions": 1, "maxSenders": 11, "maxReceivers": 11, "allowDynamicSource": false, "allowAnonymousSender": false, "sources": "public", "targets": "" },'
         ruleset_str += '"users":           { "users": "u1, u2", "remoteHosts": "*", "maxFrameSize": 222222, "maxMessageSize": 222222, "maxSessionWindow": 222222, "maxSessions": 2, "maxSenders": 22, "maxReceivers": 22, "allowDynamicSource": false, "allowAnonymousSender": false, "sources": "public, private", "targets": "public" },'

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-1/management-access.json
----------------------------------------------------------------------
diff --git a/tests/policy-1/management-access.json b/tests/policy-1/management-access.json
index aa19d28..12c7e17 100644
--- a/tests/policy-1/management-access.json
+++ b/tests/policy-1/management-access.json
@@ -24,7 +24,7 @@
 #    unnamed host- proton 0.13
 [
   ["vhost", {
-      "id": "",
+      "hostname": "",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,
@@ -48,7 +48,7 @@
     }
   ],
   ["vhost", {
-      "id": "0.0.0.0",
+      "hostname": "0.0.0.0",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,
@@ -72,7 +72,7 @@
     }
   ],
   ["vhost", {
-      "id": "localhost",
+      "hostname": "localhost",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-1/policy-boardwalk.json
----------------------------------------------------------------------
diff --git a/tests/policy-1/policy-boardwalk.json b/tests/policy-1/policy-boardwalk.json
index 7759e86..0afc028 100644
--- a/tests/policy-1/policy-boardwalk.json
+++ b/tests/policy-1/policy-boardwalk.json
@@ -21,7 +21,7 @@
     # The boardwalk policy ruleset
     ["vhost",
         {
-            "id": "boardwalk",
+            "hostname": "boardwalk",
             "maxConnections": 10,
             "maxConnectionsPerUser": 2,
             "maxConnectionsPerHost": 5,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-1/policy-boardwalk.json.in
----------------------------------------------------------------------
diff --git a/tests/policy-1/policy-boardwalk.json.in b/tests/policy-1/policy-boardwalk.json.in
index 3c9a57d..8911bc9 100644
--- a/tests/policy-1/policy-boardwalk.json.in
+++ b/tests/policy-1/policy-boardwalk.json.in
@@ -21,7 +21,7 @@
     # The boardwalk policy ruleset
     ["vhost",
         {
-            "id": "boardwalk",
+            "hostname": "boardwalk",
             "maxConnections": 10,
             "maxConnectionsPerUser": 2,
             "maxConnectionsPerHost": 5,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-1/policy-safari.json
----------------------------------------------------------------------
diff --git a/tests/policy-1/policy-safari.json b/tests/policy-1/policy-safari.json
index 107d35f..afc23e9 100644
--- a/tests/policy-1/policy-safari.json
+++ b/tests/policy-1/policy-safari.json
@@ -20,7 +20,7 @@
     # The safari policy ruleset
     ["vhost",
         {
-            "id": "safari",
+            "hostname": "safari",
             "maxConnections": 10,
             "maxConnectionsPerUser": 2,
             "maxConnectionsPerHost": 5,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-1/policy-safari.json.in
----------------------------------------------------------------------
diff --git a/tests/policy-1/policy-safari.json.in b/tests/policy-1/policy-safari.json.in
index 4a93fae..1978270 100644
--- a/tests/policy-1/policy-safari.json.in
+++ b/tests/policy-1/policy-safari.json.in
@@ -20,7 +20,7 @@
     # The safari policy ruleset
     ["vhost",
         {
-            "id": "safari",
+            "hostname": "safari",
             "maxConnections": 10,
             "maxConnectionsPerUser": 2,
             "maxConnectionsPerHost": 5,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-2/test-router-with-policy.json.in
----------------------------------------------------------------------
diff --git a/tests/policy-2/test-router-with-policy.json.in b/tests/policy-2/test-router-with-policy.json.in
index c4de9f9..936766e 100644
--- a/tests/policy-2/test-router-with-policy.json.in
+++ b/tests/policy-2/test-router-with-policy.json.in
@@ -30,7 +30,7 @@
     }],
 # Some ruleset
     ["vhost", {
-      "id": "photoserver",
+      "hostname": "photoserver",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,
@@ -136,7 +136,7 @@
       }
   }],
   ["vhost", {
-      "id": "",
+      "hostname": "",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,
@@ -160,7 +160,7 @@
     }
   ],
   ["vhost", {
-      "id": "0.0.0.0",
+      "hostname": "0.0.0.0",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,
@@ -184,7 +184,7 @@
     }
   ],
   ["vhost", {
-      "id": "localhost",
+      "hostname": "localhost",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-3/test-sender-receiver-limits.json
----------------------------------------------------------------------
diff --git a/tests/policy-3/test-sender-receiver-limits.json b/tests/policy-3/test-sender-receiver-limits.json
index 1c9f90f..2d21f3e 100644
--- a/tests/policy-3/test-sender-receiver-limits.json
+++ b/tests/policy-3/test-sender-receiver-limits.json
@@ -2,7 +2,7 @@
 # Ruleset with differing number of senders and receivers
 # so tests can determine that correct limit is matched.
   ["vhost", {
-      "id": "",
+      "hostname": "",
       "maxConnections": 50,
       "maxConnectionsPerUser": 2,
       "maxConnectionsPerHost": 4,
@@ -25,7 +25,7 @@
     }
   ],
   ["vhost", {
-      "id": "0.0.0.0",
+      "hostname": "0.0.0.0",
       "maxConnections": 50,
       "maxConnectionsPerUser": 2,
       "maxConnectionsPerHost": 4,
@@ -48,7 +48,7 @@
     }
   ],
   ["vhost", {
-      "id": "localhost",
+      "hostname": "localhost",
       "maxConnections": 50,
       "maxConnectionsPerUser": 2,
       "maxConnectionsPerHost": 4,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-4/management-access.json
----------------------------------------------------------------------
diff --git a/tests/policy-4/management-access.json b/tests/policy-4/management-access.json
index 708f547..d741a8e 100644
--- a/tests/policy-4/management-access.json
+++ b/tests/policy-4/management-access.json
@@ -27,7 +27,7 @@
 #
 [
   ["vhost", {
-      "id": "",
+      "hostname": "",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,
@@ -52,7 +52,7 @@
     }
   ],
   ["vhost", {
-      "id": "0.0.0.0",
+      "hostname": "0.0.0.0",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,
@@ -77,7 +77,7 @@
     }
   ],
   ["vhost", {
-      "id": "localhost",
+      "hostname": "localhost",
       "maxConnections": 50,
       "maxConnectionsPerUser": 5,
       "maxConnectionsPerHost": 20,

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/policy-5/permissive-default.json
----------------------------------------------------------------------
diff --git a/tests/policy-5/permissive-default.json b/tests/policy-5/permissive-default.json
index 9a17289..a9da6d4 100644
--- a/tests/policy-5/permissive-default.json
+++ b/tests/policy-5/permissive-default.json
@@ -18,7 +18,7 @@
 ##
 [
     ["vhost", {
-        "id": "$default",
+        "hostname": "$default",
         "allowUnknownUser": true,
         "groups" : {
             "$default": {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/75d8b766/tests/system_tests_policy.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_policy.py b/tests/system_tests_policy.py
index e0d5936..8e48102 100644
--- a/tests/system_tests_policy.py
+++ b/tests/system_tests_policy.py
@@ -127,7 +127,7 @@ class LoadPolicyFromFolder(TestCase):
     def new_policy(self):
         return """
 {
-    "id": "dispatch-494",
+    "hostname": "dispatch-494",
     "maxConnections": 50,
     "maxConnectionsPerHost": 20,
     "maxConnectionsPerUser": 8,
@@ -154,7 +154,6 @@ class LoadPolicyFromFolder(TestCase):
     def updated_policy(self):
         return """
 {
-    "id": "dispatch-494",
     "maxConnections": 500,
     "maxConnectionsPerHost": 2,
     "maxConnectionsPerUser": 30,
@@ -189,7 +188,7 @@ class LoadPolicyFromFolder(TestCase):
         self.assertEqual(len(rulesets), 6)
         found = False
         for ruleset in rulesets:
-            if ruleset['id'] == 'dispatch-494':
+            if ruleset['hostname'] == 'dispatch-494':
                 found = True
                 self.assertEqual(ruleset['maxConnections'], 50)
                 self.assertEqual(ruleset['maxConnectionsPerHost'], 20)
@@ -203,7 +202,7 @@ class LoadPolicyFromFolder(TestCase):
         self.assertEqual(len(rulesets), 6)
         found = False
         for ruleset in rulesets:
-            if ruleset['id'] == 'dispatch-494':
+            if ruleset['hostname'] == 'dispatch-494':
                 found = True
                 self.assertEqual(ruleset['maxConnections'], 500)
                 self.assertEqual(ruleset['maxConnectionsPerHost'], 2)
@@ -217,7 +216,7 @@ class LoadPolicyFromFolder(TestCase):
         self.assertEqual(len(rulesets), 5)
         absent = True
         for ruleset in rulesets:
-            if ruleset['id'] == 'dispatch-494':
+            if ruleset['hostname'] == 'dispatch-494':
                 absent = False
                 break
         self.assertTrue(absent)
@@ -233,7 +232,7 @@ class LoadPolicyFromFolder(TestCase):
             self.assertEqual(len(rulesets), 6)
             found = False
             for ruleset in rulesets:
-                if ruleset['id'] == 'dispatch-494':
+                if ruleset['hostname'] == 'dispatch-494':
                     found = True
                     break
             self.assertTrue(found)
@@ -244,7 +243,7 @@ class LoadPolicyFromFolder(TestCase):
             self.assertEqual(len(rulesets), 5)
             absent = True
             for ruleset in rulesets:
-                if ruleset['id'] == 'dispatch-494':
+                if ruleset['hostname'] == 'dispatch-494':
                     absent = False
                     break
             self.assertTrue(absent)
@@ -352,5 +351,220 @@ class InterrouterLinksAllowed(TestCase):
             self.assertTrue(len(disallow_lines) == 0, msg='Inter-router links should be allowed but some were blocked by policy.')
 
 
+class VhostPolicyNameField(TestCase):
+    """
+    Verify that vhosts can be created getting the name from
+    'id' or from 'hostname'.
+    This test relies on qdmanage utility.
+    """
+    @classmethod
+    def setUpClass(cls):
+        """Start the router"""
+        super(VhostPolicyNameField, cls).setUpClass()
+
+        ipv6_enabled = is_ipv6_enabled()
+
+        policy_config_path = os.path.join(DIR, 'policy-1')
+        replacements = {'{IPV6_LOOPBACK}':', ::1'}
+        for f in os.listdir(policy_config_path):
+            if f.endswith(".json.in"):
+                with open(policy_config_path+"/"+f[:-3], 'w') as outfile:
+                    with open(policy_config_path + "/" + f) as infile:
+                        for line in infile:
+                            for src, target in replacements.iteritems():
+                                if ipv6_enabled:
+                                    line = line.replace(src, target)
+                                else:
+                                    line = line.replace(src, '')
+                            outfile.write(line)
+
+        config = Qdrouterd.Config([
+            ('router', {'mode': 'standalone', 'id': 'QDR.Policy'}),
+            ('listener', {'port': cls.tester.get_port()}),
+            ('policy', {'maxConnections': 2, 'policyDir': policy_config_path, 'enableVhostPolicy': 'true'})
+        ])
+
+        cls.router = cls.tester.qdrouterd('vhost-policy-name-field', config, wait=True)
+
+    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 id_policy(self):
+        return """
+{
+    "id": "dispatch-918",
+    "maxConnections": 50,
+    "maxConnectionsPerHost": 20,
+    "maxConnectionsPerUser": 8,
+    "allowUnknownUser": true,
+    "groups": {
+        "$default": {
+            "allowAnonymousSender": true,
+            "maxReceivers": 99,
+            "users": "*",
+            "maxSessionWindow": 9999,
+            "maxFrameSize": 222222,
+            "sources": "public, private, $management",
+            "maxMessageSize": 222222,
+            "allowDynamicSource": true,
+            "remoteHosts": "*",
+            "maxSessions": 2,
+            "targets": "public, private, $management",
+            "maxSenders": 22
+        }
+    }
+}
+"""
+
+    def hostname_policy(self):
+        return """
+{
+    "hostname": "dispatch-918",
+    "maxConnections": 51,
+    "maxConnectionsPerHost": 20,
+    "maxConnectionsPerUser": 8,
+    "allowUnknownUser": true,
+    "groups": {
+        "$default": {
+            "allowAnonymousSender": true,
+            "maxReceivers": 99,
+            "users": "*",
+            "maxSessionWindow": 9999,
+            "maxFrameSize": 222222,
+            "sources": "public, private, $management",
+            "maxMessageSize": 222222,
+            "allowDynamicSource": true,
+            "remoteHosts": "*",
+            "maxSessions": 2,
+            "targets": "public, private, $management",
+            "maxSenders": 22
+        }
+    }
+}
+"""
+
+    def both_policy(self):
+        return """
+{
+    "id":       "isogyre",
+    "hostname": "dispatch-918",
+    "maxConnections": 52,
+    "maxConnectionsPerHost": 20,
+    "maxConnectionsPerUser": 8,
+    "allowUnknownUser": true,
+    "groups": {
+        "$default": {
+            "allowAnonymousSender": true,
+            "maxReceivers": 99,
+            "users": "*",
+            "maxSessionWindow": 9999,
+            "maxFrameSize": 222222,
+            "sources": "public, private, $management",
+            "maxMessageSize": 222222,
+            "allowDynamicSource": true,
+            "remoteHosts": "*",
+            "maxSessions": 2,
+            "targets": "public, private, $management",
+            "maxSenders": 22
+        }
+    }
+}
+"""
+
+    def neither_policy(self):
+        return """
+{
+    "maxConnections": 53,
+    "maxConnectionsPerHost": 20,
+    "maxConnectionsPerUser": 8,
+    "allowUnknownUser": true,
+    "groups": {
+        "$default": {
+            "allowAnonymousSender": true,
+            "maxReceivers": 99,
+            "users": "*",
+            "maxSessionWindow": 9999,
+            "maxFrameSize": 222222,
+            "sources": "public, private, $management, neither_policy",
+            "maxMessageSize": 222222,
+            "allowDynamicSource": true,
+            "remoteHosts": "*",
+            "maxSessions": 2,
+            "targets": "public, private, $management",
+            "maxSenders": 22
+        }
+    }
+}
+"""
+
+
+    def test_01_id_vs_hostname(self):
+        # verify current vhost count
+        rulesets = json.loads(self.run_qdmanage('query --type=vhost'))
+        self.assertEqual(len(rulesets), 5)
+
+        # create using 'id'
+        self.run_qdmanage('create --type=vhost --name=dispatch-918 --stdin', input=self.id_policy())
+        rulesets = json.loads(self.run_qdmanage('query --type=vhost'))
+        self.assertEqual(len(rulesets), 6)
+        found = False
+        for ruleset in rulesets:
+            if ruleset['hostname'] == 'dispatch-918':
+                found = True
+                self.assertEqual(ruleset['maxConnections'], 50)
+                break
+        self.assertTrue(found)
+
+        # update using 'hostname'
+        self.run_qdmanage('update --type=vhost --name=dispatch-918 --stdin', input=self.hostname_policy())
+        rulesets = json.loads(self.run_qdmanage('query --type=vhost'))
+        self.assertEqual(len(rulesets), 6)
+        found = False
+        for ruleset in rulesets:
+            if ruleset['hostname'] == 'dispatch-918':
+                found = True
+                self.assertEqual(ruleset['maxConnections'], 51)
+                break
+        self.assertTrue(found)
+
+        # update 'id' and 'hostname'
+        try:
+            self.run_qdmanage('update --type=vhost --name=dispatch-918 --stdin',
+                              input=self.both_policy())
+            self.assertTrue(false) # should not be able to update 'id'
+        except Exception,  e:
+            pass
+
+        # update using neither
+        self.run_qdmanage('update --type=vhost --name=dispatch-918 --stdin', input=self.neither_policy())
+        rulesets = json.loads(self.run_qdmanage('query --type=vhost'))
+        self.assertEqual(len(rulesets), 6)
+        found = False
+        for ruleset in rulesets:
+            if ruleset['hostname'] == 'dispatch-918':
+                found = True
+                self.assertEqual(ruleset['maxConnections'], 53)
+                break
+        self.assertTrue(found)
+        isoFound = False
+        for ruleset in rulesets:
+            if ruleset['hostname'] == 'isogyre':
+                isoFound = True
+                break
+        self.assertFalse(isoFound)
+
+
+
 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