blob: 5ee999f0fc5e875de45be91ebbd676ef50ef5e0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package app
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/mattermost/mattermost-server/model"
)
func TestConfigListener(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
originalSiteName := th.App.Config().TeamSettings.SiteName
th.App.UpdateConfig(func(cfg *model.Config) {
cfg.TeamSettings.SiteName = "test123"
})
listenerCalled := false
listener := func(oldConfig *model.Config, newConfig *model.Config) {
if listenerCalled {
t.Fatal("listener called twice")
}
if oldConfig.TeamSettings.SiteName != "test123" {
t.Fatal("old config contains incorrect site name")
} else if newConfig.TeamSettings.SiteName != originalSiteName {
t.Fatal("new config contains incorrect site name")
}
listenerCalled = true
}
listenerId := th.App.AddConfigListener(listener)
defer th.App.RemoveConfigListener(listenerId)
listener2Called := false
listener2 := func(oldConfig *model.Config, newConfig *model.Config) {
if listener2Called {
t.Fatal("listener2 called twice")
}
listener2Called = true
}
listener2Id := th.App.AddConfigListener(listener2)
defer th.App.RemoveConfigListener(listener2Id)
th.App.ReloadConfig()
if !listenerCalled {
t.Fatal("listener should've been called")
} else if !listener2Called {
t.Fatal("listener 2 should've been called")
}
}
func TestAsymmetricSigningKey(t *testing.T) {
th := Setup().InitBasic()
defer th.TearDown()
assert.NotNil(t, th.App.AsymmetricSigningKey())
assert.NotEmpty(t, th.App.ClientConfig()["AsymmetricSigningPublicKey"])
}
|