Example #1
0
    def test_show_running_config_on_empty_ethernet_port(self, t):
        enable(t)

        t.write("show running-config interface tengigabitethernet 0/0/1")
        t.readln("")
        t.readln("")
        t.read("my_switch#")
Example #2
0
    def test_access_vlan_that_doesnt_exist_prints_a_warning_and_config_is_unchanged(
            self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport access vlan 1200")
        t.readln("")
        t.readln("VLAN ID not found.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [""])
Example #3
0
    def test_show_vlan(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)
        add_vlan(t, 12)
        configuring_vlan(t, 17, do="name this-name-is-too-long-buddy-budd")
        add_vlan(t, 100)
        add_vlan(t, 1000)

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                                          Static")
        t.readln("11     VLAN11                                          Static")
        t.readln("12     VLAN12                                          Static")
        t.readln("17     this-name-is-too-long-buddy-budd                Static")
        t.readln("100    VLAN100                                         Static")
        t.readln("1000   VLAN1000                                        Static")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
        configuring(t, do="no vlan 12")
        configuring(t, do="no vlan 17")
        configuring(t, do="no vlan 100")
        configuring(t, do="no vlan 1000")
Example #4
0
    def test_show_vlan_id(self, t):
        enable(t)

        add_vlan(t, 1000)

        t.write("show vlan id 500")
        t.readln("")
        t.readln("ERROR: This VLAN does not exist.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id 1000")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1000   VLAN1000                                        Static")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id bleh")
        t.readln("                     ^")
        t.readln("Invalid input. Please specify an integer in the range 1 to 4093.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id")
        t.readln("")
        t.readln("Command not found / Incomplete command. Use ? to list commands.")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 1000")
    def test_show_interfaces_status(self, t):
        enable(t)

        configuring_interface(t, "tengigabitethernet 0/0/1", do='description "longer name than whats allowed"')
        create_bond(t, 43)

        t.write("show interfaces status")
        t.readln("")
        t.readln("Port      Description               Vlan  Duplex Speed   Neg  Link   Flow Ctrl")
        t.readln("                                                              State  Status")
        t.readln("--------- ------------------------- ----- ------ ------- ---- ------ ---------")
        t.readln("Te0/0/1   longer name than whats al       Full   10000   Auto Up     Active")
        t.readln("Te0/0/2                                   Full   10000   Auto Up     Active")
        t.readln("Te1/0/1                                   Full   10000   Auto Up     Active")
        t.readln("Te1/0/2                                   Full   10000   Auto Up     Active")
        t.readln("")
        t.readln("")
        t.readln("Port    Description                    Vlan  Link")
        t.readln("Channel                                      State")
        t.readln("------- ------------------------------ ----- -------")
        t.readln("Po43                                   trnk  Up")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no description")

        remove_bond(t, 43)
    def test_lldp_options_defaults_to_enabled(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp transmit')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp receive')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp med')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp med transmit-tlv capabilities')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp med transmit-tlv network-policy')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            'no lldp transmit',
            'no lldp receive',
            'no lldp med',
            'no lldp med transmit-tlv capabilities',
            'no lldp med transmit-tlv network-policy',
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp transmit')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp receive')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp med')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp med transmit-tlv capabilities')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp med transmit-tlv network-policy')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            '',
        ])
Example #7
0
    def test_invalid_command(self, t):
        enable(t)

        t.write("shizzle")
        t.readln("          ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
Example #8
0
    def test_10g_does_not_support_mtu_command_on_interface(self, t):
        enable(t)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("mtu 5000")
        t.readln("                                                     ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("no mtu")
        t.readln("                                                     ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")
    def test_access_vlan_that_doesnt_exist_prints_a_warning_and_config_is_unchanged(self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport access vlan 1200")
        t.readln("")
        t.readln("VLAN ID not found.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])
Example #10
0
    def test_show_vlan_id(self, t):
        enable(t)

        add_vlan(t, 1000)

        t.write("show vlan id 500")
        t.readln("")
        t.readln("ERROR: This VLAN does not exist.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id 1000")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1000   VLAN1000                                        Static")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id bleh")
        t.readln("                     ^")
        t.readln("Invalid input. Please specify an integer in the range 1 to 4093.")
        t.readln("")
        t.read("my_switch#")

        t.write("show vlan id")
        t.readln("")
        t.readln("Command not found / Incomplete command. Use ? to list commands.")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 1000")
Example #11
0
    def test_show_vlan_with_ports(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport mode trunk")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan 10-11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan 11")

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                           Te0/0/1-2      Static")
        t.readln("11     VLAN11                           Te0/0/1,       Static")
        t.readln("                                        Te1/0/2        ")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "tengigabitethernet 0/0/1", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 0/0/2", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 1/0/2", "no switchport mode")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan remove 10,11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan remove 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan remove 11")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
Example #12
0
    def test_show_vlan(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)
        add_vlan(t, 12)
        configuring_vlan(t, 17, do="name this-name-is-too-long-buddy-budd")
        add_vlan(t, 100)
        add_vlan(t, 1000)

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                                          Static")
        t.readln("11     VLAN11                                          Static")
        t.readln("12     VLAN12                                          Static")
        t.readln("17     this-name-is-too-long-buddy-budd                Static")
        t.readln("100    VLAN100                                         Static")
        t.readln("1000   VLAN1000                                        Static")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
        configuring(t, do="no vlan 12")
        configuring(t, do="no vlan 17")
        configuring(t, do="no vlan 100")
        configuring(t, do="no vlan 1000")
    def test_switchport_mode(self, t):
        enable(t)

        add_vlan(t, 1264)
        add_vlan(t, 1265)

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport access vlan 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode general")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264",
            "switchport general pvid 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport access vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general allowed vlan add 1265")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1265",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general allowed vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring(t, do="no vlan 1265")
        configuring(t, do="no vlan 1264")
    def test_show_interfaces_status(self, t):
        enable(t)

        configuring_interface(t, "tengigabitethernet 0/0/1", do="description \"longer name than whats allowed\"")
        create_bond(t, 43)

        t.write("show interfaces status")
        t.readln("")
        t.readln("Port      Description               Vlan  Duplex Speed   Neg  Link   Flow Ctrl")
        t.readln("                                                              State  Status")
        t.readln("--------- ------------------------- ----- ------ ------- ---- ------ ---------")
        t.readln("Te0/0/1   longer name than whats al       Full   10000   Auto Up     Active")
        t.readln("Te0/0/2                                   Full   10000   Auto Up     Active")
        t.readln("Te1/0/1                                   Full   10000   Auto Up     Active")
        t.readln("Te1/0/2                                   Full   10000   Auto Up     Active")
        t.readln("")
        t.readln("")
        t.readln("Port    Description                    Vlan  Link")
        t.readln("Channel                                      State")
        t.readln("------- ------------------------------ ----- -------")
        t.readln("Po43                                   trnk  Up")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no description")

        remove_bond(t, 43)
    def test_lldp_options_defaults_to_enabled(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no lldp transmit")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no lldp receive")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no lldp med")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no lldp med transmit-tlv capabilities")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no lldp med transmit-tlv network-policy")

        assert_interface_configuration(
            t,
            "tengigabitethernet 0/0/1",
            [
                "no lldp transmit",
                "no lldp receive",
                "no lldp med",
                "no lldp med transmit-tlv capabilities",
                "no lldp med transmit-tlv network-policy",
            ],
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="lldp transmit")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="lldp receive")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="lldp med")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="lldp med transmit-tlv capabilities")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="lldp med transmit-tlv network-policy")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])
    def test_switchport_mode(self, t):
        enable(t)

        add_vlan(t, 1264)
        add_vlan(t, 1265)

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport access vlan 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode general")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport access vlan 1264",
            "switchport general pvid 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport access vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general allowed vlan add 1265")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport general pvid 1264",
            "switchport general allowed vlan add 1265",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general allowed vlan")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring(t, do="no vlan 1265")
        configuring(t, do="no vlan 1264")
