diff --git a/app/rest/server.go b/app/rest/server.go index ca96b823..f07cc398 100644 --- a/app/rest/server.go +++ b/app/rest/server.go @@ -69,9 +69,11 @@ func (s *Server) Run(port int) { // auth routes for all providers router.Route("/auth", func(r chi.Router) { for _, provider := range s.AuthProviders { - r.Mount("/"+provider.Name, provider.Routes()) + r.Mount("/"+provider.Name, provider.Routes()) // mount auth providers as /auth/{name} + } + if len(s.AuthProviders) > 0 { + r.Get("/logout", s.AuthProviders[0].LogoutHandler) // shortcut, can be any of providers, all logouts do the same } - r.Get("/logout", s.AuthProviders[0].LogoutHandler) // shortcut, can be any of providers, all logouts do the same }) // api routes diff --git a/app/rest/server_test.go b/app/rest/server_test.go index bff7844a..6bf83f78 100644 --- a/app/rest/server_test.go +++ b/app/rest/server_test.go @@ -17,7 +17,6 @@ import ( "github.com/stretchr/testify/require" "github.com/umputun/remark/app/migrator" - "github.com/umputun/remark/app/rest/auth" "github.com/umputun/remark/app/store" ) @@ -336,12 +335,11 @@ func prep(t *testing.T) (srv *Server, port int) { dataStore, err := store.NewBoltDB(store.BoltSite{FileName: testDb, SiteID: "radio-t"}) require.Nil(t, err) srv = &Server{ - DataService: store.Service{Interface: dataStore, EditDuration: 5 * time.Minute}, - DevMode: true, - AuthFacebook: &auth.Provider{}, - AuthGithub: &auth.Provider{}, - AuthGoogle: &auth.Provider{}, - Exporter: &migrator.Remark{DataStore: dataStore}, + DataService: store.Service{Interface: dataStore, EditDuration: 5 * time.Minute}, + DevMode: true, + AuthProviders: nil, + Exporter: &migrator.Remark{DataStore: dataStore}, + Cache: &mockCache{}, } go func() { port = rand.Intn(50000) + 1025 @@ -382,3 +380,11 @@ func cleanup(srv *Server) { srv.httpServer.Shutdown(context.Background()) os.Remove(testDb) } + +type mockCache struct{} + +func (mc *mockCache) Get(key string, ttl time.Duration, fn func() ([]byte, error)) (data []byte, err error) { + return fn() +} + +func (mc *mockCache) Flush() {}