Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GGabriele committed Aug 3, 2023
1 parent ef83a97 commit 2c970cd
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
7 changes: 6 additions & 1 deletion file/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,12 @@ func (b *stateBuilder) validatePlugin(p FPlugin) error {
consumerGroupsFound = true
}
}
_, enforceConsumerGroupsFound := p.Config["enforce_consumer_groups"]
var enforceConsumerGroupsFound bool
if enforceConsumerGroups, ok := p.Config["enforce_consumer_groups"]; ok {
if enforceConsumerGroupsBool, ok := enforceConsumerGroups.(bool); ok && enforceConsumerGroupsBool {
enforceConsumerGroupsFound = true
}
}
if consumerGroupsFound || enforceConsumerGroupsFound {
return utils.ErrorConsumerGroupUpgrade
}
Expand Down
12 changes: 10 additions & 2 deletions tests/integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4522,10 +4522,14 @@ func Test_Sync_ConsumerGroupsScopedPlugins_Post340(t *testing.T) {
expectedError error
}{
{
name: "attempt to createe consumer groups scoped plugins with older Kong version",
name: "attempt to create deprecated consumer groups configuration with Kong version >= 3.4.0 fails",
kongFile: "testdata/sync/017-consumer-groups-rla-application/kong3x.yaml",
expectedError: fmt.Errorf("building state: %v", utils.ErrorConsumerGroupUpgrade),
},
{
name: "empty deprecated consumer groups configuration fields do not fail with Kong version >= 3.4.0",
kongFile: "testdata/sync/017-consumer-groups-rla-application/kong3x-empty-application.yaml",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand All @@ -4534,7 +4538,11 @@ func Test_Sync_ConsumerGroupsScopedPlugins_Post340(t *testing.T) {
defer teardown(t)

err := sync(tc.kongFile)
assert.EqualError(t, err, tc.expectedError.Error())
if tc.expectedError == nil {
assert.NoError(t, err)
} else {
assert.EqualError(t, err, tc.expectedError.Error())
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
_format_version: "3.0"
plugins:
- config:
consumer_groups: null
dictionary_name: kong_rate_limiting_counters
enforce_consumer_groups: false
header_name: null
hide_client_headers: false
identifier: consumer
limit:
- 5
namespace: dNRC6xKsRL8Koc1uVYA4Nki6DLW7XIdx
path: null
redis:
cluster_addresses: null
connect_timeout: null
database: 0
host: null
keepalive_backlog: null
keepalive_pool_size: 30
password: null
port: null
read_timeout: null
send_timeout: null
sentinel_addresses: null
sentinel_master: null
sentinel_password: null
sentinel_role: null
sentinel_username: null
server_name: null
ssl: false
ssl_verify: false
timeout: 2000
username: null
retry_after_jitter_max: 0
strategy: local
sync_rate: -1
window_size:
- 60
window_type: sliding
enabled: true
name: rate-limiting-advanced
protocols:
- grpc
- grpcs
- http
- https

0 comments on commit 2c970cd

Please sign in to comment.