Example #17
0
    def test_show_running_config_on_empty_ethernet_port(self, t):
        enable(t)

        t.write("show running-config interface tengigabitethernet 0/0/1")
        t.readln("")
        t.readln("")
        t.read("my_switch#")
Example #18
0
    def test_invalid_command(self, t):
        enable(t)

        t.write("shizzle")
        t.readln("          ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
    def test_lldp_options_defaults_to_enabled(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp transmit')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp receive')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp med')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp med transmit-tlv capabilities')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no lldp med transmit-tlv network-policy')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            'no lldp transmit',
            'no lldp receive',
            'no lldp med',
            'no lldp med transmit-tlv capabilities',
            'no lldp med transmit-tlv network-policy',
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp transmit')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp receive')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp med')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp med transmit-tlv capabilities')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='lldp med transmit-tlv network-policy')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            '',
        ])
    def test_10g_does_not_support_mtu_command_on_interface(self, t):
        enable(t)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("mtu 5000")
        t.readln("                                                     ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("no mtu")
        t.readln("                                                     ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #21
0
    def test_show_vlan_with_ports(self, t):
        enable(t)

        add_vlan(t, 10)
        add_vlan(t, 11)

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport mode trunk")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan 10-11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan 11")

        t.write("show vlan")
        t.readln("")
        t.readln("VLAN   Name                             Ports          Type")
        t.readln("-----  ---------------                  -------------  --------------")
        t.readln("1      default                                         Default")
        t.readln("10     VLAN10                           Te0/0/1-2      Static")
        t.readln("11     VLAN11                           Te0/0/1,       Static")
        t.readln("                                        Te1/0/2        ")
        t.readln("")
        t.read("my_switch#")

        configuring_interface(t, "tengigabitethernet 0/0/1", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 0/0/2", "no switchport mode")
        configuring_interface(t, "tengigabitethernet 1/0/2", "no switchport mode")

        configuring_interface(t, "tengigabitethernet 0/0/1", "switchport trunk allowed vlan remove 10,11")
        configuring_interface(t, "tengigabitethernet 0/0/2", "switchport trunk allowed vlan remove 10")
        configuring_interface(t, "tengigabitethernet 1/0/2", "switchport trunk allowed vlan remove 11")

        configuring(t, do="no vlan 10")
        configuring(t, do="no vlan 11")
Example #22
0
    def test_show_running_config_on_ethernet_port_that_does_not_exists(self, t):
        enable(t)

        t.write("show running-config interface tengigabitethernet 99/99/99")
        t.readln("")
        t.read("An invalid interface has been used for this function")
        t.readln("")
        t.read("my_switch#")
Example #23
0
    def test_show_running_config_on_ethernet_port_that_does_not_exists(self, t):
        enable(t)

        t.write("show running-config interface tengigabitethernet 99/99/99")
        t.readln("")
        t.read("An invalid interface has been used for this function")
        t.readln("")
        t.read("my_switch#")
    def test_switchport_general_pvid(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general pvid 1500")
        t.readln("Could not configure pvid.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general pvid 1264")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport general pvid 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport general pvid 1264",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring(t, do="no vlan 1264")
    def test_switchport_general_pvid(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general pvid 1500")
        t.readln("Could not configure pvid.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general pvid 1264")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
            "switchport general pvid 1264"
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode general",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport general pvid 1264")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport general pvid 1264",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport general pvid")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring(t, do="no vlan 1264")
    def test_shutting_down(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do="shutdown")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["shutdown"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no shutdown")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])
    def test_switchport_add_trunk_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1200)
        add_vlan(t, 1201)

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["switchport mode trunk"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1200")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["switchport mode trunk"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(
            t, "tengigabitethernet 0/0/1", ["switchport mode trunk", "switchport trunk allowed vlan 1200"]
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1201")
        assert_interface_configuration(
            t, "tengigabitethernet 0/0/1", ["switchport mode trunk", "switchport trunk allowed vlan 1200-1201"]
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1202")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1203")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1200")
        assert_interface_configuration(
            t, "tengigabitethernet 0/0/1", ["switchport mode trunk", "switchport trunk allowed vlan 1201-1202"]
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport trunk allowed vlan")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["switchport mode trunk"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no switchport mode")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport trunk allowed vlan add 1202 1201")
        t.readln("                                                                 ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
Example #28
0
 def test_show_running_config_displays_header(self, t):
     enable(t)
     assert_running_config_contains_in_order(t, [
         '!Current Configuration:',
         '!System Description "............."',
         '!System Software Version 3.3.7.3',
         '!Cut-through mode is configured as disabled',
         '!',
         'configure',
     ])
Example #29
0
    def test_shutting_down(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do="shutdown")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1",
                                       ["shutdown"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no shutdown")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])
Example #30
0
 def test_show_running_config_displays_header(self, t):
     enable(t)
     assert_running_config_contains_in_order(t, [
         '!Current Configuration:',
         '!System Description "............."',
         '!System Software Version 3.3.7.3',
         '!Cut-through mode is configured as disabled',
         '!',
         'configure',
     ])
    def test_switchport_add_remove_trunk_trunk_vlans(self, t):
        enable(t)

        add_vlan(t, 1200)
        add_vlan(t, 1201)
        add_vlan(t, 1202)
        add_vlan(t, 1203)
        add_vlan(t, 1205)

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1200,1201")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1201-1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1202")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201,1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1200-1203")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
        configuring(t, do="no vlan 1202")
        configuring(t, do="no vlan 1203")
        configuring(t, do="no vlan 1205")
    def test_switchport_add_remove_trunk_trunk_vlans(self, t):
        enable(t)

        add_vlan(t, 1200)
        add_vlan(t, 1201)
        add_vlan(t, 1202)
        add_vlan(t, 1203)
        add_vlan(t, 1205)

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode trunk")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1200,1201")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan add 1201-1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1202")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201,1203,1205",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1203,1205")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport trunk allowed vlan remove 1200-1203")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="switchport mode access")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "",
        ])

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
        configuring(t, do="no vlan 1202")
        configuring(t, do="no vlan 1203")
        configuring(t, do="no vlan 1205")
    def test_spanning_tree(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do="spanning-tree disable")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="spanning-tree portfast")

        assert_interface_configuration(
            t, "tengigabitethernet 0/0/1", ["spanning-tree disable", "spanning-tree portfast"]
        )

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no spanning-tree disable")
        configuring_interface(t, "tengigabitethernet 0/0/1", do="no spanning-tree portfast")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])
    def test_show_run_vs_show_run_interface_same_output(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do="shutdown")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ["shutdown"])

        assert_running_config_contains_in_order(t, ["interface tengigabitethernet 0/0/1", "shutdown", "exit", "!"])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no shutdown")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])

        config = get_running_config(t)
        assert_that(config, is_not(has_item("interface tengigabitethernet 0/0/1")))
    def test_description(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do='description "hello WORLD"')
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ['description "hello WORLD"'])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="description 'We dont know yet'")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ['description "We dont know yet"'])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="description YEEEAH")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", ['description "YEEEAH"'])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no description")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])
    def test_access_vlan(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport access vlan 1264")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264",
        ])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("no switchport access vlan")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring(t, do="no vlan 1264")
    def test_access_vlan(self, t):
        enable(t)

        add_vlan(t, 1264)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport access vlan 1264")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport access vlan 1264",
        ])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("no switchport access vlan")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            ""
        ])

        configuring(t, do="no vlan 1264")
