@@ -11985,3 +11985,68 @@ func testSyncPluginConditionalKonnectImpl(t *testing.T) {
1198511985
1198611986 testKongState (t , client , true , false , expectedStatePostSync , nil )
1198711987}
11988+
11989+ // Test_RequestTermination_Dump_Diff ensures that a create-via-API → dump → diff
11990+ // round-trip produces zero changes. This is a regression test for a bug where
11991+ // YAML-wrapped continuation lines starting with '#'
11992+ // were incorrectly stripped by renderTemplate, causing spurious diffs.
11993+ //
11994+ // test scope:
11995+ // - kong >=3.0.0
11996+ func Test_RequestTermination_Dump_Diff (t * testing.T ) {
11997+ runWhen (t , "kong" , ">=3.0.0" )
11998+ setup (t )
11999+
12000+ ctx := context .Background ()
12001+
12002+ client , err := getTestClient ()
12003+ require .NoError (t , err )
12004+
12005+ body := `{"email":[{"subject":"Lion Rock","htmlemail":"<html><head><style>` +
12006+ `body { color: #4c4c4c; background-color: #ebeced; font-size: 14px; }` +
12007+ ` .header { background-color: #006564; }` +
12008+ ` .border { border-left: 8px solid #1B3668; border: 1px solid #BCBEC0; }` +
12009+ ` .footer a { color: #116F9A; }` +
12010+ `</style></head><body>Lion Rock Business Class Lounge Pass cancellation.` +
12011+ `</body></html>","textemail":""}],"sms":"","errors":null}`
12012+
12013+ // Step 1: Create the plugin via the Kong Admin API, simulating a plugin
12014+ // created through Kong Manager UI (pristine body, no prior YAML round-trip).
12015+ createdPlugin , err := client .Plugins .Create (ctx , & kong.Plugin {
12016+ Name : kong .String ("request-termination" ),
12017+ Enabled : kong .Bool (true ),
12018+ Config : kong.Configuration {
12019+ "status_code" : float64 (200 ),
12020+ "body" : body ,
12021+ "content_type" : "application/json" ,
12022+ "echo" : false ,
12023+ "message" : nil ,
12024+ "trigger" : nil ,
12025+ },
12026+ Protocols : kong .StringSlice ("grpc" , "grpcs" , "http" , "https" ),
12027+ })
12028+ require .NoError (t , err )
12029+ t .Cleanup (func () {
12030+ if createdPlugin != nil && createdPlugin .ID != nil {
12031+ _ = client .Plugins .Delete (ctx , createdPlugin .ID )
12032+ }
12033+ })
12034+
12035+ tmpFile , err := os .CreateTemp ("" , "deck-rt-dump-*.yaml" )
12036+ require .NoError (t , err )
12037+ tmpFile .Close ()
12038+ require .NoError (t , os .Remove (tmpFile .Name ()))
12039+ t .Cleanup (func () { os .Remove (tmpFile .Name ()) }) // no-op if dump already wrote it
12040+
12041+ _ , err = dump ("-o" , tmpFile .Name ())
12042+ require .NoError (t , err )
12043+
12044+ diffOut , err := diff (tmpFile .Name ())
12045+ require .NoError (t , err )
12046+ assert .Contains (t , diffOut , "Created: 0" ,
12047+ "expected no diff between Kong state and the dumped file, got:\n %s" , diffOut )
12048+ assert .Contains (t , diffOut , "Updated: 0" ,
12049+ "expected no diff between Kong state and the dumped file, got:\n %s" , diffOut )
12050+ assert .Contains (t , diffOut , "Deleted: 0" ,
12051+ "expected no diff between Kong state and the dumped file, got:\n %s" , diffOut )
12052+ }
0 commit comments