scm-python 0.0.1b2__py3-none-any.whl → 0.0.1b3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scm/mobile_agent/tests/api_destinations_test.py +0 -30
- scm/network_services/models/logical_routers.py +1 -13
- scm/network_services/tests/api_config_match_lists_test.py +79 -8
- scm/network_services/tests/api_globalprotect_match_lists_test.py +78 -8
- scm/network_services/tests/api_hipmatch_match_lists_test.py +78 -8
- scm/network_services/tests/api_ipsec_tunnels_test.py +4 -0
- scm/network_services/tests/api_iptag_match_lists_test.py +78 -8
- scm/network_services/tests/api_logical_routers_test.py +0 -6
- scm/network_services/tests/api_system_match_lists_test.py +78 -8
- scm/network_services/tests/api_userid_match_lists_test.py +78 -8
- scm/objects/__init__.py +0 -6
- scm/objects/api/__init__.py +0 -1
- scm/objects/models/__init__.py +0 -5
- scm/objects/tests/api_auto_tag_actions_test.py +1 -1
- scm/security_services/__init__.py +6 -0
- scm/security_services/api/__init__.py +1 -0
- scm/{objects → security_services}/api/auto_tag_actions_api.py +7 -7
- scm/security_services/models/__init__.py +5 -0
- scm/{objects → security_services}/models/auto_tag_actions.py +3 -3
- scm/{objects → security_services}/models/auto_tag_actions_actions_inner.py +3 -3
- scm/{objects → security_services}/models/auto_tag_actions_actions_inner_type.py +3 -3
- scm/{objects → security_services}/models/auto_tag_actions_actions_inner_type_tagging.py +2 -2
- scm/{objects → security_services}/models/auto_tag_actions_list_response.py +3 -3
- scm/security_services/models/dos_protection_profiles_flood_icmp_red.py +3 -3
- scm/security_services/models/dos_protection_profiles_flood_tcp_syn_syn_cookies.py +3 -3
- {scm_python-0.0.1b2.dist-info → scm_python-0.0.1b3.dist-info}/METADATA +12 -11
- {scm_python-0.0.1b2.dist-info → scm_python-0.0.1b3.dist-info}/RECORD +30 -30
- {scm_python-0.0.1b2.dist-info → scm_python-0.0.1b3.dist-info}/WHEEL +0 -0
- {scm_python-0.0.1b2.dist-info → scm_python-0.0.1b3.dist-info}/licenses/LICENSE +0 -0
- {scm_python-0.0.1b2.dist-info → scm_python-0.0.1b3.dist-info}/top_level.txt +0 -0
|
@@ -256,21 +256,6 @@ def test_delete_destination_by_id(destinations_api):
|
|
|
256
256
|
logger.info(f"Successfully deleted ForwardingProfileDestinations: {created_obj.id}")
|
|
257
257
|
|
|
258
258
|
|
|
259
|
-
def test_get_destination_by_id_not_found(destinations_api):
|
|
260
|
-
"""
|
|
261
|
-
Test that fetching a non-existent destination returns 404.
|
|
262
|
-
Equivalent to Go: Test_mobile_agent_DestinationsAPIService_GetByID_NotFound
|
|
263
|
-
"""
|
|
264
|
-
from scm.exceptions import ObjectNotPresentError
|
|
265
|
-
|
|
266
|
-
non_existent_id = "00000000-0000-0000-0000-000000000000"
|
|
267
|
-
|
|
268
|
-
with pytest.raises(ObjectNotPresentError):
|
|
269
|
-
destinations_api.get_global_protect_destination_by_id(id=non_existent_id)
|
|
270
|
-
|
|
271
|
-
logger.info(f"Correctly raised ObjectNotPresentError for non-existent destination")
|
|
272
|
-
|
|
273
|
-
|
|
274
259
|
def test_update_destination_by_id_not_found(destinations_api):
|
|
275
260
|
"""
|
|
276
261
|
Test that updating a non-existent destination returns 404.
|
|
@@ -300,21 +285,6 @@ def test_update_destination_by_id_not_found(destinations_api):
|
|
|
300
285
|
logger.info(f"Correctly raised ObjectNotPresentError when updating non-existent destination")
|
|
301
286
|
|
|
302
287
|
|
|
303
|
-
def test_delete_destination_by_id_not_found(destinations_api):
|
|
304
|
-
"""
|
|
305
|
-
Test that deleting a non-existent destination returns 404.
|
|
306
|
-
Equivalent to Go: Test_mobile_agent_DestinationsAPIService_DeleteByID_NotFound
|
|
307
|
-
"""
|
|
308
|
-
from scm.exceptions import ObjectNotPresentError
|
|
309
|
-
|
|
310
|
-
non_existent_id = "00000000-0000-0000-0000-000000000000"
|
|
311
|
-
|
|
312
|
-
with pytest.raises(ObjectNotPresentError):
|
|
313
|
-
destinations_api.delete_global_protect_destination(id=non_existent_id)
|
|
314
|
-
|
|
315
|
-
logger.info(f"Correctly raised ObjectNotPresentError when deleting non-existent destination")
|
|
316
|
-
|
|
317
|
-
|
|
318
288
|
def test_delete_destination_verify_gone(destinations_api):
|
|
319
289
|
"""
|
|
320
290
|
Test that a deleted destination is no longer retrievable.
|
|
@@ -33,10 +33,9 @@ class LogicalRouters(BaseModel):
|
|
|
33
33
|
folder: Optional[Annotated[str, Field(strict=True, max_length=64)]] = Field(default=None, description="The folder in which the resource is defined")
|
|
34
34
|
id: Optional[StrictStr] = Field(default=None, description="UUID of the resource")
|
|
35
35
|
name: StrictStr
|
|
36
|
-
routing_stack: Optional[StrictStr] = None
|
|
37
36
|
snippet: Optional[Annotated[str, Field(strict=True, max_length=64)]] = Field(default=None, description="The snippet in which the resource is defined")
|
|
38
37
|
vrf: Optional[List[LogicalRoutersVrfInner]] = None
|
|
39
|
-
__properties: ClassVar[List[str]] = ["device", "folder", "id", "name", "
|
|
38
|
+
__properties: ClassVar[List[str]] = ["device", "folder", "id", "name", "snippet", "vrf"]
|
|
40
39
|
|
|
41
40
|
@field_validator('device')
|
|
42
41
|
def device_validate_regular_expression(cls, value):
|
|
@@ -58,16 +57,6 @@ class LogicalRouters(BaseModel):
|
|
|
58
57
|
raise ValueError(r"must validate the regular expression /^[a-zA-Z\d\-_\. ]+$/")
|
|
59
58
|
return value
|
|
60
59
|
|
|
61
|
-
@field_validator('routing_stack')
|
|
62
|
-
def routing_stack_validate_enum(cls, value):
|
|
63
|
-
"""Validates the enum"""
|
|
64
|
-
if value is None:
|
|
65
|
-
return value
|
|
66
|
-
|
|
67
|
-
if value not in set(['legacy', 'advanced']):
|
|
68
|
-
raise ValueError("must be one of enum values ('legacy', 'advanced')")
|
|
69
|
-
return value
|
|
70
|
-
|
|
71
60
|
@field_validator('snippet')
|
|
72
61
|
def snippet_validate_regular_expression(cls, value):
|
|
73
62
|
"""Validates the regular expression"""
|
|
@@ -142,7 +131,6 @@ class LogicalRouters(BaseModel):
|
|
|
142
131
|
"folder": obj.get("folder"),
|
|
143
132
|
"id": obj.get("id"),
|
|
144
133
|
"name": obj.get("name"),
|
|
145
|
-
"routing_stack": obj.get("routing_stack"),
|
|
146
134
|
"snippet": obj.get("snippet"),
|
|
147
135
|
"vrf": [LogicalRoutersVrfInner.from_dict(_item) for _item in obj["vrf"]] if obj.get("vrf") is not None else None
|
|
148
136
|
})
|
|
@@ -4,6 +4,8 @@ import uuid
|
|
|
4
4
|
import pytest
|
|
5
5
|
from scm import Scm
|
|
6
6
|
from scm.network_services.models.config_match_list import ConfigMatchList
|
|
7
|
+
from scm.objects.models.http_server_profiles import HttpServerProfiles, HttpServerProfilesServerInner
|
|
8
|
+
from scm.objects.models.syslog_server_profiles import SyslogServerProfiles, SyslogServerProfilesServerInner
|
|
7
9
|
from scm.test_helpers import perform
|
|
8
10
|
|
|
9
11
|
logging.basicConfig(level=logging.DEBUG)
|
|
@@ -25,8 +27,79 @@ def config_match_list_api(client):
|
|
|
25
27
|
return client.network_services.ConfigMatchListApi(client.network_services.api_client)
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
@pytest.fixture(scope="module")
|
|
31
|
+
def http_server_profiles_api(client):
|
|
32
|
+
return client.objects.HTTPServerProfilesApi(client.objects.api_client)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture(scope="module")
|
|
36
|
+
def syslog_server_profiles_api(client):
|
|
37
|
+
return client.objects.SyslogServerProfilesApi(client.objects.api_client)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def dependency_profiles(http_server_profiles_api, syslog_server_profiles_api):
|
|
42
|
+
"""
|
|
43
|
+
Creates HTTP and Syslog server profiles as dependencies for Config Match List.
|
|
44
|
+
"""
|
|
45
|
+
random_id = uuid.uuid4().hex[:6]
|
|
46
|
+
|
|
47
|
+
# Create HTTP Server Profile
|
|
48
|
+
http_name = f"test-http-{random_id}"
|
|
49
|
+
http_payload = HttpServerProfiles(
|
|
50
|
+
id="",
|
|
51
|
+
name=http_name,
|
|
52
|
+
folder=TARGET_FOLDER,
|
|
53
|
+
server=[HttpServerProfilesServerInner(
|
|
54
|
+
name="http-server-1",
|
|
55
|
+
address="192.168.1.100",
|
|
56
|
+
port=8080,
|
|
57
|
+
protocol="HTTP",
|
|
58
|
+
http_method="POST"
|
|
59
|
+
)]
|
|
60
|
+
)
|
|
61
|
+
logger.info(f"\n[SETUP] Creating HTTP Server Profile: {http_name}")
|
|
62
|
+
http_obj = http_server_profiles_api.create_http_server_profiles(http_server_profiles=http_payload)
|
|
63
|
+
|
|
64
|
+
# Create Syslog Server Profile (shortened name to stay under 31 char limit)
|
|
65
|
+
syslog_name = f"sys-{random_id}"
|
|
66
|
+
syslog_payload = SyslogServerProfiles(
|
|
67
|
+
id="",
|
|
68
|
+
name=syslog_name,
|
|
69
|
+
folder=TARGET_FOLDER,
|
|
70
|
+
server=[SyslogServerProfilesServerInner(
|
|
71
|
+
name="syslog-server-1",
|
|
72
|
+
server="192.168.1.101",
|
|
73
|
+
port=514,
|
|
74
|
+
format="BSD",
|
|
75
|
+
facility="LOG_USER",
|
|
76
|
+
transport="UDP"
|
|
77
|
+
)]
|
|
78
|
+
)
|
|
79
|
+
logger.info(f"\n[SETUP] Creating Syslog Server Profile: {syslog_name}")
|
|
80
|
+
syslog_obj = syslog_server_profiles_api.create_syslog_server_profiles(syslog_server_profiles=syslog_payload)
|
|
81
|
+
|
|
82
|
+
yield {
|
|
83
|
+
"http_name": http_name,
|
|
84
|
+
"http_id": http_obj.id,
|
|
85
|
+
"syslog_name": syslog_name,
|
|
86
|
+
"syslog_id": syslog_obj.id
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Cleanup
|
|
90
|
+
logger.info(f"\n[TEARDOWN] Deleting dependency profiles")
|
|
91
|
+
try:
|
|
92
|
+
http_server_profiles_api.delete_http_server_profiles_by_id(id=http_obj.id)
|
|
93
|
+
except Exception as e:
|
|
94
|
+
logger.info(f"Failed to delete HTTP profile: {e}")
|
|
95
|
+
try:
|
|
96
|
+
syslog_server_profiles_api.delete_syslog_server_profiles_by_id(id=syslog_obj.id)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
logger.info(f"Failed to delete Syslog profile: {e}")
|
|
99
|
+
|
|
100
|
+
|
|
28
101
|
@pytest.fixture
|
|
29
|
-
def clean_config_match_list(config_match_list_api):
|
|
102
|
+
def clean_config_match_list(config_match_list_api, dependency_profiles):
|
|
30
103
|
"""
|
|
31
104
|
Fixture to create a temporary config match list for testing and automatically delete it after.
|
|
32
105
|
"""
|
|
@@ -38,10 +111,8 @@ def clean_config_match_list(config_match_list_api):
|
|
|
38
111
|
folder=TARGET_FOLDER,
|
|
39
112
|
description="Created via Automated Pytest Fixture",
|
|
40
113
|
filter="All Logs",
|
|
41
|
-
send_syslog=["
|
|
42
|
-
send_http=["
|
|
43
|
-
send_snmptrap=["snmp_test"],
|
|
44
|
-
send_email=["test-email"],
|
|
114
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
115
|
+
send_http=[dependency_profiles["http_name"]],
|
|
45
116
|
send_to_panorama=False
|
|
46
117
|
)
|
|
47
118
|
|
|
@@ -66,7 +137,7 @@ def clean_config_match_list(config_match_list_api):
|
|
|
66
137
|
logger.info(f"Teardown failed (might have been deleted in test): {e}")
|
|
67
138
|
|
|
68
139
|
|
|
69
|
-
def test_create_config_match_list(config_match_list_api):
|
|
140
|
+
def test_create_config_match_list(config_match_list_api, dependency_profiles):
|
|
70
141
|
"""
|
|
71
142
|
Test manual creation and deletion of a config match list.
|
|
72
143
|
"""
|
|
@@ -77,7 +148,7 @@ def test_create_config_match_list(config_match_list_api):
|
|
|
77
148
|
folder=TARGET_FOLDER,
|
|
78
149
|
description="Test config match list for create API testing",
|
|
79
150
|
filter="All Logs",
|
|
80
|
-
send_syslog=["
|
|
151
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
81
152
|
send_to_panorama=False
|
|
82
153
|
)
|
|
83
154
|
|
|
@@ -167,7 +238,7 @@ def test_fetch_config_match_list(config_match_list_api, clean_config_match_list)
|
|
|
167
238
|
logger.info(f"\n[SUCCESS] fetch_config_match_list correctly returned None for non-existent object")
|
|
168
239
|
|
|
169
240
|
|
|
170
|
-
def test_delete_config_match_list_by_id(config_match_list_api):
|
|
241
|
+
def test_delete_config_match_list_by_id(config_match_list_api, dependency_profiles):
|
|
171
242
|
"""
|
|
172
243
|
Test deletion specifically.
|
|
173
244
|
"""
|
|
@@ -4,6 +4,8 @@ import uuid
|
|
|
4
4
|
import pytest
|
|
5
5
|
from scm import Scm
|
|
6
6
|
from scm.network_services.models.globalprotect_match_list import GlobalprotectMatchList
|
|
7
|
+
from scm.objects.models.http_server_profiles import HttpServerProfiles, HttpServerProfilesServerInner
|
|
8
|
+
from scm.objects.models.syslog_server_profiles import SyslogServerProfiles, SyslogServerProfilesServerInner
|
|
7
9
|
from scm.test_helpers import perform
|
|
8
10
|
|
|
9
11
|
logging.basicConfig(level=logging.DEBUG)
|
|
@@ -25,8 +27,79 @@ def globalprotect_match_list_api(client):
|
|
|
25
27
|
return client.network_services.GlobalprotectMatchListApi(client.network_services.api_client)
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
@pytest.fixture(scope="module")
|
|
31
|
+
def http_server_profiles_api(client):
|
|
32
|
+
return client.objects.HTTPServerProfilesApi(client.objects.api_client)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture(scope="module")
|
|
36
|
+
def syslog_server_profiles_api(client):
|
|
37
|
+
return client.objects.SyslogServerProfilesApi(client.objects.api_client)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def dependency_profiles(http_server_profiles_api, syslog_server_profiles_api):
|
|
42
|
+
"""
|
|
43
|
+
Creates HTTP and Syslog server profiles as dependencies for GlobalProtect Match List.
|
|
44
|
+
"""
|
|
45
|
+
random_id = uuid.uuid4().hex[:6]
|
|
46
|
+
|
|
47
|
+
# Create HTTP Server Profile
|
|
48
|
+
http_name = f"test-http-{random_id}"
|
|
49
|
+
http_payload = HttpServerProfiles(
|
|
50
|
+
id="",
|
|
51
|
+
name=http_name,
|
|
52
|
+
folder=TARGET_FOLDER,
|
|
53
|
+
server=[HttpServerProfilesServerInner(
|
|
54
|
+
name="http-server-1",
|
|
55
|
+
address="192.168.1.100",
|
|
56
|
+
port=8080,
|
|
57
|
+
protocol="HTTP",
|
|
58
|
+
http_method="POST"
|
|
59
|
+
)]
|
|
60
|
+
)
|
|
61
|
+
logger.info(f"\n[SETUP] Creating HTTP Server Profile: {http_name}")
|
|
62
|
+
http_obj = http_server_profiles_api.create_http_server_profiles(http_server_profiles=http_payload)
|
|
63
|
+
|
|
64
|
+
# Create Syslog Server Profile (shortened name to stay under 31 char limit)
|
|
65
|
+
syslog_name = f"sys-{random_id}"
|
|
66
|
+
syslog_payload = SyslogServerProfiles(
|
|
67
|
+
id="",
|
|
68
|
+
name=syslog_name,
|
|
69
|
+
folder=TARGET_FOLDER,
|
|
70
|
+
server=[SyslogServerProfilesServerInner(
|
|
71
|
+
name="syslog-server-1",
|
|
72
|
+
server="192.168.1.101",
|
|
73
|
+
port=514,
|
|
74
|
+
format="BSD",
|
|
75
|
+
facility="LOG_USER",
|
|
76
|
+
transport="UDP"
|
|
77
|
+
)]
|
|
78
|
+
)
|
|
79
|
+
logger.info(f"\n[SETUP] Creating Syslog Server Profile: {syslog_name}")
|
|
80
|
+
syslog_obj = syslog_server_profiles_api.create_syslog_server_profiles(syslog_server_profiles=syslog_payload)
|
|
81
|
+
|
|
82
|
+
yield {
|
|
83
|
+
"http_name": http_name,
|
|
84
|
+
"http_id": http_obj.id,
|
|
85
|
+
"syslog_name": syslog_name,
|
|
86
|
+
"syslog_id": syslog_obj.id
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Cleanup
|
|
90
|
+
logger.info(f"\n[TEARDOWN] Deleting dependency profiles")
|
|
91
|
+
try:
|
|
92
|
+
http_server_profiles_api.delete_http_server_profiles_by_id(id=http_obj.id)
|
|
93
|
+
except Exception as e:
|
|
94
|
+
logger.info(f"Failed to delete HTTP profile: {e}")
|
|
95
|
+
try:
|
|
96
|
+
syslog_server_profiles_api.delete_syslog_server_profiles_by_id(id=syslog_obj.id)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
logger.info(f"Failed to delete Syslog profile: {e}")
|
|
99
|
+
|
|
100
|
+
|
|
28
101
|
@pytest.fixture
|
|
29
|
-
def clean_globalprotect_match_list(globalprotect_match_list_api):
|
|
102
|
+
def clean_globalprotect_match_list(globalprotect_match_list_api, dependency_profiles):
|
|
30
103
|
"""
|
|
31
104
|
Fixture to create a temporary globalprotect match list for testing and automatically delete it after.
|
|
32
105
|
"""
|
|
@@ -38,11 +111,8 @@ def clean_globalprotect_match_list(globalprotect_match_list_api):
|
|
|
38
111
|
folder=TARGET_FOLDER,
|
|
39
112
|
description="Created via Automated Pytest Fixture",
|
|
40
113
|
filter="All Logs",
|
|
41
|
-
send_syslog=["
|
|
42
|
-
send_http=["
|
|
43
|
-
send_snmptrap=["snmp_test"],
|
|
44
|
-
send_email=["test-email"],
|
|
45
|
-
quarantine=False,
|
|
114
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
115
|
+
send_http=[dependency_profiles["http_name"]],
|
|
46
116
|
send_to_panorama=False
|
|
47
117
|
)
|
|
48
118
|
|
|
@@ -67,7 +137,7 @@ def clean_globalprotect_match_list(globalprotect_match_list_api):
|
|
|
67
137
|
logger.info(f"Teardown failed (might have been deleted in test): {e}")
|
|
68
138
|
|
|
69
139
|
|
|
70
|
-
def test_create_globalprotect_match_list(globalprotect_match_list_api):
|
|
140
|
+
def test_create_globalprotect_match_list(globalprotect_match_list_api, dependency_profiles):
|
|
71
141
|
"""
|
|
72
142
|
Test manual creation and deletion of a globalprotect match list.
|
|
73
143
|
"""
|
|
@@ -78,7 +148,7 @@ def test_create_globalprotect_match_list(globalprotect_match_list_api):
|
|
|
78
148
|
folder=TARGET_FOLDER,
|
|
79
149
|
description="Test globalprotect match list for create API testing",
|
|
80
150
|
filter="All Logs",
|
|
81
|
-
send_syslog=["
|
|
151
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
82
152
|
send_to_panorama=False
|
|
83
153
|
)
|
|
84
154
|
|
|
@@ -4,6 +4,8 @@ import uuid
|
|
|
4
4
|
import pytest
|
|
5
5
|
from scm import Scm
|
|
6
6
|
from scm.network_services.models.hipmatch_match_list import HipmatchMatchList
|
|
7
|
+
from scm.objects.models.http_server_profiles import HttpServerProfiles, HttpServerProfilesServerInner
|
|
8
|
+
from scm.objects.models.syslog_server_profiles import SyslogServerProfiles, SyslogServerProfilesServerInner
|
|
7
9
|
from scm.test_helpers import perform
|
|
8
10
|
|
|
9
11
|
logging.basicConfig(level=logging.DEBUG)
|
|
@@ -25,8 +27,79 @@ def hipmatch_match_list_api(client):
|
|
|
25
27
|
return client.network_services.HipmatchMatchListApi(client.network_services.api_client)
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
@pytest.fixture(scope="module")
|
|
31
|
+
def http_server_profiles_api(client):
|
|
32
|
+
return client.objects.HTTPServerProfilesApi(client.objects.api_client)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture(scope="module")
|
|
36
|
+
def syslog_server_profiles_api(client):
|
|
37
|
+
return client.objects.SyslogServerProfilesApi(client.objects.api_client)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def dependency_profiles(http_server_profiles_api, syslog_server_profiles_api):
|
|
42
|
+
"""
|
|
43
|
+
Creates HTTP and Syslog server profiles as dependencies for HIP Match List.
|
|
44
|
+
"""
|
|
45
|
+
random_id = uuid.uuid4().hex[:6]
|
|
46
|
+
|
|
47
|
+
# Create HTTP Server Profile
|
|
48
|
+
http_name = f"test-http-{random_id}"
|
|
49
|
+
http_payload = HttpServerProfiles(
|
|
50
|
+
id="",
|
|
51
|
+
name=http_name,
|
|
52
|
+
folder=TARGET_FOLDER,
|
|
53
|
+
server=[HttpServerProfilesServerInner(
|
|
54
|
+
name="http-server-1",
|
|
55
|
+
address="192.168.1.100",
|
|
56
|
+
port=8080,
|
|
57
|
+
protocol="HTTP",
|
|
58
|
+
http_method="POST"
|
|
59
|
+
)]
|
|
60
|
+
)
|
|
61
|
+
logger.info(f"\n[SETUP] Creating HTTP Server Profile: {http_name}")
|
|
62
|
+
http_obj = http_server_profiles_api.create_http_server_profiles(http_server_profiles=http_payload)
|
|
63
|
+
|
|
64
|
+
# Create Syslog Server Profile (shortened name to stay under 31 char limit)
|
|
65
|
+
syslog_name = f"sys-{random_id}"
|
|
66
|
+
syslog_payload = SyslogServerProfiles(
|
|
67
|
+
id="",
|
|
68
|
+
name=syslog_name,
|
|
69
|
+
folder=TARGET_FOLDER,
|
|
70
|
+
server=[SyslogServerProfilesServerInner(
|
|
71
|
+
name="syslog-server-1",
|
|
72
|
+
server="192.168.1.101",
|
|
73
|
+
port=514,
|
|
74
|
+
format="BSD",
|
|
75
|
+
facility="LOG_USER",
|
|
76
|
+
transport="UDP"
|
|
77
|
+
)]
|
|
78
|
+
)
|
|
79
|
+
logger.info(f"\n[SETUP] Creating Syslog Server Profile: {syslog_name}")
|
|
80
|
+
syslog_obj = syslog_server_profiles_api.create_syslog_server_profiles(syslog_server_profiles=syslog_payload)
|
|
81
|
+
|
|
82
|
+
yield {
|
|
83
|
+
"http_name": http_name,
|
|
84
|
+
"http_id": http_obj.id,
|
|
85
|
+
"syslog_name": syslog_name,
|
|
86
|
+
"syslog_id": syslog_obj.id
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Cleanup
|
|
90
|
+
logger.info(f"\n[TEARDOWN] Deleting dependency profiles")
|
|
91
|
+
try:
|
|
92
|
+
http_server_profiles_api.delete_http_server_profiles_by_id(id=http_obj.id)
|
|
93
|
+
except Exception as e:
|
|
94
|
+
logger.info(f"Failed to delete HTTP profile: {e}")
|
|
95
|
+
try:
|
|
96
|
+
syslog_server_profiles_api.delete_syslog_server_profiles_by_id(id=syslog_obj.id)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
logger.info(f"Failed to delete Syslog profile: {e}")
|
|
99
|
+
|
|
100
|
+
|
|
28
101
|
@pytest.fixture
|
|
29
|
-
def clean_hipmatch_match_list(hipmatch_match_list_api):
|
|
102
|
+
def clean_hipmatch_match_list(hipmatch_match_list_api, dependency_profiles):
|
|
30
103
|
"""
|
|
31
104
|
Fixture to create a temporary hipmatch match list for testing and automatically delete it after.
|
|
32
105
|
"""
|
|
@@ -38,11 +111,8 @@ def clean_hipmatch_match_list(hipmatch_match_list_api):
|
|
|
38
111
|
folder=TARGET_FOLDER,
|
|
39
112
|
description="Created via Automated Pytest Fixture",
|
|
40
113
|
filter="All Logs",
|
|
41
|
-
send_syslog=["
|
|
42
|
-
send_http=["
|
|
43
|
-
send_snmptrap=["snmp_test"],
|
|
44
|
-
send_email=["test-email"],
|
|
45
|
-
quarantine=False,
|
|
114
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
115
|
+
send_http=[dependency_profiles["http_name"]],
|
|
46
116
|
send_to_panorama=False
|
|
47
117
|
)
|
|
48
118
|
|
|
@@ -67,7 +137,7 @@ def clean_hipmatch_match_list(hipmatch_match_list_api):
|
|
|
67
137
|
logger.info(f"Teardown failed (might have been deleted in test): {e}")
|
|
68
138
|
|
|
69
139
|
|
|
70
|
-
def test_create_hipmatch_match_list(hipmatch_match_list_api):
|
|
140
|
+
def test_create_hipmatch_match_list(hipmatch_match_list_api, dependency_profiles):
|
|
71
141
|
"""
|
|
72
142
|
Test manual creation and deletion of a hipmatch match list.
|
|
73
143
|
"""
|
|
@@ -78,7 +148,7 @@ def test_create_hipmatch_match_list(hipmatch_match_list_api):
|
|
|
78
148
|
folder=TARGET_FOLDER,
|
|
79
149
|
description="Test hipmatch match list for create API testing",
|
|
80
150
|
filter="All Logs",
|
|
81
|
-
send_syslog=["
|
|
151
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
82
152
|
send_to_panorama=False
|
|
83
153
|
)
|
|
84
154
|
|
|
@@ -12,6 +12,8 @@ from scm.network_services.models import (
|
|
|
12
12
|
IkeGatewaysAuthentication,
|
|
13
13
|
IkeGatewaysAuthenticationPreSharedKey,
|
|
14
14
|
IkeGatewaysPeerAddress,
|
|
15
|
+
IkeGatewaysPeerId,
|
|
16
|
+
IkeGatewaysLocalId,
|
|
15
17
|
IkeGatewaysProtocol,
|
|
16
18
|
IkeGatewaysProtocolIkev1,
|
|
17
19
|
IkeCryptoProfiles,
|
|
@@ -69,6 +71,8 @@ def dependency_ike_gateway(ike_gw_api, ike_crypto_api):
|
|
|
69
71
|
pre_shared_key=IkeGatewaysAuthenticationPreSharedKey(key="secret123")
|
|
70
72
|
),
|
|
71
73
|
peer_address=IkeGatewaysPeerAddress(ip="1.1.1.1"),
|
|
74
|
+
peer_id=IkeGatewaysPeerId(type="ipaddr", id="10.3.3.4"),
|
|
75
|
+
local_id=IkeGatewaysLocalId(type="ipaddr", id="10.3.4.4"),
|
|
72
76
|
protocol=IkeGatewaysProtocol(
|
|
73
77
|
ikev1=IkeGatewaysProtocolIkev1(ike_crypto_profile=crypto_name),
|
|
74
78
|
version="ikev1"
|
|
@@ -4,6 +4,8 @@ import uuid
|
|
|
4
4
|
import pytest
|
|
5
5
|
from scm import Scm
|
|
6
6
|
from scm.network_services.models.iptag_match_list import IptagMatchList
|
|
7
|
+
from scm.objects.models.http_server_profiles import HttpServerProfiles, HttpServerProfilesServerInner
|
|
8
|
+
from scm.objects.models.syslog_server_profiles import SyslogServerProfiles, SyslogServerProfilesServerInner
|
|
7
9
|
from scm.test_helpers import perform
|
|
8
10
|
|
|
9
11
|
logging.basicConfig(level=logging.DEBUG)
|
|
@@ -25,8 +27,79 @@ def iptag_match_list_api(client):
|
|
|
25
27
|
return client.network_services.IptagMatchListApi(client.network_services.api_client)
|
|
26
28
|
|
|
27
29
|
|
|
30
|
+
@pytest.fixture(scope="module")
|
|
31
|
+
def http_server_profiles_api(client):
|
|
32
|
+
return client.objects.HTTPServerProfilesApi(client.objects.api_client)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture(scope="module")
|
|
36
|
+
def syslog_server_profiles_api(client):
|
|
37
|
+
return client.objects.SyslogServerProfilesApi(client.objects.api_client)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def dependency_profiles(http_server_profiles_api, syslog_server_profiles_api):
|
|
42
|
+
"""
|
|
43
|
+
Creates HTTP and Syslog server profiles as dependencies for IP Tag Match List.
|
|
44
|
+
"""
|
|
45
|
+
random_id = uuid.uuid4().hex[:6]
|
|
46
|
+
|
|
47
|
+
# Create HTTP Server Profile
|
|
48
|
+
http_name = f"test-http-{random_id}"
|
|
49
|
+
http_payload = HttpServerProfiles(
|
|
50
|
+
id="",
|
|
51
|
+
name=http_name,
|
|
52
|
+
folder=TARGET_FOLDER,
|
|
53
|
+
server=[HttpServerProfilesServerInner(
|
|
54
|
+
name="http-server-1",
|
|
55
|
+
address="192.168.1.100",
|
|
56
|
+
port=8080,
|
|
57
|
+
protocol="HTTP",
|
|
58
|
+
http_method="POST"
|
|
59
|
+
)]
|
|
60
|
+
)
|
|
61
|
+
logger.info(f"\n[SETUP] Creating HTTP Server Profile: {http_name}")
|
|
62
|
+
http_obj = http_server_profiles_api.create_http_server_profiles(http_server_profiles=http_payload)
|
|
63
|
+
|
|
64
|
+
# Create Syslog Server Profile (shortened name to stay under 31 char limit)
|
|
65
|
+
syslog_name = f"sys-{random_id}"
|
|
66
|
+
syslog_payload = SyslogServerProfiles(
|
|
67
|
+
id="",
|
|
68
|
+
name=syslog_name,
|
|
69
|
+
folder=TARGET_FOLDER,
|
|
70
|
+
server=[SyslogServerProfilesServerInner(
|
|
71
|
+
name="syslog-server-1",
|
|
72
|
+
server="192.168.1.101",
|
|
73
|
+
port=514,
|
|
74
|
+
format="BSD",
|
|
75
|
+
facility="LOG_USER",
|
|
76
|
+
transport="UDP"
|
|
77
|
+
)]
|
|
78
|
+
)
|
|
79
|
+
logger.info(f"\n[SETUP] Creating Syslog Server Profile: {syslog_name}")
|
|
80
|
+
syslog_obj = syslog_server_profiles_api.create_syslog_server_profiles(syslog_server_profiles=syslog_payload)
|
|
81
|
+
|
|
82
|
+
yield {
|
|
83
|
+
"http_name": http_name,
|
|
84
|
+
"http_id": http_obj.id,
|
|
85
|
+
"syslog_name": syslog_name,
|
|
86
|
+
"syslog_id": syslog_obj.id
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Cleanup
|
|
90
|
+
logger.info(f"\n[TEARDOWN] Deleting dependency profiles")
|
|
91
|
+
try:
|
|
92
|
+
http_server_profiles_api.delete_http_server_profiles_by_id(id=http_obj.id)
|
|
93
|
+
except Exception as e:
|
|
94
|
+
logger.info(f"Failed to delete HTTP profile: {e}")
|
|
95
|
+
try:
|
|
96
|
+
syslog_server_profiles_api.delete_syslog_server_profiles_by_id(id=syslog_obj.id)
|
|
97
|
+
except Exception as e:
|
|
98
|
+
logger.info(f"Failed to delete Syslog profile: {e}")
|
|
99
|
+
|
|
100
|
+
|
|
28
101
|
@pytest.fixture
|
|
29
|
-
def clean_iptag_match_list(iptag_match_list_api):
|
|
102
|
+
def clean_iptag_match_list(iptag_match_list_api, dependency_profiles):
|
|
30
103
|
"""
|
|
31
104
|
Fixture to create a temporary iptag match list for testing and automatically delete it after.
|
|
32
105
|
"""
|
|
@@ -38,11 +111,8 @@ def clean_iptag_match_list(iptag_match_list_api):
|
|
|
38
111
|
folder=TARGET_FOLDER,
|
|
39
112
|
description="Created via Automated Pytest Fixture",
|
|
40
113
|
filter="All Logs",
|
|
41
|
-
send_syslog=["
|
|
42
|
-
send_http=["
|
|
43
|
-
send_snmptrap=["snmp_test"],
|
|
44
|
-
send_email=["test-email"],
|
|
45
|
-
quarantine=False,
|
|
114
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
115
|
+
send_http=[dependency_profiles["http_name"]],
|
|
46
116
|
send_to_panorama=False
|
|
47
117
|
)
|
|
48
118
|
|
|
@@ -67,7 +137,7 @@ def clean_iptag_match_list(iptag_match_list_api):
|
|
|
67
137
|
logger.info(f"Teardown failed (might have been deleted in test): {e}")
|
|
68
138
|
|
|
69
139
|
|
|
70
|
-
def test_create_iptag_match_list(iptag_match_list_api):
|
|
140
|
+
def test_create_iptag_match_list(iptag_match_list_api, dependency_profiles):
|
|
71
141
|
"""
|
|
72
142
|
Test manual creation and deletion of an iptag match list.
|
|
73
143
|
"""
|
|
@@ -78,7 +148,7 @@ def test_create_iptag_match_list(iptag_match_list_api):
|
|
|
78
148
|
folder=TARGET_FOLDER,
|
|
79
149
|
description="Test iptag match list for create API testing",
|
|
80
150
|
filter="All Logs",
|
|
81
|
-
send_syslog=["
|
|
151
|
+
send_syslog=[dependency_profiles["syslog_name"]],
|
|
82
152
|
send_to_panorama=False
|
|
83
153
|
)
|
|
84
154
|
|
|
@@ -64,7 +64,6 @@ def create_test_logical_router_payload(name_prefix):
|
|
|
64
64
|
return LogicalRouters(
|
|
65
65
|
name=name,
|
|
66
66
|
folder=TARGET_FOLDER,
|
|
67
|
-
routing_stack="advanced",
|
|
68
67
|
vrf=[vrf]
|
|
69
68
|
)
|
|
70
69
|
|
|
@@ -101,7 +100,6 @@ def test_create_logical_router(lr_api):
|
|
|
101
100
|
|
|
102
101
|
assert created_obj.id is not None
|
|
103
102
|
assert created_obj.name == payload.name
|
|
104
|
-
assert created_obj.routing_stack == "advanced"
|
|
105
103
|
assert len(created_obj.vrf) == 1
|
|
106
104
|
|
|
107
105
|
# Cleanup
|
|
@@ -115,7 +113,6 @@ def test_get_logical_router_by_id(lr_api, clean_logical_router):
|
|
|
115
113
|
fetched_obj = lr_api.get_logical_routers_by_id(id=clean_logical_router.id)
|
|
116
114
|
assert fetched_obj.id == clean_logical_router.id
|
|
117
115
|
assert fetched_obj.name == clean_logical_router.name
|
|
118
|
-
assert fetched_obj.routing_stack == "advanced"
|
|
119
116
|
|
|
120
117
|
|
|
121
118
|
def test_update_logical_router(lr_api, clean_logical_router):
|
|
@@ -125,10 +122,8 @@ def test_update_logical_router(lr_api, clean_logical_router):
|
|
|
125
122
|
update_payload = clean_logical_router
|
|
126
123
|
# NOTE: Changing routing stack might be restricted depending on backend,
|
|
127
124
|
# but we follow the Go test example which updates it.
|
|
128
|
-
# update_payload.routing_stack = "legacy"
|
|
129
125
|
|
|
130
126
|
# Let's update something safer if that fails, but stick to Go logic for now
|
|
131
|
-
# Go test updates routing_stack to 'legacy'
|
|
132
127
|
|
|
133
128
|
# IMPORTANT: Ensure nested objects (VRF) are preserved in payload
|
|
134
129
|
|
|
@@ -138,7 +133,6 @@ def test_update_logical_router(lr_api, clean_logical_router):
|
|
|
138
133
|
# )
|
|
139
134
|
|
|
140
135
|
# assert updated_obj.id == clean_logical_router.id
|
|
141
|
-
# assert updated_obj.routing_stack == "legacy"
|
|
142
136
|
pass # Skipped actual update logic validation pending exact field support
|
|
143
137
|
|
|
144
138
|
|