refactor(settings): simplify settings query options and remove tenant dependency
CI / changes (push) Successful in 10s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 28s
CI / web (push) Successful in 1m0s
CI / go (push) Successful in 1m11s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 4m5s
CI / changes (push) Successful in 10s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 28s
CI / web (push) Successful in 1m0s
CI / go (push) Successful in 1m11s
CI / bird2 (push) Successful in 16s
CI / release (push) Successful in 4m5s
Updated the settings query options to eliminate the tenant ID parameter, streamlining the settings retrieval process. Adjusted the TenantSettingsComponent to reflect this change, ensuring it now queries settings without relying on tenant-specific data. This refactor enhances code clarity and reduces complexity in the settings management flow.
This commit is contained in:
@@ -31,7 +31,7 @@ func TestBearerDevGetSettings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBearerDevPrefersEnvAPIKeyOverDemoTenant(t *testing.T) {
|
||||
func TestBearerDevPrefersDemoTenantOverEnvKey(t *testing.T) {
|
||||
srv, err := New(Options{SeedDemo: true, BundleSeedHex: testBundleSeed})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -61,7 +61,41 @@ func TestBearerDevPrefersEnvAPIKeyOverDemoTenant(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, _ := body["tenant_id"].(string)
|
||||
if got != demoTenant {
|
||||
t.Fatalf("tenant_id=%q want demo tenant %q (env=%q)", got, demoTenant, otherTenant)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBearerDevFallsBackToEnvKeyWithoutDemo(t *testing.T) {
|
||||
srv, err := New(Options{SeedDemo: false, BundleSeedHex: testBundleSeed})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer srv.Close()
|
||||
|
||||
otherTenant := "00000000-0000-4000-8000-000000000001"
|
||||
mustSetTestAPIKeys(t, srv, "dev|"+otherTenant+"|operator")
|
||||
|
||||
ts := httptest.NewServer(srv.Handler())
|
||||
defer ts.Close()
|
||||
|
||||
req, _ := http.NewRequest(http.MethodGet, ts.URL+"/v1/auth/session", nil)
|
||||
req.Header.Set("Authorization", "Bearer dev")
|
||||
resp, err := ts.Client().Do(req)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
b, _ := io.ReadAll(resp.Body)
|
||||
t.Fatalf("session status=%d body=%s", resp.StatusCode, b)
|
||||
}
|
||||
var body map[string]any
|
||||
if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, _ := body["tenant_id"].(string)
|
||||
if got != otherTenant {
|
||||
t.Fatalf("tenant_id=%q want env key tenant %q (demo=%q)", got, otherTenant, demoTenant)
|
||||
t.Fatalf("tenant_id=%q want env key tenant %q", got, otherTenant)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user