Verifying Kong API configuration and routing


We would like to write unit tests to verify the API configuration and routing before deployment to production. with the caveat that we don’t want to proxy the call to the upstream API’s.

A possible solution would be to have Kong terminate the request with a custom plugin (for e.g. request-termination) but log the details of the API matched in the response returned by the custom plugin.

I wanted to check if anyone has any done something similar or if there are any plans to include this functionality in a future release of Kong.

Also, any pointers on what the approach should be in achieving this will be much appreciated.



1 Like


We are working on a debug mode that would allow Kong to short-circuit proxied requests (instead of proxying them) and reply with a summary of what Kong would have done if it were to be proxied (which Route was matched, what plugins would have been running, etc…). It is being worked on here. At this point though, we are still debating some internals, it is unclear when this would be merged or release, please do not ask.

For now, I would suggest configuring Kong with the proper matching rules for your Routes (or APIs), but make the Services’ (or API) upstream address a dummy one. Then, make your requests with the -undocumented and non-guaranteed- Kong-Debug request header. This will make Kong reply with a Kong-Service-Name (or Kong-Api-Name) response header. Would that work for you?

We understand this is a need for Kong users, and wil definitely be coming up with a solution, it is just not available yet.

We’ve fixed this ourselves with a custom plugin that terminates requests with a specific dry-run header in them.

It responds with effectively the same output that would get logged, so that a caller can hit the endpoint and verify that it was routed to the correct upstream with the expected headers etc…

Is this something that will be generally valuable to other users? We could probably open-source the plugin.

@Thomas_Freeman Great news! I don’t see why the community would not be interested in it. Please feel free to share!

Also, reminder that we introduced the Kong Hub now as a platform gathering third-party Kong extensions and integrations (including plugins) :slight_smile: