Learn AuthGuard/CarrierNode URLs from ProjectConfigurator's push
Adds the receiving end of ProjectConfigurator's core-services push (PUT /api/core-services/internal, X-Internal-Auth-gated) via the shared coreconfig package, so this service's AUTHGUARD_URL/CARRIERNODE_URL env vars become just the bootstrap/fallback value instead of the permanent source of truth. authclient.Client gains a concurrency-safe SetBaseURL so a later push retargets it in place with no restart. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
20e9461d46
commit
7c4a903f59
7 files changed
+323
-11
No files matched your search
@@ -83,3 +83,30 @@ func TestSetupStatusPropagatesTransportError(t *testing.T) {
|
||||
t.Fatal("SetupStatus() expected an error against an unreachable server, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetBaseURLRetargetsSubsequentCalls(t *testing.T) {
|
||||
client := New("http://127.0.0.1:0")
|
||||
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(map[string]bool{"setup_required": true})
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client.SetBaseURL(server.URL)
|
||||
got, err := client.SetupStatus(context.Background())
|
||||
if err != nil {
|
||||
t.Fatalf("SetupStatus() after SetBaseURL error = %v", err)
|
||||
}
|
||||
if !got {
|
||||
t.Fatalf("SetupStatus() = %v, want true", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetBaseURLIgnoresBlank(t *testing.T) {
|
||||
client := New("https://auth.example.com")
|
||||
client.SetBaseURL(" ")
|
||||
if got := client.getBaseURL(); got != "https://auth.example.com" {
|
||||
t.Fatalf("SetBaseURL(blank) changed baseURL to %q, want unchanged", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user