leekeiabstraction commented on code in PR #197:
URL:
https://github.com/apache/flink-connector-aws/pull/197#discussion_r2056055824
##########
flink-connector-aws-base/src/test/java/org/apache/flink/connector/aws/util/AWSGeneralUtilTest.java:
##########
@@ -952,4 +958,41 @@ void
testNewInstanceOfDefaultCredentialsProviderCreatedForEachClient() {
return builder;
}
+
+ @Test
+ void testGetCredentialsProviderReturnsSsoProviderForSsoProfile() throws
IOException {
+ String profileName = "my-sso-profile";
+ String ssoStartUrl = "https://my-dummy-sso-portal.awsapps.com/start";
+ String ssoRegion = "us-east-1";
+ String ssoAccountId = "123456789012";
+ String ssoRoleName = "MyTestRole";
+
+ String configFileContent =
+ "[profile " + profileName + "]\n"
+ + "sso_start_url = " + ssoStartUrl + "\n"
+ + "sso_region = " + ssoRegion + "\n"
+ + "sso_account_id = " + ssoAccountId + "\n"
+ + "sso_role_name = " + ssoRoleName + "\n"
+ + "region = " + ssoRegion + "\n";
+
+ ProfileFile profileFile = ProfileFile.builder()
+ .content(new StringInputStream(configFileContent))
+ .type(ProfileFile.Type.CONFIGURATION)
+ .build();
+
+ Profile profile = profileFile.profile(profileName).orElseThrow();
+
+ ProfileProviderCredentialsContext context =
ProfileProviderCredentialsContext.builder()
+ .profile(profile)
+ .profileFile(profileFile)
+ .build();
+
+ SsoProfileCredentialsProviderFactory factory = new
SsoProfileCredentialsProviderFactory();
+
+ assertThatThrownBy(() -> factory.create(context))
+ .isInstanceOf(java.io.UncheckedIOException.class)
+ .hasRootCauseInstanceOf(java.nio.file.NoSuchFileException.class)
+ .hasMessageContaining(".aws/sso/cache/");
+ }
Review Comment:
Can you elaborate why we're asserting that an exception is thrown here? What
would the full exception message look like?
##########
flink-connector-aws-base/src/test/java/org/apache/flink/connector/aws/util/AWSGeneralUtilTest.java:
##########
@@ -952,4 +958,41 @@ void
testNewInstanceOfDefaultCredentialsProviderCreatedForEachClient() {
return builder;
}
+
+ @Test
+ void testGetCredentialsProviderReturnsSsoProviderForSsoProfile() throws
IOException {
Review Comment:
The test case name indicates that we're expecting SsoProvider to be returned
but actual assertion is on `UncheckedIOException` being thrown. Can you
elaborate?
##########
flink-connector-aws-base/src/test/java/org/apache/flink/connector/aws/util/AWSGeneralUtilTest.java:
##########
@@ -952,4 +958,41 @@ void
testNewInstanceOfDefaultCredentialsProviderCreatedForEachClient() {
return builder;
}
+
+ @Test
+ void testGetCredentialsProviderReturnsSsoProviderForSsoProfile() throws
IOException {
+ String profileName = "my-sso-profile";
+ String ssoStartUrl = "https://my-dummy-sso-portal.awsapps.com/start";
+ String ssoRegion = "us-east-1";
+ String ssoAccountId = "123456789012";
+ String ssoRoleName = "MyTestRole";
+
+ String configFileContent =
+ "[profile " + profileName + "]\n"
+ + "sso_start_url = " + ssoStartUrl + "\n"
+ + "sso_region = " + ssoRegion + "\n"
+ + "sso_account_id = " + ssoAccountId + "\n"
+ + "sso_role_name = " + ssoRoleName + "\n"
+ + "region = " + ssoRegion + "\n";
+
+ ProfileFile profileFile = ProfileFile.builder()
+ .content(new StringInputStream(configFileContent))
+ .type(ProfileFile.Type.CONFIGURATION)
+ .build();
+
+ Profile profile = profileFile.profile(profileName).orElseThrow();
+
+ ProfileProviderCredentialsContext context =
ProfileProviderCredentialsContext.builder()
+ .profile(profile)
+ .profileFile(profileFile)
+ .build();
+
+ SsoProfileCredentialsProviderFactory factory = new
SsoProfileCredentialsProviderFactory();
+
+ assertThatThrownBy(() -> factory.create(context))
+ .isInstanceOf(java.io.UncheckedIOException.class)
+ .hasRootCauseInstanceOf(java.nio.file.NoSuchFileException.class)
+ .hasMessageContaining(".aws/sso/cache/");
+ }
Review Comment:
Can you elaborate why we're asserting that an exception is thrown here? What
would the full exception message look like?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]