use of software.amazon.awssdk.profiles.ProfileFile in project aws-sdk-java-v2 by aws.
the class SsoProfileTest method createSsoCredentialsProvider_SsoRoleNameMissing_throwException.
@Test
public void createSsoCredentialsProvider_SsoRoleNameMissing_throwException() {
String profileContent = "[profile foo]\n" + "sso_account_id=012345678901\n" + "sso_region=us-east-1\n" + "sso_start_url=https://d-abc123.awsapps.com/start-beta\n";
ProfileFile profiles = ProfileFile.builder().content(new StringInputStream(profileContent)).type(ProfileFile.Type.CONFIGURATION).build();
assertThat(profiles.profile("foo")).hasValueSatisfying(profile -> {
assertThatThrownBy(() -> new ProfileCredentialsUtils(profiles, profile, profiles::profile).credentialsProvider()).hasMessageContaining("Profile property 'sso_role_name' was not configured");
});
}
use of software.amazon.awssdk.profiles.ProfileFile in project aws-sdk-java-v2 by aws.
the class SsoProfileTest method createSsoCredentialsProvider_SsoAccountIdMissing_throwException.
@Test
public void createSsoCredentialsProvider_SsoAccountIdMissing_throwException() {
String profileContent = "[profile foo]\n" + "sso_region=us-east-1\n" + "sso_role_name=SampleRole\n" + "sso_start_url=https://d-abc123.awsapps.com/start-beta\n";
ProfileFile profiles = ProfileFile.builder().content(new StringInputStream(profileContent)).type(ProfileFile.Type.CONFIGURATION).build();
assertThat(profiles.profile("foo")).hasValueSatisfying(profile -> {
assertThatThrownBy(() -> new ProfileCredentialsUtils(profiles, profile, profiles::profile).credentialsProvider()).hasMessageContaining("Profile property 'sso_account_id' was not configured");
});
}
use of software.amazon.awssdk.profiles.ProfileFile in project aws-sdk-java-v2 by aws.
the class Ec2MetadataConfigProvider method resolveProfile.
private Optional<Profile> resolveProfile() {
ProfileFile profileFileToUse = resolveProfileFile();
String profileNameToUse = resolveProfileName();
return profileFileToUse.profile(profileNameToUse);
}
use of software.amazon.awssdk.profiles.ProfileFile in project aws-sdk-java-v2 by aws.
the class ProfileCredentialsProviderTest method presentProfileReturnsCredentials.
@Test
public void presentProfileReturnsCredentials() {
ProfileFile file = profileFile("[default]\n" + "aws_access_key_id = defaultAccessKey\n" + "aws_secret_access_key = defaultSecretAccessKey");
ProfileCredentialsProvider provider = ProfileCredentialsProvider.builder().profileFile(file).profileName("default").build();
assertThat(provider.resolveCredentials()).satisfies(credentials -> {
assertThat(credentials.accessKeyId()).isEqualTo("defaultAccessKey");
assertThat(credentials.secretAccessKey()).isEqualTo("defaultSecretAccessKey");
});
}
use of software.amazon.awssdk.profiles.ProfileFile in project aws-sdk-java-v2 by aws.
the class S3EndpointResolutionTest method regionalSettingEnabledViaProfile_usesRegionalIadEndpoint.
@Test
public void regionalSettingEnabledViaProfile_usesRegionalIadEndpoint() throws UnsupportedEncodingException {
String profile = "[profile test]\n" + "s3_us_east_1_regional_endpoint = regional";
ProfileFile profileFile = ProfileFile.builder().content(new StringInputStream(profile)).type(ProfileFile.Type.CONFIGURATION).build();
mockHttpClient.stubNextResponse(mockListObjectsResponse());
S3Client s3Client = S3Client.builder().credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"))).httpClient(mockHttpClient).region(Region.US_EAST_1).overrideConfiguration(c -> c.defaultProfileFile(profileFile).defaultProfileName("test")).serviceConfiguration(c -> c.pathStyleAccessEnabled(true)).build();
s3Client.listObjects(ListObjectsRequest.builder().bucket(BUCKET).build());
assertThat(mockHttpClient.getLastRequest().getUri().getHost()).isEqualTo("s3.us-east-1.amazonaws.com");
}
Aggregations