@@ -8540,7 +8540,146 @@ func Test_Sync_SkipConsumersWithConsumerGroups_Konnect(t *testing.T) {
85408540}
85418541
85428542func Test_Sync_Partials_Plugins (t * testing.T ) {
8543- runWhenEnterpriseOrKonnect (t , ">=3.10.0" )
8543+ runWhen (t , "enterprise" , ">=3.10.0" )
8544+
8545+ client , err := getTestClient ()
8546+ require .NoError (t , err )
8547+
8548+ ctx := context .Background ()
8549+
8550+ dumpConfig := deckDump.Config {}
8551+
8552+ partialConfig := kong.Configuration {
8553+ "cluster_max_redirections" : float64 (5 ),
8554+ "cluster_nodes" : nil ,
8555+ "connect_timeout" : float64 (2000 ),
8556+ "connection_is_proxied" : bool (false ),
8557+ "database" : float64 (0 ),
8558+ "host" : string ("127.0.0.1" ),
8559+ "keepalive_backlog" : nil ,
8560+ "keepalive_pool_size" : float64 (256 ),
8561+ "password" : nil ,
8562+ "port" : float64 (6379 ),
8563+ "read_timeout" : float64 (3001 ),
8564+ "send_timeout" : float64 (2004 ),
8565+ "sentinel_master" : nil ,
8566+ "sentinel_nodes" : nil ,
8567+ "sentinel_password" : nil ,
8568+ "sentinel_role" : nil ,
8569+ "sentinel_username" : nil ,
8570+ "server_name" : nil ,
8571+ "ssl" : bool (false ),
8572+ "ssl_verify" : bool (false ),
8573+ "username" : nil ,
8574+ }
8575+
8576+ t .Run ("create a partial and link to a plugin via name" , func (t * testing.T ) {
8577+ require .NoError (t , sync (ctx , "testdata/sync/039-partials/kong.yaml" ))
8578+ t .Cleanup (func () {
8579+ reset (t )
8580+ })
8581+
8582+ newState , err := fetchCurrentState (ctx , client , dumpConfig , t )
8583+ require .NoError (t , err )
8584+
8585+ // check for partial
8586+ partials , err := newState .Partials .GetAll ()
8587+ require .NoError (t , err )
8588+ require .NotNil (t , partials )
8589+
8590+ require .Len (t , partials , 1 )
8591+ assert .Equal (t , "my-ee-partial" , * partials [0 ].Name )
8592+ assert .Equal (t , "redis-ee" , * partials [0 ].Type )
8593+ assert .IsType (t , kong.Configuration {}, partials [0 ].Config )
8594+ assert .Equal (t , partialConfig , partials [0 ].Config )
8595+
8596+ // check for plugin
8597+ plugins , err := newState .Plugins .GetAll ()
8598+ require .NoError (t , err )
8599+ require .NotNil (t , plugins )
8600+ require .Len (t , plugins , 1 )
8601+ assert .Equal (t , "rate-limiting-advanced" , * plugins [0 ].Name )
8602+ assert .IsType (t , []* kong.PartialLink {}, plugins [0 ].Partials )
8603+ require .Len (t , plugins [0 ].Partials , 1 )
8604+ assert .Equal (t , * partials [0 ].ID , * plugins [0 ].Partials [0 ].ID )
8605+ assert .Equal (t , "config.redis" , * plugins [0 ].Partials [0 ].Path )
8606+ })
8607+
8608+ t .Run ("partial id is preserved if passed and linking can be done via id" , func (t * testing.T ) {
8609+ require .NoError (t , sync (ctx , "testdata/sync/039-partials/kong-ids.yaml" ))
8610+ t .Cleanup (func () {
8611+ reset (t )
8612+ })
8613+
8614+ newState , err := fetchCurrentState (ctx , client , dumpConfig , t )
8615+ require .NoError (t , err )
8616+
8617+ // check for partial
8618+ partials , err := newState .Partials .GetAll ()
8619+ require .NoError (t , err )
8620+ require .NotNil (t , partials )
8621+
8622+ require .Len (t , partials , 1 )
8623+ assert .Equal (t , "13dc230d-d65e-439a-9f05-9fd71abfee4d" , * partials [0 ].ID )
8624+ assert .Equal (t , "my-ee-partial" , * partials [0 ].Name )
8625+ assert .Equal (t , "redis-ee" , * partials [0 ].Type )
8626+ assert .IsType (t , kong.Configuration {}, partials [0 ].Config )
8627+ assert .Equal (t , partialConfig , partials [0 ].Config )
8628+
8629+ // check for plugin
8630+ plugins , err := newState .Plugins .GetAll ()
8631+ require .NoError (t , err )
8632+ require .NotNil (t , plugins )
8633+ require .Len (t , plugins , 1 )
8634+ assert .Equal (t , "rate-limiting-advanced" , * plugins [0 ].Name )
8635+ assert .IsType (t , []* kong.PartialLink {}, plugins [0 ].Partials )
8636+ require .Len (t , plugins [0 ].Partials , 1 )
8637+ assert .Equal (t , "13dc230d-d65e-439a-9f05-9fd71abfee4d" , * plugins [0 ].Partials [0 ].ID )
8638+ assert .Equal (t , "config.redis" , * plugins [0 ].Partials [0 ].Path )
8639+ })
8640+
8641+ t .Run ("linking to a plugin fails in case of non-existent partial" , func (t * testing.T ) {
8642+ err := sync (ctx , "testdata/sync/039-partials/kong-wrong.yaml" )
8643+ require .Error (t , err )
8644+ assert .ErrorContains (t , err , "partial non-existent-partial for plugin rate-limiting-advanced: entity not found" )
8645+ })
8646+
8647+ t .Run ("partial linking with a consumer-group scoped plugin works fine" , func (t * testing.T ) {
8648+ require .NoError (t , sync (ctx , "testdata/sync/039-partials/cg-plugin-partial.yaml" ))
8649+ t .Cleanup (func () {
8650+ reset (t )
8651+ })
8652+
8653+ newState , err := fetchCurrentState (ctx , client , dumpConfig , t )
8654+ require .NoError (t , err )
8655+
8656+ // check for partial
8657+ partials , err := newState .Partials .GetAll ()
8658+ require .NoError (t , err )
8659+ require .NotNil (t , partials )
8660+
8661+ require .Len (t , partials , 1 )
8662+ assert .Equal (t , "my-redis-ee" , * partials [0 ].Name )
8663+ assert .Equal (t , "redis-ee" , * partials [0 ].Type )
8664+
8665+ // check for plugin
8666+ plugins , err := newState .Plugins .GetAll ()
8667+ require .NoError (t , err )
8668+ require .NotNil (t , plugins )
8669+ require .Len (t , plugins , 1 )
8670+ assert .Equal (t , "rate-limiting-advanced" , * plugins [0 ].Name )
8671+ assert .IsType (t , []* kong.PartialLink {}, plugins [0 ].Partials )
8672+ require .Len (t , plugins [0 ].Partials , 1 )
8673+ assert .Equal (t , * partials [0 ].ID , * plugins [0 ].Partials [0 ].ID )
8674+ assert .Equal (t , "config.redis" , * plugins [0 ].Partials [0 ].Path )
8675+ assert .Equal (t , "foo" , * plugins [0 ].ConsumerGroup .Name )
8676+ })
8677+ }
8678+
8679+ func Test_Sync_Partials_Plugins_Konnect (t * testing.T ) {
8680+ runWhenKonnect (t )
8681+ setDefaultKonnectControlPlane (t )
8682+ setup (t )
85448683
85458684 client , err := getTestClient ()
85468685 require .NoError (t , err )
@@ -8550,6 +8689,7 @@ func Test_Sync_Partials_Plugins(t *testing.T) {
85508689 dumpConfig := deckDump.Config {}
85518690
85528691 partialConfig := kong.Configuration {
8692+ "cloud_authentication" : nil ,
85538693 "cluster_max_redirections" : float64 (5 ),
85548694 "cluster_nodes" : nil ,
85558695 "connect_timeout" : float64 (2000 ),
@@ -10063,6 +10203,7 @@ func Test_Sync_Partials_Tagging_Konnect(t *testing.T) {
1006310203 Name : kong .String ("redis-ee-common" ),
1006410204 Type : kong .String ("redis-ee" ),
1006510205 Config : kong.Configuration {
10206+ "cloud_authentication" : nil ,
1006610207 "cluster_max_redirections" : float64 (5 ),
1006710208 "cluster_nodes" : nil ,
1006810209 "connect_timeout" : float64 (2000 ),
@@ -10092,6 +10233,7 @@ func Test_Sync_Partials_Tagging_Konnect(t *testing.T) {
1009210233 Name : kong .String ("redis-ee-sentinel" ),
1009310234 Type : kong .String ("redis-ee" ),
1009410235 Config : kong.Configuration {
10236+ "cloud_authentication" : nil ,
1009510237 "cluster_max_redirections" : float64 (5 ),
1009610238 "cluster_nodes" : nil ,
1009710239 "connect_timeout" : float64 (2000 ),
0 commit comments