Skip to content

Commit

Permalink
fix(webhook): using okhttp configs instead of defaults (spinnaker#2529)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns authored Nov 27, 2018
1 parent 2809532 commit e3249f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions orca-webhook/orca-webhook.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ apply from: "$rootDir/gradle/groovy.gradle"
dependencies {
compile project(':orca-core')
compile spinnaker.dependency('kork')
compile spinnaker.dependency('korkWeb')
compile spinnaker.dependency('bootAutoConfigure')
compile spinnaker.dependency('lombok')
compile('com.jayway.jsonpath:json-path:2.2.0')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.netflix.spinnaker.orca.webhook.config;

import com.netflix.spinnaker.okhttp.OkHttpClientConfigurationProperties;
import com.netflix.spinnaker.orca.webhook.util.UnionX509TrustManager;
import okhttp3.OkHttpClient;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -70,11 +71,16 @@ public RestTemplate restTemplate(ClientHttpRequestFactory webhookRequestFactory)
}

@Bean
public ClientHttpRequestFactory webhookRequestFactory() {
public ClientHttpRequestFactory webhookRequestFactory(
OkHttpClientConfigurationProperties okHttpClientConfigurationProperties
) {
X509TrustManager trustManager = webhookX509TrustManager();
SSLSocketFactory sslSocketFactory = getSSLSocketFactory(trustManager);
OkHttpClient client = new OkHttpClient.Builder().sslSocketFactory(sslSocketFactory, trustManager).build();
return new OkHttp3ClientHttpRequestFactory(client);
OkHttp3ClientHttpRequestFactory requestFactory = new OkHttp3ClientHttpRequestFactory(client);
requestFactory.setReadTimeout(Math.toIntExact(okHttpClientConfigurationProperties.getReadTimeoutMs()));
requestFactory.setConnectTimeout(Math.toIntExact(okHttpClientConfigurationProperties.getConnectTimeoutMs()));
return requestFactory;
}

private X509TrustManager webhookX509TrustManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.netflix.spinnaker.orca.webhook.service

import com.netflix.spinnaker.okhttp.OkHttpClientConfigurationProperties
import com.netflix.spinnaker.orca.config.UserConfiguredUrlRestrictions
import com.netflix.spinnaker.orca.webhook.config.WebhookProperties
import com.netflix.spinnaker.orca.webhook.config.WebhookConfiguration
Expand All @@ -41,11 +42,14 @@ class WebhookServiceSpec extends Specification {
@Shared
def webhookProperties = new WebhookProperties()

@Shared
def okHttpClientConfigurationProperties = new OkHttpClientConfigurationProperties()

@Shared
def webhookConfiguration = new WebhookConfiguration(webhookProperties)

@Shared
def requestFactory = webhookConfiguration.webhookRequestFactory()
def requestFactory = webhookConfiguration.webhookRequestFactory(okHttpClientConfigurationProperties)

@Shared
def restTemplate = webhookConfiguration.restTemplate(requestFactory)
Expand Down

0 comments on commit e3249f2

Please sign in to comment.