Example #38
0
    def test_write_memory_any_other_key_aborts(self, t):
        enable(t)

        t.write("copy running-config startup-config")

        t.readln("")
        t.readln("This operation may take a few minutes.")
        t.readln("Management interfaces will not be available during this time.")
        t.readln("")
        t.read("Are you sure you want to save? (y/n) ")
        t.write_raw("p")
        t.readln("")
        t.readln("")
        t.readln("Configuration Not Saved!")
        t.read("my_switch#")
Example #39
0
    def test_entering_configure_unknown_interface_mode(self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("interface tengigabitethernet 1/0/99")
        t.readln("")
        t.readln("An invalid interface has been used for this function")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #40
0
    def test_entering_remove_unknown_vlan(self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("no vlan 3999")
        t.readln("")
        t.readln("These VLANs do not exist:  3999.")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #41
0
    def test_entering_configure_unknown_interface_mode(self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("interface tengigabitethernet 1/0/99")
        t.readln("")
        t.readln("An invalid interface has been used for this function")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #42
0
    def test_entering_remove_unknown_vlan(self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("no vlan 3999")
        t.readln("")
        t.readln("These VLANs do not exist:  3999.")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #43
0
    def test_write_memory_any_other_key_aborts(self, t):
        enable(t)

        t.write("copy running-config startup-config")

        t.readln("")
        t.readln("This operation may take a few minutes.")
        t.readln("Management interfaces will not be available during this time.")
        t.readln("")
        t.read("Are you sure you want to save? (y/n) ")
        t.write_raw("p")
        t.readln("")
        t.readln("")
        t.readln("Configuration Not Saved!")
        t.read("my_switch#")
    def test_spanning_tree(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do='spanning-tree disable')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='spanning-tree portfast')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            'spanning-tree disable',
            'spanning-tree portfast',
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do='no spanning-tree disable')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no spanning-tree portfast')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            ''
        ])
    def test_spanning_tree(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do='spanning-tree disable')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='spanning-tree portfast')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            'spanning-tree disable',
            'spanning-tree portfast',
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do='no spanning-tree disable')
        configuring_interface(t, "tengigabitethernet 0/0/1", do='no spanning-tree portfast')

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            ''
        ])
    def test_configuring_a_vlan(self, t):
        enable(t)

        add_vlan(t, 1000)
        add_vlan(t, 1001)
        add_vlan(t, 2000)
        configuring_vlan(t, 2000, do="name shizzle")
        assert_running_config_contains_in_order(t, [
            "vlan 2000",
            "name shizzle",
            "exit",
            "vlan 1,1000-1001",
            "exit",
        ])

        configuring(t, do="no vlan 1000")
        configuring(t, do="no vlan 1001")
        configuring(t, do="no vlan 2000")
