fix installer

This commit is contained in:
Daniel Noulet 2026-10-02 21:45:42 +02:00
parent 46030a5b14
commit c2091e746a
19 changed files with 264 additions and 73 deletions

View file

@ -1,6 +1,7 @@
package server
import (
"net/http"
"net/http/httptest"
"testing"
@ -8,11 +9,11 @@ import (
)
func TestOAuthStateCookieDomain(t *testing.T) {
server := &Server{cfg: config.Config{AuthDomain: "auth.local"}}
server := &Server{cfg: config.Config{AuthDomain: "auth.dev"}}
tenantRequest := httptest.NewRequest("GET", "http://nmbs.auth.local/auth/start", nil)
if domain := server.oauthStateCookieDomain(tenantRequest); domain != "auth.local" {
t.Fatalf("tenant cookie domain = %q, want auth.local", domain)
tenantRequest := httptest.NewRequest("GET", "http://nmbs.auth.dev/auth/start", nil)
if domain := server.oauthStateCookieDomain(tenantRequest); domain != "auth.dev" {
t.Fatalf("tenant cookie domain = %q, want auth.dev", domain)
}
localRequest := httptest.NewRequest("GET", "http://localhost:8080/auth/start", nil)
@ -20,3 +21,27 @@ func TestOAuthStateCookieDomain(t *testing.T) {
t.Fatalf("local cookie domain = %q, want host-only cookie", domain)
}
}
func TestManagementSSOIsRejectedOnTenantHost(t *testing.T) {
server := &Server{cfg: config.Config{AuthDomain: "auth.dev"}}
request := httptest.NewRequest(http.MethodGet, "http://nmbs.auth.dev/auth/start", nil)
response := httptest.NewRecorder()
server.authStart(response, request)
if response.Code != http.StatusNotFound {
t.Fatalf("status = %d, want %d", response.Code, http.StatusNotFound)
}
}
func TestClientSSOIsRejectedOnSystemHost(t *testing.T) {
server := &Server{cfg: config.Config{AuthDomain: "auth.dev"}}
request := httptest.NewRequest(http.MethodGet, "http://auth.dev/auth/start?return=client", nil)
response := httptest.NewRecorder()
server.authStart(response, request)
if response.Code != http.StatusNotFound {
t.Fatalf("status = %d, want %d", response.Code, http.StatusNotFound)
}
}