Repository: aws/aws-sdk-js
Pull request #2311 (2018-10-17 21:04:59)

Revert "Feature/load shared config (#2283)"
This reverts commit 314927948052c586297b180c3ae29a4e2d5f17ac.


Patch:
diff --git a/.changes/next-release/feature-Configuration-62b1b6d7.json b/.changes/next-release/feature-Configuration-62b1b6d7.json
deleted file mode 100644
index c2ea73b0b..000000000
--- a/.changes/next-release/feature-Configuration-62b1b6d7.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-  "type": "feature",
-  "category": "Configuration",
-  "description": "cache shared ini files for later use"
-}
\ No newline at end of file
diff --git a/lib/core.d.ts b/lib/core.d.ts
index 8e2800f21..511e4d051 100644
--- a/lib/core.d.ts
+++ b/lib/core.d.ts
@@ -21,4 +21,3 @@ export {Request} from './request';
 export {Response} from './response';
 export {Service} from './service';
 export {AWSError} from './error';
-export {IniLoader} from './shared-ini/ini-loader';
diff --git a/lib/credentials/shared_ini_file_credentials.js b/lib/credentials/shared_ini_file_credentials.js
index 1758499c2..6afc33436 100644
--- a/lib/credentials/shared_ini_file_credentials.js
+++ b/lib/credentials/shared_ini_file_credentials.js
@@ -1,5 +1,6 @@
 var AWS = require('../core');
