public void Set()
        {
            var instance = new ECSMetadataServiceCredentialsFetcher();

            Assert.Throws <ArgumentNullException>(
                () => { instance.SetRoleName(""); }
                );
            instance.WithECSMetadataServiceHost("host");
            instance.WithConnectionTimeout(100);
            instance.SetRoleName("roleName");

            Assert.Equal("roleName", instance.GetRoleName());
        }
Пример #2
0
        public virtual AlibabaCloudCredentials GetInstanceRamRoleAlibabaCloudCredential()
        {
            if (null == this.regionId || this.regionId.Equals(""))
            {
                throw new ClientException("RegionID cannot be null or empty.");
            }
            else
            {
                if (defaultProfile.DefaultClientName.Equals("default"))
                {
                    ECSMetadataServiceCredentialsFetcher eCSMetadataServiceCredentialsFetcher = new ECSMetadataServiceCredentialsFetcher();
                    eCSMetadataServiceCredentialsFetcher.SetRoleName(roleName);
                    var ecsInstanceCredential = eCSMetadataServiceCredentialsFetcher.Fetch();

                    return(ecsInstanceCredential);
                }
            }
            return(null);
        }