Merge pull request #704 from tapvirvirk/patch-1
Update AwsCodeCommitCredentialProvider.java
This commit is contained in:
@@ -19,6 +19,7 @@ package org.springframework.cloud.config.server.support;
|
||||
import static org.springframework.util.StringUtils.hasText;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -326,7 +327,8 @@ public class AwsCodeCommitCredentialProvider extends CredentialsProvider {
|
||||
}
|
||||
|
||||
try {
|
||||
URI u = new URI(uri.toLowerCase());
|
||||
URL url = new URL(uri);
|
||||
URI u = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
|
||||
if (u.getScheme().equals("https")) {
|
||||
String host = u.getHost();
|
||||
if (host.endsWith(".amazonaws.com") && host.startsWith("git-codecommit.")) {
|
||||
|
||||
@@ -48,6 +48,7 @@ public class AwsCodeCommitCredentialsProviderTests {
|
||||
private static final String USER = "test";
|
||||
private static final String AWS_REPO = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/test";
|
||||
private static final String BAD_REPO = "https://amazonaws.com/v1/repos/test";
|
||||
private static final String CURLY_BRACES_REPO = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/{application}";
|
||||
|
||||
private AwsCodeCommitCredentialProvider provider;
|
||||
|
||||
@@ -111,6 +112,15 @@ public class AwsCodeCommitCredentialsProviderTests {
|
||||
assertFalse(provider.get(new URIish(BAD_REPO), credentialItems));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUriWithCurlyBracesReturnsTrue() throws UnsupportedCredentialItem, URISyntaxException {
|
||||
GitCredentialsProviderFactory factory = new GitCredentialsProviderFactory();
|
||||
provider = (AwsCodeCommitCredentialProvider)
|
||||
factory.createFor(CURLY_BRACES_REPO, USER, PASSWORD, null);
|
||||
CredentialItem[] credentialItems = makeCredentialItems();
|
||||
assertTrue(provider.get(new URIish(CURLY_BRACES_REPO), credentialItems));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThrowsUnsupportedCredentialException() throws URISyntaxException {
|
||||
CredentialItem[] goodCredentialItems = makeCredentialItems();
|
||||
|
||||
Reference in New Issue
Block a user