Repository: opentable/oc
Pull request #811 (2018-01-24 14:01:19)

[DX-363] Registry conf.env sanitizer
Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding.
Failure to do so may result in the rejection of the pull request.

Please provide enough information so that others can review your pull request:

<!-- You can skip this if you're fixing a typo or adding an app to the Showcase. -->

Explain the **details** for making this change. What existing problem does the pull request solve?

<!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->

**Test plan (required)**

Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.

<!-- Make sure tests pass on both Travis and AppVeyor. -->

**Closing issues**

Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such).


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e6e378a7..1f4b63e9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,40 +1,5 @@
 ## Change Log
 
-### v0.42.17
-- [#810](https://github.com/opentable/oc/pull/810) [DX-270] Async update
-- [#809](https://github.com/opentable/oc/pull/809) fix(package): update cross-spawn to version 6.0.3
-- [#806](https://github.com/opentable/oc/pull/806) Update minimal-request to the latest version 🚀
-- [#805](https://github.com/opentable/oc/pull/805) Update mocha to the latest version 🚀
-- [#804](https://github.com/opentable/oc/pull/804) Update dependency-graph to the latest version 🚀
-- [#802](https://github.com/opentable/oc/pull/802) Update semver to the latest version 🚀
-- [#801](https://github.com/opentable/oc/pull/801) Update opn to the latest version 🚀
-
-### v0.42.16
-- [#792](https://github.com/opentable/oc/pull/792) Add test for issue #789 showing error message [Object object]
-
-### v0.42.15
-- [#798](https://github.com/opentable/oc/pull/798) Update oc-client to the latest version 🚀
-- [#797](https://github.com/opentable/oc/pull/797) Update oc-client-browser to the latest version 🚀
-
-### v0.42.14
-- [#795](https://github.com/opentable/oc/pull/795)  [DX-324] full async plugins initialisation
-
-### v0.42.13
-- [#794](https://github.com/opentable/oc/pull/794) [DX-296] Mocks can have the same signature as real plugins
-- [#793](https://github.com/opentable/oc/pull/793) Update oc-s3-storage-adapter to the latest version 🚀
-- [#790](https://github.com/opentable/oc/pull/790) Update oc-template-jade-compiler to the latest version 🚀
-- [#791](https://github.com/opentable/oc/pull/791) Update oc-template-handlebars-compiler to the latest version 🚀
-- [#788](https://github.com/opentable/oc/pull/788) Update fs-extra to the latest version 🚀
-
-### v0.42.12
-- [#786](https://github.com/opentable/oc/pull/786) Update oc-template-handlebars-compiler to the latest version 🚀
-- [#787](https://github.com/opentable/oc/pull/787) Update oc-template-jade-compiler to the latest version 🚀
-- [#785](https://github.com/opentable/oc/pull/785) Update oc-client to the latest version 🚀
-- [#784](https://github.com/opentable/oc/pull/784) Update oc-client-browser to the latest version 🚀
-- [#782](https://github.com/opentable/oc/pull/782) Update oc-template-jade-compiler to the latest version 🚀
-- [#783](https://github.com/opentable/oc/pull/783) Update oc-template-handlebars-compiler to the latest version 🚀
-- [#781](https://github.com/opentable/oc/pull/781) Update fs-extra to the latest version 🚀
-
 ### v0.42.10
 - [#775](https://github.com/opentable/oc/pull/775) Add github issue/PR templates
 - [#780](https://github.com/opentable/oc/pull/780) Update oc-client to the latest version 🚀
diff --git a/package.json b/package.json
index 07019f83..10a17b11 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "oc",
-  "version": "0.42.17",
+  "version": "0.42.11",
   "description": "A framework for developing and distributing html components",
   "main": "./src/index.js",
   "bin": {
@@ -51,7 +51,7 @@
     "injectr": "0.5.1",
     "lint-staged": "^6.0.0",
     "minimist": "^1.2.0",
-    "mocha": "^5.0.0",
+    "mocha": "^4.0.0",
     "node-emoji": "^1.8.1",
     "prettier-eslint-cli": "^4.0.4",
     "semver-sort": "0.0.4",
@@ -60,42 +60,42 @@
   },
   "dependencies": {
     "accept-language-parser": "1.4.1",
-    "async": "^2.6.0",
+    "async": "1.5.2",
     "basic-auth-connect": "^1.0.0",
     "body-parser": "1.18.2",
     "builtin-modules": "^2.0.0",
     "colors": "1.1.2",
-    "cross-spawn": "^6.0.3",
-    "dependency-graph": "0.7.0",
+    "cross-spawn": "^5.1.0",
+    "dependency-graph": "0.5.2",
     "errorhandler": "^1.5.0",
     "express": "4.16.0",
     "form-data": "2.1.4",
-    "fs-extra": "5.0.0",
+    "fs-extra": "4.0.3",
     "jstransformer-clean-css": "^2.0.0",
     "jstransformer-uglify-css": "^1.0.0",
     "jstransformer-uglify-js": "^1.2.0",
     "livereload": "^0.6.2",
     "lodash": "^4.17.4",
-    "minimal-request": "3.0.0",
+    "minimal-request": "2.2.0",
     "morgan": "1.9.0",
     "multer": "^1.3.0",
     "nice-cache": "0.0.5",
-    "oc-client": "3.0.7",
-    "oc-client-browser": "1.2.3",
+    "oc-client": "3.0.6",
+    "oc-client-browser": "1.2.2",
     "oc-get-unix-utc-timestamp": "1.0.1",
-    "oc-s3-storage-adapter": "1.0.4",
+    "oc-s3-storage-adapter": "1.0.3",
     "oc-storage-adapters-utils": "1.0.2",
     "oc-template-handlebars": "6.0.10",
-    "oc-template-handlebars-compiler": "6.1.11",
+    "oc-template-handlebars-compiler": "6.1.9",
     "oc-template-jade": "6.0.9",
-    "oc-template-jade-compiler": "6.1.11",
-    "opn": "5.2.0",
+    "oc-template-jade-compiler": "6.1.9",
+    "opn": "5.1.0",
     "parse-author": "2.0.0",
     "pug": "2.0.0-rc.4",
     "read": "1.0.7",
     "require-package-name": "2.0.1",
     "response-time": "^2.3.2",
-    "semver": "5.5.0",
+    "semver": "5.4.1",
     "semver-extra": "2.0.1",
     "stringformat": "0.0.5",
     "targz": "1.0.1",
diff --git a/src/cli/domain/get-mocked-plugins.js b/src/cli/domain/get-mocked-plugins.js
index bafd19d9..bd346042 100644
--- a/src/cli/domain/get-mocked-plugins.js
+++ b/src/cli/domain/get-mocked-plugins.js
@@ -1,5 +1,6 @@
 'use strict';
 
+const colors = require('colors/safe');
 const fs = require('fs-extra');
 const path = require('path');
 const _ = require('lodash');
@@ -7,71 +8,66 @@ const _ = require('lodash');
 const settings = require('../../resources/settings');
 const strings = require('../../resources/');
 
-const isMockValid = plugin => {
-  const isFunction = _.isFunction(plugin);
-  const isValidObject =
-    _.isObject(plugin) &&
-    _.isFunction(plugin.register) &&
-    _.isFunction(plugin.execute);
-  return isFunction || isValidObject;
-};
-
-const defaultRegister = (options, dependencies, next) => next();
-
-const registerStaticMocks = (mocks, logger) =>
-  _.map(mocks, (mockedValue, pluginName) => {
-    logger.ok(`├── ${pluginName} () => ${mockedValue}`);
+const registerStaticMocks = function(mocks, logger) {
+  return _.map(mocks, (mockedValue, pluginName) => {
+    logger.log(colors.green('├── ' + pluginName + ' () => ' + mockedValue));
     return {
       name: pluginName,
       register: {
-        register: defaultRegister,
-        execute: () => mockedValue
+        register: function(options, dependencies, next) {
+          return next();
+        },
+        execute: function() {
+          return mockedValue;
+        }
       }
     };
   });
+};
 
-const registerDynamicMocks = (ocJsonLocation, mocks, logger) =>
-  _.map(mocks, (source, pluginName) => {
-    let pluginMock;
+const registerDynamicMocks = function(ocJsonLocation, mocks, logger) {
+  return _.map(mocks, (source, pluginName) => {
+    let p;
     try {
-      pluginMock = require(path.resolve(ocJsonLocation, source));
+      p = require(path.resolve(ocJsonLocation, source));
     } catch (er) {
       logger.err(er.toString());
       return;
     }
 
-    if (!isMockValid(pluginMock)) {
-      logger.err(`├── ${pluginName} () => Error (skipping)`);
-      logger.err(strings.errors.cli.MOCK_PLUGIN_IS_NOT_VALID);
+    if (!_.isFunction(p)) {
+      logger.err(strings.errors.cli.MOCK_PLUGIN_IS_NOT_A_FUNCTION);
       return;
     }
 
-    const register = pluginMock.register || defaultRegister;
-    const execute = pluginMock.execute || pluginMock;
-
-    logger.ok(`├── ${pluginName} () => [Function]`);
-
+    logger.log(colors.green('├── ' + pluginName + ' () => [Function]'));
     return {
       name: pluginName,
-      register: { execute, register }
+      register: {
+        register: function(options, dependencies, next) {
+          return next();
+        },
+        execute: p
+      }
     };
-  }).filter(pluginMock => pluginMock);
+  }).filter(p => p);
+};
 
 const findPath = function(pathToResolve, fileName) {
-  const rootDir = fs.realpathSync('.');
-  const fileToResolve = path.join(pathToResolve, fileName);
+  const rootDir = fs.realpathSync('.'),
+    fileToResolve = path.join(pathToResolve, fileName);
 
   if (!fs.existsSync(fileToResolve)) {
     if (pathToResolve === rootDir) {
       return undefined;
     } else {
-      const getParent = pathToResolve =>
-        pathToResolve
-          .split('/')
-          .slice(0, -1)
-          .join('/');
-
-      const parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;
+      const getParent = function(x) {
+          return x
+            .split('/')
+            .slice(0, -1)
+            .join('/');
+        },
+        parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;
 
       return findPath(parentDir, fileName);
     }
@@ -84,15 +80,15 @@ module.exports = function(logger, componentsDir) {
   componentsDir = path.resolve(componentsDir || '.');
 
   let plugins = [];
-  const ocJsonFileName = settings.configFile.src.replace('./', '');
-  const ocJsonPath = findPath(componentsDir, ocJsonFileName);
+  const ocJsonFileName = settings.configFile.src.replace('./', ''),
+    ocJsonPath = findPath(componentsDir, ocJsonFileName);
 
   if (!ocJsonPath) {
     return plugins;
   }
 
-  const content = fs.readJsonSync(ocJsonPath);
-  const ocJsonLocation = ocJsonPath.slice(0, -ocJsonFileName.length);
+  const content = fs.readJsonSync(ocJsonPath),
+    ocJsonLocation = ocJsonPath.slice(0, -ocJsonFileName.length);
 
   if (!content.mocks || !content.mocks.plugins) {
     return plugins;
diff --git a/src/components/oc-client/package.json b/src/components/oc-client/package.json
index c9a1a01d..9aa0864e 100644
--- a/src/components/oc-client/package.json
+++ b/src/components/oc-client/package.json
@@ -1,7 +1,7 @@
 {
   "name": "oc-client",
   "description": "The OpenComponents client-side javascript client",
-  "version": "0.42.17",
+  "version": "0.42.11",
   "repository": "https://github.com/opentable/oc/tree/master/components/oc-client",
   "author": "Matteo Figus <matteofigus@gmail.com>",
   "oc": {
diff --git a/src/registry/domain/components-details.js b/src/registry/domain/components-details.js
index 2369b7ff..f650e5ab 100644
--- a/src/registry/domain/components-details.js
+++ b/src/registry/domain/components-details.js
@@ -21,34 +21,35 @@ module.exports = (conf, cdn) => {
     const details = _.extend({}, _.cloneDeep(options.details));
     details.components = details.components || {};
 
-    const missing = [];
-    _.each(options.componentsList.components, (versions, name) => {
-      details.components[name] = details.components[name] || {};
-      _.each(versions, version => {
-        if (!details.components[name][version]) {
-          missing.push({ name, version });
-        }
-      });
-    });
+    async.eachOfSeries(
+      options.componentsList.components,
+      (versions, name, done) => {
+        details.components[name] = details.components[name] || {};
 
-    async.eachLimit(
-      missing,
-      cdn.maxConcurrentRequests,
-      ({ name, version }, next) => {
-        cdn.getJson(
-          `${conf.storage.options.componentsDir}/${name}/${
-            version
-          }/package.json`,
-          true,
-          (err, content) => {
-            if (err) {
-              return next(err);
+        async.eachLimit(
+          versions,
+          cdn.maxConcurrentRequests,
+          (version, next) => {
+            if (details.components[name][version]) {
+              next();
+            } else {
+              cdn.getJson(
+                `${conf.storage.options
+                  .componentsDir}/${name}/${version}/package.json`,
+                true,
+                (err, content) => {
+                  if (err) {
+                    return next(err);
+                  }
+                  details.components[name][version] = {
+                    publishDate: content.oc.date || 0
+                  };
+                  next();
+                }
+              );
             }
-            details.components[name][version] = {
-              publishDate: content.oc.date || 0
-            };
-            next();
-          }
+          },
+          done
         );
       },
       err =>
diff --git a/src/registry/domain/options-sanitiser.js b/src/registry/domain/options-sanitiser.js
index 5fd598b2..23ac32f5 100644
--- a/src/registry/domain/options-sanitiser.js
+++ b/src/registry/domain/options-sanitiser.js
@@ -77,5 +77,9 @@ module.exports = function(input) {
     options.storage.options.verbosity = options.verbosity;
   }
 
+  if (!options.env) {
+    options.env = {};
+  }
+
   return options;
 };
diff --git a/src/registry/domain/plugins-initialiser.js b/src/registry/domain/plugins-initialiser.js
index 4996f4c9..aeeded02 100644
--- a/src/registry/domain/plugins-initialiser.js
+++ b/src/registry/domain/plugins-initialiser.js
@@ -81,10 +81,8 @@ module.exports.init = function(pluginsToRegister, callback) {
   };
 
   const loadPlugin = function(plugin, cb) {
-    const done = _.once(cb);
-
     if (registered[plugin.name]) {
-      return done();
+      return cb();
     }
 
     if (!plugin.register.dependencies) {
@@ -92,17 +90,18 @@ module.exports.init = function(pluginsToRegister, callback) {
     }
 
     if (!dependenciesRegistered(plugin.register.dependencies)) {
-      return defer(plugin, done);
+      return defer(plugin, cb);
     }
 
     const dependencies = _.pick(registered, plugin.register.dependencies);
 
-    plugin.register.register(plugin.options || {}, dependencies, err => {
-      const pluginCallback = plugin.callback || _.noop;
-      pluginCallback(err);
-      registered[plugin.name] = plugin.register.execute;
-      done(err);
-    });
+    plugin.register.register(
+      plugin.options || {},
+      dependencies,
+      plugin.callback || _.noop
+    );
+    registered[plugin.name] = plugin.register.execute;
+    cb();
   };
 
   const terminator = function(err) {
diff --git a/src/registry/domain/repository.js b/src/registry/domain/repository.js
index a1837e2c..aac0c4fb 100644
--- a/src/registry/domain/repository.js
+++ b/src/registry/domain/repository.js
@@ -14,7 +14,6 @@ const settings = require('../../resources/settings');
 const strings = require('../../resources');
 const validator = require('./validators');
 const versionHandler = require('./version-handler');
-const errorToString = require('../../utils/error-to-string');
 
 module.exports = function(conf) {
   const cdn = !conf.local && new conf.storage.adapter(conf.storage.options);
@@ -162,10 +161,7 @@ module.exports = function(conf) {
           version,
           (err, component) => {
             if (err) {
-              return callback(
-                `component not available: ${errorToString(err)}`,
-                null
-              );
+              return callback(`component not available: ${err}`, null);
             }
             callback(null, _.extend(component, { allVersions }));
           }
@@ -262,9 +258,12 @@ module.exports = function(conf) {
       )}`,
 
     getStaticFilePath: (componentName, componentVersion, filePath) =>
-      `${repository.getComponentPath(componentName, componentVersion)}${
-        conf.local ? settings.registry.localStaticRedirectorPath : ''
-      }${filePath}`,
+      `${repository.getComponentPath(
+        componentName,
+        componentVersion
+      )}${conf.local
+        ? settings.registry.localStaticRedirectorPath
+        : ''}${filePath}`,
 
     getTemplatesInfo: () => templatesInfo,
     getTemplate: type => templatesHash[type],
diff --git a/src/resources/index.js b/src/resources/index.js
index f6b6663a..959640a1 100644
--- a/src/resources/index.js
+++ b/src/resources/index.js
@@ -1,25 +1,6 @@
 'use strict';
 const colors = require('colors/safe');
 
-const validFunctionMock = `// simplified mock signature
-module.exports = (a, b) => a+b;`;
-
-const validMockObject = `// standard plugin-like signature
-
-const dbClient = require('my-db-client');
-let cache;
-
-module.exports.register = (options, dependencies, next) => {
-  let client = dbClient(options);
-  client.init((err, response) => {
-    cache = response;
-    next(err);
-  });
-};
-
-module.exports.execute = key => cache[key];
-`;
-
 module.exports = {
   commands: {
     cli: {
@@ -110,9 +91,7 @@ module.exports = {
     },
     cli: {
       scaffoldError: (url, error) =>
-        `Scaffolding failed. Please open an issue on ${
-          url
-        } with the following information: ${error}`,
+        `Scaffolding failed. Please open an issue on ${url} with the following information: ${error}`,
       COMPONENT_HREF_NOT_FOUND:
         "The specified path is not a valid component's url",
       COMPONENTS_NOT_FOUND: 'no components found in specified path',
@@ -123,13 +102,8 @@ module.exports = {
       DEV_FAIL: 'An error happened when initialising the dev runner: {0}',
       INIT_FAIL: 'An error happened when initialising the component: {0}',
       INVALID_CREDENTIALS: 'Invalid credentials',
-      MOCK_PLUGIN_IS_NOT_VALID: `Looks like you are trying to register a dynamic mock plugin but the file you specified is not a valid mock.
-The entry point should be a synchronous function or an object containing an asynchronous register() function and a synchronous execute() function.
-Example:
-
-${colors.yellow(validFunctionMock)}
-
-${colors.yellow(validMockObject)}`,
+      MOCK_PLUGIN_IS_NOT_A_FUNCTION:
+        'Looks like you are trying to register a dynamic mock plugin but the file you specified is not a function',
       NAME_NOT_VALID:
         'the name is not valid. Allowed characters are alphanumeric, _, -',
       NODE_CLI_VERSION_NEEDS_UPGRADE:
@@ -190,9 +164,7 @@ Happy coding
       installCompilerSuccess: (template, compiler, version) =>
         `${colors.green('✔')} Installed ${compiler} [${template} v${version}]`,
       legacyTemplateDeprecationWarning: (legacyType, newType) =>
-        `Template-type "${
-          legacyType
-        }" has been deprecated and is now replaced by "${newType}"`,
+        `Template-type "${legacyType}" has been deprecated and is now replaced by "${newType}"`,
       CHANGES_DETECTED: 'Changes detected on file: {0}',
       CHECKING_DEPENDENCIES: 'Ensuring dependencies are loaded...',
       COMPONENT_INITED: 'Success! Created "{0}"',
diff --git a/src/utils/error-to-string.js b/src/utils/error-to-string.js
deleted file mode 100644
index 40a1df32..00000000
--- a/src/utils/error-to-string.js
+++ /dev/null
@@ -1,12 +0,0 @@
-const _ = require('lodash');
-
-module.exports = function errorToString(err) {
-  const hasMessage = err != null && _.isString(err.msg);
-  if (_.isString(err)) {
-    return err;
-  } else if (hasMessage) {
-    return err.msg;
-  }
-
-  return err + '';
-};


Test patch:
diff --git a/test/unit/cli-domain-get-mocked-plugins.js b/test/unit/cli-domain-get-mocked-plugins.js
index 4aad7cd1..49b41ad2 100644
--- a/test/unit/cli-domain-get-mocked-plugins.js
+++ b/test/unit/cli-domain-get-mocked-plugins.js
@@ -6,14 +6,11 @@ const sinon = require('sinon');
 const _ = require('lodash');
 
 describe('cli : domain : get-mocked-plugins', () => {
-  const dynamicPluginModule = a => (a ? 'blarg' : 'flarg');
-  const notAFunctionModule = { foo: 'bar' };
-  const dynamicObjectPluginModule = {
-    register: (opts, deps, next) => next(),
-    execute: () => 'result'
-  };
+  const dynamicPluginModule = function(a) {
+      return a ? 'blarg' : 'flarg';
+    },
+    notAFunctionModule = { foo: 'bar' };
 
-  const logMock = { err: _.noop, log: _.noop, ok: _.noop, warn: _.noop };
   let fsMock, getMockedPlugins;
 
   const initialise = function(fs, pathJoinStub) {
@@ -40,7 +37,6 @@ describe('cli : domain : get-mocked-plugins', () => {
         join: pathJoinStub || fakePathFunc,
         resolve: fakePathFunc
       },
-      '/root/components/dynamic-object-plugin.js': dynamicObjectPluginModule,
       '/root/components/dynamic-plugin.js': dynamicPluginModule,
       '/root/components/not-a-function.js': notAFunctionModule
     });
@@ -52,7 +48,7 @@ describe('cli : domain : get-mocked-plugins', () => {
 
       beforeEach(() => {
         initialise({}, joinStub);
-        getMockedPlugins(logMock, undefined);
+        getMockedPlugins({ log: _.noop }, undefined);
       });
 
       it('should use . as default', () => {
@@ -65,7 +61,7 @@ describe('cli : domain : get-mocked-plugins', () => {
 
       beforeEach(() => {
         initialise({}, joinStub);
-        getMockedPlugins(logMock);
+        getMockedPlugins({ log: _.noop });
       });
 
       it('should use . as default', () => {
@@ -91,7 +87,10 @@ describe('cli : domain : get-mocked-plugins', () => {
           existsSync: sinon.stub().returns(true),
           readJsonSync: readMock
         });
-        result = getMockedPlugins(logMock, '/root/components/');
+        result = getMockedPlugins(
+          { log: () => {}, warn: () => {} },
+          '/root/components/'
+        );
       });
 
       it('should use components folder oc.json as default', () => {
@@ -134,7 +133,10 @@ describe('cli : domain : get-mocked-plugins', () => {
           existsSync: existsMock,
           readJsonSync: readMock
         });
-        result = getMockedPlugins(logMock, '/root/components/');
+        result = getMockedPlugins(
+          { log: () => {}, warn: () => {} },
+          '/root/components/'
+        );
       });
 
       it('should use root oc.json', () => {
@@ -146,7 +148,7 @@ describe('cli : domain : get-mocked-plugins', () => {
       let result;
       beforeEach(() => {
         initialise({ existsSync: sinon.stub().returns(false) });
-        result = getMockedPlugins(logMock, '/root/components/');
+        result = getMockedPlugins(console, '/root/components/');
       });
 
       it('should return an empty array', () => {
@@ -168,7 +170,7 @@ describe('cli : domain : get-mocked-plugins', () => {
           existsSync: sinon.stub().returns(true),
           readJsonSync: sinon.stub().returns(ocJson)
         });
-        result = getMockedPlugins(logMock, '/root/components/');
+        result = getMockedPlugins({ warn: sinon.stub() }, '/root/components/');
       });
 
       it('should return an empty array', () => {
@@ -194,7 +196,10 @@ describe('cli : domain : get-mocked-plugins', () => {
           existsSync: sinon.stub().returns(true),
           readJsonSync: sinon.stub().returns(ocJson)
         });
-        result = getMockedPlugins(logMock, '/root/components/');
+        result = getMockedPlugins(
+          { log: () => {}, warn: () => {} },
+          '/root/components/'
+        );
       });
 
       it('should return the static plugin', () => {
@@ -207,7 +212,7 @@ describe('cli : domain : get-mocked-plugins', () => {
       });
     });
 
-    describe('when a dynamic plugin with a function signature is specified', () => {
+    describe('when a dynamic plugin is specified', () => {
       let result;
       const ocJson = {
         registries: [],
@@ -225,7 +230,10 @@ describe('cli : domain : get-mocked-plugins', () => {
           existsSync: sinon.stub().returns(true),
           readJsonSync: sinon.stub().returns(ocJson)
         });
-        result = getMockedPlugins(logMock, '/root/components/');
+        result = getMockedPlugins(
+          { log: () => {}, warn: () => {} },
+          '/root/components/'
+        );
       });
 
       it('should return the dynamic plugin', () => {
@@ -239,37 +247,6 @@ describe('cli : domain : get-mocked-plugins', () => {
       });
     });
 
-    describe('when a dynamic plugin with an object signature is specified', () => {
-      let result;
-      const ocJson = {
-        registries: [],
-        mocks: {
-          plugins: {
-            dynamic: {
-              myPlugin: './dynamic-object-plugin.js'
-            }
-          }
-        }
-      };
-
-      beforeEach(() => {
-        initialise({
-          existsSync: sinon.stub().returns(true),
-          readJsonSync: sinon.stub().returns(ocJson)
-        });
-        result = getMockedPlugins(logMock, '/root/components/');
-      });
-
-      it('should return the dynamic plugin', () => {
-        expect(result.length).to.equal(1);
-        expect(result[0].name).to.equal('myPlugin');
-      });
-
-      it('should set up the execute method to run the module', () => {
-        expect(result[0].register.execute()).to.equal('result');
-      });
-    });
-
     describe('when a dynamic plugin is specified and the referenced file is missing', () => {
       let result;
       const ocJson = {
@@ -326,9 +303,8 @@ describe('cli : domain : get-mocked-plugins', () => {
       });
 
       it('should log an error', () => {
-        expect(logger.err.args[0][0]).to.contain('foo () => Error (skipping)');
-        expect(logger.err.args[1][0]).to.contain(
-          'Looks like you are trying to register a dynamic mock plugin but the file you specified is not a valid mock'
+        expect(logger.err.args[0][0]).to.contain(
+          'Looks like you are trying to register a dynamic mock plugin but the file you specified is not a function'
         );
       });
 
diff --git a/test/unit/registry-domain-options-sanitiser.js b/test/unit/registry-domain-options-sanitiser.js
index c0817712..1c8a687c 100644
--- a/test/unit/registry-domain-options-sanitiser.js
+++ b/test/unit/registry-domain-options-sanitiser.js
@@ -120,4 +120,20 @@ describe('registry : domain : options-sanitiser', () => {
       });
     });
   });
+
+  describe('when env', () => {
+    describe('is provided', () => {
+      const options = { baseUrl: 'dummy', env: { value: 'test' } };
+      it('should not modify it', () => {
+        expect(sanitise(options).env).to.deep.equal({ value: 'test' });
+      });
+    });
+
+    describe('is not provided', () => {
+      const options = { baseUrl: 'dummy' };
+      it('should initialize it as an empty {}', () => {
+        expect(sanitise(options).env).to.deep.equal({});
+      });
+    });
+  });
 });
diff --git a/test/unit/registry-domain-plugins-initialiser.js b/test/unit/registry-domain-plugins-initialiser.js
index a08e4e7d..029c8743 100644
--- a/test/unit/registry-domain-plugins-initialiser.js
+++ b/test/unit/registry-domain-plugins-initialiser.js
@@ -105,24 +105,29 @@ describe('registry : domain : plugins-initialiser', () => {
         {
           name: 'getValue',
           register: {
-            register: (options, deps, cb) => {
+            register: function(options, deps, cb) {
               passedOptions = options;
               cb();
             },
-            execute: key => passedOptions[key]
+            execute: function(key) {
+              return passedOptions[key];
+            }
           },
-          options: { a: 123, b: 456 }
+          options: {
+            a: 123,
+            b: 456
+          }
         },
         {
           name: 'isFlagged',
           register: {
-            register: (options, deps, cb) => {
-              setTimeout(() => {
-                flag = true;
-                cb();
-              }, 10);
+            register: function(options, deps, cb) {
+              flag = true;
+              cb();
             },
-            execute: () => flag
+            execute: function() {
+              return flag;
+            }
           }
         }
       ];
@@ -143,8 +148,8 @@ describe('registry : domain : plugins-initialiser', () => {
     });
 
     it('should be make the functionality usable', () => {
-      const a = result.getValue('a');
-      const flagged = result.isFlagged();
+      const a = result.getValue('a'),
+        flagged = result.isFlagged();
 
       expect(a).to.equal(123);
       expect(flagged).to.equal(true);
diff --git a/test/unit/registry-domain-repository.js b/test/unit/registry-domain-repository.js
index a60b5ea6..0d59b5e4 100644
--- a/test/unit/registry-domain-repository.js
+++ b/test/unit/registry-domain-repository.js
@@ -6,7 +6,6 @@ const injectr = require('injectr');
 const path = require('path');
 const sinon = require('sinon');
 const _ = require('lodash');
-const resources = require('../../src/resources');
 
 describe('registry : domain : repository', () => {
   let response;
@@ -182,31 +181,7 @@ describe('registry : domain : repository', () => {
           );
         });
       });
-      describe('when the get component info fails', () => {
-        before(done => {
-          componentsCacheMock.get.yields(null, componentsCacheBaseResponse);
-          sinon
-            .stub(repository, 'getComponentInfo')
-            .callsFake((name, version, callback) => {
-              callback({
-                msg: resources.errors.STORAGE.FILE_NOT_VALID,
-                code: resources.errors.STORAGE.FILE_NOT_VALID_CODE
-              });
-            });
-          repository.getComponent('hello-world', '1.0.0', saveResult(done));
-        });
-        after(() => {
-          repository.getComponentInfo.restore();
-        });
-        it('should respond with a proper error', () => {
-          expect(response.error).not.to.be.empty;
-          expect(response.error).to.equal(
-            `component not available: ${
-              resources.errors.STORAGE.FILE_NOT_VALID
-            }`
-          );
-        });
-      });
+
       describe('when the component exists but version does not', () => {
         before(done => {
           componentsCacheMock.get.yields(null, componentsCacheBaseResponse);