Skip to content
Snippets Groups Projects
Commit c8427e96 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-4597 Formularversand über Proxy mit Authentifizierung'...

Merge pull request 'OZG-4597 Formularversand über Proxy mit Authentifizierung' (#17) from OZG-4597-formcycle-per-proxy-access into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/formcycle-plugin/pulls/17
parents 1fee0d66 33a8c3c3
Branches
Tags
No related merge requests found
...@@ -41,7 +41,6 @@ import org.apache.http.client.methods.CloseableHttpResponse; ...@@ -41,7 +41,6 @@ import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoutePlanner; import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.BasicAuthCache; import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
...@@ -192,18 +191,11 @@ public class OzgCloudFormDataHttpClient { ...@@ -192,18 +191,11 @@ public class OzgCloudFormDataHttpClient {
var clientContext = HttpClientContext.create(); var clientContext = HttpClientContext.create();
if (nonNull(getProxyConfig())) { if (nonNull(getProxyConfig())) {
clientContext.setCredentialsProvider(getCredentialsProvider()); clientContext.setCredentialsProvider(getCredentialsProvider());
clientContext.setAuthCache(createAuthCache()); clientContext.setAuthCache(new BasicAuthCache());
} }
return clientContext; return clientContext;
} }
BasicAuthCache createAuthCache() {
var authCache = new BasicAuthCache();
var basicAuth = new BasicScheme();
authCache.put(getProxyHost(), basicAuth);
return authCache;
}
FormCycleConfirmationResponse parseResponse(CloseableHttpResponse response) throws IOException { FormCycleConfirmationResponse parseResponse(CloseableHttpResponse response) throws IOException {
checkResponseStatus(response); checkResponseStatus(response);
InputStream responseContent = response.getEntity().getContent(); InputStream responseContent = response.getEntity().getContent();
......
...@@ -39,7 +39,6 @@ import org.apache.http.StatusLine; ...@@ -39,7 +39,6 @@ import org.apache.http.StatusLine;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.conn.routing.HttpRoutePlanner; import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClientBuilder;
...@@ -57,7 +56,6 @@ import org.springframework.util.ReflectionUtils; ...@@ -57,7 +56,6 @@ import org.springframework.util.ReflectionUtils;
import de.itvsh.kop.eingangsadapter.formcycle.FormCycleConfirmationResponse; import de.itvsh.kop.eingangsadapter.formcycle.FormCycleConfirmationResponse;
import de.itvsh.kop.eingangsadapter.formcycle.FormCycleFormData; import de.itvsh.kop.eingangsadapter.formcycle.FormCycleFormData;
import de.ozgcloud.formcycle.OzgCloudFormDataHttpClient.UnexpectedStatusCodeException;
import de.ozgcloud.formcycle.attachment.FormcycleAttachment; import de.ozgcloud.formcycle.attachment.FormcycleAttachment;
import de.ozgcloud.formcycle.attachment.FormcycleAttachmentTestFactory; import de.ozgcloud.formcycle.attachment.FormcycleAttachmentTestFactory;
import lombok.SneakyThrows; import lombok.SneakyThrows;
...@@ -475,16 +473,6 @@ class OzgCloudFormDataHttpClientTest { ...@@ -475,16 +473,6 @@ class OzgCloudFormDataHttpClientTest {
assertThat(result.getCredentialsProvider()).isEqualTo(credentialsProvider); assertThat(result.getCredentialsProvider()).isEqualTo(credentialsProvider);
} }
@Test
void shouldCallCreateAuthCache() {
var authCache = mock(BasicAuthCache.class);
doReturn(authCache).when(client).createAuthCache();
var result = client.createContext();
assertThat(result.getAuthCache()).isEqualTo(authCache);
}
@Test @Test
void shouldReturnEmptyContext() { void shouldReturnEmptyContext() {
doReturn(null).when(client).getProxyConfig(); doReturn(null).when(client).getProxyConfig();
...@@ -492,7 +480,6 @@ class OzgCloudFormDataHttpClientTest { ...@@ -492,7 +480,6 @@ class OzgCloudFormDataHttpClientTest {
client.createContext(); client.createContext();
verify(client, never()).getCredentialsProvider(); verify(client, never()).getCredentialsProvider();
verify(client, never()).createAuthCache();
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment