Этот коммит содержится в:
Christopher Speller
2018-11-06 00:28:55 -08:00
коммит произвёл Saturnino Abril
родитель 46dd243331
Коммит 418a0ec10e
14 изменённых файлов: 46 добавлений и 37 удалений

Просмотреть файл

@@ -4,9 +4,10 @@
package api4 package api4
import ( import (
"net/http"
"github.com/mattermost/mattermost-server/app" "github.com/mattermost/mattermost-server/app"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"net/http"
) )
func (api *API) InitTermsOfService() { func (api *API) InitTermsOfService() {

Просмотреть файл

@@ -1,9 +1,10 @@
package api4 package api4
import ( import (
"testing"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing"
) )
func TestGetTermsOfService(t *testing.T) { func TestGetTermsOfService(t *testing.T) {

Просмотреть файл

@@ -4,9 +4,10 @@
package app package app
import ( import (
"github.com/mattermost/mattermost-server/model"
"html/template" "html/template"
"net/http" "net/http"
"github.com/mattermost/mattermost-server/model"
) )
func (a *App) isExtensionSupportEnabled() bool { func (a *App) isExtensionSupportEnabled() bool {

Просмотреть файл

@@ -9,12 +9,13 @@ import (
"strings" "strings"
"bytes" "bytes"
"io/ioutil"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/mlog"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/plugin" "github.com/mattermost/mattermost-server/plugin"
"github.com/mattermost/mattermost-server/utils" "github.com/mattermost/mattermost-server/utils"
"io/ioutil"
) )
func (a *App) ServePluginRequest(w http.ResponseWriter, r *http.Request) { func (a *App) ServePluginRequest(w http.ResponseWriter, r *http.Request) {

Просмотреть файл

@@ -5,13 +5,14 @@ package app
import ( import (
"crypto/tls" "crypto/tls"
"github.com/mattermost/mattermost-server/utils"
"net/http" "net/http"
"path" "path"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
"github.com/mattermost/mattermost-server/utils"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@@ -24,7 +25,7 @@ func TestStartServerSuccess(t *testing.T) {
serverErr := a.StartServer() serverErr := a.StartServer()
client := &http.Client{} client := &http.Client{}
checkEndpoint(t, client, "http://localhost:" + strconv.Itoa(a.Srv.ListenAddr.Port) + "/", http.StatusNotFound) checkEndpoint(t, client, "http://localhost:"+strconv.Itoa(a.Srv.ListenAddr.Port)+"/", http.StatusNotFound)
a.Shutdown() a.Shutdown()
require.NoError(t, serverErr) require.NoError(t, serverErr)
@@ -77,7 +78,7 @@ func TestStartServerTLSSuccess(t *testing.T) {
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}
checkEndpoint(t, client, "https://localhost:" + strconv.Itoa(a.Srv.ListenAddr.Port) + "/", http.StatusNotFound) checkEndpoint(t, client, "https://localhost:"+strconv.Itoa(a.Srv.ListenAddr.Port)+"/", http.StatusNotFound)
a.Shutdown() a.Shutdown()
require.NoError(t, serverErr) require.NoError(t, serverErr)
@@ -100,12 +101,12 @@ func TestStartServerTLSVersion(t *testing.T) {
tr := &http.Transport{ tr := &http.Transport{
TLSClientConfig: &tls.Config{ TLSClientConfig: &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
MaxVersion: tls.VersionTLS11, MaxVersion: tls.VersionTLS11,
}, },
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}
err = checkEndpoint(t, client, "https://localhost:" + strconv.Itoa(a.Srv.ListenAddr.Port) + "/", http.StatusNotFound) err = checkEndpoint(t, client, "https://localhost:"+strconv.Itoa(a.Srv.ListenAddr.Port)+"/", http.StatusNotFound)
if !strings.Contains(err.Error(), "remote error: tls: protocol version not supported") { if !strings.Contains(err.Error(), "remote error: tls: protocol version not supported") {
t.Errorf("Expected protocol version error, got %s", err) t.Errorf("Expected protocol version error, got %s", err)
@@ -117,7 +118,7 @@ func TestStartServerTLSVersion(t *testing.T) {
}, },
} }
err = checkEndpoint(t, client, "https://localhost:" + strconv.Itoa(a.Srv.ListenAddr.Port) + "/", http.StatusNotFound) err = checkEndpoint(t, client, "https://localhost:"+strconv.Itoa(a.Srv.ListenAddr.Port)+"/", http.StatusNotFound)
if err != nil { if err != nil {
t.Errorf("Expected nil, got %s", err) t.Errorf("Expected nil, got %s", err)
@@ -154,7 +155,7 @@ func TestStartServerTLSOverwriteCipher(t *testing.T) {
} }
client := &http.Client{Transport: tr} client := &http.Client{Transport: tr}
err = checkEndpoint(t, client, "https://localhost:" + strconv.Itoa(a.Srv.ListenAddr.Port) + "/", http.StatusNotFound) err = checkEndpoint(t, client, "https://localhost:"+strconv.Itoa(a.Srv.ListenAddr.Port)+"/", http.StatusNotFound)
if !strings.Contains(err.Error(), "remote error: tls: handshake failure") { if !strings.Contains(err.Error(), "remote error: tls: handshake failure") {
t.Errorf("Expected protocol version error, got %s", err) t.Errorf("Expected protocol version error, got %s", err)
@@ -170,7 +171,7 @@ func TestStartServerTLSOverwriteCipher(t *testing.T) {
}, },
} }
err = checkEndpoint(t, client, "https://localhost:" + strconv.Itoa(a.Srv.ListenAddr.Port) + "/", http.StatusNotFound) err = checkEndpoint(t, client, "https://localhost:"+strconv.Itoa(a.Srv.ListenAddr.Port)+"/", http.StatusNotFound)
if err != nil { if err != nil {
t.Errorf("Expected nil, got %s", err) t.Errorf("Expected nil, got %s", err)

Просмотреть файл

@@ -10,10 +10,11 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/model"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"time" "time"
"github.com/mattermost/mattermost-server/model"
) )
func TestCreateIncomingWebhookForChannel(t *testing.T) { func TestCreateIncomingWebhookForChannel(t *testing.T) {

Просмотреть файл

@@ -56,19 +56,18 @@ type TestClientRequirements struct {
type TestNewConfig struct { type TestNewConfig struct {
TestNewServiceSettings TestNewServiceSettings TestNewServiceSettings TestNewServiceSettings
TestNewTeamSettings TestNewTeamSettings TestNewTeamSettings TestNewTeamSettings
} }
type TestNewServiceSettings struct{ type TestNewServiceSettings struct {
SiteUrl *string SiteUrl *string
UseLetsEncrypt *bool UseLetsEncrypt *bool
TLSStrictTransportMaxAge *int64 TLSStrictTransportMaxAge *int64
AllowedThemes []string AllowedThemes []string
} }
type TestNewTeamSettings struct { type TestNewTeamSettings struct {
SiteName *string SiteName *string
MaxUserPerTeam *int MaxUserPerTeam *int
} }
@@ -469,16 +468,15 @@ func TestUpdateMap(t *testing.T) {
}, },
} }
// create a map of type map[string]interface // create a map of type map[string]interface
configMap := configToMap(config) configMap := configToMap(config)
cases := []struct{ cases := []struct {
Name string Name string
configSettings []string configSettings []string
newVal []string newVal []string
expected interface{} expected interface{}
} { }{
{ {
Name: "check for Map and string", Name: "check for Map and string",
configSettings: []string{"TestNewServiceSettings", "SiteUrl"}, configSettings: []string{"TestNewServiceSettings", "SiteUrl"},
@@ -517,10 +515,9 @@ func TestUpdateMap(t *testing.T) {
}, },
} }
for _, test := range cases { for _, test := range cases {
t.Run(test.Name, func(t *testing.T){ t.Run(test.Name, func(t *testing.T) {
err := UpdateMap(configMap, test.configSettings, test.newVal) err := UpdateMap(configMap, test.configSettings, test.newVal)
if err != nil { if err != nil {

Просмотреть файл

@@ -4,11 +4,12 @@
package commands package commands
import ( import (
"github.com/stretchr/testify/require"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/require"
"github.com/mattermost/mattermost-server/api4" "github.com/mattermost/mattermost-server/api4"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
) )

Просмотреть файл

@@ -4,9 +4,10 @@
package model package model
import ( import (
"github.com/stretchr/testify/assert"
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func TestTermsOfServiceIsValid(t *testing.T) { func TestTermsOfServiceIsValid(t *testing.T) {

Просмотреть файл

@@ -18,8 +18,8 @@ func TestIsValid(t *testing.T) {
"abc": true, "abc": true,
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij": true, "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij": true,
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij1": false, "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij1": false,
"../path": false, "../path": false,
"/etc/passwd": false, "/etc/passwd": false,
"com.mattermost.plugin_with_features-0.9": true, "com.mattermost.plugin_with_features-0.9": true,
"PLUGINS-THAT-YELL-ARE-OK-2": true, "PLUGINS-THAT-YELL-ARE-OK-2": true,
} }

Просмотреть файл

@@ -5,11 +5,12 @@ package sqlstore
import ( import (
"database/sql" "database/sql"
"net/http"
"github.com/mattermost/mattermost-server/einterfaces" "github.com/mattermost/mattermost-server/einterfaces"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store" "github.com/mattermost/mattermost-server/store"
"github.com/mattermost/mattermost-server/utils" "github.com/mattermost/mattermost-server/utils"
"net/http"
) )
type SqlTermsOfServiceStore struct { type SqlTermsOfServiceStore struct {

Просмотреть файл

@@ -1,8 +1,9 @@
package sqlstore package sqlstore
import ( import (
"github.com/mattermost/mattermost-server/store/storetest"
"testing" "testing"
"github.com/mattermost/mattermost-server/store/storetest"
) )
func TestTermsOfServiceStore(t *testing.T) { func TestTermsOfServiceStore(t *testing.T) {

Просмотреть файл

@@ -4,10 +4,11 @@
package storetest package storetest
import ( import (
"testing"
"github.com/mattermost/mattermost-server/model" "github.com/mattermost/mattermost-server/model"
"github.com/mattermost/mattermost-server/store" "github.com/mattermost/mattermost-server/store"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing"
) )
func TestTermsOfServiceStore(t *testing.T, ss store.Store) { func TestTermsOfServiceStore(t *testing.T, ss store.Store) {

Просмотреть файл

@@ -4,9 +4,10 @@
package testutils package testutils
import ( import (
"github.com/mattermost/mattermost-server/services/httpservice"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"github.com/mattermost/mattermost-server/services/httpservice"
) )
type MockedHTTPService struct { type MockedHTTPService struct {