Fix rooms v3 url paths for good - with tests (#1130)

* Fix rooms v3 url paths for good - with tests

- Add a test rig around `federationapi` to test routing.
- Use `JSONVerifier` over `KeyRing` so we can stub things out more easily.
- Add `test.NopJSONVerifier` which verifies nothing.
- Add `base.BaseMux` which is the original `mux.Router` used to spawn public/internal routers.
- Listen on `base.BaseMux` and not the default serve mux as it cleans paths which we don't want.
- Factor out `ListenAndServe` to `test.ListenAndServe` and add flag for listening on TLS.

* Fix comments

* Linting
This commit is contained in:
Kegsay 2020-06-15 16:57:59 +01:00 committed by GitHub
parent 1aac317341
commit 7c36fb78a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 228 additions and 76 deletions

View file

@ -135,7 +135,7 @@ func main() {
monolith.AddAllPublicRoutes(base.PublicAPIMux)
httputil.SetupHTTPAPI(
http.DefaultServeMux,
base.BaseMux,
base.PublicAPIMux,
base.InternalAPIMux,
cfg,
@ -147,6 +147,7 @@ func main() {
serv := http.Server{
Addr: *httpBindAddr,
WriteTimeout: setup.HTTPServerTimeout,
Handler: base.BaseMux,
}
logrus.Info("Listening on ", serv.Addr)
@ -158,6 +159,7 @@ func main() {
serv := http.Server{
Addr: *httpsBindAddr,
WriteTimeout: setup.HTTPServerTimeout,
Handler: base.BaseMux,
}
logrus.Info("Listening on ", serv.Addr)