feat: add Creator username password login
CI / test (push) Failing after 15m55s

This commit is contained in:
m
2026-08-16 16:56:38 +03:00
parent 111ad75dea
commit 5fca81531a
15 changed files with 279 additions and 34 deletions
+31 -1
View File
@@ -33,6 +33,34 @@ func TestGatewayForwardsOnlyCreatorAllowlist(t *testing.T) {
}
}
func TestGatewayForwardsCreatorCredentialsOnlyInBody(t *testing.T) {
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/v1/creator/sessions" || r.Method != http.MethodPost {
t.Fatalf("unexpected session target %s %s", r.Method, r.URL.Path)
}
if r.Header.Get("Authorization") != "" || r.Header.Get("Content-Type") != "application/json" {
t.Fatalf("unexpected session headers Authorization=%q Content-Type=%q", r.Header.Get("Authorization"), r.Header.Get("Content-Type"))
}
body, _ := io.ReadAll(r.Body)
if string(body) != `{"username":"m","password":"secret"}` {
t.Fatalf("session body = %s", body)
}
_, _ = io.WriteString(w, `{"Token":"bounded"}`)
}))
defer upstream.Close()
handler, err := newHandler(upstream.URL, upstream.URL, upstream.URL, upstream.Client())
if err != nil {
t.Fatal(err)
}
request := httptest.NewRequest(http.MethodPost, "/api/session", strings.NewReader(`{"username":"m","password":"secret"}`))
request.Header.Set("Content-Type", "application/json")
response := httptest.NewRecorder()
handler.ServeHTTP(response, request)
if response.Code != http.StatusOK {
t.Fatalf("session response = %d %s", response.Code, response.Body.String())
}
}
func TestGatewayDeniesInternalAndMutationRoutes(t *testing.T) {
handler, err := newHandler("http://core-runtime:8080", "http://continuity-runtime:8081", "http://commit-runtime:8082", http.DefaultClient)
if err != nil {
@@ -139,7 +167,9 @@ func TestConsoleAndSecurityHeaders(t *testing.T) {
response := httptest.NewRecorder()
handler.ServeHTTP(response, request)
if response.Code != http.StatusOK || !strings.Contains(response.Body.String(), "Домовой") ||
!strings.Contains(response.Body.String(), "satisfaction-dialog") || !strings.Contains(response.Body.String(), "Подтверждаю переход") {
!strings.Contains(response.Body.String(), "satisfaction-dialog") || !strings.Contains(response.Body.String(), "Подтверждаю переход") ||
!strings.Contains(response.Body.String(), "creator-username") || !strings.Contains(response.Body.String(), "creator-password") ||
strings.Contains(response.Body.String(), "bootstrap-token") {
t.Fatalf("console response = %d", response.Code)
}
if response.Header().Get("Content-Security-Policy") == "" {