Skip to content

Commit

Permalink
v1.0.9 (#56)
Browse files Browse the repository at this point in the history
* v1.0.5

* v1.0.6

* v1.0.7

* fixed missing hitcount filter impl

* v1.0.8

* fixed incorrect update calls

* fixed incorrect param ref #54

* added missing retry authentication after reauth (#53)

* v1.0.9

Co-authored-by: Oliver Kaiser <[email protected]>
  • Loading branch information
kaisero and Oliver Kaiser authored Oct 19, 2021
1 parent a2009cc commit 01e3290
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 59 deletions.
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# 1.0.9 [2021-10-19]

## Fixed

* requests were not retried when authentication token was refreshed (#53)
* `accesspolicy.category` exposed incorrect param before_category (#54)
* various devicerecord update calls incorrectly overrode the update function causing update calls to fail

# 1.0.8 [2021-08-03]

## Fixed

* boolean filter values were not parsed correctly resulted in incorrect filters being passed to FMC API
* added missing filter operations to `policy.accesspolicy.operational.hitcounts` `get` operation

# 1.0.7 [2021-07-25]

## New
Expand Down Expand Up @@ -45,7 +60,7 @@
* GET policy.ravpn.addressassignmensettings
* GET policy.ravpn.certificatemapsettings
* GET policy.ravpn.connectionprofile

## Fixed

* Authentication refresh failed due to incorrect object reference in utils.py
Expand Down Expand Up @@ -245,4 +260,4 @@ replaced by `FMC` that provides a hierarchical access to all resources on FMC.

* Getbyid operations fails due to incorrect limit param
* Api calls for ftd ipv4/ipv6 static routing fails due to incorrect URLs
* Update ftd sub interface fails due to missing param
* Update ftd sub interface fails due to missing param
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().update(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().update(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().get(
return super().delete(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)
8 changes: 1 addition & 7 deletions fireREST/fmc/device/devicerecord/subinterface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().update(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().get(
return super().delete(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)
8 changes: 1 addition & 7 deletions fireREST/fmc/device/devicerecord/virtualswitch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().update(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().get(
return super().delete(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().update(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().get(
return super().delete(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)
8 changes: 1 addition & 7 deletions fireREST/fmc/device/devicerecord/vlaninterface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().update(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)

@utils.support_params
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
return super().get(
return super().delete(
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
)
1 change: 0 additions & 1 deletion fireREST/fmc/integration/securexconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ class SecurexConfig(Resource):
PATH = '/integration/securexconfigs/{uuid}'
MINIMUM_VERSION_REQUIRED_GET = '7.0.0'
MINIMUM_VERSION_REQUIRED_UPDATE = '7.0.0'

1 change: 0 additions & 1 deletion fireREST/fmc/object/dnsservergroup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ def __init__(self, conn: Connection):
@utils.support_params
def get(self, uuid=None, name=None, override_target_id=None, params=None):
return super().get(uuid=uuid, name=name, params=params)

1 change: 0 additions & 1 deletion fireREST/fmc/object/dynamicobject/mapping/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ class Mapping(ChildResource):
MINIMUM_VERSION_REQUIRED_GET = '7.0.0'
MINIMUM_VERSION_REQUIRED_UPDATE = '7.0.0'
MINIMUM_VERSION_REQUIRED_DELETE = '7.0.0'

3 changes: 1 addition & 2 deletions fireREST/fmc/object/intrusionrule/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ class IntrusionRule(Resource):
SUPPORTED_FILTERS = ['gid', 'sid', 'overrides', 'ips_policy', 'fts']

@utils.support_params
def get(self, uuid=None, name=None, gid=None, sid=None,
overrides=None, ips_policy=None, fts=None, params=None):
def get(self, uuid=None, name=None, gid=None, sid=None, overrides=None, ips_policy=None, fts=None, params=None):
return super().get(uuid=uuid, name=name, params=params)
5 changes: 3 additions & 2 deletions fireREST/fmc/object/intrusionrulegroup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class IntrusionRuleGroup(Resource):
SUPPORTED_FILTERS = ['name', 'current_security_level', 'show_only_parents', 'include_count']

@utils.support_params
def get(self, uuid=None, name=None, current_security_level=None,
show_only_parents=None, include_count=None, params=None):
def get(
self, uuid=None, name=None, current_security_level=None, show_only_parents=None, include_count=None, params=None
):
return super().get(uuid=uuid, name=name, params=params)
5 changes: 2 additions & 3 deletions fireREST/fmc/policy/accesspolicy/category/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Category(ChildResource):
CONTAINER_PATH = '/policy/accesspolicies/{uuid}'
PATH = '/policy/accesspolicies/{container_uuid}/categories/{uuid}'
SUPPORTED_FILTERS = []
SUPPORTED_PARAMS = ['below_category', 'above_category', 'section', 'insert_before', 'insert_after']
SUPPORTED_PARAMS = ['above_category', 'section', 'insert_before', 'insert_after']
IGNORE_FOR_CREATE = []
IGNORE_FOR_UPDATE = []
MINIMUM_VERSION_REQUIRED_CREATE = '6.5.0'
Expand All @@ -23,8 +23,7 @@ def create(
data: Union[dict, list],
container_uuid=None,
container_name=None,
after_category=None,
before_category=None,
above_category=None,
section=None,
insert_after=None,
insert_before=None,
Expand Down
13 changes: 10 additions & 3 deletions fireREST/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import re
from re import sub
import sys
from copy import deepcopy
from functools import wraps
Expand All @@ -13,6 +13,7 @@
from . import exceptions as exc
from .mapping import FILTERS, PARAMS


logger = getLogger(__name__)


Expand Down Expand Up @@ -59,6 +60,7 @@ def inner_function(f):
@wraps(f)
def wrapper(*args, **kwargs):
if version:
# noinspection PyUnresolvedReferences
min_version = packaging.version.parse(version)
else:
operations = {
Expand All @@ -67,6 +69,7 @@ def wrapper(*args, **kwargs):
'update': args[0].MINIMUM_VERSION_REQUIRED_UPDATE,
'delete': args[0].MINIMUM_VERSION_REQUIRED_DELETE,
}
# noinspection PyUnresolvedReferences
min_version = packaging.version.parse(operations[f.__name__])

installed_version = args[0].version
Expand Down Expand Up @@ -184,9 +187,13 @@ def wrapper(*args, **kwargs):
if not args[0].dry_run:
response.raise_for_status()
except HTTPError:
if response.status_code == 401 and 'Access token invalid' in response.text:
if response.status_code == 401 and ('Access token invalid' in response.text
or 'Invalid access token' in response.text):
# Invalid access token detected. Refresh authorization token
conn.refresh()

# Repeat request with valid authentication token
response = f(*args, **kwargs)
else:
raise_for_status(response)
return response
Expand Down Expand Up @@ -284,7 +291,7 @@ def fix_url(url: str):
:return: fixed url
:rtype: str
"""
return re.sub(r'/None$', '', url).rstrip('/')
return sub(r'/None$', '', url).rstrip('/')


def sanitize_payload(method: str, payload: Dict, ignore_fields=None, _recursive=False):
Expand Down
2 changes: 1 addition & 1 deletion fireREST/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.7'
__version__ = '1.0.9'
2 changes: 1 addition & 1 deletion test/fmc/object/network/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_create_network_object_bulk(fmc):
expected_result = 201
data = [
{'name': 'FireREST-NetworkObjBulk1', 'value': '198.18.1.0/24'},
{'name': 'FireREST-NetworkObjBulk2', 'value': '198.18.2.0/24'}
{'name': 'FireREST-NetworkObjBulk2', 'value': '198.18.2.0/24'},
]

actual_result = fmc.object.network.create(data)
Expand Down
2 changes: 0 additions & 2 deletions test/fmc/test_resource.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# -*- coding: utf-8 -*-

import pytest

import fireREST.exceptions as exc

from requests.auth import HTTPBasicAuth

from fireREST import defaults
from fireREST.fmc import Resource
from fireREST.defaults import API_REFRESH_URL, API_PLATFORM_URL, API_CONFIG_URL


Expand Down

0 comments on commit 01e3290

Please sign in to comment.