Search in sources :

Example 1 with AwsCodeCommitCredentialProvider

use of org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider in project spring-cloud-config by spring-cloud.

the class JGitEnvironmentRepositoryTests method gitCredentialsProviderFactoryCreatesAwsCodeCommitProvider.

@Test
public void gitCredentialsProviderFactoryCreatesAwsCodeCommitProvider() throws Exception {
    GitCredentialsProviderFactory credentialsFactory = new GitCredentialsProviderFactory();
    Git mockGit = mock(Git.class);
    MockCloneCommand mockCloneCommand = new MockCloneCommand(mockGit);
    final String awsUri = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/test";
    JGitEnvironmentRepository envRepository = new JGitEnvironmentRepository(this.environment, new JGitEnvironmentProperties());
    envRepository.setGitFactory(new MockGitFactory(mockGit, mockCloneCommand));
    envRepository.setUri(awsUri);
    envRepository.setGitCredentialsProvider(credentialsFactory.createFor(envRepository.getUri(), null, null, null));
    envRepository.setCloneOnStart(true);
    envRepository.afterPropertiesSet();
    assertTrue(mockCloneCommand.getCredentialsProvider() instanceof AwsCodeCommitCredentialProvider);
}
Also used : Git(org.eclipse.jgit.api.Git) GitCredentialsProviderFactory(org.springframework.cloud.config.server.support.GitCredentialsProviderFactory) AwsCodeCommitCredentialProvider(org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with AwsCodeCommitCredentialProvider

use of org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider in project spring-cloud-config by spring-cloud.

the class GitCredentialsProviderFactoryTests method testCreateForAwsWithUsername.

@Test
public void testCreateForAwsWithUsername() {
    CredentialsProvider provider = factory.createFor(AWS_REPO, USER, PASSWORD, null);
    assertNotNull(provider);
    assertTrue(provider instanceof AwsCodeCommitCredentialProvider);
    AwsCodeCommitCredentialProvider aws = (AwsCodeCommitCredentialProvider) provider;
    assertEquals(USER, aws.getUsername());
    assertEquals(PASSWORD, aws.getPassword());
}
Also used : AwsCodeCommitCredentialProvider(org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider) PassphraseCredentialsProvider(org.springframework.cloud.config.server.support.PassphraseCredentialsProvider) UsernamePasswordCredentialsProvider(org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider) CredentialsProvider(org.eclipse.jgit.transport.CredentialsProvider) Test(org.junit.Test)

Example 3 with AwsCodeCommitCredentialProvider

use of org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider in project spring-cloud-config by spring-cloud.

the class GitCredentialsProviderFactoryTests method testCreateForAwsNoUsername.

@Test
public void testCreateForAwsNoUsername() {
    CredentialsProvider provider = factory.createFor(AWS_REPO, null, null, null);
    assertNotNull(provider);
    assertTrue(provider instanceof AwsCodeCommitCredentialProvider);
    AwsCodeCommitCredentialProvider aws = (AwsCodeCommitCredentialProvider) provider;
    assertNull(aws.getUsername());
    assertNull(aws.getPassword());
}
Also used : AwsCodeCommitCredentialProvider(org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider) PassphraseCredentialsProvider(org.springframework.cloud.config.server.support.PassphraseCredentialsProvider) UsernamePasswordCredentialsProvider(org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider) CredentialsProvider(org.eclipse.jgit.transport.CredentialsProvider) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 AwsCodeCommitCredentialProvider (org.springframework.cloud.config.server.support.AwsCodeCommitCredentialProvider)3 CredentialsProvider (org.eclipse.jgit.transport.CredentialsProvider)2 UsernamePasswordCredentialsProvider (org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider)2 PassphraseCredentialsProvider (org.springframework.cloud.config.server.support.PassphraseCredentialsProvider)2 Git (org.eclipse.jgit.api.Git)1 Matchers.anyString (org.mockito.Matchers.anyString)1 GitCredentialsProviderFactory (org.springframework.cloud.config.server.support.GitCredentialsProviderFactory)1