Skip to content

Commit 8d3cdda

Browse files
authored
Adds security log profile api (#1427)
Issues: Fixes #1426 Problem: The API did not exist Analysis: This adds it Tests: * functional * unit
1 parent 7220c3d commit 8d3cdda

9 files changed

Lines changed: 835 additions & 18 deletions

File tree

f5-sdk-dist/scripts/build_exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __init__(self, *args, **kargs):
108108
super(RedhatError, self).__init__(*args, **kargs)
109109

110110

111-
class TestError(BuildError):
111+
class ErrorInTest(BuildError):
112112
"""TestError
113113
114114
An Error occurred during testing...
@@ -117,7 +117,7 @@ class TestError(BuildError):
117117

118118
def __init__(self, *args, **kargs):
119119
# exception-specific logic here...
120-
super(TestError, self).__init__(*args, **kargs)
120+
super(ErrorInTest, self).__init__(*args, **kargs)
121121

122122

123123
# vim: set fileencoding=utf-8

f5-sdk-dist/scripts/install_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from . import build_expectations
4545

4646
from . terminal import terminal
47-
from . build_exceptions import TestError
47+
from . build_exceptions import ErrorInTest
4848

4949
# Globals:
5050
builds = build_expectations.Builds()
@@ -128,7 +128,7 @@ def _set_expected_opts(self, opts):
128128
if opts:
129129
if not isinstance(opts, tuple) or \
130130
not isinstance(opts[0][0], OperationSettings):
131-
raise TestError(msg=err_msg, frame=gfi(cf()),
131+
raise ErrorInTest(msg=err_msg, frame=gfi(cf()),
132132
errnum=errno.ESPIPE)
133133
self.__expected_opts = opts
134134

@@ -180,7 +180,7 @@ def collect_pkgs(self):
180180
pkg_search = dist + "/rpms/build/*.rpm"
181181
pkg_re = re.compile('el(\d+)\.noarch')
182182
else:
183-
raise TestError(opt.os_type, frame=gfi(cf()),
183+
raise ErrorInTest(opt.os_type, frame=gfi(cf()),
184184
errnum=errno.ESPIPE,
185185
msg='opt.os_type(%s) is not recognized!')
186186
entropy = glob.glob(pkg_search)
@@ -208,7 +208,7 @@ def collect_pkgs(self):
208208
break
209209
if not found:
210210
self._set_failure_reason = \
211-
TestError(opt.os_type, opt.version,
211+
ErrorInTest(opt.os_type, opt.version,
212212
frame=gfi(cf()), errno=errno.ESPIPE,
213213
msg='No pkg found built for')
214214
print(str(self.failure_reason))
@@ -266,7 +266,7 @@ def test(self, pkg):
266266
msg = "Failed to build docker container to test with"
267267
if frame:
268268
self._set_failure_reason = \
269-
TestError(pkg.pkg, msg=msg, frame=frame, errnum=errno.ESPIPE)
269+
ErrorInTest(pkg.pkg, msg=msg, frame=frame, errnum=errno.ESPIPE)
270270
raise self.failure_reason
271271

272272

@@ -301,13 +301,13 @@ def main():
301301
try:
302302
tests = InstallTest()
303303
tests.execute_tests()
304-
except TestError as Error:
304+
except ErrorInTest as Error:
305305
print(str(Error))
306306
exit(1)
307307
traceback.print_exc()
308308
except Exception as Error:
309309
print(str(Error))
310-
TestError(Error, frame=gfi(cf()), errno=-1)
310+
ErrorInTest(Error, frame=gfi(cf()), errno=-1)
311311
print(str(Error))
312312
traceback.print_exc()
313313

f5/bigip/cm/system.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def __init__(self, authn):
4747

4848

4949
class Tmos_s(Collection):
50-
def __init__(self, providers):
51-
super(Tmos_s, self).__init__(providers)
52-
if (self._meta_data['bigip']._meta_data['tmos_version'] < '13.1.0'):
50+
def __init__(self, container):
51+
super(Tmos_s, self).__init__(container)
52+
if container._meta_data['bigip']._meta_data['tmos_version'] < '13.1.0':
5353
# Starting from bigip v13.1.0 tmos resources 'kind' was changed
5454
# from 'mcpremoteproviderstate' to 'authproviderstate'
5555
# and tmos collection 'kind'
@@ -67,9 +67,9 @@ def __init__(self, providers):
6767

6868

6969
class Tmos(Resource):
70-
def __init__(self, tokens):
71-
super(Tmos, self).__init__(tokens)
72-
if (self._meta_data['bigip']._meta_data['tmos_version'] < '13.1.0'):
70+
def __init__(self, container):
71+
super(Tmos, self).__init__(container)
72+
if container._meta_data['bigip']._meta_data['tmos_version'] < '13.1.0':
7373
# Starting from bigip v13.1.0 tmos resource 'kind' was changed
7474
# from 'mcpremoteproviderstate' to 'authproviderstate'
7575
self._meta_data['required_json_kind'] = 'cm:system:authn:providers:tmos:mcpremoteproviderstate'

f5/bigip/cm/test/unit/test_system.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
@pytest.fixture
2424
def FakeTmos():
2525
mo = mock.MagicMock()
26+
r = {'tmos_version': '11.6.0'}
27+
m = mock.MagicMock()
28+
m.__getitem__.side_effect = r.__getitem__
29+
m.__iter__.side_effect = r.__iter__
30+
mo._meta_data['bigip']._meta_data = m
2631
resource = Tmos(mo)
32+
2733
return resource
2834

2935

f5/bigip/tm/security/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from f5.bigip.tm.security.analytics import Analytics
3232
from f5.bigip.tm.security.dos import Dos
3333
from f5.bigip.tm.security.firewall import Firewall
34+
from f5.bigip.tm.security.log import Log
3435
from f5.bigip.tm.security.protocol_inspection import Protocol_Inspection
3536

3637

@@ -39,4 +40,10 @@ class Security(OrganizingCollection):
3940

4041
def __init__(self, tm):
4142
super(Security, self).__init__(tm)
42-
self._meta_data['allowed_lazy_attributes'] = [Dos, Firewall, Analytics, Protocol_Inspection]
43+
self._meta_data['allowed_lazy_attributes'] = [
44+
Analytics,
45+
Dos,
46+
Firewall,
47+
Log,
48+
Protocol_Inspection,
49+
]

0 commit comments

Comments
 (0)