mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-14 13:49:18 +02:00
Publish stable GHCR self-host images, switch self-host deploys to official image pulls with a source-build fallback, and move self-host signup / Google OAuth config onto runtime /api/config.
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package handler
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestGetConfigIncludesRuntimeAuthConfig(t *testing.T) {
|
|
origStorage := testHandler.Storage
|
|
testHandler.Storage = &mockStorage{}
|
|
defer func() { testHandler.Storage = origStorage }()
|
|
|
|
t.Setenv("ALLOW_SIGNUP", "false")
|
|
t.Setenv("GOOGLE_CLIENT_ID", "google-client-id")
|
|
t.Setenv("POSTHOG_API_KEY", "phc_test")
|
|
t.Setenv("POSTHOG_HOST", "https://eu.i.posthog.com")
|
|
|
|
req := httptest.NewRequest(http.MethodGet, "/api/config", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
testHandler.GetConfig(w, req)
|
|
if w.Code != http.StatusOK {
|
|
t.Fatalf("GetConfig: expected 200, got %d: %s", w.Code, w.Body.String())
|
|
}
|
|
|
|
var cfg AppConfig
|
|
if err := json.Unmarshal(w.Body.Bytes(), &cfg); err != nil {
|
|
t.Fatalf("decode config: %v", err)
|
|
}
|
|
|
|
if cfg.CdnDomain != "cdn.example.com" {
|
|
t.Fatalf("cdn_domain: want cdn.example.com, got %q", cfg.CdnDomain)
|
|
}
|
|
if cfg.AllowSignup {
|
|
t.Fatalf("allow_signup: want false, got true")
|
|
}
|
|
if cfg.GoogleClientID != "google-client-id" {
|
|
t.Fatalf("google_client_id: want google-client-id, got %q", cfg.GoogleClientID)
|
|
}
|
|
if cfg.PosthogKey != "phc_test" {
|
|
t.Fatalf("posthog_key: want phc_test, got %q", cfg.PosthogKey)
|
|
}
|
|
if cfg.PosthogHost != "https://eu.i.posthog.com" {
|
|
t.Fatalf("posthog_host: want https://eu.i.posthog.com, got %q", cfg.PosthogHost)
|
|
}
|
|
}
|