-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create pyats_addvlan_ossfuzz.py (#5)
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
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,30 @@ | ||
from hypothesis import given, strategies as st | ||
from pyats import aetest | ||
from pyats.topology import loader | ||
import io | ||
|
||
# Assuming the device configuration functions are accessible | ||
def add_vlan(device, vlan_id, interface_name): | ||
config_commands = f''' | ||
interface {interface_name} | ||
switchport mode trunk | ||
switchport trunk allowed vlan add {vlan_id} | ||
''' | ||
device.configure(config_commands) | ||
|
||
def verify_vlan(device, vlan_id, interface_name): | ||
output = device.execute(f'show interfaces {interface_name} switchport') | ||
return f'Trunking VLANs Enabled: {vlan_id}' in output | ||
|
||
@given(vlan_id=st.integers(min_value=1, max_value=4095), interface_name=st.text()) | ||
def test_add_vlan(vlan_id, interface_name): | ||
# Replace with actual testbed loading and device connection | ||
testbed = loader.load('testbed.yaml') | ||
device = testbed.devices['switch'] | ||
device.connect() | ||
|
||
# Run fuzzing | ||
add_vlan(device, vlan_id, interface_name) | ||
assert verify_vlan(device, vlan_id, interface_name) | ||
|
||
device.disconnect() |