package store

import (
	"encoding/json"
	"strings"
	"testing"
)

func TestGatewayTaskJSONOmitsPrivateRemoteTaskPayload(t *testing.T) {
	raw, err := json.Marshal(GatewayTask{
		ID:                "task-private-state",
		RemoteTaskID:      "safe-upstream-id",
		RemoteTaskPayload: map[string]any{"imageToken": "private-image-token", "receipt": "private-receipt"},
	})
	if err != nil {
		t.Fatal(err)
	}
	serialized := strings.ToLower(string(raw))
	if strings.Contains(serialized, "private-image-token") || strings.Contains(serialized, "private-receipt") || strings.Contains(serialized, "remotetaskpayload") {
		t.Fatalf("private provider recovery state leaked into task JSON: %s", serialized)
	}
	if !strings.Contains(serialized, "safe-upstream-id") {
		t.Fatalf("public upstream task id should remain available: %s", serialized)
	}
}
