mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
fix(nwfilters): a rule is deleted and added exactly as clicked and entered
- Deleting a rule removes the row clicked, by its position, instead of the first rule with the same action, direction and priority; a filter changed since the page was read is refused instead of losing another rule. - An added rule is added as entered, with all its attributes. It was merged into a rule with the same action, direction and priority, where libvirt keeps only the first protocol, so the new rule was silently dropped. - A new filter shows in the list after it is created.
This commit is contained in:
parent
953c296324
commit
79e3f91169
7 changed files with 71 additions and 46 deletions
|
|
@ -44,15 +44,15 @@ class XPathValueTests(unittest.TestCase):
|
|||
nwf = wvmNWFilter.__new__(wvmNWFilter)
|
||||
nwf._XMLDesc = lambda flags: FILTER
|
||||
# values with quotes or brackets are compared, not parsed as XPath
|
||||
self.assertEqual(nwf.delete_rule("drop'][@priority='2", "in", "1").count("<rule "), 2)
|
||||
self.assertEqual(nwf.delete_rule("it's", "in", "1").count("<rule "), 2)
|
||||
kept = nwf.delete_rule("drop", "in", "2")
|
||||
for action in ("drop'][@priority='2", "it's"):
|
||||
with self.subTest(action=action), self.assertRaises(ValueError):
|
||||
nwf.delete_rule(0, action, "in", "1")
|
||||
kept = nwf.delete_rule(1, "drop", "in", "2")
|
||||
self.assertEqual(kept.count("<rule "), 1)
|
||||
self.assertIn("priority=\"1\"", kept)
|
||||
# add_rule appends to the matching rule only
|
||||
# add_rule adds a rule of its own
|
||||
added = nwf.add_rule("<rule action='drop' direction='in' priority='2'><icmp/></rule>")
|
||||
self.assertEqual(added.count("<rule "), 2)
|
||||
self.assertIn("<icmp", added.split('priority="2"')[1])
|
||||
self.assertEqual(added.count("<rule "), 3)
|
||||
|
||||
def test_qos_direction_must_be_known(self):
|
||||
net = wvmNetwork.__new__(wvmNetwork)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue