Skip to content

Commit

Permalink
Merge branch 'main' into fix/kong2kic-1427
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashansa-K authored Dec 12, 2024
2 parents 8347e7a + 3c24be7 commit 5f49ae2
Show file tree
Hide file tree
Showing 4 changed files with 317 additions and 8 deletions.
11 changes: 5 additions & 6 deletions tests/integration/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,11 @@ func Test_Diff_NoDiffUnorderedArray(t *testing.T) {
stateFile: "testdata/diff/004-no-diff-plugin/kong.yaml",
runWhen: ">=3.5.0 <3.8.1",
},
// Uncomment post solving: https://konghq.atlassian.net/browse/FTI-6303
// {
// name: "no diffs with unordered arrays >=3.8.1",
// stateFile: "testdata/diff/004-no-diff-plugin/kong.yaml",
// runWhen: ">=3.8.1",
// },
{
name: "no diffs with unordered arrays >=3.8.1",
stateFile: "testdata/diff/004-no-diff-plugin/kong.yaml",
runWhen: ">=3.8.1",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,14 @@ func Test_Dump_SkipConsumers(t *testing.T) {
stateFile: "testdata/dump/002-skip-consumers/kong34.yaml",
expectedFile: "testdata/dump/002-skip-consumers/expected-no-skip-381.yaml",
skipConsumers: false,
runWhen: func(t *testing.T) { runWhen(t, "enterprise", ">=3.8.1") },
runWhen: func(t *testing.T) { runWhen(t, "enterprise", ">=3.8.1 <3.9.0") },
},
{
name: "3.9.0 dump with no skip-consumers",
stateFile: "testdata/dump/002-skip-consumers/kong34.yaml",
expectedFile: "testdata/dump/002-skip-consumers/expected-no-skip-39.yaml",
skipConsumers: false,
runWhen: func(t *testing.T) { runWhen(t, "enterprise", ">=3.9.0") },
},
}
for _, tc := range tests {
Expand Down
238 changes: 237 additions & 1 deletion tests/integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,189 @@ var (
Protocols: []*string{kong.String("http"), kong.String("https")},
},
}

consumerGroupScopedPlugins390x = []*kong.Plugin{
{
Name: kong.String("rate-limiting-advanced"),
ConsumerGroup: &kong.ConsumerGroup{
ID: kong.String("77e6691d-67c0-446a-9401-27be2b141aae"),
},
Config: kong.Configuration{
"compound_identifier": nil,
"consumer_groups": nil,
"dictionary_name": string("kong_rate_limiting_counters"),
"disable_penalty": bool(false),
"enforce_consumer_groups": bool(false),
"error_code": float64(429),
"error_message": string("API rate limit exceeded"),
"header_name": nil,
"hide_client_headers": bool(false),
"identifier": string("consumer"),
"limit": []any{float64(10)},
"lock_dictionary_name": string("kong_locks"),
"namespace": string("gold"),
"path": nil,
"redis": map[string]any{
"cluster_addresses": nil,
"cluster_max_redirections": float64(5),
"cluster_nodes": nil,
"connect_timeout": float64(2000),
"connection_is_proxied": bool(false),
"database": float64(0),
"host": string("127.0.0.1"),
"keepalive_backlog": nil,
"keepalive_pool_size": float64(256),
"password": nil,
"port": float64(6379),
"read_timeout": float64(2000),
"redis_proxy_type": nil,
"send_timeout": float64(2000),
"sentinel_addresses": nil,
"sentinel_master": nil,
"sentinel_nodes": nil,
"sentinel_password": nil,
"sentinel_role": nil,
"sentinel_username": nil,
"server_name": nil,
"ssl": false,
"ssl_verify": false,
"timeout": float64(2000),
"username": nil,
},
"retry_after_jitter_max": float64(1),
"strategy": string("local"),
"sync_rate": float64(-1),
"window_size": []any{float64(60)},
"window_type": string("sliding"),
},
Enabled: kong.Bool(true),
Protocols: []*string{kong.String("grpc"), kong.String("grpcs"), kong.String("http"), kong.String("https")},
},
{
Name: kong.String("rate-limiting-advanced"),
ConsumerGroup: &kong.ConsumerGroup{
ID: kong.String("5bcbd3a7-030b-4310-bd1d-2721ff85d236"),
},
Config: kong.Configuration{
"compound_identifier": nil,
"consumer_groups": nil,
"dictionary_name": string("kong_rate_limiting_counters"),
"disable_penalty": bool(false),
"enforce_consumer_groups": bool(false),
"error_code": float64(429),
"error_message": string("API rate limit exceeded"),
"header_name": nil,
"hide_client_headers": bool(false),
"identifier": string("consumer"),
"limit": []any{float64(7)},
"lock_dictionary_name": string("kong_locks"),
"namespace": string("silver"),
"path": nil,
"redis": map[string]any{
"cluster_addresses": nil,
"cluster_max_redirections": float64(5),
"cluster_nodes": nil,
"connect_timeout": float64(2000),
"connection_is_proxied": bool(false),
"database": float64(0),
"host": string("127.0.0.1"),
"keepalive_backlog": nil,
"keepalive_pool_size": float64(256),
"password": nil,
"port": float64(6379),
"read_timeout": float64(2000),
"redis_proxy_type": nil,
"send_timeout": float64(2000),
"sentinel_addresses": nil,
"sentinel_master": nil,
"sentinel_nodes": nil,
"sentinel_password": nil,
"sentinel_role": nil,
"sentinel_username": nil,
"server_name": nil,
"ssl": false,
"ssl_verify": false,
"timeout": float64(2000),
"username": nil,
},
"retry_after_jitter_max": float64(1),
"strategy": string("local"),
"sync_rate": float64(-1),
"window_size": []any{float64(60)},
"window_type": string("sliding"),
},
Enabled: kong.Bool(true),
Protocols: []*string{kong.String("grpc"), kong.String("grpcs"), kong.String("http"), kong.String("https")},
},
{
Name: kong.String("rate-limiting-advanced"),
Config: kong.Configuration{
"compound_identifier": nil,
"consumer_groups": nil,
"dictionary_name": string("kong_rate_limiting_counters"),
"disable_penalty": bool(false),
"enforce_consumer_groups": bool(false),
"error_code": float64(429),
"error_message": string("API rate limit exceeded"),
"header_name": nil,
"hide_client_headers": bool(false),
"identifier": string("consumer"),
"limit": []any{float64(5)},
"lock_dictionary_name": string("kong_locks"),
"namespace": string("silver"),
"path": nil,
"redis": map[string]any{
"cluster_addresses": nil,
"cluster_max_redirections": float64(5),
"cluster_nodes": nil,
"connect_timeout": float64(2000),
"connection_is_proxied": bool(false),
"database": float64(0),
"host": string("127.0.0.1"),
"keepalive_backlog": nil,
"keepalive_pool_size": float64(256),
"password": nil,
"port": float64(6379),
"read_timeout": float64(2000),
"redis_proxy_type": nil,
"send_timeout": float64(2000),
"sentinel_addresses": nil,
"sentinel_master": nil,
"sentinel_nodes": nil,
"sentinel_password": nil,
"sentinel_role": nil,
"sentinel_username": nil,
"server_name": nil,
"ssl": false,
"ssl_verify": false,
"timeout": float64(2000),
"username": nil,
},
"retry_after_jitter_max": float64(1),
"strategy": string("local"),
"sync_rate": float64(-1),
"window_size": []any{float64(60)},
"window_type": string("sliding"),
},
Enabled: kong.Bool(true),
Protocols: []*string{kong.String("grpc"), kong.String("grpcs"), kong.String("http"), kong.String("https")},
},
{
Name: kong.String("key-auth"),
Config: kong.Configuration{
"anonymous": nil,
"hide_credentials": false,
"key_in_body": false,
"key_in_header": true,
"key_in_query": true,
"key_names": []interface{}{"apikey"},
"realm": nil, // This is present on 3.7.x+
"run_on_preflight": true,
},
Enabled: kong.Bool(true),
Protocols: []*string{kong.String("http"), kong.String("https")},
},
}
)

