package router import ( "net/http" "net/http/httptest" "path/filepath" "strings" "testing" "gitea.mynodes.xyz/ilker/llmgw/internal/config" ) // auth.ldap is the cluster's: a CA file one machine lacks must not keep its // control plane from starting, where nothing could put the setting right. func TestADirectoryThatCannotBeUsedHereLeavesTheGatewayUp(t *testing.T) { cfg := baseConfig(config.Endpoint{ID: "a", URL: "http://127.0.0.1:1", Models: []string{"m"}}) cfg.Auth.Enabled = true cfg.Auth.Store = filepath.Join(t.TempDir(), "store.db") cfg.Auth.LDAP = config.LDAP{URLs: []string{"ldaps://dc1"}, CAFile: filepath.Join(t.TempDir(), "missing.pem"), BindDN: "CN=svc", BindPasswordFile: "/nonexistent", BaseDN: "DC=corp"} r := newTestRouter(t, cfg) if r.directory != nil { t.Fatal("a directory was set up from a CA file that is not there") } w := httptest.NewRecorder() r.Handler().ServeHTTP(w, httptest.NewRequest(http.MethodGet, "/login", nil)) if w.Code != http.StatusOK || !strings.Contains(w.Body.String(), `type="email"`) { t.Errorf("/login: %d", w.Code) } }