-var iniLoader = require('../shared-ini').iniLoader;
+var path = require('path');
+var SharedIniFile = require('../shared_ini');
 var STS = require('../../clients/sts');
 
 /**
@@ -96,22 +97,22 @@ AWS.SharedIniFileCredentials = AWS.util.inherit(AWS.Credentials, {
 
     try {
       var profiles = {};
-      var profilesFromConfig = {};
+      var i, availableProfiles;
       if (process.env[AWS.util.configOptInEnv]) {
-        var profilesFromConfig = iniLoader.loadFrom({
+        var config = new SharedIniFile({
           isConfig: true,
           filename: process.env[AWS.util.sharedConfigFileEnv]
         });
+        for (i = 0, availableProfiles = config.getProfiles(); i < availableProfiles.length; i++) {
+          profiles[availableProfiles[i]] = config.getProfile(availableProfiles[i]);
+        }
       }
-      var profilesFromCreds = iniLoader.loadFrom({
+      var creds = new SharedIniFile({
         filename: this.filename ||
           (process.env[AWS.util.configOptInEnv] && process.env[AWS.util.sharedCredentialsFileEnv])
       });
-      for (var i = 0, profileNames = Object.keys(profilesFromConfig); i < profileNames.length; i++) {
-        profiles[profileNames[i]] = profilesFromConfig[profileNames[i]];
-      }
-      for (var i = 0, profileNames = Object.keys(profilesFromCreds); i < profileNames.length; i++) {
-        profiles[profileNames[i]] = profilesFromCreds[profileNames[i]];
+      for (i = 0, availableProfiles = creds.getProfiles(); i < availableProfiles.length; i++) {
+        profiles[availableProfiles[i]] = creds.getProfile(availableProfiles[i]);
       }
       var profile = profiles[this.profile] || {};
 
diff --git a/lib/node_loader.js b/lib/node_loader.js
index 798463b80..36ac0ff34 100644
--- a/lib/node_loader.js
+++ b/lib/node_loader.js
@@ -36,8 +36,6 @@ AWS.XML.Parser = require('./xml/node_parser');
 // Load Node HTTP client
 require('./http/node');
 
-require('./shared-ini/ini-loader');
-
 // Load custom credential providers
 require('./credentials/ec2_metadata_credentials');
 require('./credentials/remote_credentials');
@@ -46,6 +44,8 @@ require('./credentials/environment_credentials');
 require('./credentials/file_system_credentials');
 require('./credentials/shared_ini_file_credentials');
 
+var SharedIniFile = require('./shared_ini');
+
 // Setup default chain providers
 // If this changes, please update documentation for
 // AWS.CredentialProviderChain.defaultProviders in
@@ -89,10 +89,11 @@ AWS.util.update(AWS.Config.prototype.keys, {
         {filename: env[AWS.util.sharedCredentialsFileEnv]},
         {isConfig: true, filename: env[AWS.util.sharedConfigFileEnv]}
       ];
-      var iniLoader = require('./shared-ini').iniLoader;
       while (!region && toCheck.length) {
-        var configFile = iniLoader.loadFrom(toCheck.shift());
-        var profile = configFile[env.AWS_PROFILE || AWS.util.defaultProfile];
+        var configFile = new SharedIniFile(toCheck.shift());
+        var profile = configFile.getProfile(
+          env.AWS_PROFILE || AWS.util.defaultProfile
+        );
         region = profile && profile.region;
       }
     }
diff --git a/lib/publisher/configuration.js b/lib/publisher/configuration.js
index 4948679ac..c7fed3ba4 100644
--- a/lib/publisher/configuration.js
+++ b/lib/publisher/configuration.js
@@ -1,5 +1,5 @@
 var AWS = require('../core');
-var iniLoader = require('../shared-ini').iniLoader;
+var SharedIniFile = require('../shared_ini');
 /**
  * Resolve client-side monitoring configuration from either environmental variables
  * or shared config file. Configurations from environmental variables have higher priority
@@ -38,15 +38,15 @@ function fromEnvironment(config) {
  * @api private
  */
 function fromConfigFile(config) {
+  var profile = process.env.AWS_PROFILE || AWS.util.defaultProfile;
+  var file = process.env[AWS.util.sharedConfigFileEnv]
   var sharedFileConfig;
   try {
-    var configFile = iniLoader.loadFrom({
+    var configFile = new SharedIniFile({
       isConfig: true,
-      filename: process.env[AWS.util.sharedConfigFileEnv]
+      filename: file
     });
-    var sharedFileConfig = configFile[
-      process.env.AWS_PROFILE || AWS.util.defaultProfile
-    ];
+    var sharedFileConfig = configFile.getProfile(profile);
   } catch (err) {
     return false;
   }
diff --git a/lib/shared-ini/index.d.ts b/lib/shared-ini/index.d.ts
deleted file mode 100644
index 75cc9f459..000000000
--- a/lib/shared-ini/index.d.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import {IniLoader} from './ini-loader';
-
-export const iniLoader: IniLoader;
\ No newline at end of file
diff --git a/lib/shared-ini/index.js b/lib/shared-ini/index.js
deleted file mode 100644
index 84bf0a68b..000000000
--- a/lib/shared-ini/index.js
+++ /dev/null
@@ -1,6 +0,0 @@
-var IniLoader = require('./ini-loader').IniLoader;
-/**
- * Singleton object to load specified config/credentials files.
- * It will cache all the files ever loaded;
- */
-module.exports.iniLoader = new IniLoader();
\ No newline at end of file
diff --git a/lib/shared-ini/ini-loader.d.ts b/lib/shared-ini/ini-loader.d.ts
deleted file mode 100644
index 861053dba..000000000
--- a/lib/shared-ini/ini-loader.d.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-export interface LoadFileOptions {
-  filename?: string,
-  isConfig?: boolean,
-}
-
-export interface IniFileContent {
-  [key: string]: {[key: string]: string}
-}
-
-/**
- * Ini file loader class the same as that used in the SDK. It loads and 
- * parses config and credentials files in .ini format and cache the content
- * to assure files are only read once. 
- * Note that calling operations on the instance instantiated from this class
- * won't affect the behavior of SDK since SDK uses an internal singleton of
- * this class.
- */
-export class IniLoader{
-  
-/** Remove all cached files. Used after config files are updated. */
-  clearCachedFiles():void;
-
-/**
- * Load configurations from config/credentials files and cache them 
- * for later use. If no file is specified it will try to load default
- * files.
- * @returns {object} object of all profile information in the file
- */
-  loadFrom(options: LoadFileOptions): IniFileContent;
-}
-
-/**
- * Read specified file and return parsed config object. This method will always
- * read from disk and won't update cache. This is a lower level function of 
- * loadFrom().
- * @param filename [string] valid readable file path containing aws credentials
- * or aws configs
- * @param isConfig [boolean] true if specified file is an aws config file; false
- * if the file is an aws credentials file
- */
-export function parseFile(filename: string, isConfig: boolean): IniFileContent;
\ No newline at end of file
diff --git a/lib/shared-ini/ini-loader.js b/lib/shared-ini/ini-loader.js
deleted file mode 100644
index 473d2645b..000000000
--- a/lib/shared-ini/ini-loader.js
+++ /dev/null
@@ -1,105 +0,0 @@
-var AWS = require('../core');
-var os = require('os');
-var path = require('path');
-
-function parseFile(filename, isConfig) {
-  if (!isConfig) {
-    return AWS.util.ini.parse(AWS.util.readFileSync(filename));
-  } else {
-    var content = AWS.util.ini.parse(AWS.util.readFileSync(filename));
-    var tmpContent = {};
-    Object.keys(content).forEach(function(profileName) {
-      var profileContent = content[profileName];
-      tmpContent[profileName.replace(/^profile\s/, '')] = profileContent;
-    })
-    return tmpContent;
-  }
-}
-
-/**
- * Ini file loader class the same as that used in the SDK. It loads and
- * parses config and credentials files in .ini format and cache the content
- * to assure files are only read once.
- * Note that calling operations on the instance instantiated from this class
- * won't affect the behavior of SDK since SDK uses an internal singleton of
- * this class.
- * @!macro nobrowser
- */
-AWS.IniLoader = AWS.util.inherit({
-  constructor: function IniLoader() {
-    this.resolvedProfiles = {};
-  },
-
-  /** Remove all cached files. Used after config files are updated. */
-  clearCachedFiles: function clearCachedFiles() {
-    this.resolvedProfiles = {};
-  },
-
-/**
- * Load configurations from config/credentials files and cache them
- * for later use. If no file is specified it will try to load default
- * files.
- * @param options [map] information describing the file
- * @option options filename [String] ('~/.aws/credentials' or defined by
- *   AWS_SHARED_CREDENTIALS_FILE process env var or '~/.aws/config' if
- *   isConfig is set to true)
- *   path to the file to be read.
- * @option options isConfig [Boolean] (false) True to read config file.
- * @return [map<String,String>] object containing contents from file in key-value
- *   pairs.
- */
-  loadFrom: function loadFrom(options) {
-    options = options || {};
-    var isConfig = options.isConfig === true;
-    var filename = options.filename || this.getDefaultFilePath(isConfig);
-    if (!this.resolvedProfiles[filename]) {
-      this.resolvedProfiles[filename] = this.parseFile(filename, isConfig);
-    }
-    return this.resolvedProfiles[filename];
-  },
-
-  /**
-   * @api private
-   */
-  parseFile: parseFile,
-
-  /**
-   * @api private
-   */
-  getDefaultFilePath: function getDefaultFilePath(isConfig) {
-    return path.join(
-      this.getHomeDir(),
-      '.aws',
-      isConfig ? 'config' : 'credentials'
-    );
-  },
-
-  /**
-   * @api private
-   */
-  getHomeDir: function getHomeDir() {
-    var env = process.env;
-    var home = env.HOME ||
-      env.USERPROFILE ||
-      (env.HOMEPATH ? ((env.HOMEDRIVE || 'C:/') + env.HOMEPATH) : null);
-
-    if (home) {
-      return home;
-    }
-
-    if (typeof os.homedir === 'function') {
-      return os.homedir();
-    }
-
-    throw AWS.util.error(
-      new Error('Cannot load credentials, HOME path not set')
-    );
-  }
-});
-
-var IniLoader = AWS.IniLoader;
-
-module.exports = {
-  IniLoader: IniLoader,
-  parseFile: parseFile,
-}
\ No newline at end of file
diff --git a/lib/shared_ini.js b/lib/shared_ini.js
new file mode 100644
index 000000000..4154ce5c8
--- /dev/null
+++ b/lib/shared_ini.js
@@ -0,0 +1,72 @@
+var AWS = require('./core');
+var os = require('os');
+var path = require('path');
+
+/**
+ * @api private
+ */
+module.exports = AWS.util.inherit({
+  constructor: function SharedIniFile(options) {
+    options = options || {};
+
+    this.isConfig = options.isConfig === true;
+    this.filename = options.filename || this.getDefaultFilepath();
+  },
+
+  ensureFileLoaded: function loadFile() {
+    if (!this.parsedContents) {
+      this.parsedContents = AWS.util.ini.parse(
+        AWS.util.readFileSync(this.filename)
+      );
+    }
+  },
+
+  getDefaultFilepath: function getDefaultFilepath() {
+    return path.join(
+      this.getHomeDir(),
+      '.aws',
+      this.isConfig ? 'config' : 'credentials'
+    );
+  },
+
+  getHomeDir: function getHomeDir() {
+    var env = process.env;
+    var home = env.HOME ||
+      env.USERPROFILE ||
+      (env.HOMEPATH ? ((env.HOMEDRIVE || 'C:/') + env.HOMEPATH) : null);
+
+    if (home) {
+      return home;
+    }
+
+    if (typeof os.homedir === 'function') {
+      return os.homedir();
+    }
+
+    throw AWS.util.error(
+      new Error('Cannot load credentials, HOME path not set')
+    );
+  },
+
+  getProfile: function loadProfile(profile) {
+    this.ensureFileLoaded();
+
+    var profileIndex = profile !== AWS.util.defaultProfile && this.isConfig ?
+      'profile ' + profile : profile;
+
+    return this.parsedContents[profileIndex];
+  },
+
+  getProfiles: function loadProfileNames() {
+    this.ensureFileLoaded();
+    var isConfig = this.isConfig;
+
+    return Object.keys(this.parsedContents).map(function(profileName) {
+      if (isConfig) {
+        return profileName.replace(/^profile\s/, '');
+      }
+
+      return profileName;
+    });
+  }
+});
diff --git a/ts/core.ts b/ts/core.ts
index e34337fdc..ec71ba050 100644
--- a/ts/core.ts
+++ b/ts/core.ts
@@ -35,6 +35,4 @@ if (core.CognitoIdentityCredentials) {
 
 } else if (core.SAMLCredentials) {
     
-} else if (core.IniLoader) {
-  
 }
\ No newline at end of file


Test patch:
diff --git a/test/config.spec.js b/test/config.spec.js
index 8a4be2a2d..8aaecef22 100644
--- a/test/config.spec.js
+++ b/test/config.spec.js
@@ -1,7 +1,7 @@
 var hasProp = {}.hasOwnProperty;
 var helpers = require('./helpers');
 var AWS = helpers.AWS;
-var iniLoader = require('../lib/shared-ini').iniLoader;
+var SharedIniFile = require('../lib/shared_ini');
 var configure = function(options) {
   return new AWS.Config(options);
 };
@@ -41,7 +41,6 @@ describe('AWS.Config', function() {
 
     afterEach(function() {
       process.env = oldEnv;
-      iniLoader.clearCachedFiles();
     });
 
     it('defaults to undefined', function() {
diff --git a/test/credentials.spec.js b/test/credentials.spec.js
index b8987d580..fd168126a 100644
--- a/test/credentials.spec.js
+++ b/test/credentials.spec.js
@@ -8,8 +8,6 @@
 
   STS = require('../clients/sts');
 
-  var iniLoader = require('../lib/shared-ini').iniLoader;
-
   validateCredentials = function(creds, key, secret, session) {
     expect(creds.accessKeyId).to.equal(key || 'akid');
     expect(creds.secretAccessKey).to.equal(secret || 'secret');
@@ -193,8 +191,9 @@
       });
     });
     describe('AWS.SharedIniFileCredentials', function() {
-      var os = require('os');
-      var homedir = os.homedir;
+      var homedir, os;
+      os = require('os');
+      homedir = os.homedir;
       beforeEach(function() {
         delete os.homedir;
         delete process.env.AWS_PROFILE;
@@ -203,11 +202,10 @@
         delete process.env.HOME;
         delete process.env.HOMEPATH;
         delete process.env.HOMEDRIVE;
-        delete process.env.USERPROFILE;
+        return delete process.env.USERPROFILE;
       });
       afterEach(function() {
-        iniLoader.clearCachedFiles();
-        os.homedir = homedir;
+        return os.homedir = homedir;
       });
       describe('constructor', function() {
         beforeEach(function() {
@@ -226,7 +224,7 @@
           process.env.HOME = '/home/user';
           helpers.spyOn(os, 'homedir').andReturn(process.env.HOME + '/foo/bar');
 
-          new AWS.SharedIniFileCredentials();
+           new AWS.SharedIniFileCredentials();
           expect(os.homedir.calls.length).to.equal(0);
           expect(AWS.util.readFileSync.calls.length).to.equal(1);
           return expect(AWS.util.readFileSync.calls[0].arguments[0]).to
@@ -274,10 +272,7 @@
       });
       describe('loading', function() {
         beforeEach(function() {
-          process.env.HOME = '/home/user';
-        });
-        afterEach(function() {
-          iniLoader.clearCachedFiles();
+          return process.env.HOME = '/home/user';
         });
         it('loads credentials from ~/.aws/credentials using default profile', function() {
           var creds, mock;
@@ -392,13 +387,10 @@
           return validateCredentials(creds);
         });
       });
-      describe('refresh', function() {
+      return describe('refresh', function() {
         beforeEach(function() {
           return process.env.HOME = '/home/user';
         });
-        afterEach(function() {
-          iniLoader.clearCachedFiles();
-        });
         it('should refresh from disk', function() {
           var creds, mock;
           mock = '[default]\naws_access_key_id = RELOADED\naws_secret_access_key = RELOADED\naws_session_token = RELOADED';
@@ -424,10 +416,7 @@
       beforeEach(function() {
         var os;
         os = require('os');
-        helpers.spyOn(os, 'homedir').andReturn('/home/user');
-      });
-      afterEach(function() {
-        iniLoader.clearCachedFiles();
+        return helpers.spyOn(os, 'homedir').andReturn('/home/user');
       });
       it('will fail if assume role is disabled', function() {
         var creds, mock;
diff --git a/test/publisher/configuration.spec.js b/test/publisher/configuration.spec.js
index 0084fd3da..0d592924a 100644
--- a/test/publisher/configuration.spec.js
+++ b/test/publisher/configuration.spec.js
@@ -2,7 +2,6 @@ var helpers = require('../helpers');
 var AWS = helpers.AWS;
 var spyOn = helpers.spyOn;
 var monitoringConfig = require('../../lib/publisher/configuration');
-var iniLoader = require('../../lib/shared-ini').iniLoader;
 
 if (AWS.util.isNode()) {
   describe('configuration resolving', function () {
@@ -20,10 +19,6 @@ if (AWS.util.isNode()) {
         'HOME': '/home/user'
       };
     });
-
-    afterEach(function() {
-      iniLoader.clearCachedFiles();
-    });
   
     describe('get configurations from environmental variable', function () {
       it('should correctly parse truthy value to true', function () {
diff --git a/test/shared_ini.spec.js b/test/shared_ini.spec.js
deleted file mode 100644
index 6e010dfe1..000000000
--- a/test/shared_ini.spec.js
+++ /dev/null
@@ -1,147 +0,0 @@
-var helpers = require('./helpers');
-var os = require('os');
-var AWS = helpers.AWS;
-var IniLoader = AWS.IniLoader;
-
-function validateCachedFiles(iniFile, expectedCache) {
-  if (!expectedCache) return false;
-  helpers.spyOn(AWS.util, 'readFileSync').andCallFake(function() {throw new Error('shouldn\'t load new profiles')})
-  for (var i = 0, filePaths = Object.keys(expectedCache); i < filePaths.length; i++) {
-    var path = filePaths[i];
-    expect(iniFile.loadFrom({filename: path})).to.eql(expectedCache[path]);
-  }
-}
-
-if (AWS.util.isNode()) {
-  describe('AWS.iniLoader', function() {
-    var homedir = os.homedir;
-    var env = process.env;
-    
-    beforeEach(function() {
-      process.env = {};
-    });
-  
-    after(function() {
-      os.homedir = homedir;
-      process.env = env;
-    });
-  
-    describe ('constructor', function() {
-      it('should only read config file lazily when need to', function() {
-        helpers.spyOn(os, 'homedir').andReturn('/foo/bar/baz');
-        helpers.spyOn(AWS.util, 'readFileSync');
-        var iniLoader = new IniLoader();
-        expect(AWS.util.readFileSync.calls.length).to.equal(0);
-      });
-    });
-  
-    describe('loadFrom', function() {
-      var iniLoader;
-  
-      beforeEach(function() {
-        iniLoader = new IniLoader();
-      })
-  
-      it('load config file with profile name indexed', function () {
-        helpers.spyOn(AWS.util, 'readFileSync').andCallFake(function(path) {
-          if (path === '/User/foo/config') {
-            return '[default]\naws_access_key_id = akid\naws_secret_access_key = secret\n[profile user1]\naws_access_key_id = acki\naws_secret_access_key = asak\n';
-          }
-          return '[default]\naws_access_key_id = akid\naws_secret_access_key = secret\n';
-        });
-        iniLoader.loadFrom({isConfig: true, filename: '/User/foo/config'});
-        validateCachedFiles(iniLoader, {
-          '/User/foo/config': {
-            'default': {
-              'aws_access_key_id': 'akid',
-              'aws_secret_access_key': 'secret'
-            },
-            'user1': {
-              'aws_access_key_id': 'acki',
-              'aws_secret_access_key': 'asak'
-            }
-          }
-        })
-      });
-  
-      it('load default profiles filename is not supplied', function() {
-        process.env.HOME = '/foo';
-        helpers.spyOn(AWS.util, 'readFileSync').andCallFake(function(path) {
-          if (path === '/foo/.aws/config') return '[default]\naws_access_key_id = akid\naws_secret_access_key = secret';
-          else return '[default]\naws_access_key_id = akid2\naws_secret_access_key = secret2'
-        });
-        var iniFile = new IniLoader();
-        expect(iniFile.loadFrom({isConfig: true})).to.eql({'default': {'aws_access_key_id': 'akid', 'aws_secret_access_key': 'secret'}});
-        expect(iniFile.loadFrom({})).to.eql({'default': {'aws_access_key_id': 'akid2', 'aws_secret_access_key': 'secret2'}});
-      });
-  
-      it('load credentials file if isConfig parameter is not set', function() {
-        helpers.spyOn(AWS.util, 'readFileSync').andCallFake(function(path) {
-          if (path === '/foo/bar') return '[profile user]\naws_access_key_id = akid\naws_secret_access_key = secret';
-          else if (path === '/foo/qux') return '[profile user2]\naws_access_key_id = akid2\naws_secret_access_key = secret2'
-        });
-        var iniFile = new IniLoader();
-        expect(iniFile.loadFrom({isConfig: true, filename: '/foo/bar'})).to.eql({'user': {'aws_access_key_id': 'akid', 'aws_secret_access_key': 'secret'}});
-        //for credients, the prefix 'profile ' of the profile name won't be removed
-        expect(iniFile.loadFrom({filename: '/foo/qux'})).to.eql({'profile user2': {'aws_access_key_id': 'akid2', 'aws_secret_access_key': 'secret2'}});
-      });
-  
-      it('won\'t load same file twice', function() {
-        helpers.spyOn(AWS.util, 'readFileSync').andReturn('');
-        iniLoader.loadFrom({filename: 'foo'});
-        iniLoader.loadFrom({filename: 'foo'});
-        expect(AWS.util.readFileSync.calls.length).to.eql(1);
-      });
-
-      it('load default profiles according to environmental variables', function() {
-        helpers.spyOn(os, 'homedir').andCallThrough();
-        helpers.spyOn(AWS.util, 'readFileSync').andReturn('');
-        process.env = {HOME: '/foo', USERPROFILE: '/bar', HOMEPATH: '/baz', HOMEDRIVE: '/quz'};
-        var iniFile = new IniLoader();
-        iniFile.loadFrom({isConfig: true});
-        iniFile.loadFrom({});
-        expect(AWS.util.readFileSync.calls.length).to.eql(2);
-        expect(AWS.util.readFileSync.calls[0].arguments).to.eql(['/foo/.aws/config']);
-        expect(AWS.util.readFileSync.calls[1].arguments).to.eql(['/foo/.aws/credentials']);
-        delete process.env.HOME;
-        iniFile.loadFrom({isConfig: true});
-        iniFile.loadFrom({});
-        expect(AWS.util.readFileSync.calls.length).to.eql(4);
-        expect(AWS.util.readFileSync.calls[2].arguments).to.eql(['/bar/.aws/config']);
-        expect(AWS.util.readFileSync.calls[3].arguments).to.eql(['/bar/.aws/credentials']);
-        delete process.env.USERPROFILE;
-        iniFile.loadFrom({isConfig: true});
-        iniFile.loadFrom({});
-        expect(AWS.util.readFileSync.calls.length).to.eql(6);
-        expect(AWS.util.readFileSync.calls[4].arguments).to.eql(['/quz/baz/.aws/config']);
-        expect(AWS.util.readFileSync.calls[5].arguments).to.eql(['/quz/baz/.aws/credentials']);
-        delete process.env.HOMEDRIVE;
-        iniFile.loadFrom({isConfig: true});
-        iniFile.loadFrom({});
-        expect(AWS.util.readFileSync.calls.length).to.eql(8);
-        expect(AWS.util.readFileSync.calls[6].arguments).to.eql(['C:/baz/.aws/config']);
-        expect(AWS.util.readFileSync.calls[7].arguments).to.eql(['C:/baz/.aws/credentials']);
-        expect(os.homedir.calls.length).to.eql(0);
-      });
-    });
-  
-    describe('clearCachedFiles', function() {
-      it('remove all cached files', function() {
-        process.env.HOME = '/foo';
-        helpers.spyOn(AWS.util, 'readFileSync').andReturn('');
-        var iniFile = new IniLoader();
-        iniFile.loadFrom();
-        validateCachedFiles(iniFile, {
-          '/foo/.aws/credentials': {},
-        });
-        helpers.spyOn(AWS.util, 'readFileSync').andReturn('');
-        expect(AWS.util.readFileSync.calls.length).to.eql(0);
-        iniFile.loadFrom();
-        expect(AWS.util.readFileSync.calls.length).to.eql(0);
-        iniFile.clearCachedFiles();
-        iniFile.loadFrom();
-        expect(AWS.util.readFileSync.calls.length).to.eql(1);
-      })
-    });
-  });
-}
\ No newline at end of file