|
@@ -26,7 +26,10 @@ func TestISUPPORT(t *testing.T) {
|
26
|
26
|
tListLong.AddNoValue("D")
|
27
|
27
|
tListLong.AddNoValue("E")
|
28
|
28
|
tListLong.AddNoValue("F")
|
29
|
|
- tListLong.RegenerateCachedReply()
|
|
29
|
+ err := tListLong.RegenerateCachedReply()
|
|
30
|
+ if err != nil {
|
|
31
|
+ t.Error(err)
|
|
32
|
+ }
|
30
|
33
|
|
31
|
34
|
longReplies := [][]string{
|
32
|
35
|
{"1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D"},
|
|
@@ -44,7 +47,10 @@ func TestISUPPORT(t *testing.T) {
|
44
|
47
|
tList1.Add("INVEX", "i")
|
45
|
48
|
tList1.AddNoValue("EXTBAN")
|
46
|
49
|
tList1.Add("RANDKILL", "whenever")
|
47
|
|
- tList1.RegenerateCachedReply()
|
|
50
|
+ err = tList1.RegenerateCachedReply()
|
|
51
|
+ if err != nil {
|
|
52
|
+ t.Error(err)
|
|
53
|
+ }
|
48
|
54
|
|
49
|
55
|
expected := [][]string{{"CASEMAPPING=rfc1459-strict", "EXTBAN", "INVEX=i", "RANDKILL=whenever", "SASL=yes"}}
|
50
|
56
|
if !reflect.DeepEqual(tList1.CachedReply, expected) {
|
|
@@ -58,7 +64,10 @@ func TestISUPPORT(t *testing.T) {
|
58
|
64
|
tList2.AddNoValue("INVEX")
|
59
|
65
|
tList2.Add("EXTBAN", "TestBah")
|
60
|
66
|
tList2.AddNoValue("STABLEKILL")
|
61
|
|
- tList2.RegenerateCachedReply()
|
|
67
|
+ err = tList2.RegenerateCachedReply()
|
|
68
|
+ if err != nil {
|
|
69
|
+ t.Error(err)
|
|
70
|
+ }
|
62
|
71
|
|
63
|
72
|
expected = [][]string{{"CASEMAPPING=ascii", "EXTBAN=TestBah", "INVEX", "SASL=yes", "STABLEKILL"}}
|
64
|
73
|
if !reflect.DeepEqual(tList2.CachedReply, expected) {
|
|
@@ -72,3 +81,26 @@ func TestISUPPORT(t *testing.T) {
|
72
|
81
|
t.Error("difference reply does not match expected difference reply")
|
73
|
82
|
}
|
74
|
83
|
}
|
|
84
|
+
|
|
85
|
+func TestBadToken(t *testing.T) {
|
|
86
|
+ list := NewList()
|
|
87
|
+ list.Add("NETWORK", "Bad Network Name")
|
|
88
|
+ list.Add("SASL", "yes")
|
|
89
|
+ list.Add("CASEMAPPING", "rfc1459-strict")
|
|
90
|
+ list.Add("INVEX", "i")
|
|
91
|
+ list.AddNoValue("EXTBAN")
|
|
92
|
+
|
|
93
|
+ err := list.RegenerateCachedReply()
|
|
94
|
+ if err == nil {
|
|
95
|
+ t.Error("isupport token generation should fail due to space in network name")
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ // should produce a list containing the other, valid params
|
|
99
|
+ numParams := 0
|
|
100
|
+ for _, tokenLine := range list.CachedReply {
|
|
101
|
+ numParams += len(tokenLine)
|
|
102
|
+ }
|
|
103
|
+ if numParams != 4 {
|
|
104
|
+ t.Errorf("expected the other 4 params to be generated, got %v", list.CachedReply)
|
|
105
|
+ }
|
|
106
|
+}
|