public void InvalidProfile() { using (var tester = new NetSDKCredentialsFileTestFixture(InvalidProfileText)) { tester.TestTryGetProfile("InvalidProfile", true, false); } }
public void ReadRegionOnlyProfile() { using (var tester = new NetSDKCredentialsFileTestFixture(RegionOnlyProfileText)) { tester.TestTryGetProfile("RegionOnlyProfile", true, false); } }
public void WriteRegionCredentialsUntouched() { using (var tester = new NetSDKCredentialsFileTestFixture()) { // 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.ProfileStore.RegisterProfile(profile); // now write just the region var emptyOptions = new CredentialProfileOptions(); var regionOnlyProfile = new CredentialProfile("WriteRegionKeepOptionsProfile", basicOptions); profile.Region = RegionEndpoint.APSouth1; tester.ProfileStore.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 ProfileNotFound() { using (var tester = new NetSDKCredentialsFileTestFixture()) { tester.TestTryGetProfile("DoesNotExist", false, false); } }
public void TestAllProfileTypes() { foreach (CredentialProfileType type in Enum.GetValues(typeof(CredentialProfileType))) { using (var tester = new NetSDKCredentialsFileTestFixture()) { var profileName = type.ToString() + Guid.NewGuid().ToString(); var originalProfile = CredentialProfileTestHelper.GetRandomProfile(profileName, type); Assert.IsTrue(originalProfile.CanCreateAWSCredentials); Assert.IsNotNull(CredentialProfileUtils.GetUniqueKey(originalProfile)); tester.ProfileStore.RegisterProfile(originalProfile); var readProfile = tester.TestTryGetProfile(profileName, true, true); Assert.AreEqual(originalProfile, readProfile); //Making sure that the endpoint_discovery_enabled field is set to the default Assert.IsNull(readProfile.EndpointDiscoveryEnabled); // make sure the ProfileType is written, even though it's ignored var expectedType = type.ToString(); if (type == CredentialProfileType.Basic) { expectedType = AWSCredentialsProfileType; } else if (type == CredentialProfileType.SAMLRole || type == CredentialProfileType.SAMLRoleUserIdentity) { expectedType = SAMLRoleProfileType; } tester.AssertJsonProperty(profileName, SettingsConstants.ProfileTypeField, expectedType); } } }
public void UnregisterProfile() { using (var tester = new NetSDKCredentialsFileTestFixture()) { // register tester.ProfileStore.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile(Guid.NewGuid(), CredentialProfileType.Basic.ToString(), CredentialProfileTestHelper.GetRandomOptions(CredentialProfileType.Basic))); // check that it's there tester.TestTryGetProfile(CredentialProfileType.Basic.ToString(), true, true); // unregister tester.ProfileStore.UnregisterProfile(CredentialProfileType.Basic.ToString()); // check that it's not there tester.TestTryGetProfile(CredentialProfileType.Basic.ToString(), false, false); } }
public void ReadUniqueKeyProperty() { using (var tester = new NetSDKCredentialsFileTestFixture(LegacyCredentialsTypeProfileText)) { var profile = tester.TestTryGetProfile("LegacyCredentialsTypeProfile", true, false); Assert.AreEqual(UniqueKey.ToString("D"), CredentialProfileUtils.GetUniqueKey(profile)); } }
public void LegacyCredentialsTypeProfile() { using (var tester = new NetSDKCredentialsFileTestFixture(LegacyCredentialsTypeProfileText)) { var profile = tester.TestTryGetProfile("LegacyCredentialsTypeProfile", true, false); var credentialType = CredentialProfileUtils.GetProperty(profile, "CredentialsType"); Assert.AreEqual("the_credentials_type", credentialType); } }
public void ReadDefaultConfigurationModeNameOnlyProfile() { using (var tester = new NetSDKCredentialsFileTestFixture(DefaultConfigurationModeNameOnlyProfileText)) { var profile = tester.TestTryGetProfile("DefaultConfigurationModeNameOnlyProfile", expectProfile: true, expectValidProfile: false); Assert.AreEqual(DefaultConfigurationMode.InRegion.ToString(), profile.DefaultConfigurationModeName); } }
public void WriteEndpointDiscoveryEnabledOnlyProfile() { using (var tester = new NetSDKCredentialsFileTestFixture()) { var emptyOptions = new CredentialProfileOptions(); var profile = new CredentialProfile("EndpointDiscoveryEnabledOnlyProfile", emptyOptions); profile.EndpointDiscoveryEnabled = true; tester.ProfileStore.RegisterProfile(profile); var readProfile = tester.TestTryGetProfile("EndpointDiscoveryEnabledOnlyProfile", true, false); Assert.IsTrue(readProfile.EndpointDiscoveryEnabled.HasValue); Assert.IsTrue(readProfile.EndpointDiscoveryEnabled.Value); } }
public void WriteRegionOnlyProfile() { using (var tester = new NetSDKCredentialsFileTestFixture()) { var emptyOptions = new CredentialProfileOptions(); var profile = new CredentialProfile("RegionOnlyProfile", emptyOptions); profile.Region = RegionEndpoint.USGovCloudWest1; tester.ProfileStore.RegisterProfile(profile); var readProfile = tester.TestTryGetProfile("RegionOnlyProfile", true, false); Assert.AreEqual(RegionEndpoint.USGovCloudWest1, readProfile.Region); Assert.IsTrue((bool)ReflectionHelpers.Invoke(readProfile.Options, "IsEmpty")); } }