Skip to content

Commit 01e3290

Browse files
kaiseroOliver Kaiser
and
Oliver Kaiser
authored
v1.0.9 (#56)
* 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 <ok@on.at>
1 parent a2009cc commit 01e3290

File tree

17 files changed

+40
-59
lines changed

17 files changed

+40
-59
lines changed

CHANGELOG.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# 1.0.9 [2021-10-19]
2+
3+
## Fixed
4+
5+
* requests were not retried when authentication token was refreshed (#53)
6+
* `accesspolicy.category` exposed incorrect param before_category (#54)
7+
* various devicerecord update calls incorrectly overrode the update function causing update calls to fail
8+
9+
# 1.0.8 [2021-08-03]
10+
11+
## Fixed
12+
13+
* boolean filter values were not parsed correctly resulted in incorrect filters being passed to FMC API
14+
* added missing filter operations to `policy.accesspolicy.operational.hitcounts` `get` operation
15+
116
# 1.0.7 [2021-07-25]
217

318
## New
@@ -45,7 +60,7 @@
4560
* GET policy.ravpn.addressassignmensettings
4661
* GET policy.ravpn.certificatemapsettings
4762
* GET policy.ravpn.connectionprofile
48-
63+
4964
## Fixed
5065

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

246261
* Getbyid operations fails due to incorrect limit param
247262
* Api calls for ftd ipv4/ipv6 static routing fails due to incorrect URLs
248-
* Update ftd sub interface fails due to missing param
263+
* Update ftd sub interface fails due to missing param

fireREST/fmc/device/devicerecord/physicalinterface/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,3 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
1818
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
1919
)
2020

21-
@utils.support_params
22-
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
23-
return super().update(
24-
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
25-
)

fireREST/fmc/device/devicerecord/redundantinterface/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
2020
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
2121
)
2222

23-
@utils.support_params
24-
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
25-
return super().update(
26-
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
27-
)
28-
2923
@utils.support_params
3024
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
31-
return super().get(
25+
return super().delete(
3226
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
3327
)

fireREST/fmc/device/devicerecord/subinterface/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
2020
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
2121
)
2222

23-
@utils.support_params
24-
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
25-
return super().update(
26-
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
27-
)
28-
2923
@utils.support_params
3024
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
31-
return super().get(
25+
return super().delete(
3226
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
3327
)

fireREST/fmc/device/devicerecord/virtualswitch/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
2020
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
2121
)
2222

23-
@utils.support_params
24-
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
25-
return super().update(
26-
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
27-
)
28-
2923
@utils.support_params
3024
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
31-
return super().get(
25+
return super().delete(
3226
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
3327
)

fireREST/fmc/device/devicerecord/virtualtunnelinterface/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
2020
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
2121
)
2222

23-
@utils.support_params
24-
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
25-
return super().update(
26-
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
27-
)
28-
2923
@utils.support_params
3024
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
31-
return super().get(
25+
return super().delete(
3226
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
3327
)

fireREST/fmc/device/devicerecord/vlaninterface/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ def get(self, container_uuid=None, container_name=None, uuid=None, name=None, pa
2020
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
2121
)
2222

23-
@utils.support_params
24-
def update(self, data: Dict, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
25-
return super().update(
26-
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
27-
)
28-
2923
@utils.support_params
3024
def delete(self, container_uuid=None, container_name=None, uuid=None, name=None, params=None):
31-
return super().get(
25+
return super().delete(
3226
container_uuid=container_uuid, container_name=container_name, uuid=uuid, name=name, params=params
3327
)

fireREST/fmc/integration/securexconfig/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ class SecurexConfig(Resource):
55
PATH = '/integration/securexconfigs/{uuid}'
66
MINIMUM_VERSION_REQUIRED_GET = '7.0.0'
77
MINIMUM_VERSION_REQUIRED_UPDATE = '7.0.0'
8-

fireREST/fmc/object/dnsservergroup/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ def __init__(self, conn: Connection):
1919
@utils.support_params
2020
def get(self, uuid=None, name=None, override_target_id=None, params=None):
2121
return super().get(uuid=uuid, name=name, params=params)
22-

fireREST/fmc/object/dynamicobject/mapping/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ class Mapping(ChildResource):
88
MINIMUM_VERSION_REQUIRED_GET = '7.0.0'
99
MINIMUM_VERSION_REQUIRED_UPDATE = '7.0.0'
1010
MINIMUM_VERSION_REQUIRED_DELETE = '7.0.0'
11-

fireREST/fmc/object/intrusionrule/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ class IntrusionRule(Resource):
1313
SUPPORTED_FILTERS = ['gid', 'sid', 'overrides', 'ips_policy', 'fts']
1414

1515
@utils.support_params
16-
def get(self, uuid=None, name=None, gid=None, sid=None,
17-
overrides=None, ips_policy=None, fts=None, params=None):
16+
def get(self, uuid=None, name=None, gid=None, sid=None, overrides=None, ips_policy=None, fts=None, params=None):
1817
return super().get(uuid=uuid, name=name, params=params)

fireREST/fmc/object/intrusionrulegroup/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class IntrusionRuleGroup(Resource):
1212
SUPPORTED_FILTERS = ['name', 'current_security_level', 'show_only_parents', 'include_count']
1313

1414
@utils.support_params
15-
def get(self, uuid=None, name=None, current_security_level=None,
16-
show_only_parents=None, include_count=None, params=None):
15+
def get(
16+
self, uuid=None, name=None, current_security_level=None, show_only_parents=None, include_count=None, params=None
17+
):
1718
return super().get(uuid=uuid, name=name, params=params)

fireREST/fmc/policy/accesspolicy/category/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Category(ChildResource):
99
CONTAINER_PATH = '/policy/accesspolicies/{uuid}'
1010
PATH = '/policy/accesspolicies/{container_uuid}/categories/{uuid}'
1111
SUPPORTED_FILTERS = []
12-
SUPPORTED_PARAMS = ['below_category', 'above_category', 'section', 'insert_before', 'insert_after']
12+
SUPPORTED_PARAMS = ['above_category', 'section', 'insert_before', 'insert_after']
1313
IGNORE_FOR_CREATE = []
1414
IGNORE_FOR_UPDATE = []
1515
MINIMUM_VERSION_REQUIRED_CREATE = '6.5.0'
@@ -23,8 +23,7 @@ def create(
2323
data: Union[dict, list],
2424
container_uuid=None,
2525
container_name=None,
26-
after_category=None,
27-
before_category=None,
26+
above_category=None,
2827
section=None,
2928
insert_after=None,
3029
insert_before=None,

fireREST/utils.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import re
1+
from re import sub
22
import sys
33
from copy import deepcopy
44
from functools import wraps
@@ -13,6 +13,7 @@
1313
from . import exceptions as exc
1414
from .mapping import FILTERS, PARAMS
1515

16+
1617
logger = getLogger(__name__)
1718

1819

@@ -59,6 +60,7 @@ def inner_function(f):
5960
@wraps(f)
6061
def wrapper(*args, **kwargs):
6162
if version:
63+
# noinspection PyUnresolvedReferences
6264
min_version = packaging.version.parse(version)
6365
else:
6466
operations = {
@@ -67,6 +69,7 @@ def wrapper(*args, **kwargs):
6769
'update': args[0].MINIMUM_VERSION_REQUIRED_UPDATE,
6870
'delete': args[0].MINIMUM_VERSION_REQUIRED_DELETE,
6971
}
72+
# noinspection PyUnresolvedReferences
7073
min_version = packaging.version.parse(operations[f.__name__])
7174

7275
installed_version = args[0].version
@@ -184,9 +187,13 @@ def wrapper(*args, **kwargs):
184187
if not args[0].dry_run:
185188
response.raise_for_status()
186189
except HTTPError:
187-
if response.status_code == 401 and 'Access token invalid' in response.text:
190+
if response.status_code == 401 and ('Access token invalid' in response.text
191+
or 'Invalid access token' in response.text):
188192
# Invalid access token detected. Refresh authorization token
189193
conn.refresh()
194+
195+
# Repeat request with valid authentication token
196+
response = f(*args, **kwargs)
190197
else:
191198
raise_for_status(response)
192199
return response
@@ -284,7 +291,7 @@ def fix_url(url: str):
284291
:return: fixed url
285292
:rtype: str
286293
"""
287-
return re.sub(r'/None$', '', url).rstrip('/')
294+
return sub(r'/None$', '', url).rstrip('/')
288295

289296

290297
def sanitize_payload(method: str, payload: Dict, ignore_fields=None, _recursive=False):

fireREST/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.7'
1+
__version__ = '1.0.9'

test/fmc/object/network/test_network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_create_network_object_bulk(fmc):
2424
expected_result = 201
2525
data = [
2626
{'name': 'FireREST-NetworkObjBulk1', 'value': '198.18.1.0/24'},
27-
{'name': 'FireREST-NetworkObjBulk2', 'value': '198.18.2.0/24'}
27+
{'name': 'FireREST-NetworkObjBulk2', 'value': '198.18.2.0/24'},
2828
]
2929

3030
actual_result = fmc.object.network.create(data)

test/fmc/test_resource.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# -*- coding: utf-8 -*-
2-
32
import pytest
43

54
import fireREST.exceptions as exc
65

76
from requests.auth import HTTPBasicAuth
87

98
from fireREST import defaults
10-
from fireREST.fmc import Resource
119
from fireREST.defaults import API_REFRESH_URL, API_PLATFORM_URL, API_CONFIG_URL
1210

1311

0 commit comments

Comments
 (0)