public void ReadUnsupportedProfileType() { HashSet <CredentialProfileType> originalWhitelist = null; var field = typeof(SharedCredentialsFile).GetField("ProfileTypeWhitelist", BindingFlags.NonPublic | BindingFlags.Static); try { // Instead of trying to read an unsupported profile type we remove the list of supported types and read one of those. // We do this because the check in the TryGetProfile method is there for future safety, and won't fail otherwise. //mock ProfileTypeWhitelist originalWhitelist = (HashSet <CredentialProfileType>)field.GetValue(null); field.SetValue(null, new HashSet <CredentialProfileType>()); using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText)) { tester.TestTryGetProfile("session_profile", false, false); } } finally { // unmock ProfileTypeWhitelist field.SetValue(null, originalWhitelist); } }
public void ReadProfileDoesNotExist() { using (var tester = new SharedCredentialsFileTestFixture()) { tester.TestTryGetProfile("profile_does_not_exist", false, false); } }
public void ReadBasicProfileConfigInvalidGuid() { using (var tester = new SharedCredentialsFileTestFixture(null, BasicProfileConfigText.Replace(UniqueKey.ToString(), "blah"))) { tester.TestTryGetProfile("basic_profile", false, false); } }
public void WriteRegionCredentialsUntouched() { using (var tester = new SharedCredentialsFileTestFixture()) { // write the whole profile - credentials options and region var basicOptions = new CredentialProfileOptions { AccessKey = "access_key", SecretKey = "secret_key" }; var profile = new CredentialProfile("WriteRegionKeepOptionsProfile", basicOptions); profile.Region = RegionEndpoint.USGovCloudWest1; tester.CredentialsFile.RegisterProfile(profile); // now write just the region var emptyOptions = new CredentialProfileOptions(); var regionOnlyProfile = new CredentialProfile("WriteRegionKeepOptionsProfile", basicOptions); profile.Region = RegionEndpoint.APSouth1; tester.CredentialsFile.RegisterProfile(profile); // Make sure it has the original options and the new region var readProfile = tester.TestTryGetProfile("WriteRegionKeepOptionsProfile", true, true); Assert.AreEqual("access_key", readProfile.Options.AccessKey); Assert.AreEqual("secret_key", readProfile.Options.SecretKey); Assert.AreEqual(RegionEndpoint.APSouth1, readProfile.Region); } }
public void ReadInvalidProfile() { using (var tester = new SharedCredentialsFileTestFixture(InvalidProfileText)) { tester.TestTryGetProfile("invalid_profile", true, false); } }
public void ReadEndpointDiscoveryEnabledOnlyProfile() { using (var tester = new SharedCredentialsFileTestFixture(EndpointDiscoveryEnabledOnlyProfileText)) { tester.TestTryGetProfile("endpoint_discovery_enabled_only_profile", true, false); } }
public void ReadRegionOnlyProfile() { using (var tester = new SharedCredentialsFileTestFixture(RegionOnlyProfileText)) { tester.TestTryGetProfile("region_only_profile", true, false); } }
public void ReadDefaultConfigProfile() { using (var tester = new SharedCredentialsFileTestFixture(null, DefaultProfileText)) { tester.TestTryGetProfile("default", true, true); } }
public void ListProfilesWithProfileKeyword() { using (var tester = new SharedCredentialsFileTestFixture(ProfileSessionProfileText)) { var profiles = tester.CredentialsFile.ListProfiles(); Assert.AreEqual(1, profiles.Count); var profileNames = profiles.Select(p => p.Name).ToList(); Assert.IsTrue(profileNames.Contains("session_profile")); tester.TestTryGetProfile("session_profile", true, true); } }