Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
fix: Security tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jjeff07 committed Feb 16, 2022
1 parent c033b9b commit 59b4870
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ipfabric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
from typing import Optional, Union
from urllib.parse import urlparse

from pkg_resources import parse_version

from ipfabric import models
from ipfabric.api import IPFabricAPI
from ipfabric.intent import Intent
from ipfabric.pathlookup import Diagram
from ipfabric.security import Security
from pkg_resources import parse_version

DEFAULT_ID = "$last"

Expand Down Expand Up @@ -43,7 +44,8 @@ def __init__(
self.inventory = models.Inventory(client=self)
self.graphs = Diagram(self) if parse_version(self.os_version) < parse_version("4.3") else \
ImportError("v4.3 digrams has been moved to ipfabrc-diagrams python package")
self.security = Security(client=self)
self.security = Security(client=self) if parse_version(self.os_version) < parse_version("4.3") else \
ImportError("Security Policy tables have changed and need updated")
self.intent = Intent(client=self)

@check_format
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/test_security.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import unittest

from pkg_resources import parse_version

import ipfabric.security
from ipfabric import IPFClient

Expand All @@ -11,16 +13,22 @@
class MyTestCase(unittest.TestCase):
def test_get_acl(self):
ipf = IPFClient()
if parse_version(ipf.os_version) >= parse_version("4.3"):
self.skipTest('IP Fabric version under 4.3')
acls = ipf.security.search_acl_policies()
self.assertIsInstance(acls, list)

def test_get_zone(self):
ipf = IPFClient()
if parse_version(ipf.os_version) >= parse_version("4.3"):
self.skipTest('IP Fabric version under 4.3')
zones = ipf.security.search_zone_policies()
self.assertIsInstance(zones, list)

def test_get_policy(self):
ipf = IPFClient()
if parse_version(ipf.os_version) >= parse_version("4.3"):
self.skipTest('IP Fabric version under 4.3')
acl = ipf.security.search_acl_policies()[0]
policy = ipf.security.get_policy(acl)
self.assertIsInstance(policy, ipfabric.security.Policy)
Expand Down

0 comments on commit 59b4870

Please sign in to comment.