@@ -7732,7 +7732,114 @@ func Test_Sync_SkipConsumersWithConsumerGroups_Konnect(t *testing.T) {
7732
7732
}
7733
7733
7734
7734
func Test_Sync_Partials_Plugins (t * testing.T ) {
7735
- runWhenEnterpriseOrKonnect (t , ">=3.10.0" )
7735
+ runWhen (t , "enterprise" , ">=3.10.0" )
7736
+
7737
+ client , err := getTestClient ()
7738
+ require .NoError (t , err )
7739
+
7740
+ ctx := context .Background ()
7741
+
7742
+ dumpConfig := deckDump.Config {}
7743
+
7744
+ partialConfig := kong.Configuration {
7745
+ "cluster_max_redirections" : float64 (5 ),
7746
+ "cluster_nodes" : nil ,
7747
+ "connect_timeout" : float64 (2000 ),
7748
+ "connection_is_proxied" : bool (false ),
7749
+ "database" : float64 (0 ),
7750
+ "host" : string ("127.0.0.1" ),
7751
+ "keepalive_backlog" : nil ,
7752
+ "keepalive_pool_size" : float64 (256 ),
7753
+ "password" : nil ,
7754
+ "port" : float64 (6379 ),
7755
+ "read_timeout" : float64 (3001 ),
7756
+ "send_timeout" : float64 (2004 ),
7757
+ "sentinel_master" : nil ,
7758
+ "sentinel_nodes" : nil ,
7759
+ "sentinel_password" : nil ,
7760
+ "sentinel_role" : nil ,
7761
+ "sentinel_username" : nil ,
7762
+ "server_name" : nil ,
7763
+ "ssl" : bool (false ),
7764
+ "ssl_verify" : bool (false ),
7765
+ "username" : nil ,
7766
+ }
7767
+
7768
+ t .Run ("create a partial and link to a plugin via name" , func (t * testing.T ) {
7769
+ require .NoError (t , sync (ctx , "testdata/sync/039-partials/kong.yaml" ))
7770
+ t .Cleanup (func () {
7771
+ reset (t )
7772
+ })
7773
+
7774
+ newState , err := fetchCurrentState (ctx , client , dumpConfig , t )
7775
+ require .NoError (t , err )
7776
+
7777
+ // check for partial
7778
+ partials , err := newState .Partials .GetAll ()
7779
+ require .NoError (t , err )
7780
+ require .NotNil (t , partials )
7781
+
7782
+ require .Len (t , partials , 1 )
7783
+ assert .Equal (t , "my-ee-partial" , * partials [0 ].Name )
7784
+ assert .Equal (t , "redis-ee" , * partials [0 ].Type )
7785
+ assert .IsType (t , kong.Configuration {}, partials [0 ].Config )
7786
+ assert .Equal (t , partialConfig , partials [0 ].Config )
7787
+
7788
+ // check for plugin
7789
+ plugins , err := newState .Plugins .GetAll ()
7790
+ require .NoError (t , err )
7791
+ require .NotNil (t , plugins )
7792
+ require .Len (t , plugins , 1 )
7793
+ assert .Equal (t , "rate-limiting-advanced" , * plugins [0 ].Name )
7794
+ assert .IsType (t , []* kong.PartialLink {}, plugins [0 ].Partials )
7795
+ require .Len (t , plugins [0 ].Partials , 1 )
7796
+ assert .Equal (t , * partials [0 ].ID , * plugins [0 ].Partials [0 ].ID )
7797
+ assert .Equal (t , "config.redis" , * plugins [0 ].Partials [0 ].Path )
7798
+ })
7799
+
7800
+ t .Run ("partial id is preserved if passed and linking can be done via id" , func (t * testing.T ) {
7801
+ require .NoError (t , sync (ctx , "testdata/sync/039-partials/kong-ids.yaml" ))
7802
+ t .Cleanup (func () {
7803
+ reset (t )
7804
+ })
7805
+
7806
+ newState , err := fetchCurrentState (ctx , client , dumpConfig , t )
7807
+ require .NoError (t , err )
7808
+
7809
+ // check for partial
7810
+ partials , err := newState .Partials .GetAll ()
7811
+ require .NoError (t , err )
7812
+ require .NotNil (t , partials )
7813
+
7814
+ require .Len (t , partials , 1 )
7815
+ assert .Equal (t , "13dc230d-d65e-439a-9f05-9fd71abfee4d" , * partials [0 ].ID )
7816
+ assert .Equal (t , "my-ee-partial" , * partials [0 ].Name )
7817
+ assert .Equal (t , "redis-ee" , * partials [0 ].Type )
7818
+ assert .IsType (t , kong.Configuration {}, partials [0 ].Config )
7819
+ assert .Equal (t , partialConfig , partials [0 ].Config )
7820
+
7821
+ // check for plugin
7822
+ plugins , err := newState .Plugins .GetAll ()
7823
+ require .NoError (t , err )
7824
+ require .NotNil (t , plugins )
7825
+ require .Len (t , plugins , 1 )
7826
+ assert .Equal (t , "rate-limiting-advanced" , * plugins [0 ].Name )
7827
+ assert .IsType (t , []* kong.PartialLink {}, plugins [0 ].Partials )
7828
+ require .Len (t , plugins [0 ].Partials , 1 )
7829
+ assert .Equal (t , "13dc230d-d65e-439a-9f05-9fd71abfee4d" , * plugins [0 ].Partials [0 ].ID )
7830
+ assert .Equal (t , "config.redis" , * plugins [0 ].Partials [0 ].Path )
7831
+ })
7832
+
7833
+ t .Run ("linking to a plugin fails in case of non-existent partial" , func (t * testing.T ) {
7834
+ err := sync (ctx , "testdata/sync/039-partials/kong-wrong.yaml" )
7835
+ require .Error (t , err )
7836
+ assert .ErrorContains (t , err , "partial non-existent-partial for plugin rate-limiting-advanced: entity not found" )
7837
+ })
7838
+ }
7839
+
7840
+ func Test_Sync_Partials_Plugins_Konnect (t * testing.T ) {
7841
+ runWhen (t , "konnect" , "" )
7842
+ setDefaultKonnectControlPlane (t )
7736
7843
7737
7844
client , err := getTestClient ()
7738
7845
require .NoError (t , err )
@@ -7763,6 +7870,7 @@ func Test_Sync_Partials_Plugins(t *testing.T) {
7763
7870
"ssl" : bool (false ),
7764
7871
"ssl_verify" : bool (false ),
7765
7872
"username" : nil ,
7873
+ "timeout" : float64 (2000 ),
7766
7874
}
7767
7875
7768
7876
t .Run ("create a partial and link to a plugin via name" , func (t * testing.T ) {
0 commit comments