Skip to content

Commit

Permalink
fix: correct user-id tag_user / untag_user (#299)
Browse files Browse the repository at this point in the history
Fixes #287 - correcting attribute checked to "user" for both tag_user()
and untag_user()

New unittests have been added and pass successfully.
  • Loading branch information
shinmog committed May 6, 2021
1 parent 48faab5 commit 1de69f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions panos/userid.py
Expand Up @@ -674,7 +674,7 @@ def tag_user(self, user, tags, timeout=None, prefix=None):
# Find the tags section for this specific user.
entries = ru.findall("./entry")
for entry in entries:
if entry.attrib["name"] == user:
if entry.attrib["user"] == user:
te = entry.find("./tag")
break
else:
Expand Down Expand Up @@ -718,7 +718,7 @@ def untag_user(self, user, tags=None, prefix=None):
# Find the tags section for this specific user.
entries = uu.findall("./entry")
for entry in entries:
if entry.attrib["name"] == user:
if entry.attrib["user"] == user:
break
else:
entry = ET.SubElement(uu, "entry", {"user": user,})
Expand Down
18 changes: 18 additions & 0 deletions tests/test_userid.py
Expand Up @@ -61,6 +61,24 @@ def test_login(self):

fw._xapi_private.user_id.assert_called_once_with(cmd=expected, vsys=vsys)

def test_batch_tag_user(self):
fw = panos.firewall.Firewall(
"fw1", "user", "passwd", "authkey", serial="Serial", vsys="vsys1"
)
fw.xapi
fw.userid.batch_start()
fw.userid.tag_user("user1", ["tag1",])
fw.userid.tag_user("user2", ["tag1",])

def test_batch_untag_user(self):
fw = panos.firewall.Firewall(
"fw1", "user", "passwd", "authkey", serial="Serial", vsys="vsys2"
)
fw.xapi
fw.userid.batch_start()
fw.userid.untag_user("user1", ["tag1",])
fw.userid.untag_user("user2", ["tag1",])


if __name__ == "__main__":
unittest.main()

0 comments on commit 1de69f8

Please sign in to comment.