Example #47
0
    def test_show_run_vs_show_run_interface_same_output(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do="shutdown")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1",
                                       ["shutdown"])

        assert_running_config_contains_in_order(t, [
            "interface tengigabitethernet 0/0/1",
            "shutdown",
            "exit",
            "!",
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="no shutdown")

        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [""])

        config = get_running_config(t)
        assert_that(config,
                    is_not(has_item("interface tengigabitethernet 0/0/1")))
    def test_write_memory_abort_does_not_delay(self, t):
        t.child.timeout = 10
        enable(t)

        t.write("copy running-config startup-config")

        t.readln("")
        t.readln("This operation may take a few minutes.")
        t.readln("Management interfaces will not be available during this time.")
        t.readln("")
        t.read("Are you sure you want to save? (y/n) ")
        t.write_raw("n")
        start_time = time()
        t.readln("")
        t.readln("")
        t.readln("Configuration Not Saved!")
        end_time = time()
        t.read("my_switch#")

        assert_that((end_time - start_time), less_than(COMMIT_DELAY))
Example #49
0
    def test_switchport_mode_failure(self, t):
        enable(t)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode shizzle")
        t.readln("                                         ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")
    def test_description(self, t):
        enable(t)
        configuring_interface(t, "tengigabitethernet 0/0/1", do='description "hello WORLD"')
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            "description \"hello WORLD\""
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do="description 'We dont know yet'")
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            "description \"We dont know yet\""
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do='description YEEEAH')
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            "description \"YEEEAH\""
        ])

        configuring_interface(t, "tengigabitethernet 0/0/1", do='no description')
        assert_interface_configuration(t, "tengigabitethernet 0/0/1", [
            ""
        ])
