feat: allow proxyProvider outpost field to be updated

This commit is contained in:
2026-05-25 13:12:10 +02:00
parent 7735f363f0
commit 5f0785502a
2 changed files with 23 additions and 1 deletions
+5 -1
View File
@@ -212,9 +212,13 @@ func (c *ProxyProviderController) reconcileUpdate(ctx context.Context, pp *v1alp
if err != nil { if err != nil {
return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyPartialUpdate`: %w with response %v", err, r) return fmt.Errorf("error when calling `ProvidersAPI.ProvidersProxyPartialUpdate`: %w with response %v", err, r)
} }
pp.Status.PK = strconv.Itoa(int(resp.Pk)) pp.Status.PK = strconv.Itoa(int(resp.Pk))
err = c.reconcileOutpost(ctx, pp.Spec.Outpost, int32(pk), ReconcileOutpostModeAdd)
if err != nil {
return fmt.Errorf("error when calling `reconcileOutpost`: %w", err)
}
return c.updateProxyProviderStatus(ctx, pp) return c.updateProxyProviderStatus(ctx, pp)
} }
@@ -123,6 +123,7 @@ func TestController_syncHandler_update(t *testing.T) {
pp.Status.PK = "42" pp.Status.PK = "42"
pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer} pp.Finalizers = []string{DeleteAuthentikProxyProviderFinalizer}
var outpostPartialUpdateCalled bool
server := newAuthentikTestServer(t, authentikTestHandlers{ server := newAuthentikTestServer(t, authentikTestHandlers{
allRetrieve: func(w http.ResponseWriter, _ *http.Request) { allRetrieve: func(w http.ResponseWriter, _ *http.Request) {
writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42}) writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42})
@@ -130,6 +131,20 @@ func TestController_syncHandler_update(t *testing.T) {
proxyPartialUpdate: func(w http.ResponseWriter, _ *http.Request) { proxyPartialUpdate: func(w http.ResponseWriter, _ *http.Request) {
writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42}) writeJSON(t, w, http.StatusOK, map[string]any{"pk": 42})
}, },
outpostRetrieve: outpostRetrieveHandler(t, nil),
outpostPartialUpdate: func(w http.ResponseWriter, r *http.Request) {
outpostPartialUpdateCalled = true
var body struct {
Providers []int32 `json:"providers"`
}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
t.Fatalf("decode outpost patch body: %v", err)
}
if !slices.Contains(body.Providers, 42) {
t.Fatalf("patched providers = %v, want to contain 42", body.Providers)
}
writeJSON(t, w, http.StatusOK, map[string]any{"pk": testOutpostID, "providers": body.Providers})
},
}) })
t.Cleanup(server.Close) t.Cleanup(server.Close)
@@ -140,6 +155,9 @@ func TestController_syncHandler_update(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("syncHandler() error = %v", err) t.Fatalf("syncHandler() error = %v", err)
} }
if !outpostPartialUpdateCalled {
t.Fatal("expected Authentik outpost partial update call")
}
got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name) got := getProxyProvider(t, ctrl, pp.Namespace, pp.Name)
if got.Status.PK != "42" { if got.Status.PK != "42" {