Skip to content
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/fatih/color v1.19.0
github.com/google/go-cmp v0.7.0
github.com/kong/go-apiops v0.4.0
github.com/kong/go-database-reconciler v1.36.1
github.com/kong/go-database-reconciler v1.36.2
github.com/kong/go-kong v0.75.0
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.10.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kong/go-apiops v0.4.0 h1:rXxdcE6VkDTOkhGt/ZytYqp8elw3SfrBQ/+r42lX2J4=
github.com/kong/go-apiops v0.4.0/go.mod h1:Xt99d90LallLVwYJAGaufiNbBdsK0KKboe7gR4Ryths=
github.com/kong/go-database-reconciler v1.36.1 h1:o8BVuYiKeneG9RUUSYDvEQXQ5VgfCuipaKlaPZ74nF8=
github.com/kong/go-database-reconciler v1.36.1/go.mod h1:0UfhRA9oelppRbirZMp0EM9qTlxb7iu3gJd+WKzoC0w=
github.com/kong/go-database-reconciler v1.36.2 h1:fUKSWonpR1UmJdLumJ9CdD4cYQ2wDEF627hJoFr3OBI=
github.com/kong/go-database-reconciler v1.36.2/go.mod h1:0UfhRA9oelppRbirZMp0EM9qTlxb7iu3gJd+WKzoC0w=
github.com/kong/go-kong v0.75.0 h1:QXbujfCJc5TauYS0EhKde2hbOCDe0YZTRYIX+qa+Adc=
github.com/kong/go-kong v0.75.0/go.mod h1:Wx5aTcMjyUnIF94M5NYFWb/EnuEkqB5STrWvybFSYYQ=
github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY=
Expand Down
66 changes: 66 additions & 0 deletions tests/integration/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"testing"

"github.com/kong/go-database-reconciler/pkg/utils"
"github.com/kong/go-kong/kong"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -1124,3 +1125,68 @@ func Test_Diff_Konnect_Workspace(t *testing.T) {
})
}
}

// Test_RequestTermination_Dump_Diff ensures that a create-via-API → dump → diff
// round-trip produces zero changes. This is a regression test for a bug where
// YAML-wrapped continuation lines starting with '#'
// were incorrectly stripped by renderTemplate, causing spurious diffs.
//
// test scope:
// - kong >=3.0.0
func Test_RequestTermination_Dump_Diff(t *testing.T) {
runWhen(t, "kong", ">=3.0.0")
setup(t)

ctx := context.Background()

client, err := getTestClient()
require.NoError(t, err)

body := `{"email":[{"subject":"Lion Rock","htmlemail":"<html><head><style>` +
`body { color: #4c4c4c; background-color: #ebeced; font-size: 14px; }` +
` .header { background-color: #006564; }` +
` .border { border-left: 8px solid #1B3668; border: 1px solid #BCBEC0; }` +
` .footer a { color: #116F9A; }` +
`</style></head><body>Lion Rock Business Class Lounge Pass cancellation.` +
`</body></html>","textemail":""}],"sms":"","errors":null}`

// Step 1: Create the plugin via the Kong Admin API, simulating a plugin
// created through Kong Manager UI (pristine body, no prior YAML round-trip).
createdPlugin, err := client.Plugins.Create(ctx, &kong.Plugin{
Name: kong.String("request-termination"),
Enabled: kong.Bool(true),
Config: kong.Configuration{
"status_code": float64(200),
"body": body,
"content_type": "application/json",
"echo": false,
"message": nil,
"trigger": nil,
},
Protocols: kong.StringSlice("grpc", "grpcs", "http", "https"),
})
require.NoError(t, err)
t.Cleanup(func() {
if createdPlugin != nil && createdPlugin.ID != nil {
_ = client.Plugins.Delete(ctx, createdPlugin.ID)
}
})

tmpFile, err := os.CreateTemp("", "deck-rt-dump-*.yaml")
require.NoError(t, err)
tmpFile.Close()
require.NoError(t, os.Remove(tmpFile.Name()))
t.Cleanup(func() { os.Remove(tmpFile.Name()) }) // no-op if dump already wrote it

_, err = dump("-o", tmpFile.Name())
require.NoError(t, err)

diffOut, err := diff(tmpFile.Name())
require.NoError(t, err)
assert.Contains(t, diffOut, "Created: 0",
"expected no diff between Kong state and the dumped file, got:\n%s", diffOut)
assert.Contains(t, diffOut, "Updated: 0",
"expected no diff between Kong state and the dumped file, got:\n%s", diffOut)
assert.Contains(t, diffOut, "Deleted: 0",
"expected no diff between Kong state and the dumped file, got:\n%s", diffOut)
}
Loading