org.eclipse.jgit.transport.http.HttpConnection Java Examples
The following examples show how to use
org.eclipse.jgit.transport.http.HttpConnection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
private HttpClientBuilder getActualHttpClientBuilder( HttpConnection actualConnection) { HttpClient actualHttpClient = getActualHttpClient(actualConnection); Field closeablesField = ReflectionUtils.findField(actualHttpClient.getClass(), "closeables"); ReflectionUtils.makeAccessible(closeablesField); List<?> closables = (List<?>) ReflectionUtils.getField(closeablesField, actualHttpClient); return closables.stream().map(o -> { Field builderField = Arrays.stream(o.getClass().getDeclaredFields()).filter( field -> HttpClientBuilder.class.isAssignableFrom(field.getType())) .findFirst().orElse(null); if (builderField != null) { ReflectionUtils.makeAccessible(builderField); return ReflectionUtils.getField(builderField, o); } return null; }).filter(Objects::nonNull).map(HttpClientBuilder.class::cast).findFirst().get(); }
Example #2
Source File: HttpConnectionFactoryImpl.java From gradle-golang-plugin with Mozilla Public License 2.0 | 6 votes |
@Nonnull protected HttpConnection configure(@Nonnull HttpConnection input) throws IOException { try { final KeyStore keyStore = loadKeyStore(); final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keyStore); final TrustManager[] defaultTrustManagers = trustManagerFactory.getTrustManagers(); final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); keyManagerFactory.init(keyStore, null); final KeyManager[] keyManagers = keyManagerFactory.getKeyManagers(); input.configure(keyManagers, defaultTrustManagers, null); input.setInstanceFollowRedirects(true); return input; } catch (final GeneralSecurityException e) { throw new IOException(e.getMessage(), e); } }
Example #3
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void composite_longerUrlsWithPlaceholders() throws Exception { MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties(); properties1 .setUri("http://localhost/path/{placeholder3}/{placeholder4}-test.git"); MultipleJGitEnvironmentProperties properties2 = new MultipleJGitEnvironmentProperties(); properties2 .setUri("http://localhost/{placeholder1}/path/{placeholder2}-test.git"); this.connectionFactory.addConfiguration(properties1); this.connectionFactory.addConfiguration(properties2); HttpConnection actualConnection = this.connectionFactory .create(new URL(properties2.getUri().replace("{placeholder1}", "value1") .replace("{placeholder2}", "value2") + "/some/path.properties")); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .get(properties2.getUri()); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #4
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void composite_urlsWithPlaceholders_identicalTemplatesWontBeResolvedProperly() throws Exception { MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties(); properties1 .setUri("http://localhost/{placeholder3}/path/{placeholder4}-test.git"); MultipleJGitEnvironmentProperties properties2 = new MultipleJGitEnvironmentProperties(); properties2 .setUri("http://localhost/{placeholder1}/path/{placeholder2}-test.git"); this.connectionFactory.addConfiguration(properties1); this.connectionFactory.addConfiguration(properties2); HttpConnection actualConnection = this.connectionFactory .create(new URL(properties2.getUri().replace("{placeholder1}", "value1") .replace("{placeholder2}", "value2"))); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .get(properties2.getUri()); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isNotSameAs(expectedHttpClientBuilder); }
Example #5
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void composite_urlsWithPlaceholders() throws Exception { MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties(); properties1.setUri("http://localhost/path/{placeholder3}/more/test.git"); MultipleJGitEnvironmentProperties properties2 = new MultipleJGitEnvironmentProperties(); properties2 .setUri("http://localhost/{placeholder1}/path/{placeholder2}-test.git"); this.connectionFactory.addConfiguration(properties1); this.connectionFactory.addConfiguration(properties2); HttpConnection actualConnection = this.connectionFactory .create(new URL(properties2.getUri().replace("{placeholder1}", "value1") .replace("{placeholder2}", "value2"))); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .get(properties2.getUri()); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #6
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void multipleMatchesWithPlaceholder() throws Exception { MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties(); properties1.setUri("https://github.com/user/user-{application}.git"); MultipleJGitEnvironmentProperties properties2 = new MultipleJGitEnvironmentProperties(); properties2.setUri("https://github.com/user/user-MultiApps.git"); MultipleJGitEnvironmentProperties properties3 = new MultipleJGitEnvironmentProperties(); properties1.setUri("https://github.com/user/user-{application}"); this.connectionFactory.addConfiguration(properties1); this.connectionFactory.addConfiguration(properties2); this.connectionFactory.addConfiguration(properties3); HttpConnection actualConnection = this.connectionFactory.create(new URL( "https://github.com/user/user-MultiApps.git/info/refs?service=git-upload-pack")); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .get(properties2.getUri()); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #7
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void composite_differentHost() throws Exception { MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties(); properties1.setUri("http://localhost1/test.git"); MultipleJGitEnvironmentProperties properties2 = new MultipleJGitEnvironmentProperties(); properties2.setUri("http://localhost2/test.git"); this.connectionFactory.addConfiguration(properties1); this.connectionFactory.addConfiguration(properties2); HttpConnection actualConnection = this.connectionFactory .create(new URL(properties1.getUri())); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .get(properties1.getUri()); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #8
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void longerUrl() throws Exception { MultipleJGitEnvironmentProperties properties = new MultipleJGitEnvironmentProperties(); String url = "http://localhost/test.git"; properties.setUri(url); this.connectionFactory.addConfiguration(properties); HttpConnection actualConnection = this.connectionFactory .create(new URL(url + "/some/path.properties")); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .values().stream().findFirst().get(); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #9
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void composite_sameHost() throws Exception { MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties(); properties1.setUri("http://localhost/test1.git"); MultipleJGitEnvironmentProperties properties2 = new MultipleJGitEnvironmentProperties(); properties2.setUri("http://localhost/test2.git"); this.connectionFactory.addConfiguration(properties1); this.connectionFactory.addConfiguration(properties2); HttpConnection actualConnection = this.connectionFactory .create(new URL(properties1.getUri())); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .get(properties1.getUri()); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #10
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Test public void urlWithPlaceholdersAtEnd() throws Exception { MultipleJGitEnvironmentProperties properties = new MultipleJGitEnvironmentProperties(); properties.setUri("https://localhost/v1/repos/pvvts_configs-{application}"); this.connectionFactory.addConfiguration(properties); HttpConnection actualConnection = this.connectionFactory.create( new URL("https://localhost/v1/repos/pvvts_configs-applicationPasswords" + "/some/path.properties")); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .values().stream().findFirst().get(); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #11
Source File: PreemptiveAuthHttpClientConnectionFactory.java From git-client-plugin with MIT License | 5 votes |
protected HttpConnection innerCreate(final URL url, final Proxy proxy) { if (credentialsProvider == null) { throw new IllegalStateException(NEED_CREDENTIALS_PROVIDER); } return new PreemptiveAuthHttpClientConnection(credentialsProvider, url.toString(), proxy); }
Example #12
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void urlWithPlaceholders() throws Exception { MultipleJGitEnvironmentProperties properties = new MultipleJGitEnvironmentProperties(); properties.setUri("http://localhost/{placeholder}-test.git"); this.connectionFactory.addConfiguration(properties); HttpConnection actualConnection = this.connectionFactory.create( new URL("http://localhost/value-test.git" + "/some/path.properties")); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .values().stream().findFirst().get(); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #13
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void matchingUrl() throws Exception { String url = "http://localhost/test.git"; MultipleJGitEnvironmentProperties properties = new MultipleJGitEnvironmentProperties(); properties.setUri(url); this.connectionFactory.addConfiguration(properties); HttpConnection actualConnection = this.connectionFactory.create(new URL(url)); HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri .values().stream().findFirst().get(); HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder( actualConnection); assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder); }
Example #14
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Test public void noConfigAdded() throws Exception { HttpConnection actual = this.connectionFactory .create(new URL("http://localhost/test.git")); assertThat(actual).isNotNull(); }
Example #15
Source File: ConfigurableHttpConnectionFactoryIntegrationTests.java From spring-cloud-config with Apache License 2.0 | 5 votes |
private HttpClient getHttpClientForUrl(String repoUrl) throws IOException { HttpConnectionFactory connectionFactory = HttpTransport.getConnectionFactory(); URL url = new URL(repoUrl); HttpConnection httpConnection = connectionFactory.create(url); assertThat(httpConnection).isInstanceOf(HttpClientConnection.class); return (HttpClient) ReflectionTestUtils.getField(httpConnection, "client"); }
Example #16
Source File: HttpClientConfigurableHttpConnectionFactory.java From spring-cloud-config with Apache License 2.0 | 4 votes |
@Override public HttpConnection create(URL url, Proxy proxy) throws IOException { return new HttpClientConnection(url.toString(), null, lookupHttpClientBuilder(url).build()); }
Example #17
Source File: HttpClientConfigurableHttpConnectionFactory.java From spring-cloud-config with Apache License 2.0 | 4 votes |
@Override public HttpConnection create(URL url) throws IOException { return create(url, null); }
Example #18
Source File: HttpClientConfigurableHttpConnectionFactoryTest.java From spring-cloud-config with Apache License 2.0 | 4 votes |
private HttpClient getActualHttpClient(HttpConnection actualConnection) { Field clientField = ReflectionUtils.findField(actualConnection.getClass(), "client"); ReflectionUtils.makeAccessible(clientField); return (HttpClient) ReflectionUtils.getField(clientField, actualConnection); }
Example #19
Source File: HttpConnectionFactoryImpl.java From gradle-golang-plugin with Mozilla Public License 2.0 | 4 votes |
@Override public HttpConnection create(URL url, Proxy proxy) throws IOException { return configure(super.create(url, proxy)); }
Example #20
Source File: PreemptiveAuthHttpClientConnectionFactory.java From git-client-plugin with MIT License | 4 votes |
public HttpConnection create(final URL url) throws IOException { return innerCreate(url, null); }
Example #21
Source File: PreemptiveAuthHttpClientConnectionFactory.java From git-client-plugin with MIT License | 4 votes |
public HttpConnection create(final URL url, final Proxy proxy) throws IOException { return innerCreate(url, null); }
Example #22
Source File: HttpConnectionFactoryImpl.java From gradle-golang-plugin with Mozilla Public License 2.0 | 4 votes |
@Override public HttpConnection create(URL url) throws IOException { return configure(super.create(url)); }