/** * ProfilesConfigFileWriter still deals with legacy {@link Profile} interface so it can only * modify credential related properties. All other properties should be preserved when * modifying profiles. */ @Override protected boolean isSupportedProperty(String propertyName) { return ProfileKeyConstants.AWS_ACCESS_KEY_ID.equals(propertyName) || ProfileKeyConstants.AWS_SECRET_ACCESS_KEY.equals(propertyName) || ProfileKeyConstants.AWS_SESSION_TOKEN.equals(propertyName) || ProfileKeyConstants.EXTERNAL_ID.equals(propertyName) || ProfileKeyConstants.ROLE_ARN.equals(propertyName) || ProfileKeyConstants.ROLE_SESSION_NAME.equals(propertyName) || ProfileKeyConstants.SOURCE_PROFILE.equals(propertyName); }
@Test public void profilesNonEmptyButGivenProfileNotPresent_ProvidesNullRegion() { final String otherProfileName = "other_profile"; final BasicProfile other_profile = new BasicProfile(otherProfileName, ImmutableMapParameter .of(ProfileKeyConstants.REGION, "us-east-8")); final AllProfiles profiles = new AllProfiles( ImmutableMapParameter.of(otherProfileName, other_profile)); stubLoadProfile(profiles); assertNull(regionProvider.getRegion()); }
@Test public void profilePresentButRegionIsEmpty_ProvidesNullRegion() { final BasicProfile profile = new BasicProfile(PROFILE, ImmutableMapParameter .of(ProfileKeyConstants.REGION, "")); final AllProfiles profiles = new AllProfiles(ImmutableMapParameter.of(PROFILE, profile)); stubLoadProfile(profiles); assertNull(regionProvider.getRegion()); }
@Test public void profilePresentAndRegionIsSet_ProvidesCorrectRegion() { final String expectedRegion = "us-east-8"; final BasicProfile profile = new BasicProfile(PROFILE, ImmutableMapParameter .of(ProfileKeyConstants.REGION, expectedRegion)); final AllProfiles profiles = new AllProfiles(ImmutableMapParameter.of(PROFILE, profile)); stubLoadProfile(profiles); assertEquals(expectedRegion, regionProvider.getRegion()); }