Example #51
0
    def test_write_memory_abort_does_not_delay(self, t):
        t.child.timeout = 10
        enable(t)

        t.write("copy running-config startup-config")

        t.readln("")
        t.readln("This operation may take a few minutes.")
        t.readln(
            "Management interfaces will not be available during this time.")
        t.readln("")
        t.read("Are you sure you want to save? (y/n) ")
        t.write_raw("n")
        start_time = time()
        t.readln("")
        t.readln("")
        t.readln("Configuration Not Saved!")
        end_time = time()
        t.read("my_switch#")

        assert_that((end_time - start_time), less_than(COMMIT_DELAY))
    def test_switchport_mode_failure(self, t):
        enable(t)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode shizzle")
        t.readln("                                         ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #53
0
    def test_entering_configure_unknown_vlan(self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("vlan 5000")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN 5000      ERROR: VLAN ID is out of range")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #54
0
    def test_entering_configure_unknown_vlan(self, t):
        enable(t)
        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("vlan 5000")
        t.readln("")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN 5000      ERROR: VLAN ID is out of range")
        t.readln("")
        t.read("my_switch(config)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch#")
Example #55
0
 def test_exit_returns_to_unprivileged_mode(self, t):
     enable(t)
     t.write("exit")
     t.readln("")
     t.read("my_switch>")
Example #56
0
 def test_quit_disconnects(self, t):
     enable(t)
     t.write("quit")
     t.read_eof()
Example #57
0
    def test_switchport_add_general_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1201)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1200")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1200-1202")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200-1202")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1202-1201")
        t.readln(
            "VLAN range - separate non-consecutive IDs with ',' and no spaces.  Use '-' for range."
        )
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1202 1201")
        t.readln(
            "                                                                 ^"
        )
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode access")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 1201")
Example #58
0
    def test_switchport_add_trunk_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1200)
        add_vlan(t, 1201)

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport mode trunk")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan add 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan add 1201")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1200-1201",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan add 1202")
        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan remove 1203")
        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="switchport trunk allowed vlan remove 1200")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
            "switchport trunk allowed vlan 1201-1202",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="no switchport trunk allowed vlan")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [
            "switchport mode trunk",
        ])

        configuring_interface(t,
                              "tengigabitethernet 0/0/1",
                              do="no switchport mode")
        assert_interface_configuration(t, 'tengigabitethernet 0/0/1', [""])

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")
        t.write("switchport trunk allowed vlan add 1202 1201")
        t.readln(
            "                                                                 ^"
        )
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 1200")
        configuring(t, do="no vlan 1201")
    def test_switchport_add_general_trunk_vlans_special_cases(self, t):
        enable(t)

        add_vlan(t, 1201)

        t.write("configure")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("interface tengigabitethernet 0/0/1")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode general")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1200")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1200-1202")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 1")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan remove 1200-1202")
        t.readln("")
        t.readln("          Failure Information")
        t.readln("---------------------------------------")
        t.readln("   VLANs failed to be configured : 2")
        t.readln("---------------------------------------")
        t.readln("   VLAN             Error")
        t.readln("---------------------------------------")
        t.readln("VLAN      1200 ERROR: This VLAN does not exist.")
        t.readln("VLAN      1202 ERROR: This VLAN does not exist.")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1202-1201")
        t.readln("VLAN range - separate non-consecutive IDs with ',' and no spaces.  Use '-' for range.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport general allowed vlan add 1202 1201")
        t.readln("                                                                 ^")
        t.readln("% Invalid input detected at '^' marker.")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("switchport mode access")
        t.readln("")
        t.read("my_switch(config-if-Te0/0/1)#")

        t.write("exit")
        t.readln("")
        t.read("my_switch(config)#")
        t.write("exit")
        t.readln("")
        t.read("my_switch#")

        configuring(t, do="no vlan 1201")