Skip to content

Commit 9fce824

Browse files
authored
tests: lint fix and konnect tests correction (#1895)
* style: lint fixes * tests: fixed Konnect test for partial * tests: fixed konnect plugin-partial default lookups test
1 parent ef04ee6 commit 9fce824

File tree

4 files changed

+48
-50
lines changed

4 files changed

+48
-50
lines changed

.golangci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,26 @@ linters:
8484
- gosec
8585
path: file/codegen/main.go
8686
text: Expect WriteFile permissions to be 0600 or less
87+
# Exclude gosec G101 (hardcoded credentials) for test files
88+
- linters:
89+
- gosec
90+
path: _test\.go
91+
text: G101
92+
# Exclude gosec G101 for static entity maps (false positive on entity type names)
93+
- linters:
94+
- gosec
95+
path: (sanitize/schemas|validate/validate)\.go
96+
text: G101
97+
# Exclude gosec G704 (SSRF) for test files where HTTP requests are expected
98+
- linters:
99+
- gosec
100+
path: tests/integration/
101+
text: G704
102+
# Exclude gosec G115 (integer overflow) for safe port number conversion
103+
- linters:
104+
- gosec
105+
path: kong2kic/route\.go
106+
text: G115
87107
- linters:
88108
- unparam
89109
- unused

kong2kic/route.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func addBackendRefs(httpRoute *k8sgwapiv1.HTTPRoute, service file.FService, rout
352352
},
353353
}
354354
if service.Port != nil {
355-
portNumber := k8sgwapiv1.PortNumber(*service.Port) //nolint:gosec
355+
portNumber := k8sgwapiv1.PortNumber(*service.Port)
356356
backendRef.Port = &portNumber
357357
}
358358

kong2tf/generate_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ func (i importKeys) Marshal() (string, error) {
202202
return "", err
203203
}
204204
for _, k := range keys {
205-
_, err := sb.WriteString(fmt.Sprintf(`\"%s\": \"%s\", `, k, *i.keyValues[k]))
205+
_, err := fmt.Fprintf(&sb, `\"%s\": \"%s\", `, k, *i.keyValues[k])
206206
if err != nil {
207207
return "", err
208208
}
209209
}
210210

211-
_, err := sb.WriteString(fmt.Sprintf(`\"control_plane_id\": \"%s\"`, *i.controlPlaneID))
211+
_, err := fmt.Fprintf(&sb, `\"control_plane_id\": \"%s\"`, *i.controlPlaneID)
212212
if err != nil {
213213
return "", err
214214
}

