summaryrefslogtreecommitdiffstats
path: root/model/utils_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-09-15 06:56:08 -0400
committerGeorge Goldberg <george@gberg.me>2017-09-15 11:56:08 +0100
commit600beb5af3e35fd82a2b06995b67629d08fe0fe3 (patch)
tree1bb4b6b99420aff52c1efec5631f3094a927c2a9 /model/utils_test.go
parentb6fb98a43176215f16fc52b64abebde51355e5c1 (diff)
downloadchat-600beb5af3e35fd82a2b06995b67629d08fe0fe3.tar.gz
chat-600beb5af3e35fd82a2b06995b67629d08fe0fe3.tar.bz2
chat-600beb5af3e35fd82a2b06995b67629d08fe0fe3.zip
Add some checking of channel ID before sending websocket event (#7431)
Diffstat (limited to 'model/utils_test.go')
-rw-r--r--model/utils_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/model/utils_test.go b/model/utils_test.go
index bc2aa6ce7..fd333b40c 100644
--- a/model/utils_test.go
+++ b/model/utils_test.go
@@ -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)
+ }
+ }
+}