Add some checking of channel ID before sending websocket event (#7431)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
b6fb98a431
Коммит
600beb5af3
@@ -331,3 +331,38 @@ func TestIsValidAlphaNumHyphenUnderscore(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsValidId(t *testing.T) {
|
||||
cases := []struct {
|
||||
Input string
|
||||
Result bool
|
||||
}{
|
||||
{
|
||||
Input: NewId(),
|
||||
Result: true,
|
||||
},
|
||||
{
|
||||
Input: "",
|
||||
Result: false,
|
||||
},
|
||||
{
|
||||
Input: "junk",
|
||||
Result: false,
|
||||
},
|
||||
{
|
||||
Input: "qwertyuiop1234567890asdfg{",
|
||||
Result: false,
|
||||
},
|
||||
{
|
||||
Input: NewId() + "}",
|
||||
Result: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
actual := IsValidId(tc.Input)
|
||||
if actual != tc.Result {
|
||||
t.Fatalf("case: %v\tshould returned: %#v", tc, tc.Result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user