@@ -2323,6 +2323,115 @@ R6InCcH2Wh8wSeY5AuDXvu2tv9g/PW9wIJmPuKSHMA==
2323
2323
}, post_config (input ))
2324
2324
end )
2325
2325
2326
+ it (" snis in certificates without certificate" , function ()
2327
+ local res = assert (client :send {
2328
+ method = " POST" ,
2329
+ path = " /config?flatten_errors=1" ,
2330
+ body = {
2331
+ _format_version = " 1.1" ,
2332
+ consumers = {
2333
+ {
2334
+ username = " x" ,
2335
+ basicauth_credentials = {
2336
+ username = " x" ,
2337
+ password = " x" ,
2338
+ }
2339
+ }
2340
+ },
2341
+ certificates = {
2342
+ {
2343
+ cert = ssl_fixtures .cert ,
2344
+ id = " d83994d2-c24c-4315-b431-ee76b6611dcb" ,
2345
+ key = ssl_fixtures .key ,
2346
+ snis = {
2347
+ {
2348
+ name = " foo.example" ,
2349
+ id = " 1c6e83b7-c9ad-40ac-94e8-52f5ee7bde44" ,
2350
+ },
2351
+ }
2352
+ }
2353
+ },
2354
+ },
2355
+ headers = {
2356
+ [" Content-Type" ] = " application/json"
2357
+ }
2358
+ })
2359
+
2360
+ local body = assert .response (res ).has .status (400 )
2361
+ local entities = cjson .decode (body )
2362
+ assert .equals (" snis:required field missing:certificate" , entities .flattened_errors [1 ].errors [1 ].message )
2363
+ end )
2364
+
2365
+ it (" flatten_errors1 when conflicting inputs" , function ()
2366
+ local conflicting_input = {
2367
+ _format_version = " 3.0" ,
2368
+ consumers = {
2369
+ {
2370
+ username = " username1" ,
2371
+ tags = {
2372
+ " k8s-group:configuration.konghq.com" ,
2373
+ " k8s-version:v1" ,
2374
+ " k8s-kind:KongConsumer" ,
2375
+ " k8s-namespace:default" ,
2376
+ " k8s-name:consumer1"
2377
+ },
2378
+ basicauth_credentials = {
2379
+ {
2380
+ username = " username1" ,
2381
+ password = " password" ,
2382
+ tags = {
2383
+ " k8s-group:" ,
2384
+ " k8s-version:v1" ,
2385
+ " k8s-kind:Secret" ,
2386
+ " k8s-namespace:default" ,
2387
+ " k8s-name:basic-1"
2388
+ }
2389
+ },
2390
+ {
2391
+ username = " username1" ,
2392
+ password = " password" ,
2393
+ tags = {
2394
+ " k8s-group:" ,
2395
+ " k8s-version:v1" ,
2396
+ " k8s-kind:Secret" ,
2397
+ " k8s-namespace:default" ,
2398
+ " k8s-name:basic-2"
2399
+ }
2400
+ },
2401
+ }
2402
+ }
2403
+ }
2404
+ }
2405
+ validate ({
2406
+ {
2407
+ entity = {
2408
+ username = " username1" ,
2409
+ password = " password" ,
2410
+ tags = {
2411
+ " k8s-group:" ,
2412
+ " k8s-version:v1" ,
2413
+ " k8s-kind:Secret" ,
2414
+ " k8s-namespace:default" ,
2415
+ " k8s-name:basic-2"
2416
+ }
2417
+ },
2418
+ entity_tags = {
2419
+ " k8s-group:" ,
2420
+ " k8s-version:v1" ,
2421
+ " k8s-kind:Secret" ,
2422
+ " k8s-namespace:default" ,
2423
+ " k8s-name:basic-2"
2424
+ },
2425
+ entity_type = " basicauth_credential" ,
2426
+ errors = { {
2427
+ message = " uniqueness violation: 'basicauth_credentials' entity with username set to 'username1' already declared" ,
2428
+ type = " entity" ,
2429
+ }
2430
+ }
2431
+ },
2432
+ }, post_config (conflicting_input ))
2433
+ end )
2434
+
2326
2435
it (" correctly handles nested entity errors" , function ()
2327
2436
local consumers = {
2328
2437
{
0 commit comments