示例#1
0
    def test_dot(self):
        import panos.device as Device

        expected = (
            "digraph configtree {graph [rankdir=LR, fontsize=10, margin=0.001];"
            "node [shape=box, fontsize=10, height=0.001, margin=0.1, ordering=out];"
            '"PanDevice : None" [style=filled fillcolor= '
            'URL="http://pan-os-python.readthedocs.io/en/latest/module-base.html#panos.base.PanDevice" '
            'target="_blank"];"SystemSettings : " [style=filled fillcolor=lightpink '
            'URL="http://pan-os-python.readthedocs.io/en/latest/module-device.html'
            '#panos.device.SystemSettings" target="_blank"];'
            '"PanDevice : None" -> "SystemSettings : ";}')

        fw = Base.PanDevice(hostname=None, serial="Serial")
        sys = Device.SystemSettings()
        fw.add(sys)

        ret_val = fw.dot()
        self.assertEqual(ret_val, expected)
示例#2
0
    def test_not_present(self):
        resp = [
            "<response>",
            "<result>",
            "<admins>",
            "<entry><admin>user1</admin><type>Web</type></entry>",
            "<entry><admin>user2</admin><type>Web</type></entry>",
            "<entry><admin>user3</admin><type>Web</type></entry>",
            "</admins>",
            "</result>",
            "</response>",
        ]

        spec = {
            "return_value": ET.fromstring("".join(resp)),
        }

        con = Base.PanDevice("127.0.0.1", "a", "b", "c")
        con.op = mock.Mock(**spec)

        self.assertIsNone(con.whoami())
示例#3
0
    def test_self_is_present(self):
        expected = "user2"
        resp = [
            "<response>",
            "<result>",
            "<admins>",
            "<entry><admin>user1</admin><type>Web</type></entry>",
            "<entry><admin>{0}</admin><type>Web</type><self/></entry>".format(
                expected),
            "</admins>",
            "</result>",
            "</response>",
        ]

        spec = {
            "return_value": ET.fromstring("".join(resp)),
        }

        con = Base.PanDevice("127.0.0.1", "a", "b", "c")
        con.op = mock.Mock(**spec)

        self.assertEqual(expected, con.whoami())
示例#4
0
 def setUp(self):
     self.obj = Base.PanDevice("localhost", "admin", "admin", "secret")
     self.obj._version_info = (99, 0, 0)