mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* Remove all remaining occurences of fakeApp Migrated any remaining methods under server. And for everything else, renamed fakeApp to app. The word fakeApp is confusing and we should just call it for what it is - an app. https://focalboard-community.octo.mattermost.com/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=639a0bc1-4401-43d5-81ec-0dd54e796d9a ```release-note NONE ``` * fix tests
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"hash/maphash"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/mattermost/mattermost-server/v5/config"
|
|
"github.com/mattermost/mattermost-server/v5/model"
|
|
)
|
|
|
|
func TestServePluginPublicRequest(t *testing.T) {
|
|
t.Run("returns not found when plugins environment is nil", func(t *testing.T) {
|
|
cfg := model.Config{}
|
|
cfg.SetDefaults()
|
|
configStore := config.NewTestMemoryStore()
|
|
configStore.Set(&cfg)
|
|
|
|
srv := &Server{
|
|
goroutineExitSignal: make(chan struct{}, 1),
|
|
RootRouter: mux.NewRouter(),
|
|
LocalRouter: mux.NewRouter(),
|
|
licenseListeners: map[string]func(*model.License, *model.License){},
|
|
hashSeed: maphash.MakeSeed(),
|
|
uploadLockMap: map[string]bool{},
|
|
configStore: configStore,
|
|
}
|
|
app := New(ServerConnector(srv))
|
|
app.UpdateConfig(func(cfg *model.Config) { *cfg.PluginSettings.Enable = true })
|
|
|
|
req, err := http.NewRequest("GET", "/plugins", nil)
|
|
require.NoError(t, err)
|
|
|
|
rr := httptest.NewRecorder()
|
|
handler := http.HandlerFunc(srv.ServePluginPublicRequest)
|
|
handler.ServeHTTP(rr, req)
|
|
|
|
assert.Equal(t, http.StatusNotFound, rr.Code)
|
|
})
|
|
}
|