Skip to content

Commit

Permalink
Create pyats_addvlan_ossfuzz.py (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
emomeni authored Jul 15, 2024
1 parent 156712f commit c5627a7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pyats_addvlan_ossfuzz.py
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()

0 comments on commit c5627a7

Please sign in to comment.