Return HTTP Client of configuration if there is an exact match on the git url and not a placeholder (#1507)
* Return HTTP Client of configuration if there is an exact match on the git url and not a placeholder * Removing resource class circleci config
This commit is contained in:
@@ -10,7 +10,6 @@ jobs:
|
||||
branches:
|
||||
ignore:
|
||||
- gh-pages # list of branches to ignore
|
||||
resource_class: large
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
@@ -37,4 +36,4 @@ jobs:
|
||||
destination: artifacts
|
||||
- store_test_results:
|
||||
path: ~/junit/
|
||||
destination: testartifacts
|
||||
destination: testartifacts
|
||||
|
||||
@@ -105,6 +105,19 @@ public class HttpClientConfigurableHttpConnectionFactory
|
||||
return HttpClients.custom();
|
||||
}
|
||||
if (builderMap.size() > 1) {
|
||||
/*
|
||||
* Try to determine if there is an exact match URL or not. So if there is a placeholder in the URL, filter
|
||||
* it out. We should be left with only URLs which have no placeholders.
|
||||
* That is the one we want to use in the case there are multiple matches.
|
||||
*/
|
||||
List<String> keys = builderMap.keySet().stream().filter(key -> {
|
||||
String[] tokens = key.split(PLACEHOLDER_PATTERN);
|
||||
return tokens.length == 1;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
if (keys.size() == 1) {
|
||||
return builderMap.get(keys.get(0));
|
||||
}
|
||||
this.log.error(String.format(
|
||||
"More than one git repo URL template matched URL:"
|
||||
+ " %s, proxy and skipSslValidation config won't be applied. Matched templates: %s",
|
||||
|
||||
@@ -79,9 +79,9 @@ public class RefreshableConfigServerIntegrationTests {
|
||||
}
|
||||
|
||||
/*
|
||||
* We're emulating an application "foo" which is running with the "development" profile
|
||||
* and is asking for its properties using the REST endpoint. We're also calling the
|
||||
* /env & /refresh actuator endpoints to change the
|
||||
* We're emulating an application "foo" which is running with the "development"
|
||||
* profile and is asking for its properties using the REST endpoint. We're also
|
||||
* calling the /env & /refresh actuator endpoints to change the
|
||||
* `spring.cloud.config.server.overrides.foo` property. Since we see that we only get
|
||||
* the overridden "foo" property after the context refresh we are sure that the
|
||||
* properties have been set and the EnvironmentController bean has successfully been
|
||||
|
||||
@@ -159,6 +159,24 @@ public class HttpClientConfigurableHttpConnectionFactoryTest {
|
||||
assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multipleMatchesWithPlaceholder() throws Exception {
|
||||
MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties();
|
||||
properties1.setUri("https://github.com/marnee01/mderider-{application}.git");
|
||||
MultipleJGitEnvironmentProperties properties2 = new MultipleJGitEnvironmentProperties();
|
||||
properties2.setUri("https://github.com/marnee01/mderider-MultiApps.git");
|
||||
this.connectionFactory.addConfiguration(properties1);
|
||||
this.connectionFactory.addConfiguration(properties2);
|
||||
|
||||
HttpConnection actualConnection = this.connectionFactory.create(new URL(
|
||||
"https://github.com/marnee01/mderider-MultiApps.git/info/refs?service=git-upload-pack"));
|
||||
HttpClientBuilder expectedHttpClientBuilder = this.connectionFactory.httpClientBuildersByUri
|
||||
.get(properties2.getUri());
|
||||
HttpClientBuilder actualHttpClientBuilder = getActualHttpClientBuilder(
|
||||
actualConnection);
|
||||
assertThat(actualHttpClientBuilder).isSameAs(expectedHttpClientBuilder);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void composite_urlsWithPlaceholders() throws Exception {
|
||||
MultipleJGitEnvironmentProperties properties1 = new MultipleJGitEnvironmentProperties();
|
||||
|
||||
Reference in New Issue
Block a user