tests/integration/sync_test.go

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8766,28 +8766,17 @@ func Test_Sync_Partials_Plugins_Konnect(t *testing.T) {
87668766
dumpConfig := deckDump.Config{}
87678767

87688768
partialConfig := kong.Configuration{
8769-
"cloud_authentication": nil,
87708769
"cluster_max_redirections": float64(5),
8771-
"cluster_nodes": nil,
87728770
"connect_timeout": float64(2000),
87738771
"connection_is_proxied": bool(false),
87748772
"database": float64(0),
87758773
"host": string("127.0.0.1"),
8776-
"keepalive_backlog": nil,
87778774
"keepalive_pool_size": float64(256),
8778-
"password": nil,
87798775
"port": float64(6379),
87808776
"read_timeout": float64(3001),
87818777
"send_timeout": float64(2004),
8782-
"sentinel_master": nil,
8783-
"sentinel_nodes": nil,
8784-
"sentinel_password": nil,
8785-
"sentinel_role": nil,
8786-
"sentinel_username": nil,
8787-
"server_name": nil,
87888778
"ssl": bool(false),
87898779
"ssl_verify": bool(false),
8790-
"username": nil,
87918780
}
87928781

87938782
t.Run("create a partial and link to a plugin via name", func(t *testing.T) {
@@ -10280,28 +10269,17 @@ func Test_Sync_Partials_Tagging_Konnect(t *testing.T) {
1028010269
Name: kong.String("redis-ee-common"),
1028110270
Type: kong.String("redis-ee"),
1028210271
Config: kong.Configuration{
10283-
"cloud_authentication": nil,
1028410272
"cluster_max_redirections": float64(5),
10285-
"cluster_nodes": nil,
1028610273
"connect_timeout": float64(2000),
1028710274
"connection_is_proxied": bool(false),
1028810275
"database": float64(0),
1028910276
"host": string("127.0.0.1"),
10290-
"keepalive_backlog": nil,
1029110277
"keepalive_pool_size": float64(256),
10292-
"password": nil,
1029310278
"port": float64(6379),
1029410279
"read_timeout": float64(3001),
1029510280
"send_timeout": float64(2004),
10296-
"sentinel_master": nil,
10297-
"sentinel_nodes": nil,
10298-
"sentinel_password": nil,
10299-
"sentinel_role": nil,
10300-
"sentinel_username": nil,
10301-
"server_name": nil,
1030210281
"ssl": bool(false),
1030310282
"ssl_verify": bool(false),
10304-
"username": nil,
1030510283
},
1030610284
Tags: kong.StringSlice("redis-partials"),
1030710285
},
@@ -10310,16 +10288,12 @@ func Test_Sync_Partials_Tagging_Konnect(t *testing.T) {
1031010288
Name: kong.String("redis-ee-sentinel"),
1031110289
Type: kong.String("redis-ee"),
1031210290
Config: kong.Configuration{
10313-
"cloud_authentication": nil,
1031410291
"cluster_max_redirections": float64(5),
10315-
"cluster_nodes": nil,
1031610292
"connect_timeout": float64(2000),
1031710293
"connection_is_proxied": bool(false),
1031810294
"database": float64(0),
1031910295
"host": string("127.0.0.1"),
10320-
"keepalive_backlog": nil,
1032110296
"keepalive_pool_size": float64(256),
10322-
"password": nil,
1032310297
"port": float64(6379),
1032410298
"read_timeout": float64(2000),
1032510299
"send_timeout": float64(2000),
@@ -10329,13 +10303,9 @@ func Test_Sync_Partials_Tagging_Konnect(t *testing.T) {
1032910303
map[string]any{"host": string("redis-node-1"), "port": float64(26379)},
1033010304
map[string]any{"host": string("redis-node-2"), "port": float64(26379)},
1033110305
},
10332-
"sentinel_password": nil,
10333-
"sentinel_role": string("master"),
10334-
"sentinel_username": nil,
10335-
"server_name": nil,
10336-
"ssl": bool(false),
10337-
"ssl_verify": bool(false),
10338-
"username": nil,
10306+
"sentinel_role": string("master"),
10307+
"ssl": bool(false),
10308+
"ssl_verify": bool(false),
1033910309
},
1034010310
Tags: kong.StringSlice("redis-partials"),
1034110311
},
@@ -10375,19 +10345,23 @@ func Test_Sync_Partials_Tagging_Konnect(t *testing.T) {
1037510345
"lock_dictionary_name": string("kong_locks"),
1037610346
"namespace": string("test-ns"),
1037710347
"path": nil,
10378-
"retry_after_jitter_max": float64(0),
10379-
"strategy": string("local"),
10380-
"sync_rate": float64(-1),
10381-
"throttling": nil,
10382-
"window_size": []any{float64(60)},
10383-
"window_type": string("fixed"),
10348+
"redis": map[string]any{
10349+
"redis_proxy_type": nil,
10350+
},
10351+
"retry_after_jitter_max": float64(0),
10352+
"strategy": string("local"),
10353+
"sync_rate": float64(-1),
10354+
"throttling": nil,
10355+
"window_size": []any{float64(60)},
10356+
"window_type": string("fixed"),
1038410357
},
1038510358
Enabled: kong.Bool(true),
1038610359
Protocols: kong.StringSlice("grpc", "grpcs", "http", "https"),
1038710360
Partials: []*kong.PartialLink{
1038810361
{
1038910362
Partial: &kong.Partial{
10390-
ID: kong.String("13dc230d-d65e-439a-9f05-9fd71abfee4d"),
10363+
ID: kong.String("13dc230d-d65e-439a-9f05-9fd71abfee4d"),
10364+
Name: kong.String("redis-ee-common"),
1039110365
},
1039210366
Path: kong.String("config.redis"),
1039310367
},
@@ -10414,20 +10388,24 @@ func Test_Sync_Partials_Tagging_Konnect(t *testing.T) {
1041410388
"lock_dictionary_name": string("kong_locks"),
1041510389
"namespace": string("testns"),
1041610390
"path": nil,
10417-
"retry_after_jitter_max": float64(0),
10418-
"strategy": string("redis"),
10419-
"sync_rate": float64(2),
10420-
"throttling": nil,
10421-
"window_size": []any{float64(30)},
10422-
"window_type": string("sliding"),
10391+
"redis": map[string]any{
10392+
"redis_proxy_type": nil,
10393+
},
10394+
"retry_after_jitter_max": float64(0),
10395+
"strategy": string("redis"),
10396+
"sync_rate": float64(2),
10397+
"throttling": nil,
10398+
"window_size": []any{float64(30)},
10399+
"window_type": string("sliding"),
1042310400
},
1042410401
Enabled: kong.Bool(true),
1042510402
Protocols: kong.StringSlice("grpc", "grpcs", "http", "https"),
1042610403
Tags: kong.StringSlice("api:partials-test-1"),
1042710404
Partials: []*kong.PartialLink{
1042810405
{
1042910406
Partial: &kong.Partial{
10430-
ID: kong.String("b426adc7-7f11-4cda-a862-112ddabae9ef"),
10407+
ID: kong.String("b426adc7-7f11-4cda-a862-112ddabae9ef"),
10408+
Name: kong.String("redis-ee-sentinel"),
1043110409
},
1043210410
Path: kong.String("config.redis"),
1043310411
},

0 commit comments

Comments
 (0)