This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a25de9
commit 25d3bc5
Showing
5 changed files
with
97 additions
and
56 deletions.
There are no files selected for viewing
Empty file.
32 changes: 32 additions & 0 deletions
32
catalystwan/integration_tests/feature_profile/sdwan/policy/base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Type | ||
|
||
from catalystwan.api.feature_profile_api import PolicyObjectFeatureProfileAPI | ||
from catalystwan.endpoints.configuration_feature_profile import ConfigurationFeatureProfile | ||
from catalystwan.integration_tests.base import TestCaseBase | ||
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import AnyPolicyObjectParcel | ||
|
||
|
||
class PolicyTestCaseBase(TestCaseBase): | ||
policy_api: PolicyObjectFeatureProfileAPI | ||
parcel_type: Type[AnyPolicyObjectParcel] | ||
|
||
@classmethod | ||
def setUpClass(cls) -> None: | ||
super().setUpClass() | ||
cls.policy_api = cls.session.api.sdwan_feature_profiles.policy_object | ||
cls.profile_uuid = ( | ||
ConfigurationFeatureProfile(cls.session) | ||
.get_sdwan_feature_profiles() | ||
.filter(profile_type="policy-object") | ||
.single_or_default() | ||
).profile_id | ||
|
||
def setUp(self) -> None: | ||
self.created_id = None | ||
return super().setUp() | ||
|
||
def tearDown(self) -> None: | ||
if self.created_id: | ||
self.policy_api.delete(self.profile_uuid, self.parcel_type, self.created_id) | ||
|
||
return super().tearDown() |
33 changes: 33 additions & 0 deletions
33
catalystwan/integration_tests/feature_profile/sdwan/policy/test_extended_community.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
|
||
from catalystwan.integration_tests.base import create_name_with_run_id | ||
from catalystwan.integration_tests.feature_profile.sdwan.policy.base import PolicyTestCaseBase | ||
from catalystwan.models.configuration.feature_profile.sdwan.policy_object import ExtendedCommunityParcel | ||
from catalystwan.typed_list import DataSequence | ||
|
||
|
||
class TestExtendedCommunityParcel(PolicyTestCaseBase): | ||
parcel_type = ExtendedCommunityParcel | ||
|
||
def test_get_all_parcels(self): | ||
parcels = self.policy_api.get(self.profile_uuid, self.parcel_type) | ||
assert type(parcels) is DataSequence | ||
|
||
def test_create_extended_community_parcel(self): | ||
# Arrange | ||
parcel_name = create_name_with_run_id("ext") | ||
ext = ExtendedCommunityParcel(parcel_name=parcel_name) | ||
ext.add_route_target_community(100, 2000) | ||
ext.add_route_target_community(300, 5000) | ||
ext.add_site_of_origin_community("1.2.3.4", 1000) | ||
ext.add_site_of_origin_community("10.20.30.40", 3000) | ||
# Act | ||
self.created_id = self.policy_api.create_parcel(self.profile_uuid, ext).id | ||
parcel = self.policy_api.get(self.profile_uuid, self.parcel_type, parcel_id=self.created_id) | ||
# Assert | ||
assert parcel.payload.parcel_name == parcel_name | ||
assert len(parcel.payload.entries) == 4 | ||
assert parcel.payload.entries[0].extended_community.value == "rt 100:2000" | ||
assert parcel.payload.entries[1].extended_community.value == "rt 300:5000" | ||
assert parcel.payload.entries[2].extended_community.value == "soo 1.2.3.4:1000" | ||
assert parcel.payload.entries[3].extended_community.value == "soo 10.20.30.40:3000" |
32 changes: 32 additions & 0 deletions
32
catalystwan/integration_tests/feature_profile/sdwan/policy/test_security_app_list.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
from catalystwan.integration_tests.base import create_name_with_run_id | ||
from catalystwan.integration_tests.feature_profile.sdwan.policy.base import PolicyTestCaseBase | ||
from catalystwan.models.configuration.feature_profile.sdwan.policy_object.security.application_list import ( | ||
SecurityApplicationListParcel, | ||
) | ||
from catalystwan.typed_list import DataSequence | ||
|
||
|
||
class TestSecurityApplicationListParcelParcel(PolicyTestCaseBase): | ||
parcel_type = SecurityApplicationListParcel | ||
|
||
def test_get_all_parcels(self): | ||
parcels = self.policy_api.get(self.profile_uuid, self.parcel_type) | ||
assert type(parcels) is DataSequence | ||
|
||
def test_createsecurity_application_list_parcel(self): | ||
# Arrange | ||
parcel_name = create_name_with_run_id("sal") | ||
sal = SecurityApplicationListParcel(parcel_name=parcel_name) | ||
sal.add_application_family("web") | ||
sal.add_application_family("file-server") | ||
sal.add_application_family("audio-video") | ||
# Act | ||
self.created_id = self.policy_api.create_parcel(self.profile_uuid, sal).id | ||
parcel = self.policy_api.get(self.profile_uuid, self.parcel_type, parcel_id=self.created_id) | ||
# Assert | ||
assert parcel.payload.parcel_name == parcel_name | ||
assert len(parcel.payload.entries) == 3 | ||
assert parcel.payload.entries[0].app_list_family.value == "web" | ||
assert parcel.payload.entries[1].app_list_family.value == "file-server" | ||
assert parcel.payload.entries[2].app_list_family.value == "audio-video" |
56 changes: 0 additions & 56 deletions
56
catalystwan/integration_tests/feature_profile/sdwan/test_extended_community.py
This file was deleted.
Oops, something went wrong.