github.com/trigonella/mattermost-server@v5.11.1+incompatible/plugin/valid_test.go (about) 1 package plugin_test 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 8 "github.com/mattermost/mattermost-server/plugin" 9 ) 10 11 func TestIsValid(t *testing.T) { 12 t.Parallel() 13 14 testCases := map[string]bool{ 15 "": false, 16 "a": false, 17 "ab": false, 18 "abc": true, 19 "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij": true, 20 "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij1": false, 21 "../path": false, 22 "/etc/passwd": false, 23 "com.mattermost.plugin_with_features-0.9": true, 24 "PLUGINS-THAT-YELL-ARE-OK-2": true, 25 } 26 27 for id, valid := range testCases { 28 t.Run(id, func(t *testing.T) { 29 assert.Equal(t, valid, plugin.IsValidId(id)) 30 }) 31 } 32 }