Skip to content

Commit

Permalink
Merge pull request #18 from hmcts/EM-1875-openId-coonect-proxy
Browse files Browse the repository at this point in the history
Added in changes for proxy
  • Loading branch information
yogesh-hullatti authored Feb 10, 2020
2 parents 1c8d8a7 + fa1313e commit 3574e6a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ dependencies {
api group: 'io.github.openfeign', name: 'feign-httpclient', version: feignVersion
api group: 'io.github.openfeign.form', name: 'feign-form', version: feignFormVersion
api group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8'

compile "com.squareup.okhttp3:okhttp:4.3.1"
compileOnly group: 'org.projectlombok', name: 'lombok', version: lombokVersion
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: lombokVersion

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/uk/gov/hmcts/reform/em/EmTestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

import java.net.InetSocketAddress;
import java.net.Proxy;


@Configuration
@ComponentScan({"uk.gov.hmcts.reform.em.test.**"})
Expand All @@ -14,7 +18,12 @@ public class EmTestConfig {

@Bean
RestTemplate restTemplate() {
return new RestTemplate();
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyout.reform.hmcts.net", 8080));
requestFactory.setProxy(proxy);

return new RestTemplate(requestFactory);
}

}
24 changes: 24 additions & 0 deletions src/main/java/uk/gov/hmcts/reform/em/FooConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package uk.gov.hmcts.reform.em;

import okhttp3.OkHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

import java.net.InetSocketAddress;
import java.net.Proxy;

@Configuration
public class FooConfiguration {

@Bean
@Scope("prototype")
public OkHttpClient client() {

OkHttpClient okHttpClient = new OkHttpClient.Builder()
.proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyout.reform.hmcts.net", 8080)))
.build();

return okHttpClient;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import uk.gov.hmcts.reform.em.FooConfiguration;

@FeignClient(
name = "idam-test-api-delete",
url = "${idam.api.url}/testing-support"
url = "${idam.api.url}/testing-support",
configuration = FooConfiguration.class
)
@ConditionalOnProperty("idam.api.url")
public interface DeleteUserApi {
Expand Down

0 comments on commit 3574e6a

Please sign in to comment.