forked from Team254/cheesy-arena
-
Notifications
You must be signed in to change notification settings - Fork 0
/
catalyst_test.go
36 lines (30 loc) · 1.59 KB
/
catalyst_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2014 Team 254. All Rights Reserved.
// Author: [email protected] (Patrick Fairbank)
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestConfigureCatalyst(t *testing.T) {
catalystTelnetPort = 9050
eventSettings = &EventSettings{SwitchAddress: "127.0.0.1", SwitchPassword: "password"}
var command string
// Should do nothing if current configuration is blank.
mockTelnet(t, catalystTelnetPort, "", &command)
assert.Nil(t, ConfigureTeamEthernet(nil, nil, nil, nil, nil, nil))
assert.Equal(t, "", command)
// Should remove any existing teams but not other SSIDs.
catalystTelnetPort += 1
mockTelnet(t, catalystTelnetPort,
"interface Vlan2\nip address 10.0.100.2\ninterface Vlan15\nip address 10.2.54.61\n", &command)
assert.Nil(t, ConfigureTeamEthernet(nil, nil, nil, nil, nil, nil))
assert.Equal(t, "password\nenable\npassword\nterminal length 0\nconfig terminal\ninterface Vlan15\nno ip"+
" address\nno access-list 115\nend\ncopy running-config startup-config\n\nexit\n", command)
// Should configure new teams and leave existing ones alone if still needed.
catalystTelnetPort += 1
mockTelnet(t, catalystTelnetPort, "interface Vlan15\nip address 10.2.54.61\n", &command)
assert.Nil(t, ConfigureTeamEthernet(nil, &Team{Id: 1114}, nil, nil, &Team{Id: 254}, nil))
assert.Equal(t, "password\nenable\npassword\nterminal length 0\nconfig terminal\nno access-list 112\n"+
"access-list 112 permit ip 10.11.14.0 0.0.0.255 host 10.0.100.50\ninterface Vlan12\nip address "+
"10.11.14.61 255.255.255.0\nend\ncopy running-config startup-config\n\nexit\n", command)
}