forked from trustpilot/kafka-connect-dynamodb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from fetch-rewards/add-assumed-role-arn
Add assumed role arn
- Loading branch information
Showing
7 changed files
with
111 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
source/src/test/java/com/trustpilot/connector/dynamodb/aws/AwsClientsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.trustpilot.connector.dynamodb.aws; | ||
|
||
import com.amazonaws.auth.AWSCredentialsProvider; | ||
import com.amazonaws.auth.AWSStaticCredentialsProvider; | ||
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain; | ||
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class AwsClientsTests { | ||
|
||
@Test | ||
public void stsAssumeRoleProviderReturned() { | ||
String testRoleArn = "arn:aws:iam::111111111111:role/unit-test"; | ||
AWSCredentialsProvider provider = AwsClients.getCredentials( | ||
null, | ||
null, | ||
testRoleArn | ||
); | ||
|
||
DefaultAWSCredentialsProviderChain testChain = Mockito.mock(DefaultAWSCredentialsProviderChain.class); | ||
STSAssumeRoleSessionCredentialsProvider expectedProvider = new STSAssumeRoleSessionCredentialsProvider( | ||
testChain.getInstance(), | ||
testRoleArn, | ||
"kafkaconnect" | ||
); | ||
assertEquals(provider.getClass(), expectedProvider.getClass()); | ||
} | ||
|
||
@Test | ||
public void defaultProviderReturned() { | ||
AWSCredentialsProvider provider = AwsClients.getCredentials( | ||
null, | ||
null, | ||
null | ||
); | ||
|
||
assertEquals(provider.getClass(), DefaultAWSCredentialsProviderChain.class); | ||
} | ||
|
||
@Test | ||
public void staticCredentialsReturned() { | ||
AWSCredentialsProvider provider = AwsClients.getCredentials( | ||
"unit-test", | ||
"unit-test", | ||
null | ||
); | ||
|
||
assertEquals(provider.getClass(), AWSStaticCredentialsProvider.class); | ||
} | ||
} |