Java Spring Framework Is there a way to only allow the application to make network requests to specific urls

57 Views Asked by At

I have a slightly strange use case where my application can run on two different types of networks one of which is extremely restricted and I have encountered issues where the application works on the unrestricted network but fails to run on the restricted one.

This is because this application makes queries to third party rest apis using various methods (eg rest templates and other third party libraries)

So I want to be able to capture this in tests to make sure that the use cases that I want to run on the restricted network are able to run. Note not all use cases of the app need to be ran on the restricted network.

Basically my idea is to be able to have a whitelist of urls that I know the restricted network is able to access.

I have tried adding an interceptor to my rest templates and this works but only for the rest APIs that I have implemented myself, for the third party libraries it doesn't work. (Example of a third party library I am currently using org.kohsuke.github-api)

Also please note I am not using spring boot for this application.

0

There are 0 best solutions below