// test scope:
Expand Down Expand Up @@ -5045,7 +5228,7 @@ func Test_Sync_ConsumerGroupsScopedPlugins_After360(t *testing.T) {
},
{
name: "creates consumer groups scoped plugins",
runWhen: ">=3.8.1",
runWhen: ">=3.8.1 <3.9.0",
kongFile: "testdata/sync/025-consumer-groups-scoped-plugins/kong3x.yaml",
expectedState: utils.KongRawState{
Consumers: consumerGroupsConsumers,
Expand Down Expand Up @@ -5096,6 +5279,59 @@ func Test_Sync_ConsumerGroupsScopedPlugins_After360(t *testing.T) {
},
},
},
{
name: "creates consumer groups scoped plugins",
runWhen: ">=3.9.0",
kongFile: "testdata/sync/025-consumer-groups-scoped-plugins/kong3x.yaml",
expectedState: utils.KongRawState{
Consumers: consumerGroupsConsumers,
ConsumerGroups: []*kong.ConsumerGroupObject{
{
ConsumerGroup: &kong.ConsumerGroup{
Name: kong.String("silver"),
},
Consumers: []*kong.Consumer{
{
Username: kong.String("bar"),
},
},
},
{
ConsumerGroup: &kong.ConsumerGroup{
Name: kong.String("gold"),
},
Consumers: []*kong.Consumer{
{
Username: kong.String("foo"),
},
},
},
},
Plugins: consumerGroupScopedPlugins390x,
Services: svc1_207,
Routes: route1_20x,
KeyAuths: []*kong.KeyAuth{
{
Consumer: &kong.Consumer{
ID: kong.String("87095815-5395-454e-8c18-a11c9bc0ef04"),
},
Key: kong.String("i-am-special"),
},
{
Consumer: &kong.Consumer{
ID: kong.String("5a5b9369-baeb-4faa-a902-c40ccdc2928e"),
},
Key: kong.String("i-am-not-so-special"),
},
{
Consumer: &kong.Consumer{
ID: kong.String("e894ea9e-ad08-4acf-a960-5a23aa7701c7"),
},
Key: kong.String("i-am-just-average"),
},
},
},
},
}
for _, tc := range tests {
t.Run(tc.name+"/"+tc.runWhen, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
_format_version: "3.0"
consumer_groups:
- name: basic
plugins:
- config:
compound_identifier: null
consumer_groups: null
dictionary_name: kong_rate_limiting_counters
disable_penalty: false
enforce_consumer_groups: false
error_code: 429
error_message: API rate limit exceeded
header_name: null
hide_client_headers: false
identifier: consumer
limit:
- 30000
lock_dictionary_name: kong_locks
namespace: basic
path: null
redis:
cluster_addresses: null
cluster_max_redirections: 5
cluster_nodes: null
connect_timeout: 2000
connection_is_proxied: false
database: 0
host: 127.0.0.1
keepalive_backlog: null
keepalive_pool_size: 256
password: null
port: 6379
read_timeout: 2000
redis_proxy_type: null
send_timeout: 2000
sentinel_addresses: null
sentinel_master: null
sentinel_nodes: 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:
- 2628000
window_type: sliding
name: rate-limiting-advanced
consumers:
- groups:
- name: basic
username: foo
services:
- connect_timeout: 60000
enabled: true
host: mockbin.org
name: svc1
port: 80
protocol: http
read_timeout: 60000
retries: 5
write_timeout: 60000

0 comments on commit 5f49ae2

Please sign in to comment.