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 WriteRegionOnlyProfile() { using (var tester = new SharedCredentialsFileTestFixture(RegionOnlyProfileText)) { tester.AssertWriteProfile("region_only_profile", RegionOnlyProfileOptions, RegionOnlyProfileText); } }
public void ReadAssumeRoleMfaProfile() { using (var tester = new SharedCredentialsFileTestFixture(AssumeRoleMfaProfileText)) { tester.ReadAndAssertProfile("assume_role_mfa_profile", AssumeRoleMfaProfileOptions); } }
public void WriteAssumeRoleMfaProfile() { using (var tester = new SharedCredentialsFileTestFixture()) { tester.AssertWriteProfile("assume_role_mfa_profile", AssumeRoleMfaProfileOptions, AssumeRoleMfaProfileText); } }
public void WriteSessionProfile() { using (var tester = new SharedCredentialsFileTestFixture()) { tester.AssertWriteProfile("session_profile", SessionProfileOptions, SessionProfileText); } }
public void ReadSessionProfile() { using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText)) { tester.ReadAndAssertProfile("session_profile", SessionProfileOptions); } }
public void WriteBasicProfile() { using (var tester = new SharedCredentialsFileTestFixture()) { tester.AssertWriteProfile("basic_profile", BasicProfileOptions, RegionEndpoint.CACentral1, UniqueKey, BasicProfileCredentialsText); } }
public void ReadBasicProfileConfigInvalidGuid() { using (var tester = new SharedCredentialsFileTestFixture(null, BasicProfileConfigText.Replace(UniqueKey.ToString(), "blah"))) { tester.TestTryGetProfile("basic_profile", false, false); } }
public void WriteEndpointDiscoveryEnabledOnlyProfile() { using (var tester = new SharedCredentialsFileTestFixture()) { tester.AssertWriteProfile("endpoint_discovery_enabled_only_profile", EndpointDiscoveryEnabledOnlyProfileOptions, true, EndpointDiscoveryEnabledOnlyProfileText); } }
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 ReadBasicProfileConfig() { using (var tester = new SharedCredentialsFileTestFixture(null, BasicProfileConfigText)) { tester.ReadAndAssertProfile("basic_profile", BasicProfileOptions, RegionEndpoint.CACentral1, UniqueKey); } }
public FallbackFactoryTestFixture(string sharedCredsFileContent, string awsProfileValue, string enableEndpointDiscoveryValue = null) { sharedFixture = new SharedCredentialsFileTestFixture(sharedCredsFileContent); netSdkFixture = new NetSDKCredentialsFileTestFixture(); originalCredsChain = (CredentialProfileStoreChain)ReflectionHelpers.Invoke(typeof(FallbackCredentialsFactory), "credentialProfileChain"); ReflectionHelpers.Invoke(typeof(FallbackCredentialsFactory), "credentialProfileChain", new CredentialProfileStoreChain(sharedFixture.CredentialsFilePath)); originalRegionChain = (CredentialProfileStoreChain)ReflectionHelpers.Invoke(typeof(FallbackRegionFactory), "credentialProfileChain"); ReflectionHelpers.Invoke(typeof(FallbackRegionFactory), "credentialProfileChain", new CredentialProfileStoreChain(sharedFixture.CredentialsFilePath)); originalEndpointDiscoveryEnabledChain = (CredentialProfileStoreChain)ReflectionHelpers.Invoke(typeof(FallbackEndpointDiscoveryEnabledFactory), "credentialProfileChain"); ReflectionHelpers.Invoke(typeof(FallbackEndpointDiscoveryEnabledFactory), "credentialProfileChain", new CredentialProfileStoreChain(sharedFixture.CredentialsFilePath)); originalAWSProfileValue = Environment.GetEnvironmentVariable(AWS_PROFILE_ENVIRONMENT_VARIABLE); Environment.SetEnvironmentVariable(AWS_PROFILE_ENVIRONMENT_VARIABLE, awsProfileValue); originalAWSEnableEndpointDiscoveryValue = Environment.GetEnvironmentVariable(AWS_ENABLE_ENDPOINT_DISCOVERY_ENVIRONMENT_VARIABLE); Environment.SetEnvironmentVariable(AWS_ENABLE_ENDPOINT_DISCOVERY_ENVIRONMENT_VARIABLE, enableEndpointDiscoveryValue); // reset before use to ensure the new credentialProfileChains are used. FallbackCredentialsFactory.Reset(); FallbackRegionFactory.Reset(); FallbackEndpointDiscoveryEnabledFactory.Reset(); }
public void ReadDefaultConfigProfile() { using (var tester = new SharedCredentialsFileTestFixture(null, DefaultProfileText)) { tester.TestTryGetProfile("default", true, true); } }
public void ReadProfileDoesNotExist() { using (var tester = new SharedCredentialsFileTestFixture()) { tester.TestTryGetProfile("profile_does_not_exist", 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 DeleteProfile() { using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText + Environment.NewLine + BasicProfileCredentialsText)) { tester.CredentialsFile.UnregisterProfile("session_profile"); tester.AssertCredentialsFileContents(BasicProfileCredentialsText); } }
public void UpdateProfileWithProperties() { using (var tester = new SharedCredentialsFileTestFixture(UpdatedProfileWithPropertiesTextBefore)) { tester.ReadAndAssertProfile("basic_profile", UpdatedProfileWithPropertiesOptions, UpdatedProfileWithPropertiesBefore); tester.AssertWriteProfile("basic_profile", UpdatedProfileWithPropertiesOptions, UpdatedProfileWithPropertiesAfter, UpdatedProfileWithPropertiesTextAfter); } }
public void ReadInvalidEndpointDiscoveryEnabledOnlyProfile() { using (var tester = new SharedCredentialsFileTestFixture(EndpointDiscoveryEnabledOnlyProfileText_Invalid)) { CredentialProfile profile1; Assert.IsFalse(tester.CredentialsFile.TryGetProfile("endpoint_discovery_enabled_only_profile", out profile1)); } }
public void ListProfilesExcludeInvalidDuplicateProperty() { using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText + Environment.NewLine + "aws_session_token=session_aws_session_token")) { var profiles = tester.CredentialsFile.ListProfiles(); Assert.AreEqual(0, profiles.Count); } }
public void ListProfilesEmpty() { using (var tester = new SharedCredentialsFileTestFixture()) { var profiles = tester.CredentialsFile.ListProfiles(); Assert.AreEqual(0, profiles.Count); } }
public void UpdateProfile() { using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText)) { tester.ReadAndAssertProfile("session_profile", SessionProfileOptions); tester.AssertWriteProfile("session_profile", SessionProfileOptionsUpdated, SessionProfileTextUpdated); } }
public void ReadBasicProfileCredentialsTakesPrecedence() { using (var tester = new SharedCredentialsFileTestFixture( BasicProfileTextCredentialsPrecedence, BasicProfileTextConfigPrecedence)) { tester.ReadAndAssertProfile("basic_profile", BasicProfilePrecedenceOptions); } }
public void ReadBasicProfileSplit() { using (var tester = new SharedCredentialsFileTestFixture( BasicProfileTextCredentialsPartial, BasicProfileTextConfigPartial)) { tester.ReadAndAssertProfile("basic_profile", BasicProfileOptions); } }
public void ListProfilesExcludeInvalidNoCredentials() { using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText + Environment.NewLine + InvalidProfileText)) { var profiles = tester.CredentialsFile.ListProfiles(); Assert.AreEqual(1, profiles.Count); Assert.AreEqual("session_profile", profiles[0].Name); } }
public void ListProfiles() { using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText)) { var profiles = tester.CredentialsFile.ListProfiles(); Assert.AreEqual(1, profiles.Count); Assert.AreEqual("session_profile", profiles[0].Name); } }
public void ListProfileNames() { using (var tester = new SharedCredentialsFileTestFixture(SessionProfileText)) { var profileNames = tester.CredentialsFile.ListProfileNames(); Assert.AreEqual(1, profileNames.Count); Assert.IsTrue(profileNames.Contains("session_profile")); } }
public void ReadBasicProfileAllConfigExtraSpacesAndTabInName() { var basicProfileInConfigWithWhitespace = BasicProfileConfigText.Replace("profile basic_profile", "profile \t basic_profile"); using (var tester = new SharedCredentialsFileTestFixture(null, basicProfileInConfigWithWhitespace)) { tester.ReadAndAssertProfile("basic_profile", BasicProfileOptions, RegionEndpoint.CACentral1, UniqueKey); } }
public void ReadBasicProfileAllConfigForgotProfileKeyword() { using (var tester = new SharedCredentialsFileTestFixture(null, BasicProfileCredentialsText)) { CredentialProfile profile = null; Assert.IsFalse(tester.CredentialsFile.TryGetProfile("basic_profile", out profile)); Assert.IsNull(profile); } }