Ejemplo n.º 1
0
 def setUp(self):
     hostname = '10.34.4.73'
     username = '******'
     password = '******'
     self.api = Client(hostname=hostname,
                       username=username,
                       password=password)
Ejemplo n.º 2
0
 def setUp(self):
     hostname = 'fmc.example.com'
     username = '******'
     password = '******'
     self.api = Client(hostname=hostname,
                       username=username,
                       password=password)
Ejemplo n.º 3
0
    def setUpClass(cls):
        super(TestFireREST, cls).setUpClass()
        cls.hostname = 'fmc.example.com'
        cls.username = '******'
        cls.password = '******'

        cls.api = Client(hostname=cls.hostname,
                         username=cls.username,
                         password=cls.password)
Ejemplo n.º 4
0
class TestFireRESTAuth(unittest.TestCase):
    def setUp(self):
        hostname = '10.34.4.73'
        username = '******'
        password = '******'
        self.api = Client(hostname=hostname,
                          username=username,
                          password=password)

    def tearDown(self):
        return

    def test_authentication(self):
        self.api.domains = dict()
        del self.api.headers['X-auth-access-token']
        del self.api.headers['X-auth-refresh-token']

        self.api._login()

        self.assertTrue(self.api.domains)
        self.assertIn('X-auth-access-token', self.api.headers)
        self.assertIn('X-auth-refresh-token', self.api.headers)

    def test_authentication_with_incorrect_credentials(self):
        self.api.cred = HTTPBasicAuth('admin', 'incorrect-password')
        self.assertRaises(FireRESTAuthException, self.api._login)

    def test_authentication_refresh_counter_after_successful_authentication(
            self):
        self.api._login()
        expected_counter = 0
        actual_counter = self.api.refresh_counter

        self.assertEqual(actual_counter, expected_counter)

    def test_authentication_refresh_counter_incrementing(self):
        counter_before_refresh = self.api.refresh_counter
        self.api._refresh()

        expected_counter = counter_before_refresh + 1
        actual_counter = self.api.refresh_counter

        self.assertEqual(actual_counter, expected_counter)

    def test_re_authentication(self):
        self.api.refresh_counter = 3
        self.api._refresh()

        expected_counter = 0
        actual_counter = self.api.refresh_counter

        self.assertEqual(actual_counter, expected_counter)
Ejemplo n.º 5
0
# import required dependencies
from __future__ import print_function
# import fireREST
from fireREST import Client

# set variables for execution. Make sure your credentials are correct, ACP exists and syslog alert definition exists
loglevel = 'DEBUG'
device = '10.34.4.73'
username = '******'
password = '******'
domain = 'Global'
policy = 'IPS-CDMX'
syslog_alert = 'Splunk'
# Initialize a new api object
api = Client(hostname=device, username=username, password=password)

# Get IDs for specified acp and syslog alert. API PK = UUID, so we have to find the matching api object for the name
# specified.

acp_id = api.get_acp_id_by_name(policy)
syslog_alert_id = api.get_syslog_alert_id_by_name(syslog_alert)

# Get all access control rules for the access control policy specified
acp_rules = api.get_acp_rules(acp_id, expanded=True)

# Loop through HTTP response objects
for response in acp_rules:
    # Loop through access control rules in http response object
    for acp_rule in response.json()['items']:
        # Only change syslog settings if no syslog alert configuration exists
        if 'syslogConfig' not in acp_rule:
Ejemplo n.º 6
0
def api(constants):
    return Client(hostname=constants['hostname'], username=constants['username'], password=constants['password'])
Ejemplo n.º 7
0
def api(constants):
    return Client(hostname=constants['hostname'], username=constants['username'], password=constants['password'])
    api.domains = dict()
    del api.headers['X-auth-access-token']
    del api.headers['X-auth-refresh-token']
Ejemplo n.º 8
0
from fireREST import Client

client = Client(hostname='192.168.0.239', username='******', password='******')

net_obj = { 
    'name': '{{  NetObjName  }}',
    'value': '{{  address  }}',
}

response = client.create_object('networks', net_obj)
Ejemplo n.º 9
0
from fireREST import Client

client = Client(hostname='192.168.0.239',
                username='******',
                password='******')

name = 'server-3'
uuid = client.get_object_id_by_name('networks', name)
Ejemplo n.º 10
0
from fireREST import Client

client = Client(hostname='192.168.0.239',
                username='******',
                password='******')

obj_name = 'NetObjViaAPI-2'
obj_id = client.get_object_id_by_name('network', 'NetObjViaAPI-2')
obj_payload = client.get_object('network', obj_id)