Пример #1
0
        public IAlibabaCloudCredentials GetCredentials()
        {
            string filePath = AuthUtils.EnvironmentCredentialsFile;

            if (filePath == null)
            {
                filePath = AuthConstant.GetDefaultFilePath();
            }
            else if (filePath.Length == 0)
            {
                throw new CredentialException("The specified credentials file is empty");
            }

            IniFileHelper iniFile;

            try
            {
                iniFile = new IniFileHelper(filePath);
            }
            catch (IOException)
            {
                return(null);
            }

            if (!iniFile.Ini.ContainsKey(AuthUtils.ClientType))
            {
                throw new CredentialException("Client is not open in the specified credentials file");
            }
            return(CreateCredential(iniFile.Ini[AuthUtils.ClientType]));
        }
        public void GetDefaultFilePathTest()
        {
            string path = AuthConstant.GetDefaultFilePath();

            Assert.NotEmpty(path);
        }