Beispiel #1
0
 public void InvalidProfile()
 {
     using (var tester = new NetSDKCredentialsFileTestFixture(InvalidProfileText))
     {
         tester.TestTryGetProfile("InvalidProfile", true, false);
     }
 }
Beispiel #2
0
 public void ReadRegionOnlyProfile()
 {
     using (var tester = new NetSDKCredentialsFileTestFixture(RegionOnlyProfileText))
     {
         tester.TestTryGetProfile("RegionOnlyProfile", true, false);
     }
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
 public void ProfileNotFound()
 {
     using (var tester = new NetSDKCredentialsFileTestFixture())
     {
         tester.TestTryGetProfile("DoesNotExist", false, false);
     }
 }
Beispiel #5
0
        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);
                }
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
 public void ReadUniqueKeyProperty()
 {
     using (var tester = new NetSDKCredentialsFileTestFixture(LegacyCredentialsTypeProfileText))
     {
         var profile = tester.TestTryGetProfile("LegacyCredentialsTypeProfile", true, false);
         Assert.AreEqual(UniqueKey.ToString("D"), CredentialProfileUtils.GetUniqueKey(profile));
     }
 }
Beispiel #8
0
 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);
     }
 }
Beispiel #9
0
        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);
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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"));
            }
        }