mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Add test coverage for config verification
This commit is contained in:
parent
9f27e691fc
commit
59a5dd2bfa
|
|
@ -361,7 +361,7 @@ func (c *Dendrite) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
|||
&c.Global, &c.ClientAPI, &c.FederationAPI,
|
||||
&c.KeyServer, &c.MediaAPI, &c.RoomServer,
|
||||
&c.SyncAPI, &c.UserAPI,
|
||||
&c.AppServiceAPI, &c.MSCs,
|
||||
&c.AppServiceAPI, &c.RelayAPI, &c.MSCs,
|
||||
} {
|
||||
c.Verify(configErrs, isMonolith)
|
||||
}
|
||||
|
|
@ -377,6 +377,7 @@ func (c *Dendrite) Wiring() {
|
|||
c.SyncAPI.Matrix = &c.Global
|
||||
c.UserAPI.Matrix = &c.Global
|
||||
c.AppServiceAPI.Matrix = &c.Global
|
||||
c.RelayAPI.Matrix = &c.Global
|
||||
c.MSCs.Matrix = &c.Global
|
||||
|
||||
c.ClientAPI.Derived = &c.Derived
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func TestLoadConfigRelative(t *testing.T) {
|
||||
_, err := loadConfig("/my/config/dir", []byte(testConfig),
|
||||
cfg, err := loadConfig("/my/config/dir", []byte(testConfig),
|
||||
mockReadFile{
|
||||
"/my/config/dir/matrix_key.pem": testKey,
|
||||
"/my/config/dir/tls_cert.pem": testCert,
|
||||
|
|
@ -32,6 +33,15 @@ func TestLoadConfigRelative(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Error("failed to load config:", err)
|
||||
}
|
||||
|
||||
configErrors := &ConfigErrors{}
|
||||
cfg.Verify(configErrors, false)
|
||||
if len(*configErrors) > 0 {
|
||||
for _, err := range *configErrors {
|
||||
logrus.Errorf("Configuration error: %s", err)
|
||||
}
|
||||
t.Error("configuration verification failed")
|
||||
}
|
||||
}
|
||||
|
||||
const testConfig = `
|
||||
|
|
@ -66,6 +76,8 @@ global:
|
|||
display_name: "Server alerts"
|
||||
avatar: ""
|
||||
room_name: "Server Alerts"
|
||||
jetstream:
|
||||
addresses: ["test"]
|
||||
app_service_api:
|
||||
internal_api:
|
||||
listen: http://localhost:7777
|
||||
|
|
@ -82,7 +94,7 @@ client_api:
|
|||
connect: http://localhost:7771
|
||||
external_api:
|
||||
listen: http://[::]:8071
|
||||
registration_disabled: false
|
||||
registration_disabled: true
|
||||
registration_shared_secret: ""
|
||||
enable_registration_captcha: false
|
||||
recaptcha_public_key: ""
|
||||
|
|
@ -110,6 +122,8 @@ federation_api:
|
|||
connect: http://localhost:7772
|
||||
external_api:
|
||||
listen: http://[::]:8072
|
||||
database:
|
||||
connection_string: file:federationapi.db
|
||||
key_server:
|
||||
internal_api:
|
||||
listen: http://localhost:7779
|
||||
|
|
@ -192,6 +206,17 @@ user_api:
|
|||
max_open_conns: 100
|
||||
max_idle_conns: 2
|
||||
conn_max_lifetime: -1
|
||||
relay_api:
|
||||
internal_api:
|
||||
listen: http://localhost:7775
|
||||
connect: http://localhost:7775
|
||||
external_api:
|
||||
listen: http://[::]:8075
|
||||
database:
|
||||
connection_string: file:relayapi.db
|
||||
mscs:
|
||||
database:
|
||||
connection_string: file:federationapi.db
|
||||
tracing:
|
||||
enabled: false
|
||||
jaeger:
|
||||
|
|
|
|||
Loading…
Reference in a new issue