mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-09 15:13:12 -06:00
Merge branch 'main' into neilalexander/restrictedmakesendjoin
This commit is contained in:
commit
5708a51d72
|
|
@ -55,60 +55,62 @@ var servers = map[string]*server{
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
// Set up the server key API for each "server" that we
|
// Set up the server key API for each "server" that we
|
||||||
// will use in our tests.
|
// will use in our tests.
|
||||||
for _, s := range servers {
|
os.Exit(func() int {
|
||||||
// Generate a new key.
|
for _, s := range servers {
|
||||||
_, testPriv, err := ed25519.GenerateKey(nil)
|
// Generate a new key.
|
||||||
if err != nil {
|
_, testPriv, err := ed25519.GenerateKey(nil)
|
||||||
panic("can't generate identity key: " + err.Error())
|
if err != nil {
|
||||||
|
panic("can't generate identity key: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new cache but don't enable prometheus!
|
||||||
|
s.cache, err = caching.NewInMemoryLRUCache(false)
|
||||||
|
if err != nil {
|
||||||
|
panic("can't create cache: " + err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a temporary directory for JetStream.
|
||||||
|
d, err := ioutil.TempDir("./", "jetstream*")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(d)
|
||||||
|
|
||||||
|
// Draw up just enough Dendrite config for the server key
|
||||||
|
// API to work.
|
||||||
|
cfg := &config.Dendrite{}
|
||||||
|
cfg.Defaults(true)
|
||||||
|
cfg.Global.ServerName = gomatrixserverlib.ServerName(s.name)
|
||||||
|
cfg.Global.PrivateKey = testPriv
|
||||||
|
cfg.Global.JetStream.InMemory = true
|
||||||
|
cfg.Global.JetStream.TopicPrefix = string(s.name[:1])
|
||||||
|
cfg.Global.JetStream.StoragePath = config.Path(d)
|
||||||
|
cfg.Global.KeyID = serverKeyID
|
||||||
|
cfg.Global.KeyValidityPeriod = s.validity
|
||||||
|
cfg.FederationAPI.Database.ConnectionString = config.DataSource("file::memory:")
|
||||||
|
s.config = &cfg.FederationAPI
|
||||||
|
|
||||||
|
// Create a transport which redirects federation requests to
|
||||||
|
// the mock round tripper. Since we're not *really* listening for
|
||||||
|
// federation requests then this will return the key instead.
|
||||||
|
transport := &http.Transport{}
|
||||||
|
transport.RegisterProtocol("matrix", &MockRoundTripper{})
|
||||||
|
|
||||||
|
// Create the federation client.
|
||||||
|
s.fedclient = gomatrixserverlib.NewFederationClient(
|
||||||
|
s.config.Matrix.ServerName, serverKeyID, testPriv,
|
||||||
|
gomatrixserverlib.WithTransport(transport),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Finally, build the server key APIs.
|
||||||
|
sbase := base.NewBaseDendrite(cfg, "Monolith", base.DisableMetrics)
|
||||||
|
s.api = NewInternalAPI(sbase, s.fedclient, nil, s.cache, nil, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new cache but don't enable prometheus!
|
// Now that we have built our server key APIs, start the
|
||||||
s.cache, err = caching.NewInMemoryLRUCache(false)
|
// rest of the tests.
|
||||||
if err != nil {
|
return m.Run()
|
||||||
panic("can't create cache: " + err.Error())
|
}())
|
||||||
}
|
|
||||||
|
|
||||||
// Create a temporary directory for JetStream.
|
|
||||||
d, err := ioutil.TempDir("./", "jetstream*")
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(d)
|
|
||||||
|
|
||||||
// Draw up just enough Dendrite config for the server key
|
|
||||||
// API to work.
|
|
||||||
cfg := &config.Dendrite{}
|
|
||||||
cfg.Defaults(true)
|
|
||||||
cfg.Global.ServerName = gomatrixserverlib.ServerName(s.name)
|
|
||||||
cfg.Global.PrivateKey = testPriv
|
|
||||||
cfg.Global.JetStream.InMemory = true
|
|
||||||
cfg.Global.JetStream.TopicPrefix = string(s.name[:1])
|
|
||||||
cfg.Global.JetStream.StoragePath = config.Path(d)
|
|
||||||
cfg.Global.KeyID = serverKeyID
|
|
||||||
cfg.Global.KeyValidityPeriod = s.validity
|
|
||||||
cfg.FederationAPI.Database.ConnectionString = config.DataSource("file::memory:")
|
|
||||||
s.config = &cfg.FederationAPI
|
|
||||||
|
|
||||||
// Create a transport which redirects federation requests to
|
|
||||||
// the mock round tripper. Since we're not *really* listening for
|
|
||||||
// federation requests then this will return the key instead.
|
|
||||||
transport := &http.Transport{}
|
|
||||||
transport.RegisterProtocol("matrix", &MockRoundTripper{})
|
|
||||||
|
|
||||||
// Create the federation client.
|
|
||||||
s.fedclient = gomatrixserverlib.NewFederationClient(
|
|
||||||
s.config.Matrix.ServerName, serverKeyID, testPriv,
|
|
||||||
gomatrixserverlib.WithTransport(transport),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Finally, build the server key APIs.
|
|
||||||
sbase := base.NewBaseDendrite(cfg, "Monolith", base.DisableMetrics)
|
|
||||||
s.api = NewInternalAPI(sbase, s.fedclient, nil, s.cache, nil, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that we have built our server key APIs, start the
|
|
||||||
// rest of the tests.
|
|
||||||
os.Exit(m.Run())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type MockRoundTripper struct{}
|
type MockRoundTripper struct{}
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -30,7 +30,7 @@ require (
|
||||||
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
||||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16
|
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20220513103617-eee8fd528433
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20220523164922-dfd9bd7c03fb
|
||||||
github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48
|
github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48
|
||||||
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
|
github.com/matrix-org/util v0.0.0-20200807132607-55161520e1d4
|
||||||
github.com/mattn/go-sqlite3 v1.14.10
|
github.com/mattn/go-sqlite3 v1.14.10
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -795,8 +795,8 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0=
|
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 h1:ZtO5uywdd5dLDCud4r0r55eP4j9FuUNpl60Gmntcop4=
|
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 h1:ZtO5uywdd5dLDCud4r0r55eP4j9FuUNpl60Gmntcop4=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20220513103617-eee8fd528433 h1:nwAlThHGPI2EAAJklXvgMcdhXF6ZiHp60+fmaYMoaDA=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20220523164922-dfd9bd7c03fb h1:MRhaR1IKYdizM2vECOcJlleExLEwy4KAvQ6v73QQRnA=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20220513103617-eee8fd528433/go.mod h1:V5eO8rn/C3rcxig37A/BCeKerLFS+9Avg/77FIeTZ48=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20220523164922-dfd9bd7c03fb/go.mod h1:V5eO8rn/C3rcxig37A/BCeKerLFS+9Avg/77FIeTZ48=
|
||||||
github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48 h1:W0sjjC6yjskHX4mb0nk3p0fXAlbU5bAFUFeEtlrPASE=
|
github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48 h1:W0sjjC6yjskHX4mb0nk3p0fXAlbU5bAFUFeEtlrPASE=
|
||||||
github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48/go.mod h1:ulJzsVOTssIVp1j/m5eI//4VpAGDkMt5NrRuAVX7wpc=
|
github.com/matrix-org/pinecone v0.0.0-20220408153826-2999ea29ed48/go.mod h1:ulJzsVOTssIVp1j/m5eI//4VpAGDkMt5NrRuAVX7wpc=
|
||||||
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U=
|
github.com/matrix-org/util v0.0.0-20190711121626-527ce5ddefc7/go.mod h1:vVQlW/emklohkZnOPwD3LrZUBqdfsbiyO3p1lNV8F6U=
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue